Initial TCA commit into DCAEGEN2
[dcaegen2/analytics/tca.git] / dcae-analytics-dmaap / src / main / java / org / openecomp / dcae / apod / analytics / dmaap / service / publisher / DMaaPMRPublisherQueue.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *   You may obtain a copy of the License at
10  *
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *  ============================LICENSE_END===========================================
19  */
20
21 package org.openecomp.dcae.apod.analytics.dmaap.service.publisher;
22
23 import java.util.List;
24
25 /**
26  * <p>
27  *     DMaaP MR Publisher Queue handles back pressure in case DMaaP MR Publisher topic
28  *     is offline for some reason. It does so by having a recovery queue which keeps
29  *     messages in order in case there is temporary interruption in DMaaP Publisher
30  * </p>
31  *
32  * @author Rajiv Singla . Creation Date: 11/1/2016.
33  */
34 public interface DMaaPMRPublisherQueue {
35
36     /**
37      * <p>
38      *     Add batchMessages to Batch Queue
39      * </p>
40      *
41      * @param batchMessages messages that needs to be added to batch queue
42      * @return current size of batch queue. Throws {@link IllegalStateException}
43      * if batch queue does not have enough space
44      */
45     int addBatchMessages(List<String> batchMessages);
46
47
48     /**
49      * <p>
50      *     Add recoverable messages to Recoverable Queue
51      * </p>
52      *
53      * @param recoverableMessages messages that needs to be added to recoverable queue
54      * @return current size of the recoverable queue. Throws {@link IllegalStateException}
55      * if recoverable queue does not have enough space
56      */
57     int addRecoverableMessages(List<String> recoverableMessages);
58
59     /**
60      * <p>
61      *     Get messages that need to be published to DMaaP topic. Messages in recoverable
62      *     queue are appended if present.
63      * </p>
64      *
65      * @return List of messages from both batch and recovery queue
66      */
67     List<String> getMessageForPublishing();
68
69     /**
70      * <p>
71      *     Remaining capacity of Batch Queue
72      * </p>
73      *
74      * @return Remaining Batch Queue Size
75      */
76     int getBatchQueueRemainingSize();
77
78     /**
79      * <p>
80      *     Remaining capacity of Recovery Queue
81      * </p>
82      *
83      * @return Remaining Recovery Queue Size
84      */
85     int getRecoveryQueueRemainingSize();
86
87 }