X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=sdnr%2Fwt%2Fdevicemanager%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fccsdk%2Ffeatures%2Fsdnr%2Fwt%2Fdevicemanager%2Fimpl%2FDeviceManagerImpl.java;h=689336f5e11f527f1aad9de9b7219885f91a17b8;hb=9fb395380431345b7da7a765651185815a9ac91d;hp=d202def5e8066b9c40e06cbf532d2cf83e706496;hpb=9751ab7122a05e9ca10dde1348869f06899fa0cc;p=ccsdk%2Ffeatures.git diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java index d202def5e..689336f5e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java @@ -1,4 +1,25 @@ -/******************************************************************************* +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,11 +35,10 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl; import java.util.List; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; @@ -29,7 +49,6 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig; import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.AaiProviderClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice.ArchiveCleanService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal; 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.DeviceMonitorImpl; @@ -45,7 +64,6 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.FactoryRegistrat import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory; 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.performancemanager.impl.database.service.MicrowaveHistoricalPerformanceWriterService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.AaiService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService; @@ -55,23 +73,22 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.DevicemanagerNotificationDelayService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.VESCollectorServiceImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketmanagerService; import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.MountPoint; import org.opendaylight.mdsal.binding.api.MountPointService; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; -import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketmanagerService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Devicemanager - * - Handles startup and closedown of network element handlers for netconf session - * - Provide common services for network element specific components + * Devicemanager - Handles startup and closedown of network element handlers for netconf session - Provide common + * services for network element specific components */ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceManagerServiceProvider, AutoCloseable { @@ -79,31 +96,27 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa private static final String APPLICATION_NAME = "DeviceManager"; private static final String MYDBKEYNAMEBASE = "SDN-Controller"; private static final String CONFIGURATIONFILE = "etc/devicemanager.properties"; - public static final long DATABASE_TIMEOUT_MS = 120*1000L; + public static final long DATABASE_TIMEOUT_MS = 120 * 1000L; @SuppressWarnings("unused") private static final String STARTUPLOG_FILENAME = "etc/devicemanager.startup.log"; - // private static final String STARTUPLOG_FILENAME2 = "data/cache/devicemanager.startup.log"; // MDSAL Services private DataBroker dataBroker; private MountPointService mountPointService; private RpcProviderService rpcProviderRegistry; - @SuppressWarnings("unused") - private NotificationPublishService notificationPublishService; private ClusterSingletonServiceProvider clusterSingletonServiceProvider; private WebsocketmanagerService websocketmanagerService; private IEntityDataProvider iEntityDataProvider; // Devicemanager common services for network element handler - private @Nullable WebSocketServiceClientInternal webSocketService; + private WebSocketServiceClientInternal webSocketService; private ODLEventListenerHandler odlEventListenerHandler; //EventHandlingService - //private NetconfChangeListener netconfChangeListener; private DeviceManagerApiServiceImpl rpcApiService; private PerformanceManagerImpl performanceManager; private DcaeProviderClient dcaeProviderClient; private AaiProviderClient aaiProviderClient; - private DcaeForwarderInternal aotsDcaeForwarder; + private DcaeForwarderImpl aotsDcaeForwarder; private DeviceMonitor deviceMonitor; private MaintenanceServiceImpl maintenanceService; private DevicemanagerNotificationDelayService notificationDelayService; @@ -112,20 +125,17 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa private ConnectionStatusHousekeepingService housekeepingService; private NetconfNodeStateService netconfNodeStateService; private DataProvider dataProvider; - //private HtDatabaseClient htDatabaseClient; + private VESCollectorServiceImpl vesCollectorServiceImpl; + // Handler - private RpcPushNotificationsHandler rpcPushNotificationsHandler; - private DeviceManagerNetconfConnectHandler forTest; + private DeviceManagerNetconfConnectHandler deviceManagerNetconfConnectHandler; + // Attributes - private final Object networkelementLock; - private final ConcurrentHashMap networkElementRepresentations; - private final List> factoryList; + private final List factoryList; private DeviceManagerDatabaseNotificationService deviceManagerDatabaseAndNotificationService; - private ClusterSingletonServiceRegistration cssRegistration; - private ClusterSingletonServiceRegistration cssRegistration2; - + ConfigurationFileRepresentation config; private Boolean devicemanagerInitializationOk; // Blueprint 1 @@ -133,13 +143,10 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa LOG.info("Creating provider for {}", APPLICATION_NAME); this.devicemanagerInitializationOk = false; this.factoryList = new CopyOnWriteArrayList<>(); - this.networkelementLock = new Object(); - this.networkElementRepresentations = new ConcurrentHashMap<>(); this.dataBroker = null; this.mountPointService = null; this.rpcProviderRegistry = null; - this.notificationPublishService = null; this.clusterSingletonServiceProvider = null; this.websocketmanagerService = null; this.iEntityDataProvider = null; @@ -155,45 +162,41 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa this.rpcProviderRegistry = rpcProviderRegistry; } - public void setNotificationPublishService(NotificationPublishService notificationPublishService) { - this.notificationPublishService = notificationPublishService; - } + public void setNotificationPublishService(NotificationPublishService notificationPublishService) {} public void setMountPointService(MountPointService mountPointService) { this.mountPointService = mountPointService; } + public void setClusterSingletonService(ClusterSingletonServiceProvider clusterSingletonService) { this.clusterSingletonServiceProvider = clusterSingletonService; } + public void setNetconfNodeStateService(NetconfNodeStateService netconfNodeStateService) { this.netconfNodeStateService = netconfNodeStateService; } + public void setWebsocketmanagerService(WebsocketmanagerService websocketmanagerService) { this.websocketmanagerService = websocketmanagerService; } + public void setEntityDataProvider(IEntityDataProvider iEntityDataProvider) { this.iEntityDataProvider = iEntityDataProvider; } - @SuppressWarnings({ "deprecation", "null" }) - public void init() throws Exception { + public void init() { LOG.info("Session Initiated start {}", APPLICATION_NAME); + this.iEntityDataProvider.setReadyStatus(false); - this.dataProvider = iEntityDataProvider.getDataProvider(); // Get configuration + this.dataProvider = iEntityDataProvider.getDataProvider(); - ConfigurationFileRepresentation config = new ConfigurationFileRepresentation(CONFIGURATIONFILE); + // Get configuration + this.config = new ConfigurationFileRepresentation(CONFIGURATIONFILE); this.notificationDelayService = new DevicemanagerNotificationDelayService(config); - //EsConfig dbConfig = new EsConfig(config); - //LOG.debug("esConfig=" + dbConfig.toString()); - // Start database - // TODO Remove this database client - //this.htDatabaseClient = new HtDatabaseClient(dbConfig.getHosts()); - //this.htDatabaseClient.waitForYellowStatus(DATABASE_TIMEOUT_MS); - // start service for device maintenance service this.maintenanceService = new MaintenanceServiceImpl(iEntityDataProvider.getHtDatabaseMaintenance()); @@ -205,26 +208,26 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa this.dcaeProviderClient = new DcaeProviderClient(config, esConfig.getCluster(), this); this.aaiProviderClient = new AaiProviderClient(config, this); + + this.vesCollectorServiceImpl = new VESCollectorServiceImpl(config); // EM String myDbKeyNameExtended = MYDBKEYNAMEBASE + "-" + esConfig.getCluster(); this.aotsDcaeForwarder = new DcaeForwarderImpl(null, dcaeProviderClient, maintenanceService); - this.deviceManagerDatabaseAndNotificationService = new DeviceManagerDatabaseNotificationService(dataProvider, maintenanceService,webSocketService, notificationDelayService, aotsDcaeForwarder); - - this.rpcPushNotificationsHandler = new RpcPushNotificationsHandler(webSocketService, - dataProvider, aotsDcaeForwarder); - this.odlEventListenerHandler = new ODLEventListenerHandler(myDbKeyNameExtended, webSocketService, - dataProvider, aotsDcaeForwarder); - this.archiveCleanService = new ArchiveCleanService(iEntityDataProvider.getEsConfig(), dataProvider); - this.housekeepingService = new ConnectionStatusHousekeepingService(this.dataBroker, - dataProvider); - this.cssRegistration = this.clusterSingletonServiceProvider - .registerClusterSingletonService(this.archiveCleanService); - this.cssRegistration2 = this.clusterSingletonServiceProvider - .registerClusterSingletonService(this.housekeepingService); + this.deviceManagerDatabaseAndNotificationService = new DeviceManagerDatabaseNotificationService(dataProvider, + maintenanceService, webSocketService, notificationDelayService, aotsDcaeForwarder); + + RpcPushNotificationsHandler rpcPushNotificationsHandler = + new RpcPushNotificationsHandler(webSocketService, dataProvider, aotsDcaeForwarder); + this.odlEventListenerHandler = + new ODLEventListenerHandler(myDbKeyNameExtended, webSocketService, dataProvider, aotsDcaeForwarder); + this.archiveCleanService = new ArchiveCleanService(iEntityDataProvider.getEsConfig(), + clusterSingletonServiceProvider, dataProvider); + this.housekeepingService = new ConnectionStatusHousekeepingService(config, clusterSingletonServiceProvider, + this.dataBroker, dataProvider); // PM - this.performanceManager = new PerformanceManagerImpl(60, this, new MicrowaveHistoricalPerformanceWriterService(dataProvider), config); + this.performanceManager = new PerformanceManagerImpl(60, this, dataProvider, config); // DM // DeviceMonitor has to be available before netconfSubscriptionManager is // configured @@ -232,9 +235,8 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa this.deviceMonitor = new DeviceMonitorImpl(dataBroker, odlEventListenerHandler, config); // ResyncNetworkElementHouskeepingService - this.resyncNetworkElementHouskeepingService = new ResyncNetworkElementHouskeepingService( - this, mountPointService, odlEventListenerHandler, - dataProvider, deviceMonitor); + this.resyncNetworkElementHouskeepingService = new ResyncNetworkElementHouskeepingService(this, + mountPointService, odlEventListenerHandler, dataProvider, deviceMonitor); // RPC Service for specific services // Start RPC Service @@ -243,19 +245,11 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa resyncNetworkElementHouskeepingService, rpcPushNotificationsHandler); // netconfSubscriptionManager should be the last one because this is a callback + // service LOG.debug("start NetconfSubscriptionManager Service"); - // this.netconfSubscriptionManager = new - // NetconfSubscriptionManagerOfDeviceManager(this, dataBroker); - // this.netconfSubscriptionManager.register(); - - //---->>>>>>> OLD OLD OLD - //this.netconfChangeListener = new NetconfChangeListener(this, dataBroker); - //this.netconfChangeListener.register(); - - //---->>>>>>> NEW NEW NEW - this.forTest = new DeviceManagerNetconfConnectHandler(netconfNodeStateService, odlEventListenerHandler, - deviceMonitor, this, factoryList); + this.deviceManagerNetconfConnectHandler = new DeviceManagerNetconfConnectHandler(netconfNodeStateService, + clusterSingletonServiceProvider, odlEventListenerHandler, deviceMonitor, this, factoryList); writeToEventLog(APPLICATION_NAME, "startup", "done"); this.devicemanagerInitializationOk = true; @@ -270,62 +264,40 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa LOG.info("DeviceManagerImpl closing ..."); close(performanceManager); close(dcaeProviderClient); + close(aotsDcaeForwarder); close(aaiProviderClient); close(deviceMonitor); - //close(htDatabaseClient); - //close(netconfChangeListener); close(maintenanceService); close(rpcApiService); close(notificationDelayService); close(archiveCleanService); close(housekeepingService); - close(forTest); - close(cssRegistration, cssRegistration2); + close(deviceManagerNetconfConnectHandler); + close(vesCollectorServiceImpl); LOG.info("DeviceManagerImpl closing done"); } @Override - public @NonNull FactoryRegistration registerNetworkElementFactory(@NonNull L factory) { + public @NonNull FactoryRegistration registerBindingNetworkElementFactory( + @NonNull final L factory) { LOG.info("Factory registration {}", factory.getClass().getName()); - MyNetworkElementFactory myFactory = new MyNetworkElementFactory<>(factory, (a,b,c) -> initDefault(a,b,c)); - factoryList.add(myFactory); + + factoryList.add(factory); return new FactoryRegistration() { @Override public @NonNull L getInstance() { - return myFactory.getFactory(); + return factory; } @Override public void close() { - factoryList.remove(myFactory); + factoryList.remove(factory); } }; } - /** - * Execute register command, for network element - * @param mountPointNodeName of new network element - * @param mountPoint of new network element - * @param inNe that needs to register - */ - private void initDefault(String mountPointNodeName, MountPoint mountPoint, NetworkElement inNe) { - // sendUpdateNotification(mountPointNodeName, nNode.getConnectionStatus(), nNode); - - NetworkElement result; - synchronized (networkelementLock) { - result = networkElementRepresentations.put(mountPointNodeName, inNe); - } - if (result != null) { - LOG.warn("NE list was not empty as expected, but contained {} ", result.getNodeId()); - } else { - deviceMonitor.deviceConnectMasterIndication(mountPointNodeName, inNe); - inNe.register(); // Call NE specific initialization - odlEventListenerHandler.connectIndication(mountPointNodeName, inNe.getDeviceType()); - } - } - @SuppressWarnings("null") @Override public @NonNull DataProvider getDataProvider() { @@ -373,10 +345,18 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa public @NonNull EventHandlingService getEventHandlingService() { return this.odlEventListenerHandler; } + + @SuppressWarnings("null") + @Override + public @NonNull ConfigurationFileRepresentation getConfigurationFileRepresentation() { + return this.config; + } + // Deviceinitialization /** * Used to close all Services, that should support AutoCloseable Pattern + * * @param toClose */ private void close(AutoCloseable... toCloseList) { @@ -410,6 +390,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa /** * Indication if init() of devicemanager successfully done. + * * @return true if init() was sucessfull. False if not done or not successfull. */ public boolean isDevicemanagerInitializationOk() { @@ -418,12 +399,13 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa /** * Get NE object. Used by DCAE Service + * * @param mountpoint mount point name * @return null or NE specific data */ - public @Nullable NetworkElement getNeByMountpoint(String mountpoint) { + public @Nullable NetworkElement getConnectedNeByMountpoint(String mountpoint) { - return networkElementRepresentations.get(mountpoint); + return this.deviceManagerNetconfConnectHandler.getConnectedNeByMountpoint(mountpoint); } @@ -432,4 +414,9 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa this.odlEventListenerHandler.writeEventLog(objectId, msg, value); } + @Override + public @NonNull VESCollectorService getVESCollectorService() { + return this.vesCollectorServiceImpl; + } + }