2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.holmes.engine.dcaepolling;
18 import lombok.extern.slf4j.Slf4j;
19 import org.onap.holmes.common.dcae.DcaeConfigurationQuery;
20 import org.onap.holmes.common.dcae.DcaeConfigurationsCache;
21 import org.onap.holmes.common.dcae.entity.DcaeConfigurations;
22 import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
23 import org.onap.holmes.common.exception.CorrelationException;
24 import org.onap.holmes.dsa.dmaappolling.Subscriber;
25 import org.onap.holmes.engine.dmaappolling.SubscriberAction;
28 public class DcaeConfigurationPolling implements Runnable{
30 private String hostname;
32 private String subscriberKey = "sec_fault_unsecure";
34 public static long POLLING_PERIOD = 10 * 1000L;
36 public DcaeConfigurationPolling(String hostname) {
37 this.hostname = hostname;
42 DcaeConfigurations dcaeConfigurations = null;
44 dcaeConfigurations = DcaeConfigurationQuery
45 .getDcaeConfigurations(hostname);
46 } catch (CorrelationException e) {
47 log.error("Failed to polling dcae configurations" + e.getMessage());
49 if (dcaeConfigurations != null) {
50 DcaeConfigurationsCache.setDcaeConfigurations(dcaeConfigurations);
51 addSubscriber(dcaeConfigurations);
55 private void addSubscriber(DcaeConfigurations dcaeConfigurations) {
56 SubscriberAction subscriberAction = ServiceLocatorHolder.getLocator()
57 .getService(SubscriberAction.class);
58 Subscriber subscriber = new Subscriber();
59 subscriber.setUrl(dcaeConfigurations.getSubSecInfo(subscriberKey).getDmaapInfo()
61 subscriberAction.addSubscriber(subscriber);