2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.openecomp.appc.listener;
24 import java.util.Collection;
25 import java.util.List;
29 * EventHandler defines a class that wraps DMaaP operations (most notably Get Message and Post Message) to make them
33 public interface EventHandler {
36 * Gets a list of messages as Strings on the read topic.
38 * @return A list of String messages. Never returns null.
40 public List<String> getIncomingEvents();
43 * Gets a list of messages as String on the read topic.
46 * The maximum amount of entries to return
47 * @return A list of String messages. Never returns null.
49 public List<String> getIncomingEvents(int limit);
52 * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
55 * The class to map the message to.
56 * @return A list of objects of the provided class. Never returns null.
58 public <T> List<T> getIncomingEvents(Class<T> cls);
61 * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
64 * The class to map the message to.
66 * The maximum amount of entries to return
67 * @return A list of objects of the provided class. Never returns null.
69 public <T> List<T> getIncomingEvents(Class<T> cls, int limit);
72 * Posts the String message to the write topic(s).
77 public void postStatus(String event);
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.
84 * The partition to post to or null if no partition should be used.
88 public void postStatus(String partition, String event);
91 * @return The client/group id used to read messages
93 public String getClientId();
96 * Set the client/group id used to read messages
99 * The new clientId to use
101 public void setClientId(String clientId);
104 * @return The client/group name to use.
106 public String getClientName();
109 * Set the client/group name used to read messages.
112 * The new clientName to use
114 public void setClientName(String clientName);
117 * @return The name of the topic to read from
119 public String getReadTopic();
122 * Set the name of the topic to read from.
125 * The new topic to read from
127 public void setReadTopic(String topic);
130 * @return The name of the topic to write to
132 public Set<String> getWriteTopics();
135 * Set the name of the topic to write to
138 * The new topic to write to
140 public void setWriteTopics(Set<String> topic);
143 * Adds a DMaaP host to the host pool
146 * The host to add to the pool in <host>:<port> format
148 public void addToPool(String host);
151 * Remove the host name from the pool if it exists
154 * The host to add to the pool in <host>:<port> format
156 public void removeFromPool(String host);
159 * Get all of the hosts in the DMaaP pool
161 * @return A collection of host in <host>:<port> format
163 public Collection<String> getPool();
166 * Clear any provided api credentials and make future requests as an unauthenticated user
168 public void clearCredentials();
171 * Set the api credentials and make future requests as an authenticated user
174 * The access portion of the credentials (either user name or api key)
176 * The secret portion of the credentials (either password or api secret)
178 public void setCredentials(String access, String secret);
181 * Close consumer/producer DMaaP clients
183 public void closeClients();