summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager-core/provider
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2023-11-01 19:06:38 +0000
committerGerrit Code Review <gerrit@onap.org>2023-11-01 19:06:38 +0000
commit36877e03ab4224988f2a5f8a11b0b73a54131785 (patch)
tree7c33ac67cee58015d5fd560c7ff1b9db7c39c7d8 /sdnr/wt/devicemanager-core/provider
parent44ee391fe4c0f890346ee651a57ef028fa119b0c (diff)
parent95cd762f70b292dbd9bf306f31e560c7dd5aeddb (diff)
Merge "Device manager selection"
Diffstat (limited to 'sdnr/wt/devicemanager-core/provider')
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java12
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java30
2 files changed, 32 insertions, 10 deletions
diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
index 881f6b415..4c8003b17 100644
--- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
+++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
@@ -38,6 +38,7 @@
*/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.jdt.annotation.NonNull;
@@ -60,8 +61,10 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping.ResyncNetworkE
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientImpl;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceServiceImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.DevicemanagerNature;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.FactoryRegistration;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory2;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.PerformanceManagerImpl;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.AaiService;
@@ -274,11 +277,12 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa
}
@Override
- public @NonNull <L extends NetworkElementFactory> FactoryRegistration<L> registerBindingNetworkElementFactory(
+ synchronized public @NonNull <L extends NetworkElementFactory> FactoryRegistration<L> registerBindingNetworkElementFactory(
@NonNull final L factory) {
LOG.debug("Factory registration {}", factory.getClass().getName());
factoryList.add(factory);
+ Collections.sort(factoryList, (a,b) -> DevicemanagerNature.compareTo(a, b) );
factory.init(getServiceProvider());
return new FactoryRegistration<L>() {
@@ -295,7 +299,11 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa
};
}
- @SuppressWarnings("null")
+ private DevicemanagerNature getNature(NetworkElementFactory a) {
+ return (a instanceof NetworkElementFactory2) ? ((NetworkElementFactory2)a).getDevicemanagerNature()
+ : DevicemanagerNature.NETWORKELEMENT_FACTORY_DEFAULT;
+ }
+
@Override
public @NonNull DataProvider getDataProvider() {
return this.dataProvider;
diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java
index 5d9a7dbb7..e9c5f7ab0 100644
--- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java
+++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java
@@ -89,14 +89,11 @@ public class DeviceManagerNetconfConnectHandler extends DeviceManagerNetconfNotC
// update db with connect status
NetconfNode netconfNode = acessor.getNetconfNode();
sendUpdateNotification(acessor.getNodeId(), netconfNode.getConnectionStatus(), netconfNode);
-
- for (NetworkElementFactory f : getFactoryList()) {
- Optional<NetworkElement> optionalNe = f.create(acessor, getServiceProvider());
- if (optionalNe.isPresent()) {
- // sendUpdateNotification(mountPointNodeName, nNode.getConnectionStatus(), nNode);
- handleNeStartup(acessor.getNodeId(), optionalNe.get());
- break; // Use the first provided
- }
+ // Start devicemanager if possible
+ Optional<NetworkElement> optionalNe = createNetworkElement(acessor);
+ // Startup device
+ if (optionalNe.isPresent()) {
+ handleNeStartup(acessor.getNodeId(), optionalNe.get());
}
}
@@ -136,6 +133,23 @@ public class DeviceManagerNetconfConnectHandler extends DeviceManagerNetconfNotC
*/
/**
+ * Get the NetworkElement from list
+ *
+ * @param accessor
+ * @return Optional<NetowrkElement>
+ */
+ private Optional<NetworkElement> createNetworkElement(NetconfAccessor accessor) {
+ Optional<NetworkElement> optionalNe = Optional.empty();
+ for (NetworkElementFactory f : getFactoryList()) {
+ optionalNe = f.create(accessor, getServiceProvider());
+ if (optionalNe.isPresent()) {
+ return optionalNe; // Use the first provided
+ }
+ }
+ return Optional.empty();
+ }
+
+ /**
* Do all tasks necessary to move from mountpoint state connected -> connecting
*
* @param mountPointNodeName provided