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