Changed to unmaintained
[appc.git] / appc-event-listener / appc-event-listener-bundle / src / main / java / org / onap / appc / listener / EventHandler.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.listener;
25
26 import java.util.Collection;
27 import java.util.List;
28 import java.util.Set;
29
30 /**
31  * EventHandler defines a class that wraps DMaaP operations (most notably Get Message and Post Message) to make them
32  * easier to use.
33  *
34  */
35 public interface EventHandler {
36
37     /**
38      * Gets a list of messages as Strings on the read topic.
39      *
40      * @return A list of String messages. Never returns null.
41      */
42     public List<String> getIncomingEvents();
43
44     /**
45      * Gets a list of messages as String on the read topic.
46      *
47      * @param limit
48      *            The maximum amount of entries to return
49      * @return A list of String messages. Never returns null.
50      */
51     public List<String> getIncomingEvents(int limit);
52
53     /**
54      * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
55      *
56      * @param cls
57      *            The class to map the message to.
58      * @return A list of objects of the provided class. Never returns null.
59      */
60     public <T> List<T> getIncomingEvents(Class<T> cls);
61
62     /**
63      * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
64      *
65      * @param cls
66      *            The class to map the message to.
67      * @param limit
68      *            The maximum amount of entries to return
69      * @return A list of objects of the provided class. Never returns null.
70      */
71     public <T> List<T> getIncomingEvents(Class<T> cls, int limit);
72
73     /**
74      * Posts the String message to the write topic(s).
75      *
76      * @param event
77      *            The String to post.
78      */
79     public void postStatus(String event);
80
81     /**
82      * Posts the String message to the write topic(s) on the specified partition. Partitions are only used to guarantee
83      * ordering and do not impact if data is retreived.
84      *
85      * @param partition
86      *            The partition to post to or null if no partition should be used.
87      * @param event
88      *            The String to post.
89      */
90     public void postStatus(String partition, String event);
91
92     /**
93      * @return The client/group id used to read messages
94      */
95     public String getClientId();
96
97     /**
98      * Set the client/group id used to read messages
99      *
100      * @param clientId
101      *            The new clientId to use
102      */
103     public void setClientId(String clientId);
104
105     /**
106      * @return The client/group name to use.
107      */
108     public String getClientName();
109
110     /**
111      * Set the client/group name used to read messages.
112      *
113      * @param clientName
114      *            The new clientName to use
115      */
116     public void setClientName(String clientName);
117
118     /**
119      * @return The name of the topic to read from
120      */
121     public String getReadTopic();
122
123     /**
124      * Set the name of the topic to read from.
125      *
126      * @param topic
127      *            The new topic to read from
128      */
129     public void setReadTopic(String topic);
130
131     /**
132      * @return The name of the topic to write to
133      */
134     public Set<String> getWriteTopics();
135
136     /**
137      * Set the name of the topic to write to
138      *
139      * @param topic
140      *            The new topic to write to
141      */
142     public void setWriteTopics(Set<String> topic);
143
144     /**
145      * Adds a DMaaP host to the host pool
146      *
147      * @param host
148      *            The host to add to the pool in &lt;host&gt;:&lt;port&gt; format
149      */
150     public void addToPool(String host);
151
152     /**
153      * Remove the host name from the pool if it exists
154      *
155      * @param host
156      *            The host to add to the pool in &lt;host&gt;:&lt;port&gt; format
157      */
158     public void removeFromPool(String host);
159
160     /**
161      * Get all of the hosts in the DMaaP pool
162      *
163      * @return A collection of host in &lt;host&gt;:&lt;port&gt; format
164      */
165     public Collection<String> getPool();
166
167     /**
168      * Clear any provided api credentials and make future requests as an unauthenticated user
169      */
170     public void clearCredentials();
171
172     /**
173      *  Sets Blacklist time for a server with response problem in seconds
174      */
175     void setResponseProblemBlacklistTime(String duration);
176
177     /**
178      *  Sets Blacklist time for a server with server problem in seconds
179      */
180     void setServerProblemBlacklistTime(String duration);
181
182     /**
183      *  Sets Blacklist time for a server with DNS problem in seconds
184      */
185     void setDnsIssueBlacklistTime(String duration);
186
187     /**
188      *  Sets Blacklist time for a server with IO Exception problem in seconds
189      */
190     void setIOExceptionBlacklistTime(String duration);
191     /**
192      * Set the api credentials and make future requests as an authenticated user
193      *
194      * @param access
195      *            The access portion of the credentials (either user name or api key)
196      * @param secret
197      *            The secret portion of the credentials (either password or api secret)
198      */
199
200
201     public void setCredentials(String access, String secret);
202
203     /**
204      * Close consumer/producer DMaaP clients
205      */
206     public void closeClients();
207
208 }