2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=======================================================
25 package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
28 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 public class MountpointStateProviderImpl implements AutoCloseable {
34 private static final Logger LOG = LoggerFactory.getLogger(MountpointStateProviderImpl.class);
35 private static final String APPLICATION_NAME = "mountpoint-state-provider";
37 private NetconfNodeStateService netconfNodeStateService;
38 private NetconfNetworkElementService netconfNetworkElementService;
40 private MountpointNodeConnectListenerImpl nodeConnectListener;
41 private MountpointNodeStateListenerImpl nodeStateListener;
42 private MountpointStatePublisher mountpointStatePublisher;
44 public MountpointStateProviderImpl() {
45 LOG.info("Creating provider class for {}", APPLICATION_NAME);
46 nodeConnectListener = null;
47 nodeStateListener = null;
50 public void setNetconfNodeStateService(NetconfNodeStateService netconfNodeStateService) {
51 this.netconfNodeStateService = netconfNodeStateService;
54 public void setNetconfNetworkElementService(NetconfNetworkElementService netconfNetworkElementService) {
55 this.netconfNetworkElementService = netconfNetworkElementService;
59 LOG.info("Init call for {}", APPLICATION_NAME);
61 nodeConnectListener = new MountpointNodeConnectListenerImpl(netconfNodeStateService);
62 nodeStateListener = new MountpointNodeStateListenerImpl(netconfNodeStateService);
68 * Reflect status for Unit Tests
70 * @return Text with status
72 public String isInitializationOk() {
73 return "No implemented";
76 public void startPublishing() {
77 mountpointStatePublisher = new MountpointStatePublisher(netconfNetworkElementService.getServiceProvider().getVESCollectorService());
78 Thread t = new Thread(mountpointStatePublisher);
81 nodeConnectListener.start(mountpointStatePublisher);
82 nodeStateListener.start(mountpointStatePublisher);
86 public void close() throws Exception {
87 LOG.info("{} closing ...", this.getClass().getName());
88 mountpointStatePublisher.stop();
89 close(nodeConnectListener, nodeStateListener);
90 LOG.info("{} closing done", APPLICATION_NAME);
94 * Used to close all Services, that should support AutoCloseable Pattern
99 private void close(AutoCloseable... toCloseList) throws Exception {
100 for (AutoCloseable element : toCloseList) {
101 if (element != null) {