2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Amdocs
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=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.openecomp.appc.listener;
25 import java.util.Collection;
26 import java.util.List;
30 * EventHandler defines a class that wraps DMaaP operations (most notably Get Message and Post Message) to make them
34 public interface EventHandler {
37 * Gets a list of messages as Strings on the read topic.
39 * @return A list of String messages. Never returns null.
41 public List<String> getIncomingEvents();
44 * Gets a list of messages as String on the read topic.
47 * The maximum amount of entries to return
48 * @return A list of String messages. Never returns null.
50 public List<String> getIncomingEvents(int limit);
53 * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
56 * The class to map the message to.
57 * @return A list of objects of the provided class. Never returns null.
59 public <T> List<T> getIncomingEvents(Class<T> cls);
62 * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
65 * The class to map the message to.
67 * The maximum amount of entries to return
68 * @return A list of objects of the provided class. Never returns null.
70 public <T> List<T> getIncomingEvents(Class<T> cls, int limit);
73 * Posts the String message to the write topic(s).
78 public void postStatus(String event);
81 * Posts the String message to the write topic(s) on the specified partition. Partitions are only used to guarantee
82 * ordering and do not impact if data is retreived.
85 * The partition to post to or null if no partition should be used.
89 public void postStatus(String partition, String event);
92 * @return The client/group id used to read messages
94 public String getClientId();
97 * Set the client/group id used to read messages
100 * The new clientId to use
102 public void setClientId(String clientId);
105 * @return The client/group name to use.
107 public String getClientName();
110 * Set the client/group name used to read messages.
113 * The new clientName to use
115 public void setClientName(String clientName);
118 * @return The name of the topic to read from
120 public String getReadTopic();
123 * Set the name of the topic to read from.
126 * The new topic to read from
128 public void setReadTopic(String topic);
131 * @return The name of the topic to write to
133 public Set<String> getWriteTopics();
136 * Set the name of the topic to write to
139 * The new topic to write to
141 public void setWriteTopics(Set<String> topic);
144 * Adds a DMaaP host to the host pool
147 * The host to add to the pool in <host>:<port> format
149 public void addToPool(String host);
152 * Remove the host name from the pool if it exists
155 * The host to add to the pool in <host>:<port> format
157 public void removeFromPool(String host);
160 * Get all of the hosts in the DMaaP pool
162 * @return A collection of host in <host>:<port> format
164 public Collection<String> getPool();
167 * Clear any provided api credentials and make future requests as an unauthenticated user
169 public void clearCredentials();
172 * Set the api credentials and make future requests as an authenticated user
175 * The access portion of the credentials (either user name or api key)
177 * The secret portion of the credentials (either password or api secret)
179 public void setCredentials(String access, String secret);
182 * Close consumer/producer DMaaP clients
184 public void closeClients();