Update appc-dispatcher for >1 ansible servers
[appc.git] / appc-dispatcher / appc-dispatcher-common / transaction-recorder / src / main / java / org / onap / appc / transactionrecorder / TransactionRecorder.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.transactionrecorder;
25
26
27 import org.onap.appc.domainmodel.lcm.RequestStatus;
28 import org.onap.appc.exceptions.APPCException;
29 import org.onap.appc.domainmodel.lcm.TransactionRecord;
30 import org.onap.appc.transactionrecorder.objects.TransactionConstants;
31
32 import java.util.List;
33 import java.util.Map;
34
35 /**
36  * Interface to persist and query LCM requests
37  */
38 public interface TransactionRecorder {
39     /**
40      * Stores transaction record to appc database by calling APPC Dao layer.
41      * @param record Transaction record data.
42      */
43     void store(TransactionRecord record) throws APPCException;
44
45     /**
46      * This method is called when a particular row in transactions needs to be updated
47      * @param key This is TransactionId which uniquely identifies the record.
48      * @param requestId
49      * @param updateColumns Map containing names of updated columns and their values.
50      * @throws APPCException
51      */
52     void update(String key, String requestId, Map<TransactionConstants.TRANSACTION_ATTRIBUTES, String> updateColumns)
53             throws APPCException;
54
55     /**
56      * Marks all records in Transactions table in non-terminal state as ABORTED. This method is to be called during
57      * APPC startup.
58      *
59      * @param appcInstanceId
60      */
61     void markTransactionsAborted(String appcInstanceId);
62
63     /**
64      * Fetch list of Transactions which are in non-terminal state i.e. ACCEPTED or RECEIVED for particular TargetId.
65      * @param record Transactions object from which TargetId and StartTime is extracted to fetch list of in progress
66      *               requests which APPC received before the current request.
67      * @param interval Number of hours - Time window to consider requests as being in progress
68      * @return List of Transactions in non terminal state.
69      * @throws APPCException
70      */
71     List<TransactionRecord> getInProgressRequests(TransactionRecord record, int interval) throws APPCException;
72
73     /**
74      * Checks whether the incoming request is duplicate.
75      * @param record Transaction object from which RequestId, SubRequestId, OriginatorId is extracted to check duplicate request.
76      * @return
77      * @throws APPCException
78      */
79     Boolean isTransactionDuplicate(TransactionRecord record) throws APPCException;
80
81     /**
82      * Retrieves {@link RequestStatus} from transaction table based on the passed parameters.
83      * @param requestId: RequestId of the request to search (Required)
84      * @param subrequestId: Sub-requestId (Optional)
85      * @param originatorId: Originator Id who sent the request(Optional)
86      * @param vnfId: VNFId to search (Required)
87      * @return list of RequestStatus'es
88      */
89     List<RequestStatus> getRecords(String requestId, String subrequestId, String originatorId, String vnfId)
90             throws APPCException;
91
92     /**
93      * Count of all requests which are currently in non-terminal state.
94      * @return Count of all request in state RECEIVED and ACCEPTED.
95      */
96     Integer getInProgressRequestsCount() throws APPCException;
97
98     /**
99      *
100      * @param appcInstanceId
101      */
102     void setAppcInstanceId(String appcInstanceId);
103 }