Change nexus values to properties
[appc.git] / appc-event-listener / appc-event-listener-bundle / src / main / java / org / openecomp / appc / listener / EventHandler.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.openecomp.appc.listener;
23
24 import java.util.Collection;
25 import java.util.List;
26 import java.util.Set;
27
28 /**
29  * EventHandler defines a class that wraps DMaaP operations (most notably Get Message and Post Message) to make them
30  * easier to use.
31  *
32  */
33 public interface EventHandler {
34
35     /**
36      * Gets a list of messages as Strings on the read topic.
37      * 
38      * @return A list of String messages. Never returns null.
39      */
40     public List<String> getIncomingEvents();
41
42     /**
43      * Gets a list of messages as String on the read topic.
44      * 
45      * @param limit
46      *            The maximum amount of entries to return
47      * @return A list of String messages. Never returns null.
48      */
49     public List<String> getIncomingEvents(int limit);
50
51     /**
52      * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
53      *
54      * @param cls
55      *            The class to map the message to.
56      * @return A list of objects of the provided class. Never returns null.
57      */
58     public <T> List<T> getIncomingEvents(Class<T> cls);
59
60     /**
61      * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
62      *
63      * @param cls
64      *            The class to map the message to.
65      * @param limit
66      *            The maximum amount of entries to return
67      * @return A list of objects of the provided class. Never returns null.
68      */
69     public <T> List<T> getIncomingEvents(Class<T> cls, int limit);
70
71     /**
72      * Posts the String message to the write topic(s).
73      * 
74      * @param event
75      *            The String to post.
76      */
77     public void postStatus(String event);
78
79     /**
80      * Posts the String message to the write topic(s) on the specified partition. Partitions are only used to guarantee
81      * ordering and do not impact if data is retreived.
82      *
83      * @param partition
84      *            The partition to post to or null if no partition should be used.
85      * @param event
86      *            The String to post.
87      */
88     public void postStatus(String partition, String event);
89
90     /**
91      * @return The client/group id used to read messages
92      */
93     public String getClientId();
94
95     /**
96      * Set the client/group id used to read messages
97      * 
98      * @param clientId
99      *            The new clientId to use
100      */
101     public void setClientId(String clientId);
102
103     /**
104      * @return The client/group name to use.
105      */
106     public String getClientName();
107
108     /**
109      * Set the client/group name used to read messages.
110      * 
111      * @param clientName
112      *            The new clientName to use
113      */
114     public void setClientName(String clientName);
115
116     /**
117      * @return The name of the topic to read from
118      */
119     public String getReadTopic();
120
121     /**
122      * Set the name of the topic to read from.
123      * 
124      * @param topic
125      *            The new topic to read from
126      */
127     public void setReadTopic(String topic);
128
129     /**
130      * @return The name of the topic to write to
131      */
132     public Set<String> getWriteTopics();
133
134     /**
135      * Set the name of the topic to write to
136      * 
137      * @param topic
138      *            The new topic to write to
139      */
140     public void setWriteTopics(Set<String> topic);
141
142     /**
143      * Adds a DMaaP host to the host pool
144      * 
145      * @param host
146      *            The host to add to the pool in &lt;host&gt;:&lt;port&gt; format
147      */
148     public void addToPool(String host);
149
150     /**
151      * Remove the host name from the pool if it exists
152      * 
153      * @param host
154      *            The host to add to the pool in &lt;host&gt;:&lt;port&gt; format
155      */
156     public void removeFromPool(String host);
157
158     /**
159      * Get all of the hosts in the DMaaP pool
160      * 
161      * @return A collection of host in &lt;host&gt;:&lt;port&gt; format
162      */
163     public Collection<String> getPool();
164
165     /**
166      * Clear any provided api credentials and make future requests as an unauthenticated user
167      */
168     public void clearCredentials();
169
170     /**
171      * Set the api credentials and make future requests as an authenticated user
172      * 
173      * @param access
174      *            The access portion of the credentials (either user name or api key)
175      * @param secret
176      *            The secret portion of the credentials (either password or api secret)
177      */
178     public void setCredentials(String access, String secret);
179     
180     /**
181      * Close consumer/producer DMaaP clients
182      */
183     public void closeClients();
184
185 }