2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.listener;
26 import java.util.Collection;
27 import java.util.List;
31 * EventHandler defines a class that wraps DMaaP operations (most notably Get Message and Post Message) to make them
35 public interface EventHandler {
38 * Gets a list of messages as Strings on the read topic.
40 * @return A list of String messages. Never returns null.
42 public List<String> getIncomingEvents();
45 * Gets a list of messages as String on the read topic.
48 * The maximum amount of entries to return
49 * @return A list of String messages. Never returns null.
51 public List<String> getIncomingEvents(int limit);
54 * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
57 * The class to map the message to.
58 * @return A list of objects of the provided class. Never returns null.
60 public <T> List<T> getIncomingEvents(Class<T> cls);
63 * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
66 * The class to map the message to.
68 * The maximum amount of entries to return
69 * @return A list of objects of the provided class. Never returns null.
71 public <T> List<T> getIncomingEvents(Class<T> cls, int limit);
74 * Posts the String message to the write topic(s).
79 public void postStatus(String event);
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.
86 * The partition to post to or null if no partition should be used.
90 public void postStatus(String partition, String event);
93 * @return The client/group id used to read messages
95 public String getClientId();
98 * Set the client/group id used to read messages
101 * The new clientId to use
103 public void setClientId(String clientId);
106 * @return The client/group name to use.
108 public String getClientName();
111 * Set the client/group name used to read messages.
114 * The new clientName to use
116 public void setClientName(String clientName);
119 * @return The name of the topic to read from
121 public String getReadTopic();
124 * Set the name of the topic to read from.
127 * The new topic to read from
129 public void setReadTopic(String topic);
132 * @return The name of the topic to write to
134 public Set<String> getWriteTopics();
137 * Set the name of the topic to write to
140 * The new topic to write to
142 public void setWriteTopics(Set<String> topic);
145 * Adds a DMaaP host to the host pool
148 * The host to add to the pool in <host>:<port> format
150 public void addToPool(String host);
153 * Remove the host name from the pool if it exists
156 * The host to add to the pool in <host>:<port> format
158 public void removeFromPool(String host);
161 * Get all of the hosts in the DMaaP pool
163 * @return A collection of host in <host>:<port> format
165 public Collection<String> getPool();
168 * Clear any provided api credentials and make future requests as an unauthenticated user
170 public void clearCredentials();
173 * Sets Blacklist time for a server with response problem in seconds
175 void setResponseProblemBlacklistTime(String duration);
178 * Sets Blacklist time for a server with server problem in seconds
180 void setServerProblemBlacklistTime(String duration);
183 * Sets Blacklist time for a server with DNS problem in seconds
185 void setDnsIssueBlacklistTime(String duration);
188 * Sets Blacklist time for a server with IO Exception problem in seconds
190 void setIOExceptionBlacklistTime(String duration);
192 * Set the api credentials and make future requests as an authenticated user
195 * The access portion of the credentials (either user name or api key)
197 * The secret portion of the credentials (either password or api secret)
201 public void setCredentials(String access, String secret);
204 * Close consumer/producer DMaaP clients
206 public void closeClients();