f6d4b531e81473d24121cde7c332baaf790ed7e7
[policy/common.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * policy-endpoints
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2018-2019 Samsung Electronics Co., Ltd.
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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  */
21
22 package org.onap.policy.common.endpoints.event.comm.bus.internal;
23
24 import org.onap.policy.common.endpoints.event.comm.Topic;
25 import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSource;
26
27 /**
28  * This topic source implementation specializes in reading messages over an UEB Bus topic source and
29  * notifying its listeners.
30  */
31 public class SingleThreadedUebTopicSource extends SingleThreadedBusTopicSource implements UebTopicSource {
32
33     /**
34      * Constructor.
35      *
36      * @param busTopicParams Parameters object containing all the required inputs
37      * @throws IllegalArgumentException An invalid parameter passed in
38      */
39     public SingleThreadedUebTopicSource(BusTopicParams busTopicParams) {
40         super(busTopicParams);
41
42         this.init();
43     }
44
45     /**
46      * Initialize the Cambria client.
47      */
48     @Override
49     public void init() {
50         this.consumer = new BusConsumer.CambriaConsumerWrapper(BusTopicParams.builder()
51                 .servers(this.servers)
52                 .topic(this.topic)
53                 .apiKey(this.apiKey)
54                 .apiSecret(this.apiSecret)
55                 .consumerGroup(this.consumerGroup)
56                 .consumerInstance(this.consumerInstance)
57                 .fetchTimeout(this.fetchTimeout)
58                 .fetchLimit(this.fetchLimit)
59                 .useHttps(this.useHttps)
60                 .allowSelfSignedCerts(this.allowSelfSignedCerts).build());
61     }
62
63     @Override
64     public CommInfrastructure getTopicCommInfrastructure() {
65         return Topic.CommInfrastructure.UEB;
66     }
67
68     @Override
69     public String toString() {
70         StringBuilder builder = new StringBuilder();
71         builder.append("SingleThreadedUebTopicSource [getTopicCommInfrastructure()=")
72                 .append(getTopicCommInfrastructure()).append(", toString()=").append(super.toString()).append("]");
73         return builder.toString();
74     }
75
76 }