import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.GeoConfig;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.PmConfig;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeProviderClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitor;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitorEmptyImpl;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitorImpl;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service.HtDatabaseEventsService;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.NetconfChangeListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.ClusteredConnectionStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
private @Nullable PerformanceManagerImpl performanceManager = null;
private ProviderClient dcaeProviderClient;
private ProviderClient aotsMProvider;
- private @Nullable AaiProviderClient aaiProviderClient;
- private DeviceMonitorImpl deviceMonitor;
+ private @Nullable AaiProviderClient aaiProviderClient = null;
+ private @Nullable DeviceMonitor deviceMonitor = new DeviceMonitorEmptyImpl();
private IndexUpdateService updateService;
private IndexConfigService configService;
private IndexMwtnService mwtnService;
LOG.warn("No configuration available. Don't start event manager");
} else {
this.databaseClientEvents = new HtDatabaseEventsService(htDatabase);
- //Make sure to start for one cluster node only
- if (akkaConfig == null || akkaConfig.isClusterAndFirstNode() || akkaConfig.isSingleNode()) {
- }
String myDbKeyNameExtended = MYDBKEYNAMEBASE + "-" + dbConfig.getCluster();
// DeviceMonitor has to be available before netconfSubscriptionManager is
// configured
LOG.debug("start DeviceMonitor Service");
- this.deviceMonitor = new DeviceMonitorImpl(dataBroker, odlEventListener);
+ this.deviceMonitor = new DeviceMonitorImpl(dataBroker, odlEventListener, config);
// netconfSubscriptionManager should be the last one because this is a callback
// service
return;
}
- if (!isMaster(nNode)) {
+ if (!isNetconfNodeMaster(nNode)) {
// Change Devicemonitor-status to connected ... for non master mountpoints.
deviceMonitor.deviceConnectSlaveIndication(mountPointNodeName);
return;
ne.initialReadFromNetworkElement();
ne.initSynchronizationExtension();
- // Setup Service that monitors registration/ deregistration of session
- ConnectionStatus csts = nNode.getConnectionStatus();
- sendCreateOrUpdateNotification(mountPointNodeName, action, csts);
+
+ sendUpdateNotification(mountPointNodeName, nNode.getConnectionStatus());
if (aaiProviderClient != null) {
aaiProviderClient.onDeviceRegistered(mountPointNodeName);
public void enterNonConnectedState(Action action, NodeId nNodeId, NetconfNode nNode) {
String mountPointNodeName = nNodeId.getValue();
ConnectionStatus csts = nNode.getConnectionStatus();
-
- sendCreateOrUpdateNotification(mountPointNodeName, action, csts);
+ if (isNetconfNodeMaster(nNode)) {
+ sendUpdateNotification(mountPointNodeName, csts);
+ }
// Handling if mountpoint exist. connected -> connecting/UnableToConnect
stopListenerOnNodeForConnectedState(mountPointNodeName);
- if (deviceMonitor != null) {
- deviceMonitor.deviceDisconnectIndication(mountPointNodeName);
- }
+ deviceMonitor.deviceDisconnectIndication(mountPointNodeName);
}
}
}
- private void sendCreateOrUpdateNotification(String mountPointNodeName, Action action, ConnectionStatus csts) {
- LOG.info("enter Non ConnectedState for device :: Name : {} Action {} ConnectionStatus {}", mountPointNodeName, action, csts);
- if (action == Action.CREATE) {
- odlEventListener.registration(mountPointNodeName);
- } else {
- odlEventListener.updateRegistration(mountPointNodeName, ConnectionStatus.class.getSimpleName(), csts != null ? csts.getName() : "null");
+ private void sendUpdateNotification(String mountPointNodeName, ConnectionStatus csts) {
+ LOG.info("enter Non ConnectedState for device :: Name : {} ConnectionStatus {}", mountPointNodeName, csts);
+ if (odlEventListener != null) {
+ odlEventListener.updateRegistration(mountPointNodeName, ConnectionStatus.class.getSimpleName(), csts != null ? csts.getName() : "null");
}
}
* Handle netconf/mountpoint changes
*/
@Override
- public void netconfChangeHandler(Action action, @Nullable ConnectionStatus csts, NodeId nodeId, NetconfNode nnode) {
- switch (action) {
- case REMOVE:
- removeMountpointState(nodeId); // Stop Monitor
- //deviceManagerService.enterNonConnectedState(nodeId, nnode); // Remove Mountpoint handler
- break;
-
- case UPDATE:
- case CREATE:
- if (csts != null) {
- switch (csts) {
- case Connected: {
- startListenerOnNodeForConnectedState(action, nodeId, nnode);
- break;
- }
- case UnableToConnect:
- case Connecting: {
- enterNonConnectedState(action, nodeId, nnode);
- break;
- }
- }
- } else {
- LOG.debug("NETCONF Node handled with null status for action", action);
- }
- break;
- }
+ public void netconfChangeHandler(Action action, @Nullable ConnectionStatus csts, NodeId nodeId, NetconfNode nNode) {
+
+ ClusteredConnectionStatus ccsts = nNode.getClusteredConnectionStatus();
+ String nodeIdString = nodeId.getValue();
+ if (action == Action.CREATE) {
+ if (odlEventListener != null) {
+ odlEventListener.registration(nodeIdString);
+ }
+ }
+ boolean isCluster = akkaConfig == null && akkaConfig.isCluster();
+ if (isCluster && ccsts == null) {
+ LOG.debug("NETCONF Node {} {} does not provide cluster status. Stop execution.", nodeIdString, action);
+ } else {
+ switch (action) {
+ case REMOVE:
+ removeMountpointState(nodeId); // Stop Monitor
+ break;
+
+ case UPDATE:
+ case CREATE:
+ if (csts != null) {
+ switch (csts) {
+ case Connected: {
+ startListenerOnNodeForConnectedState(action, nodeId, nNode);
+ break;
+ }
+ case UnableToConnect:
+ case Connecting: {
+ enterNonConnectedState(action, nodeId, nNode);
+ break;
+ }
+ }
+ } else {
+ LOG.debug("NETCONF Node handled with null status for action", action);
+ }
+ break;
+ }
+ }
}
/*-------------------------------------------------------------------------------------------
}
// Force a sync
- if (this.deviceMonitor != null) {
- this.deviceMonitor.refreshAlarmsInDb();
- }
+ this.deviceMonitor.refreshAlarmsInDb();
threadDoClearCurrentFaultByNodename = new Thread(() -> {
refreshCounter++;
return this.akkaConfig == null ? "" : this.akkaConfig.getClusterConfig().getClusterSeedNodeName("abc");
}
- private boolean isMaster(NetconfNode nnode) {
+ private boolean isNetconfNodeMaster(NetconfNode nnode) {
if (isInClusterMode()) {
LOG.debug("check if me is responsible for node");
String masterNodeName = nnode.getClusteredConnectionStatus() == null ? "null"
: nnode.getClusteredConnectionStatus().getNetconfMasterNode();
- /*
- * List<NodeStatus> clusterNodeStatusList=nnode.getClusteredConnectionStatus()==null?null:nnode.
- * getClusteredConnectionStatus().getNodeStatus(); if(clusterNodeStatusList!=null) { for(NodeStatus
- * s: clusterNodeStatusList) LOG.debug("node "+s.getNode()+
- * " with status "+(s.getStatus()==null?"null":s.getStatus().getName())); }
- */
String myNodeName = getClusterNetconfNodeName();
LOG.debug("sdnMasterNode=" + masterNodeName + " and sdnMyNode=" + myNodeName);
if (!masterNodeName.equals(myNodeName)) {