fa5e56f9469b016c4494c24a2b361a6f3e9c8d90
[policy/common.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2022 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END=========================================================
17  */
18
19 package org.onap.policy.common.endpoints.event.comm.bus;
20
21 import java.util.List;
22 import java.util.Properties;
23 import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
24
25 /**
26  * KAFKA Topic Sink Factory.
27  */
28 public interface KafkaTopicSinkFactory {
29
30     /**
31      * Instantiates a new KAFKA Topic Writer.
32      *
33      * @param busTopicParams parameters object
34      * @return an KAFKA Topic Sink
35      */
36     KafkaTopicSink build(BusTopicParams busTopicParams);
37
38     /**
39      * Creates an KAFKA Topic Writer based on properties files.
40      *
41      * @param properties Properties containing initialization values
42      *
43      * @return an KAFKA Topic Writer
44      * @throws IllegalArgumentException if invalid parameters are present
45      */
46     List<KafkaTopicSink> build(Properties properties);
47
48     /**
49      * Instantiates a new KAFKA Topic Writer.
50      *
51      * @param servers list of servers
52      * @param topic topic name
53      *
54      * @return an KAFKA Topic Writer
55      * @throws IllegalArgumentException if invalid parameters are present
56      */
57     KafkaTopicSink build(List<String> servers, String topic);
58
59     /**
60      * Destroys an KAFKA Topic Writer based on a topic.
61      *
62      * @param topic topic name
63      * @throws IllegalArgumentException if invalid parameters are present
64      */
65     void destroy(String topic);
66
67     /**
68      * Destroys all KAFKA Topic Writers.
69      */
70     void destroy();
71
72     /**
73      * gets an KAFKA Topic Writer based on topic name.
74      *
75      * @param topic the topic name
76      *
77      * @return an KAFKA Topic Writer with topic name
78      * @throws IllegalArgumentException if an invalid topic is provided
79      * @throws IllegalStateException if the KAFKA Topic Reader is an incorrect state
80      */
81     KafkaTopicSink get(String topic);
82
83     /**
84      * Provides a snapshot of the KAFKA Topic Writers.
85      *
86      * @return a list of the KAFKA Topic Writers
87      */
88     List<KafkaTopicSink> inventory();
89 }