2 * ============LICENSE_START=======================================================
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
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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.listener;
27 import java.util.Collection;
28 import java.util.List;
32 * EventHandler defines a class that wraps DMaaP operations (most notably Get Message and Post Message) to make them
36 public interface EventHandler {
39 * Gets a list of messages as Strings on the read topic.
41 * @return A list of String messages. Never returns null.
43 public List<String> getIncomingEvents();
46 * Gets a list of messages as String on the read topic.
49 * The maximum amount of entries to return
50 * @return A list of String messages. Never returns null.
52 public List<String> getIncomingEvents(int limit);
55 * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
58 * The class to map the message to.
59 * @return A list of objects of the provided class. Never returns null.
61 public <T> List<T> getIncomingEvents(Class<T> cls);
64 * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
67 * The class to map the message to.
69 * The maximum amount of entries to return
70 * @return A list of objects of the provided class. Never returns null.
72 public <T> List<T> getIncomingEvents(Class<T> cls, int limit);
75 * Posts the String message to the write topic(s).
80 public void postStatus(String event);
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.
87 * The partition to post to or null if no partition should be used.
91 public void postStatus(String partition, String event);
94 * @return The client/group id used to read messages
96 public String getClientId();
99 * Set the client/group id used to read messages
102 * The new clientId to use
104 public void setClientId(String clientId);
107 * @return The client/group name to use.
109 public String getClientName();
112 * Set the client/group name used to read messages.
115 * The new clientName to use
117 public void setClientName(String clientName);
120 * @return The name of the topic to read from
122 public String getReadTopic();
125 * Set the name of the topic to read from.
128 * The new topic to read from
130 public void setReadTopic(String topic);
133 * @return The name of the topic to write to
135 public Set<String> getWriteTopics();
138 * Set the name of the topic to write to
141 * The new topic to write to
143 public void setWriteTopics(Set<String> topic);
146 * Adds a DMaaP host to the host pool
149 * The host to add to the pool in <host>:<port> format
151 public void addToPool(String host);
154 * Remove the host name from the pool if it exists
157 * The host to add to the pool in <host>:<port> format
159 public void removeFromPool(String host);
162 * Get all of the hosts in the DMaaP pool
164 * @return A collection of host in <host>:<port> format
166 public Collection<String> getPool();
169 * Clear any provided api credentials and make future requests as an unauthenticated user
171 public void clearCredentials();
174 * Set the api credentials and make future requests as an authenticated user
177 * The access portion of the credentials (either user name or api key)
179 * The secret portion of the credentials (either password or api secret)
181 public void setCredentials(String access, String secret);
184 * Close consumer/producer DMaaP clients
186 public void closeClients();