e5642daa2245b50ca42effa7b234bdde3c7f5110
[policy/common.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2022-2023 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 Source Factory.
27  */
28 public interface KafkaTopicSourceFactory {
29
30     /**
31      * Creates a Kafka Topic Source based on properties files.
32      *
33      * @param properties Properties containing initialization values
34      *
35      * @return a Kafka Topic Source
36      * @throws IllegalArgumentException if invalid parameters are present
37      */
38     List<KafkaTopicSource> build(Properties properties);
39
40     /**
41      * Instantiates a new Kafka Topic Source.
42      *
43      * @param busTopicParams parameters object
44      * @return a Kafka Topic Source
45      */
46     KafkaTopicSource build(BusTopicParams busTopicParams);
47
48     /**
49      * Instantiates a new Kafka Topic Source.
50      *
51      * @param servers list of servers
52      * @param topic topic name
53      *
54      * @return a Kafka Topic Source
55      * @throws IllegalArgumentException if invalid parameters are present
56      */
57     KafkaTopicSource build(List<String> servers, String topic);
58
59     /**
60      * Destroys a Kafka Topic Source 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 Sources.
69      */
70     void destroy();
71
72     /**
73      * Gets a Kafka Topic Source based on topic name.
74      *
75      * @param topic the topic name
76      * @return a Kafka Topic Source with topic name
77      * @throws IllegalArgumentException if an invalid topic is provided
78      * @throws IllegalStateException if the Kafka Topic Source is an incorrect state
79      */
80     KafkaTopicSource get(String topic);
81
82     /**
83      * Provides a snapshot of the Kafka Topic Sources.
84      *
85      * @return a list of the Kafka Topic Sources
86      */
87     List<KafkaTopicSource> inventory();
88 }