diff options
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/main/java/org/onap')
26 files changed, 1182 insertions, 903 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationWorker.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationWorker.java index b6e0ca23c..9a073e20e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationWorker.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationWorker.java @@ -6,9 +6,9 @@ * ================================================================================================= * 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 @@ -22,6 +22,14 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; +/** + * Provide a thread that is receiving and process notifications. + * @param <T> represents the object that is provided with a notification and + * forwarded to the NotificationActor<T>. + * + * @author herbert + */ + public class NotificationWorker<T> implements AutoCloseable { private final BlockingQueue<T> workQueue; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java index 3a38c4e28..a06e4a601 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java @@ -17,51 +17,28 @@ ******************************************************************************/ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; + import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm; + import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.OnfMicrowaveModel; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperMicrowaveModelRev170324; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperMicrowaveModelRev180907; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperMicrowaveModelRev181010; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service.HtDatabaseEventsService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.MicrowaveEventListener12; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.NetconfEventListener12; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance15Minutes; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance24Hours; import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.MountPoint; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; -import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; -import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp; -import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; -import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG; -import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac; -import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.pac.NetworkElementCurrentProblems; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.common.QName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Optional; /** * Get information over NETCONF device according to ONF Coremodel. Read networkelement and @@ -86,12 +63,9 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base /*----------------------------------------------------------------------------- * Class members */ - private final @Nonnull MicrowaveEventListener12 microwaveEventListener; - private final @Nonnull OnfMicrowaveModel microwaveModel; + private final @Nonnull NetconfEventListener12 netconfEventListener; private final NotificationWorker<AttributeValueChangedNotificationXml> notificationQueue; - private ListenerRegistration<NotificationListener> listenerRegistrationresult = null; - /*----------------------------------------------------------------------------- * Construction */ @@ -106,71 +80,20 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base * @param databaseService to access the database * @param dcaeProvider to forward problem / change notifications */ - private ONFCoreNetworkElement12(String mountPointNodeName, Capabilities capabilities, + ONFCoreNetworkElement12(String mountPointNodeName, Capabilities capabilities, DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService, HtDatabaseEventsService databaseService, ProviderClient dcaeProvider, @Nullable ProviderClient aotsmClient, MaintenanceService maintenanceService, - NotificationDelayService<ProblemNotificationXml> notificationDelayService, - OnfMicrowaveModel onfMicrowaveModel) { + NotificationDelayService<ProblemNotificationXml> notificationDelayService ) { super(mountPointNodeName, netconfNodeDataBroker, capabilities); - this.microwaveModel = onfMicrowaveModel; - this.microwaveModel.setCoreData(this); - - // Create MicrowaveService here - this.microwaveEventListener = new MicrowaveEventListener12(mountPointNodeName, webSocketService, + this.netconfEventListener = new NetconfEventListener12(mountPointNodeName, webSocketService, databaseService, dcaeProvider, aotsmClient, maintenanceService, notificationDelayService, this); - this.microwaveModel.setOnfMicrowaveModelListener(microwaveEventListener); - this.notificationQueue = new NotificationWorker<>(1, 100, this); - // ->Below shifted to super class - // this.isNetworkElementCurrentProblemsSupporting12 = - // capabilities.isSupportingNamespaceAndRevision(NetworkElementPac.QNAME); - // LOG.debug("support necurrent-problem-list=" + this.isNetworkElementCurrentProblemsSupporting12); - // LOG.info("Create NE instance {}", InstanceList.QNAME.getLocalName()); - } - /** - * Check capabilities are matching the this specific implementation and create network element - * representation if so. - * - * @param mountPointNodeName as String - * @param capabilities of the specific network element - * @param netconfNodeDataBroker for the network element specific data - * @param webSocketService to forward event notifications - * @param databaseService to access the database - * @param dcaeProvider to forward problem / change notifications - * @return created Object if conditions are OK or null if not. - */ - public static @Nullable ONFCoreNetworkElement12 build(String mountPointNodeName, Capabilities capabilities, - DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService, - HtDatabaseEventsService databaseService, ProviderClient dcaeProvider, @Nullable ProviderClient aotsmClient, - MaintenanceService maintenanceService, - NotificationDelayService<ProblemNotificationXml> notificationDelayService) { - - if (capabilities.isSupportingNamespaceAndRevision(NetworkElement.QNAME)) { - OnfMicrowaveModel onfMicrowaveModel = null; - - if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)) { - onfMicrowaveModel = new WrapperMicrowaveModelRev170324(); - } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)) { - onfMicrowaveModel = new WrapperMicrowaveModelRev180907(); - } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)) { - onfMicrowaveModel = new WrapperMicrowaveModelRev181010(); - } - - if (onfMicrowaveModel != null) { - return new ONFCoreNetworkElement12(mountPointNodeName, capabilities, netconfNodeDataBroker, - webSocketService, databaseService, dcaeProvider, aotsmClient, maintenanceService, - notificationDelayService, onfMicrowaveModel); - } - } - return null; - - } /*----------------------------------------------------------------------------- * Functions @@ -184,9 +107,9 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base synchronized (dmLock) { boolean change = readNetworkElementAndInterfaces(); if (change) { - int problems = microwaveEventListener.removeAllCurrentProblemsOfNode(); + int problems = netconfEventListener.removeAllCurrentProblemsOfNode(); List<ProblemNotificationXml> resultList = readAllCurrentProblemsOfNode(); - microwaveEventListener.initCurrentProblemStatus(resultList); + netconfEventListener.initCurrentProblemStatus(resultList); LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountPointNodeName(), getUuId(), problems, resultList.size()); } @@ -250,11 +173,11 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base */ private synchronized void syncEquipmentPac(String uuidString) { - int problems = microwaveEventListener.removeObjectsCurrentProblemsOfNode(uuidString); + int problems = netconfEventListener.removeObjectsCurrentProblemsOfNode(uuidString); LOG.debug("Removed {} problems for uuid {}", problems, uuidString); - List<ProblemNotificationXml> resultList = equipment.addProblemsofNodeObject(uuidString); - microwaveEventListener.initCurrentProblemStatus(resultList); + List<ProblemNotificationXml> resultList = getEquipment().addProblemsofNodeObject(uuidString); + netconfEventListener.initCurrentProblemStatus(resultList); LOG.debug("Added {} problems for uuid {}", resultList.size(), uuidString); } @@ -272,7 +195,7 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base // optionalNe.getLtp().get(0).getLp(); LOG.debug("Get info about {}", getMountPointNodeName()); - int problems = microwaveEventListener.removeAllCurrentProblemsOfNode(); + int problems = netconfEventListener.removeAllCurrentProblemsOfNode(); LOG.debug("Removed all {} problems from database at registration", problems); // Step 2.1: access data broker within this mount point @@ -280,132 +203,22 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base // Step 2.2: read ne from data store readNetworkElementAndInterfaces(); - equipment.readNetworkElementEquipment(); + getEquipment().readNetworkElementEquipment(); // Step 2.3: read the existing faults and add to DB List<ProblemNotificationXml> resultList = readAllCurrentProblemsOfNode(); - equipment.addProblemsofNode(resultList); + getEquipment().addProblemsofNode(resultList); - microwaveEventListener.initCurrentProblemStatus(resultList); + netconfEventListener.initCurrentProblemStatus(resultList); - microwaveEventListener.writeEquipment(equipment); + netconfEventListener.writeEquipment(getEquipment()); LOG.info("Found info at {} for device {} number of problems: {}", getMountPointNodeName(), getUuId(), resultList.size()); } - /** - * LOG the newly added problems of the interface pac - * - * @param idxStart - * @param uuid - * @param resultList - */ - private void debugResultList(String uuid, List<ProblemNotificationXml> resultList, int idxStart) { - if (LOG.isDebugEnabled()) { - StringBuffer sb = new StringBuffer(); - int idx = 0; - for (int t = idxStart; t < resultList.size(); t++) { - sb.append(idx++); - sb.append(":{"); - sb.append(resultList.get(t)); - sb.append('}'); - } - LOG.debug("Found problems {} {}", uuid, sb.toString()); - } - } - - /** - * Read from NetworkElement and verify LTPs have changed. If the NE has changed, update to the new - * structure. From initial state it changes also. - */ - private synchronized boolean readNetworkElementAndInterfaces() { - - LOG.debug("Update mountpoint if changed {}", getMountPointNodeName()); - - optionalNe = GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, - NETWORKELEMENT_IID);; - synchronized (pmLock) { - boolean change = false; - - if (optionalNe == null) { - LOG.debug("Unable to read NE data for mountpoint {}", getMountPointNodeName()); - if (!interfaceList.isEmpty()) { - interfaceList.clear(); - interfaceListIterator = null; - change = true; - } - - } else { - LOG.debug("Mountpoint '{}' NE-Name '{}'", getMountPointNodeName(), optionalNe.getName()); - List<Lp> actualInterfaceList = getLtpList(optionalNe); - if (!interfaceList.equals(actualInterfaceList)) { - LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", getMountPointNodeName(), - actualInterfaceList.size()); - interfaceList.clear(); - interfaceList.addAll(actualInterfaceList); - interfaceListIterator = null; - change = true; - } - } - return change; - } - } - /** - * Read current problems of AirInterfaces and EthernetContainer according to NE status into DB - * - * @return List with all problems - */ - private List<ProblemNotificationXml> readAllCurrentProblemsOfNode() { - // Step 2.3: read the existing faults and add to DB - List<ProblemNotificationXml> resultList = new ArrayList<>(); - int idxStart; // Start index for debug messages - UniversalId uuid; - - synchronized (pmLock) { - for (Lp lp : interfaceList) { - - idxStart = resultList.size(); - uuid = lp.getUuid(); - Class<?> lpClass = getLpExtension(lp); - - ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(lp.getLayerProtocolName()); - - microwaveModel.readTheFaultsOfMicrowaveModel(lpName, lpClass, uuid, resultList); - - debugResultList(uuid.getValue(), resultList, idxStart); - - } - } - - // Step 2.4: Read other problems from mountpoint - if (isNetworkElementCurrentProblemsSupporting12) { - idxStart = resultList.size(); - readNetworkElementCurrentProblems12(resultList); - debugResultList("CurrentProblems12", resultList, idxStart); - } - - return resultList; - - } - - /** - * Get uuid of Optional NE. - * - * @return Uuid or EMPTY String if optionNE is not available - */ - private String getUuId() { - String uuid = EMPTY; - - try { - uuid = optionalNe != null ? optionalNe.getUuid() != null ? optionalNe.getUuid().getValue() : EMPTY : EMPTY; - } catch (NullPointerException e) { - // Unfortunately throws null pointer if not definied - } - return uuid; - } /** * Read the NetworkElement part from database. @@ -423,54 +236,6 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base } /** - * Get from LayerProtocolExtensions the related generated ONF Interface PAC class which represents it. - * - * @param lp logical termination point - * @return Class of InterfacePac - */ - @Nullable - private Class<?> getLpExtension(@Nullable Lp lp) { - - String capability = EMPTY; - String revision = EMPTY; - String conditionalPackage = EMPTY; - Class<?> res = null; - - if (lp != null) { - for (Extension e : getExtensionList(lp)) { - if (e.getValueName().contentEquals("capability")) { - capability = e.getValue(); - int idx = capability.indexOf("?"); - if (idx != -1) { - capability = capability.substring(0, idx); - } - } - if (e.getValueName().contentEquals("revision")) { - revision = e.getValue(); - } - if (e.getValueName().contentEquals("conditional-package")) { - conditionalPackage = e.getValue(); - } - } - } - // QName qName = - // org.opendaylight.yangtools.yang.common.QName.create("urn:onf:params:xml:ns:yang:microwave-model", - // "2017-03-24", "mw-air-interface-pac").intern(); - LOG.info("LpExtension capability={} revision={} conditionalPackage={}", capability, revision, - conditionalPackage); - if (!capability.isEmpty() && !revision.isEmpty() && !conditionalPackage.isEmpty()) { - try { - QName qName = QName.create(capability, revision, conditionalPackage); - res = this.microwaveModel.getClassForLtpExtension(qName); - } catch (IllegalArgumentException e) { - LOG.debug("Can not create QName from ({}{}{}): {}", capability, revision, conditionalPackage, - e.getMessage()); - } - } - return res; - } - - /** * Read element from class that could be not available * * @param ltp layer termination point @@ -486,257 +251,16 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base } /** - * Get List of UUIDs for conditional packages from Networkelement<br> - * Possible interfaces are:<br> - * MWPS, LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface<br> - * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac<br> - * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, - * MicrowaveModel-ObjectClasses-AirInterfaceDiversity<br> - * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure<br> - * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure<br> - * - * @param ne Networkelement - * @return Id List, never null. - */ - private static List<Lp> getLtpList(@Nullable NetworkElement ne) { - - List<Lp> res = Collections.synchronizedList(new ArrayList<Lp>()); - - if (ne != null) { - List<Ltp> ltpRefList = ne.getLtp(); - if (ltpRefList == null) { - LOG.debug("DBRead NE-Interfaces: null"); - } else { - for (Ltp ltRefListE : ltpRefList) { - List<Lp> lpList = ltRefListE.getLp(); - if (lpList == null) { - LOG.debug("DBRead NE-Interfaces Reference List: null"); - } else { - for (Lp ltp : lpList) { - //// LayerProtocolName layerProtocolName = lpListE.getLayerProtocolName(); - // UniversalId uuId = lpListE.getUuid(); - res.add(ltp); - } - } - } - } - } else { - LOG.debug("DBRead NE: null"); - } - - // ---- Debug - if (LOG.isDebugEnabled()) { - StringBuffer strBuf = new StringBuffer(); - for (Lp ltp : res) { - if (strBuf.length() > 0) { - strBuf.append(", "); - } - strBuf.append(ltp.getLayerProtocolName().getValue()); - strBuf.append(':'); - strBuf.append(ltp.getUuid().getValue()); - } - LOG.debug("DBRead NE-Interfaces: {}", strBuf.toString()); - } - // ---- Debug end - - return res; - } - - - @Nonnull - private List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(Lp lp) { - ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(lp.getLayerProtocolName()); - - return this.microwaveModel.readTheHistoricalPerformanceData(lpName, lp); - /* - * switch (lpName) { case MWAirInterface: return - * readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp); - * - * case EthernetContainer12: return readTheHistoricalPerformanceDataOfEthernetContainer(lp); - * - * case EthernetContainer10: case EthernetPhysical: case Ethernet: case TDMContainer: case - * Structure: case Unknown: LOG.debug("Do not read HistoricalPM data for {} {}", lpName, - * lp.getUuid().getValue()); break; } return new ArrayList<>(); - */ - } - - @Override - public AllPm getHistoricalPM() { - - synchronized (pmLock) { - if (pmLp != null) { - LOG.debug("Enter query PM"); - AllPm allPm = new AllPm(); - Lp lp = pmLp; - - List<? extends OtnHistoryDataG> resultList = readTheHistoricalPerformanceData(lp); - LOG.debug("Got records: {}", resultList.size()); - // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType - GranularityPeriodType granularityPeriod; - for (OtnHistoryDataG perf : resultList) { - - granularityPeriod = perf.getGranularityPeriod(); - if (granularityPeriod == null) { - granularityPeriod = GranularityPeriodType.Unknown; - } - - switch (granularityPeriod) { - case Period15Min: { - EsHistoricalPerformance15Minutes pm = - new EsHistoricalPerformance15Minutes(getMountPointNodeName(), lp) - .setHistoricalRecord15Minutes(perf); - allPm.add(pm); - } - break; - - case Period24Hours: { - EsHistoricalPerformance24Hours pm = - new EsHistoricalPerformance24Hours(getMountPointNodeName(), lp) - .setHistoricalRecord24Hours(perf); - LOG.debug("Write 24h write to DB"); - allPm.add(pm); - } - break; - - default: - LOG.warn("Unknown granularity {}", perf.getGranularityPeriod()); - break; - - } - } - LOG.debug("Deliver normalized records: {}", allPm.size()); - return allPm; - } else { - LOG.debug("Deliver empty, no LTP"); - return AllPm.getEmpty(); - } - } - } - - @Override - public void resetPMIterator() { - synchronized (pmLock) { - interfaceListIterator = interfaceList.iterator(); - } - LOG.debug("PM reset iterator"); - } - - @Override - public boolean hasNext() { - boolean res; - synchronized (pmLock) { - res = interfaceListIterator != null ? interfaceListIterator.hasNext() : false; - } - LOG.debug("PM hasNext LTP {}", res); - return res; - } - - @Override - public void next() { - synchronized (pmLock) { - if (interfaceListIterator == null) { - pmLp = null; - LOG.debug("PM next LTP null"); - } else { - pmLp = interfaceListIterator.next(); - LOG.debug("PM next LTP {}", pmLp.getLayerProtocolName().getValue()); - } - } - } - - @Override - public String pmStatusToString() { - StringBuffer res = new StringBuffer(); - synchronized (pmLock) { - res.append(pmLp == null ? "no interface" : pmLp.getLayerProtocolName().getValue()); - for (Lp lp : interfaceList) { - res.append("IF:"); - res.append(lp.getLayerProtocolName().getValue()); - res.append(" "); - } - } - return res.toString(); - } - - /** * Remove all entries from list */ @Override public int removeAllCurrentProblemsOfNode() { - return microwaveEventListener.removeAllCurrentProblemsOfNode(); - } - - /** - * Register the listener - */ - @Override - public void doRegisterMicrowaveEventListener(MountPoint mountPoint) { - LOG.info("End registration listener for Mountpoint {}", mountPoint.getIdentifier().toString()); - final Optional<NotificationService> optionalNotificationService = - mountPoint.getService(NotificationService.class); - final NotificationService notificationService = optionalNotificationService.get(); - // notificationService.registerNotificationListener(microwaveEventListener); - listenerRegistrationresult = - notificationService.registerNotificationListener(microwaveModel.getNotificationListener()); - LOG.info("End registration listener for Mountpoint {} Listener: {} Result: {}", - mountPoint.getIdentifier().toString(), optionalNotificationService, listenerRegistrationresult); + return netconfEventListener.removeAllCurrentProblemsOfNode(); } - /*------------------------------------------------------------ - * private function to access database - */ - - /*----------------------------------------------------------------------------- - * Reading problems for the networkElement V1.2 - */ - - private List<ProblemNotificationXml> readNetworkElementCurrentProblems12(List<ProblemNotificationXml> resultList) { - - LOG.info("DBRead Get {} NetworkElementCurrentProblems12", getMountPointNodeName()); - - InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac> networkElementCurrentProblemsIID = - InstanceIdentifier.builder( - org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac.class) - .build(); - - // Step 2.3: read to the config data store - NetworkElementPac problemPac; - NetworkElementCurrentProblems problems; - try { - problemPac = GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, - networkElementCurrentProblemsIID); - problems = problemPac.getNetworkElementCurrentProblems(); - if (problems == null) { - LOG.debug("DBRead no NetworkElementCurrentProblems12"); - } else if (problems.getCurrentProblemList() == null) { - LOG.debug("DBRead empty CurrentProblemList12"); - } else { - for (org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.current.problems.g.CurrentProblemList problem : problems - .getCurrentProblemList()) { - resultList.add(new ProblemNotificationXml(getMountPointNodeName(), problem.getObjectReference(), - problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()), - problem.getSequenceNumber().toString(), - InternalDateAndTime.valueOf(problem.getTimeStamp()))); - } - } - } catch (Exception e) { - LOG.warn("DBRead {} NetworkElementCurrentProblems12 not supported. Message '{}' ", getMountPointNodeName(), - e.getMessage()); - } - return resultList; - - } - - @Override - public void close() throws Exception { - super.close(); - if (listenerRegistrationresult != null) { - listenerRegistrationresult.close(); - } - } - - - + @Override + public void close() throws Exception { + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Base.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Base.java index f0ce392d7..2aa8dd99b 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Base.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Base.java @@ -25,32 +25,38 @@ import java.util.concurrent.CopyOnWriteArrayList; import javax.annotation.Nonnull; import javax.annotation.Nullable; + +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperPTPModelRev170208; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.MountPoint; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListKey; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.PortDsEntry; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsList; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentity; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.pac.NetworkElementCurrentProblems; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** - * This class contains the ONF Core model Version 1.2 related functions. - * It should import + * This class contains the ONF Core model Version 1.2 related functions.<br> + * Provides the basic ONF Core Model function.<br> + * - initialReadFromNetworkElement is not implemented in child classes. */ @SuppressWarnings("deprecation") -public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementBase implements ONFCOreNetworkElementCoreData { +public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementBase implements ONFCoreNetworkElementCoreData { private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Base.class); @@ -60,8 +66,6 @@ public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementB protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier .builder(NetworkElement.class).build(); - protected static final InstanceIdentifier<InstanceList> PTPINSTANCES_IID = InstanceIdentifier - .builder(InstanceList.class, new InstanceListKey(1)).build(); /*----------------------------------------------------------------------------- * Class members @@ -69,12 +73,12 @@ public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementB // Non specific part. Used by all functions. /** interfaceList is used by PM task and should be synchronized */ - protected final @Nonnull List<Lp> interfaceList = Collections.synchronizedList(new CopyOnWriteArrayList<>()); - protected @Nullable NetworkElement optionalNe = null; + private final @Nonnull List<Lp> interfaceList = Collections.synchronizedList(new CopyOnWriteArrayList<>()); + private @Nullable NetworkElement optionalNe = null; // Performance monitoring specific part /** Lock for the PM access specific elements that could be null */ - protected final @Nonnull Object pmLock = new Object(); + private final @Nonnull Object pmLock = new Object(); protected @Nullable Iterator<Lp> interfaceListIterator = null; /** Actual pmLp used during iteration over interfaces */ protected @Nullable Lp pmLp = null; @@ -85,7 +89,9 @@ public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementB protected final boolean isNetworkElementCurrentProblemsSupporting12; - protected final ONFCoreNetworkElement12Equipment equipment; + private final ONFCoreNetworkElement12Equipment equipment; + + private @Nonnull InventoryInformation inventoryInformation = new InventoryInformation(); /* * Constructor @@ -97,6 +103,7 @@ public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementB // TODO Auto-generated constructor stub this.isNetworkElementCurrentProblemsSupporting12 = capabilities.isSupportingNamespaceAndRevision(NetworkElementPac.QNAME); this.equipment = new ONFCoreNetworkElement12Equipment(this, capabilities); + WrapperPTPModelRev170208.initSynchronizationExtension(mountPointNodeName, netconfNodeDataBroker, capabilities); LOG.debug("support necurrent-problem-list=" + this.isNetworkElementCurrentProblemsSupporting12); LOG.info("Create NE instance {}", InstanceList.QNAME.getLocalName()); } @@ -110,95 +117,250 @@ public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementB return optionalNe; } + List<Lp> getInterfaceList() { + return interfaceList; + } + + public Object getPmLock() { + return pmLock; + } + + public ONFCoreNetworkElement12Equipment getEquipment() { + return equipment; + } /*--------------------------------------------------------------- - * Device Monitor + * Core model related function */ - @Override - public boolean checkIfConnectionToMediatorIsOk() { - synchronized (dmLock) { - return optionalNe != null; - } + /** + * Read the NetworkElement part from database. + * + * @return Optional with NetworkElement or empty + */ + @Nullable + private NetworkElement readNetworkElement() { + // Step 2.2: construct data and the relative iid + // The schema path to identify an instance is + // <i>CoreModel-CoreNetworkModule-ObjectClasses/NetworkElement</i> + // Read to the config data store + return GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, + NETWORKELEMENT_IID); } - /* - * New implementation to interpret status with empty LTP List as notConnected => return false - * 30.10.2018 Since this behavior is very specific and implicit for specific NE Types - * it needs to be activated by extension or configuration. Change to be disabled at the moment + /** + * Get uuid of Optional NE. + * + * @return Uuid or EMPTY String if optionNE is not available */ - @Override - public boolean checkIfConnectionToNeIsOk() { - return true; + protected String getUuId() { + String uuid = EMPTY; + + try { + uuid = optionalNe != null ? optionalNe.getUuid() != null ? optionalNe.getUuid().getValue() : EMPTY : EMPTY; + } catch (NullPointerException e) { + // Unfortunately throws null pointer if not definied + } + return uuid; } - /*--------------------------------------------------------------- - * Synchronization + /** + * Read from NetworkElement and verify LTPs have changed. If the NE has changed, update to the new + * structure. From initial state it changes also. */ + protected synchronized boolean readNetworkElementAndInterfaces() { + + LOG.debug("Update mountpoint if changed {}", getMountPointNodeName()); + + optionalNe = GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, + NETWORKELEMENT_IID);; + synchronized (pmLock) { + boolean change = false; + + if (optionalNe == null) { + LOG.debug("Unable to read NE data for mountpoint {}", getMountPointNodeName()); + if (!interfaceList.isEmpty()) { + interfaceList.clear(); + interfaceListIterator = null; + change = true; + } + + } else { + LOG.debug("Mountpoint '{}' NE-Name '{}'", getMountPointNodeName(), optionalNe.getName()); + List<Lp> actualInterfaceList = getLtpList(optionalNe); + if (!interfaceList.equals(actualInterfaceList)) { + LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", getMountPointNodeName(), + actualInterfaceList.size()); + interfaceList.clear(); + interfaceList.addAll(actualInterfaceList); + interfaceListIterator = null; + change = true; + } + } + return change; + } + } /** - * Query synchronization information out of NE + * Get List of UUIDs for conditional packages from Networkelement<br> + * Possible interfaces are:<br> + * MWPS, LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface<br> + * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac<br> + * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, + * MicrowaveModel-ObjectClasses-AirInterfaceDiversity<br> + * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure<br> + * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure<br> + * + * @param ne NetworkElement + * @return Id List, never null. */ - @Override - public void initSynchronizationExtension() { - // ClockIdentityType vv; - try { - if (!getCapabilities().isSupportingNamespaceAndRevision(InstanceList.QNAME)) { - LOG.debug("Mountpoint {} does not support PTP", getMountPointNodeName()); + private static List<Lp> getLtpList(@Nullable NetworkElement ne) { + + List<Lp> res = Collections.synchronizedList(new ArrayList<Lp>()); + + if (ne != null) { + List<Ltp> ltpRefList = ne.getLtp(); + if (ltpRefList == null) { + LOG.debug("DBRead NE-Interfaces: null"); } else { - StringBuffer sb = new StringBuffer(); - sb.append("NE " + getMountPointNodeName() + " does support synchronisation.\n"); - InstanceList ptpInstance = readPTPClockInstances(); - if (ptpInstance != null) { - List<PortDsList> dsList = ptpInstance.getPortDsList(); - if (dsList != null) { - int t = 0; - for (PortDsEntry portDs : ptpInstance.getPortDsList()) { - PortIdentity portId = portDs.getPortIdentity(); - if (portId != null) { - sb.append("Port["); - sb.append(portId.getPortNumber()); - sb.append("]{ ClockId: "); - sb.append(portId.getClockIdentity()); - sb.append(", Portstate: "); - sb.append(portDs.getPortState()); - sb.append("}, "); - } else { - sb.append("Incomplete port #" + t + ", "); - } - t++; - } + for (Ltp ltRefListE : ltpRefList) { + List<Lp> lpList = ltRefListE.getLp(); + if (lpList == null) { + LOG.debug("DBRead NE-Interfaces Reference List: null"); } else { - sb.append("dsList contains null"); + for (Lp ltp : lpList) { + res.add(ltp); + } } - } else { - sb.append("ptpInstance equals null"); } - LOG.trace(sb.toString()); } - } catch (Exception e) { - LOG.info("Inconsistent synchronisation structure: " + e.getMessage()); + } else { + LOG.debug("DBRead NE: null"); + } + + // ---- Debug + if (LOG.isDebugEnabled()) { + StringBuffer strBuf = new StringBuffer(); + for (Lp ltp : res) { + if (strBuf.length() > 0) { + strBuf.append(", "); + } + strBuf.append(ltp.getLayerProtocolName().getValue()); + strBuf.append(':'); + strBuf.append(ltp.getUuid().getValue()); + } + LOG.debug("DBRead NE-Interfaces: {}", strBuf.toString()); } + // ---- Debug end + return res; } - @Nullable - private InstanceList readPTPClockInstances() { - return GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, - PTPINSTANCES_IID); + /** + * Read current problems of AirInterfaces and EthernetContainer according to NE status into DB + * + * @return List with all problems + */ + protected List<ProblemNotificationXml> readAllCurrentProblemsOfNode() { + + // Step 2.3: read the existing faults and add to DB + List<ProblemNotificationXml> resultList = new ArrayList<>(); + int idxStart; // Start index for debug messages + UniversalId uuid; + + synchronized (pmLock) { + for (Lp lp : interfaceList) { + + idxStart = resultList.size(); + uuid = lp.getUuid(); + ProblemNotificationXml.debugResultList(LOG, uuid.getValue(), resultList, idxStart); + + } + } + + // Step 2.4: Read other problems from mountpoint + if (isNetworkElementCurrentProblemsSupporting12) { + idxStart = resultList.size(); + readNetworkElementCurrentProblems12(resultList); + ProblemNotificationXml.debugResultList(LOG, "CurrentProblems12", resultList, idxStart); + } + + return resultList; + + } + + /** + * Reading problems for the networkElement V1.2 + * @param resultList + * @return + */ + private List<ProblemNotificationXml> readNetworkElementCurrentProblems12(List<ProblemNotificationXml> resultList) { + + LOG.info("DBRead Get {} NetworkElementCurrentProblems12", getMountPointNodeName()); + + InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac> networkElementCurrentProblemsIID = + InstanceIdentifier.builder( + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac.class) + .build(); + + // Step 2.3: read to the config data store + NetworkElementPac problemPac; + NetworkElementCurrentProblems problems; + try { + problemPac = GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, + networkElementCurrentProblemsIID); + problems = problemPac.getNetworkElementCurrentProblems(); + if (problems == null) { + LOG.debug("DBRead no NetworkElementCurrentProblems12"); + } else if (problems.getCurrentProblemList() == null) { + LOG.debug("DBRead empty CurrentProblemList12"); + } else { + for (org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.current.problems.g.CurrentProblemList problem : problems + .getCurrentProblemList()) { + resultList.add(new ProblemNotificationXml(getMountPointNodeName(), problem.getObjectReference(), + problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()), + problem.getSequenceNumber().toString(), + InternalDateAndTime.valueOf(problem.getTimeStamp()))); + } + } + } catch (Exception e) { + LOG.warn("DBRead {} NetworkElementCurrentProblems12 not supported. Message '{}' ", getMountPointNodeName(), + e.getMessage()); + } + return resultList; } /*--------------------------------------------------------------- - * Equipment related functions + * Device Monitor */ + @Override + public boolean checkIfConnectionToMediatorIsOk() { + synchronized (dmLock) { + return optionalNe != null; + } + } + /* + * New implementation to interpret status with empty LTP List as notConnected => return false + * 30.10.2018 Since this behavior is very specific and implicit for specific NE Types + * it needs to be activated by extension or configuration. Change to be disabled at the moment + */ @Override - public InventoryInformation getInventoryInformation() { - return this.getInventoryInformation(null); + public boolean checkIfConnectionToNeIsOk() { + return true; } + /*--------------------------------------------------------------- + * Synchronization + */ + + + + /*--------------------------------------------------------------- + * Equipment related functions + */ @Override public @Nonnull InventoryInformation getInventoryInformation(String layerProtocolFilter) { @@ -206,11 +368,11 @@ public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementB return this.equipment.getInventoryInformation(getFilteredInterfaceUuidsAsStringList(layerProtocolFilter)); } - /*--------------------------------------------------------------- - * Other - */ + @Override + public InventoryInformation getInventoryInformation() { + return getInventoryInformation(null); + } - @Override protected List<String> getFilteredInterfaceUuidsAsStringList(String layerProtocolFilter) { List<String> uuids = new ArrayList<>(); @@ -230,4 +392,66 @@ public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementB return uuids; } + + /*--------------------------------------------------------------- + * Performancemanagement specific interface + */ + + @Override + public void resetPMIterator() { + synchronized (pmLock) { + interfaceListIterator = interfaceList.iterator(); + } + LOG.debug("PM reset iterator"); + } + + @Override + public boolean hasNext() { + boolean res; + synchronized (pmLock) { + res = interfaceListIterator != null ? interfaceListIterator.hasNext() : false; + } + LOG.debug("PM hasNext LTP {}", res); + return res; + } + + @Override + public void next() { + synchronized (pmLock) { + if (interfaceListIterator == null) { + pmLp = null; + LOG.debug("PM next LTP null"); + } else { + pmLp = interfaceListIterator.next(); + LOG.debug("PM next LTP {}", pmLp.getLayerProtocolName().getValue()); + } + } + } + + @Override + public String pmStatusToString() { + StringBuffer res = new StringBuffer(); + synchronized (pmLock) { + res.append(pmLp == null ? "no interface" : pmLp.getLayerProtocolName().getValue()); + for (Lp lp : getInterfaceList()) { + res.append("IF:"); + res.append(lp.getLayerProtocolName().getValue()); + res.append(" "); + } + } + return res.toString(); + } + + @Override + public AllPm getHistoricalPM() { + return AllPm.getEmpty(); + } + + + @Override + public void doRegisterMicrowaveEventListener(MountPoint mountPoint) { + //Do nothing + } + + } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Equipment.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Equipment.java index 205afc0d3..dcce28c35 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Equipment.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Equipment.java @@ -50,8 +50,9 @@ public class ONFCoreNetworkElement12Equipment { private static final UniversalId EQUIPMENTROOT = new UniversalId("network-element"); private static final int EQUIPMENTROOTLEVEL = 0; + private static final OnfInterfacePac EMPTYEQUIPMENTPAC = (interfacePacUuid, resultList) -> { return(resultList); }; - private final ONFCOreNetworkElementCoreData coreData; + private final ONFCoreNetworkElementCoreData coreData; private final OnfInterfacePac equipmentPac; private final ValueNameList extensionList; @@ -59,15 +60,15 @@ public class ONFCoreNetworkElement12Equipment { private final List<ProblemNotificationXml> globalProblemList; private final List<ExtendedEquipment> globalEquipmentList; - public ONFCoreNetworkElement12Equipment(ONFCOreNetworkElementCoreData coreData, Capabilities capabilities) { + public ONFCoreNetworkElement12Equipment(ONFCoreNetworkElementCoreData coreData, Capabilities capabilities) { LOG.debug("Initialize " + ONFCoreNetworkElement12Equipment.class.getName()); this.coreData = coreData; if (capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)) { this.equipmentPac = new WrapperEquipmentPacRev170402(coreData); - LOG.debug("Equipement pac supported {}", WrapperEquipmentPacRev170402.QNAME); + LOG.debug("Equipment pac supported {}", WrapperEquipmentPacRev170402.QNAME); } else { - this.equipmentPac = null; - LOG.debug("Equipement pac not supported {}", WrapperEquipmentPacRev170402.QNAME); + this.equipmentPac = EMPTYEQUIPMENTPAC; + LOG.debug("Equipment pac not supported {}", WrapperEquipmentPacRev170402.QNAME); } extensionList = new ValueNameList(); @@ -178,21 +179,18 @@ public class ONFCoreNetworkElement12Equipment { Equipment equipment = this.readEquipment(uuid); - if (equipment != null) { - equipmentList.add(new ExtendedEquipment(parentUuid.getValue(), equipment, treeLevel)); - - if (this.equipmentPac != null) { - this.equipmentPac.readTheFaults(uuid, problemList); - - List<ContainedHolder> containedHolderListe = equipment.getContainedHolder(); - if (containedHolderListe != null) { - for (ContainedHolder containedHolder : containedHolderListe) { - recurseReadEquipmentProblems(containedHolder.getOccupyingFru(), uuid, treeLevel + 1, - problemList, equipmentList); - } - } - } - } + if (equipment != null) { + equipmentList.add(new ExtendedEquipment(parentUuid.getValue(), equipment, treeLevel)); + + this.equipmentPac.readTheFaults(uuid, problemList); + List<ContainedHolder> containedHolderListe = equipment.getContainedHolder(); + if (containedHolderListe != null) { + for (ContainedHolder containedHolder : containedHolderListe) { + recurseReadEquipmentProblems(containedHolder.getOccupyingFru(), uuid, treeLevel + 1, + problemList, equipmentList); + } + } + } } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Microwave.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Microwave.java new file mode 100644 index 000000000..d8a052f7f --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Microwave.java @@ -0,0 +1,520 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.OnfMicrowaveModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service.HtDatabaseEventsService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.NetconfEventListener12; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClient; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance15Minutes; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance24Hours; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.MountPoint; +import org.opendaylight.controller.md.sal.binding.api.NotificationService; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.pac.NetworkElementCurrentProblems; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.common.QName; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Optional; + +/** + * Get information over NETCONF device according to ONF Coremodel. Read networkelement and + * conditional packages. + * + * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP), + * MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client), + * MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, + * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP), + * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP), + * ,MicrowaveModel-ObjectClasses-PureEthernetStructure + * + * @author herbert + * + */ +@SuppressWarnings("deprecation") +public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Base + implements ONFCoreNetworkElementCallback, NotificationActor<AttributeValueChangedNotificationXml> { + + private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Microwave.class); + + /*----------------------------------------------------------------------------- + * Class members + */ + private final @Nonnull NetconfEventListener12 microwaveEventListener; + private final @Nonnull OnfMicrowaveModel microwaveModel; + private final NotificationWorker<AttributeValueChangedNotificationXml> notificationQueue; + + private ListenerRegistration<NotificationListener> listenerRegistrationresult = null; + + /*----------------------------------------------------------------------------- + * Construction + */ + + /** + * Constructor + * + * @param mountPointNodeName as String + * @param capabilities of the specific network element + * @param netconfNodeDataBroker for the network element specific data + * @param webSocketService to forward event notifications + * @param databaseService to access the database + * @param dcaeProvider to forward problem / change notifications + */ + ONFCoreNetworkElement12Microwave(String mountPointNodeName, Capabilities capabilities, + DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService, + HtDatabaseEventsService databaseService, ProviderClient dcaeProvider, @Nullable ProviderClient aotsmClient, + MaintenanceService maintenanceService, + NotificationDelayService<ProblemNotificationXml> notificationDelayService, + OnfMicrowaveModel onfMicrowaveModel) { + + super(mountPointNodeName, netconfNodeDataBroker, capabilities); + + this.microwaveModel = onfMicrowaveModel; + this.microwaveModel.setCoreData(this); + + // Create MicrowaveService here + this.microwaveEventListener = new NetconfEventListener12(mountPointNodeName, webSocketService, + databaseService, dcaeProvider, aotsmClient, maintenanceService, notificationDelayService, this); + this.microwaveModel.setOnfMicrowaveModelListener(microwaveEventListener); + + this.notificationQueue = new NotificationWorker<>(1, 100, this); + + // ->Below shifted to super class + // this.isNetworkElementCurrentProblemsSupporting12 = + // capabilities.isSupportingNamespaceAndRevision(NetworkElementPac.QNAME); + // LOG.debug("support necurrent-problem-list=" + this.isNetworkElementCurrentProblemsSupporting12); + // LOG.info("Create NE instance {}", InstanceList.QNAME.getLocalName()); + + } + + /*----------------------------------------------------------------------------- + * Functions + */ + + /** + * DeviceMonitor Prepare check by updating NE state and reading all interfaces. + */ + @Override + public void prepareCheck() { + synchronized (dmLock) { + boolean change = readNetworkElementAndInterfaces(); + if (change) { + int problems = microwaveEventListener.removeAllCurrentProblemsOfNode(); + List<ProblemNotificationXml> resultList = readAllCurrentProblemsOfNode(); + microwaveEventListener.initCurrentProblemStatus(resultList); + LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountPointNodeName(), + getUuId(), problems, resultList.size()); + } + } + } + + // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class + // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class + + /*----------------------------------------------------------------------------- + * Synchronization + */ + + // public void initSynchronizationExtension() -> Shifted to super class + // private InstanceList readPTPClockInstances() -> Shifted to super class + + /*----------------------------------------------------------------------------- + * Services for NE/Device synchronization + */ + + /** + * Handling of specific Notifications from NE, indicating changes and need for synchronization. + * + * <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model"> + * <attribute-name>/equipment-pac/equipment-current-problems</attribute-name> + * <object-id-ref>CARD-1.1.1.0</object-id-ref> <new-value></new-value> + * </attribute-value-changed-notification> + * <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model"> + * <attribute-name>/network-element/extension[value-name="top-level-equipment"]/value</attribute-name> + * <object-id-ref>Hybrid-Z</object-id-ref> + * <new-value>SHELF-1.1.0.0,IDU-1.55.0.0,ODU-1.56.0.0,IDU-1.65.0.0</new-value> + * </attribute-value-changed-notification> + */ + + + @Override + public void notificationFromNeListener(AttributeValueChangedNotificationXml notificationXml) { + notificationQueue.put(notificationXml); + } + + @Override + public void notificationActor(AttributeValueChangedNotificationXml notificationXml) { + + LOG.debug("Enter change notification listener"); + if (LOG.isTraceEnabled()) { + LOG.trace("Notification: {}", notificationXml); + } + if (notificationXml.getAttributeName().equals("/equipment-pac/equipment-current-problems")) { + syncEquipmentPac(notificationXml.getObjectId()); + } else if (notificationXml.getAttributeName() + .equals("/network-element/extension[value-name=\"top-level-equipment\"]/value")) { + initialReadFromNetworkElement(); + } + LOG.debug("Leave change notification listener"); + } + + /** + * Synchronize problems for a specific equipment-pac + * + * @param uuidString of the equipment-pac + */ + private synchronized void syncEquipmentPac(String uuidString) { + + int problems = microwaveEventListener.removeObjectsCurrentProblemsOfNode(uuidString); + LOG.debug("Removed {} problems for uuid {}", problems, uuidString); + + List<ProblemNotificationXml> resultList = getEquipment().addProblemsofNodeObject(uuidString); + microwaveEventListener.initCurrentProblemStatus(resultList); + LOG.debug("Added {} problems for uuid {}", resultList.size(), uuidString); + + } + + + /*----------------------------------------------------------------------------- + * Problem/Fault related functions + */ + + /** + * Read during startup all relevant structure and status parameters from device + */ + @Override + public synchronized void initialReadFromNetworkElement() { + // optionalNe.getLtp().get(0).getLp(); + LOG.debug("Get info about {}", getMountPointNodeName()); + + int problems = microwaveEventListener.removeAllCurrentProblemsOfNode(); + LOG.debug("Removed all {} problems from database at registration", problems); + + // Step 2.1: access data broker within this mount point + LOG.debug("DBRead start"); + + // Step 2.2: read ne from data store + readNetworkElementAndInterfaces(); + getEquipment().readNetworkElementEquipment(); + + // Step 2.3: read the existing faults and add to DB + List<ProblemNotificationXml> resultList = readAllCurrentProblemsOfNode(); + getEquipment().addProblemsofNode(resultList); + + microwaveEventListener.initCurrentProblemStatus(resultList); + + microwaveEventListener.writeEquipment(getEquipment()); + + LOG.info("Found info at {} for device {} number of problems: {}", getMountPointNodeName(), getUuId(), + resultList.size()); + } + + /** + * LOG the newly added problems of the interface pac + * + * @param idxStart + * @param uuid + * @param resultList + */ + private void debugResultList(String uuid, List<ProblemNotificationXml> resultList, int idxStart) { + if (LOG.isDebugEnabled()) { + StringBuffer sb = new StringBuffer(); + int idx = 0; + for (int t = idxStart; t < resultList.size(); t++) { + sb.append(idx++); + sb.append(":{"); + sb.append(resultList.get(t)); + sb.append('}'); + } + LOG.debug("Found problems {} {}", uuid, sb.toString()); + } + } + + /** + * Read current problems of AirInterfaces and EthernetContainer according to NE status into DB + * + * @return List with all problems + */ + @Override + protected List<ProblemNotificationXml> readAllCurrentProblemsOfNode() { + + // Step 2.3: read the existing faults and add to DB + List<ProblemNotificationXml> resultList = new ArrayList<>(); + int idxStart; // Start index for debug messages + UniversalId uuid; + + synchronized (getPmLock()) { + for (Lp lp : getInterfaceList()) { + + idxStart = resultList.size(); + uuid = lp.getUuid(); + Class<?> lpClass = getLpExtension(lp); + + ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(lp.getLayerProtocolName()); + + microwaveModel.readTheFaultsOfMicrowaveModel(lpName, lpClass, uuid, resultList); + + debugResultList(uuid.getValue(), resultList, idxStart); + + } + } + + // Step 2.4: Read other problems from mountpoint + if (isNetworkElementCurrentProblemsSupporting12) { + idxStart = resultList.size(); + readNetworkElementCurrentProblems12(resultList); + debugResultList("CurrentProblems12", resultList, idxStart); + } + + return resultList; + + } + + /** + * Get from LayerProtocolExtensions the related generated ONF Interface PAC class which represents it. + * + * @param lp logical termination point + * @return Class of InterfacePac + */ + @Nullable + private Class<?> getLpExtension(@Nullable Lp lp) { + + String capability = EMPTY; + String revision = EMPTY; + String conditionalPackage = EMPTY; + Class<?> res = null; + + if (lp != null) { + for (Extension e : getExtensionList(lp)) { + if (e.getValueName().contentEquals("capability")) { + capability = e.getValue(); + int idx = capability.indexOf("?"); + if (idx != -1) { + capability = capability.substring(0, idx); + } + } + if (e.getValueName().contentEquals("revision")) { + revision = e.getValue(); + } + if (e.getValueName().contentEquals("conditional-package")) { + conditionalPackage = e.getValue(); + } + } + } + // QName qName = + // org.opendaylight.yangtools.yang.common.QName.create("urn:onf:params:xml:ns:yang:microwave-model", + // "2017-03-24", "mw-air-interface-pac").intern(); + LOG.info("LpExtension capability={} revision={} conditionalPackage={}", capability, revision, + conditionalPackage); + if (!capability.isEmpty() && !revision.isEmpty() && !conditionalPackage.isEmpty()) { + try { + QName qName = QName.create(capability, revision, conditionalPackage); + res = this.microwaveModel.getClassForLtpExtension(qName); + } catch (IllegalArgumentException e) { + LOG.debug("Can not create QName from ({}{}{}): {}", capability, revision, conditionalPackage, + e.getMessage()); + } + } + return res; + } + + /** + * Read element from class that could be not available + * + * @param ltp layer termination point + * @return List with extension parameters or empty list + */ + @Nonnull + private static List<Extension> getExtensionList(@Nullable Lp ltp) { + if (ltp != null && ltp.getExtension() != null) { + return ltp.getExtension(); + } else { + return EMPTYLTPEXTENSIONLIST; + } + } + + @Nonnull + private List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(Lp lp) { + ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(lp.getLayerProtocolName()); + + return this.microwaveModel.readTheHistoricalPerformanceData(lpName, lp); + } + + @Override + public AllPm getHistoricalPM() { + + synchronized (getPmLock()) { + if (pmLp != null) { + LOG.debug("Enter query PM"); + AllPm allPm = new AllPm(); + Lp lp = pmLp; + + List<? extends OtnHistoryDataG> resultList = readTheHistoricalPerformanceData(lp); + LOG.debug("Got records: {}", resultList.size()); + // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType + GranularityPeriodType granularityPeriod; + for (OtnHistoryDataG perf : resultList) { + + granularityPeriod = perf.getGranularityPeriod(); + if (granularityPeriod == null) { + granularityPeriod = GranularityPeriodType.Unknown; + } + + switch (granularityPeriod) { + case Period15Min: { + EsHistoricalPerformance15Minutes pm = + new EsHistoricalPerformance15Minutes(getMountPointNodeName(), lp) + .setHistoricalRecord15Minutes(perf); + allPm.add(pm); + } + break; + + case Period24Hours: { + EsHistoricalPerformance24Hours pm = + new EsHistoricalPerformance24Hours(getMountPointNodeName(), lp) + .setHistoricalRecord24Hours(perf); + LOG.debug("Write 24h write to DB"); + allPm.add(pm); + } + break; + + default: + LOG.warn("Unknown granularity {}", perf.getGranularityPeriod()); + break; + + } + } + LOG.debug("Deliver normalized records: {}", allPm.size()); + return allPm; + } else { + LOG.debug("Deliver empty, no LTP"); + return AllPm.getEmpty(); + } + } + } + + + /** + * Remove all entries from list + */ + @Override + public int removeAllCurrentProblemsOfNode() { + return microwaveEventListener.removeAllCurrentProblemsOfNode(); + } + + /** + * Register the listener + */ + @Override + public void doRegisterMicrowaveEventListener(MountPoint mountPoint) { + LOG.info("End registration listener for Mountpoint {}", mountPoint.getIdentifier().toString()); + final Optional<NotificationService> optionalNotificationService = + mountPoint.getService(NotificationService.class); + final NotificationService notificationService = optionalNotificationService.get(); + // notificationService.registerNotificationListener(microwaveEventListener); + listenerRegistrationresult = + notificationService.registerNotificationListener(microwaveModel.getNotificationListener()); + LOG.info("End registration listener for Mountpoint {} Listener: {} Result: {}", + mountPoint.getIdentifier().toString(), optionalNotificationService, listenerRegistrationresult); + } + + + /*------------------------------------------------------------ + * private function to access database + */ + + /*----------------------------------------------------------------------------- + * Reading problems for the networkElement V1.2 + */ + + private List<ProblemNotificationXml> readNetworkElementCurrentProblems12(List<ProblemNotificationXml> resultList) { + + LOG.info("DBRead Get {} NetworkElementCurrentProblems12", getMountPointNodeName()); + + InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac> networkElementCurrentProblemsIID = + InstanceIdentifier.builder( + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac.class) + .build(); + + // Step 2.3: read to the config data store + NetworkElementPac problemPac; + NetworkElementCurrentProblems problems; + try { + problemPac = GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, + networkElementCurrentProblemsIID); + problems = problemPac.getNetworkElementCurrentProblems(); + if (problems == null) { + LOG.debug("DBRead no NetworkElementCurrentProblems12"); + } else if (problems.getCurrentProblemList() == null) { + LOG.debug("DBRead empty CurrentProblemList12"); + } else { + for (org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.current.problems.g.CurrentProblemList problem : problems + .getCurrentProblemList()) { + resultList.add(new ProblemNotificationXml(getMountPointNodeName(), problem.getObjectReference(), + problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()), + problem.getSequenceNumber().toString(), + InternalDateAndTime.valueOf(problem.getTimeStamp()))); + } + } + } catch (Exception e) { + LOG.warn("DBRead {} NetworkElementCurrentProblems12 not supported. Message '{}' ", getMountPointNodeName(), + e.getMessage()); + } + return resultList; + + } + + @Override + public void close() throws Exception { + if (listenerRegistrationresult != null) { + listenerRegistrationresult.close(); + } + } + + + + +} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementBase.java index 530dabb42..f6fdb13b6 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementBase.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementBase.java @@ -20,9 +20,6 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf; -import java.util.List; -import javax.annotation.Nonnull; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.slf4j.Logger; @@ -42,10 +39,6 @@ public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCor private final String mountPointNodeName; private final DataBroker netconfNodeDataBroker; private final Capabilities capabilities; - private final boolean isNetworkElementCurrentProblemsSupporting10; - - private @Nonnull InventoryInformation inventoryInformation = new InventoryInformation(); - protected ONFCoreNetworkElementBase(String mountPointNodeName, DataBroker netconfNodeDataBroker, Capabilities capabilities) { @@ -54,8 +47,6 @@ public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCor this.netconfNodeDataBroker = netconfNodeDataBroker; this.capabilities = capabilities; - this.isNetworkElementCurrentProblemsSupporting10 = false; - } @Override @@ -77,33 +68,6 @@ public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCor return capabilities; } - /** - * @return the isNetworkElementCurrentProblemsSupporting10 - */ - public boolean isNetworkElementCurrentProblemsSupporting10() { - return isNetworkElementCurrentProblemsSupporting10; - } - - public void setInventoryInformation(InventoryInformation newInventoryInformation) { - this.inventoryInformation = newInventoryInformation; - } - - @Override - public InventoryInformation getInventoryInformation() { - return getInventoryInformation(null); - } - - @Override - public InventoryInformation getInventoryInformation(String layerProtocolFilter) { - InventoryInformation res = new InventoryInformation(inventoryInformation); - res.setInterfaceUuidList(getFilteredInterfaceUuidsAsStringList(layerProtocolFilter)); - - return res; - } - - @Override - public void close() throws Exception {} - /*--------------------------------------------------------------- * Getter/ Setter */ @@ -116,13 +80,4 @@ public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCor return netconfNodeDataBroker; } - /*----------------------------------------------------------------------------- - * Sychronization - */ - - @Override - public void initSynchronizationExtension() {} - - protected @Nonnull abstract List<String> getFilteredInterfaceUuidsAsStringList(String layerProtocolFilter); - } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCOreNetworkElementCoreData.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementCoreData.java index 3aa7116d6..d394af7b4 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCOreNetworkElementCoreData.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementCoreData.java @@ -17,14 +17,16 @@ ******************************************************************************/ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf; +import javax.annotation.Nullable; + import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; @SuppressWarnings("deprecation") -public interface ONFCOreNetworkElementCoreData { +public interface ONFCoreNetworkElementCoreData { public String getMountpoint(); public DataBroker getDataBroker(); - public NetworkElement getOptionalNetworkElement(); + public @Nullable NetworkElement getOptionalNetworkElement(); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreEmpty.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementEmpty.java index 00393d967..fe0c144a1 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreEmpty.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementEmpty.java @@ -22,18 +22,26 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.MountPoint; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author herbert * */ -public class ONFCoreEmpty implements ONFCoreNetworkElementRepresentation { +@SuppressWarnings("deprecation") +public class ONFCoreNetworkElementEmpty implements ONFCoreNetworkElementRepresentation { + + private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementEmpty.class); private String mountPointNodeName = ""; - ONFCoreEmpty(String mountPointNodeName) { + ONFCoreNetworkElementEmpty(String mountPointNodeName) { + LOG.info("Create {}",ONFCoreNetworkElementEmpty.class.getSimpleName()); this.mountPointNodeName = mountPointNodeName; } @@ -46,6 +54,11 @@ public class ONFCoreEmpty implements ONFCoreNetworkElementRepresentation { return mountPointNodeName; } + @Override + public String getMountpoint() { + return mountPointNodeName; + } + @Override public void resetPMIterator() { } @@ -66,7 +79,7 @@ public class ONFCoreEmpty implements ONFCoreNetworkElementRepresentation { @Override public String pmStatusToString() { - return "ONFCoreEmpty"; + return this.getClass().getSimpleName(); } @Override @@ -95,10 +108,6 @@ public class ONFCoreEmpty implements ONFCoreNetworkElementRepresentation { } @Override - public void initSynchronizationExtension() { - } - - @Override public InventoryInformation getInventoryInformation() { return InventoryInformation.getDefault(); } @@ -108,4 +117,14 @@ public class ONFCoreEmpty implements ONFCoreNetworkElementRepresentation { return InventoryInformation.getDefault(); } + @Override + public DataBroker getDataBroker() { + return null; + } + + @Override + public NetworkElement getOptionalNetworkElement() { + return null; + } + } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java index 2921401bc..3455f1681 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java @@ -21,6 +21,10 @@ import com.google.common.base.Optional; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.OnfMicrowaveModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperMicrowaveModelRev170324; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperMicrowaveModelRev180907; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperMicrowaveModelRev181010; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service.HtDatabaseEventsService; @@ -31,6 +35,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; 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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; @@ -66,7 +71,7 @@ public class ONFCoreNetworkElementFactory { if (csts == ConnectionStatus.Connected) { Capabilities capabilities = Capabilities.getAvailableCapabilities(nnode); LOG.info("Mountpoint {} capabilities {}", mountPointNodeName, capabilities); - res = ONFCoreNetworkElement12.build(mountPointNodeName, capabilities, mountpointDataBroker, + res = build(mountPointNodeName, capabilities, mountpointDataBroker, webSocketService, databaseService, dcaeProvider, aotsmClient, maintenanceService, notificationDelayService); LOG.info("ONFCoreNetworkElementRepresentation12 value is not null? " + (res != null)); @@ -78,14 +83,57 @@ public class ONFCoreNetworkElementFactory { LOG.warn("Can not generate specific NE Version representation. ", e); } if (res == null) { - res = new ONFCoreEmpty(mountPointNodeName); + res = new ONFCoreNetworkElementEmpty(mountPointNodeName); } LOG.info("Mointpoint {} started as {}", mountPointNodeName, res.getClass().getSimpleName()); return res; } public static @Nonnull ONFCoreNetworkElementRepresentation getEmpty(String mountPointNodeName) { - return new ONFCoreEmpty(mountPointNodeName); + return new ONFCoreNetworkElementEmpty(mountPointNodeName); + } + + /** + * Check capabilities are matching the this specific implementation and create network element + * representation if so. + * + * @param mountPointNodeName as String + * @param capabilities of the specific network element + * @param netconfNodeDataBroker for the network element specific data + * @param webSocketService to forward event notifications + * @param databaseService to access the database + * @param dcaeProvider to forward problem / change notifications + * @return created Object if conditions are OK or null if not. + */ + private static @Nullable ONFCoreNetworkElementRepresentation build(String mountPointNodeName, Capabilities capabilities, + DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService, + HtDatabaseEventsService databaseService, ProviderClient dcaeProvider, @Nullable ProviderClient aotsmClient, + MaintenanceService maintenanceService, + NotificationDelayService<ProblemNotificationXml> notificationDelayService) { + + if (capabilities.isSupportingNamespaceAndRevision(NetworkElement.QNAME)) { + OnfMicrowaveModel onfMicrowaveModel = null; + + if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)) { + onfMicrowaveModel = new WrapperMicrowaveModelRev170324(); + } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)) { + onfMicrowaveModel = new WrapperMicrowaveModelRev180907(); + } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)) { + onfMicrowaveModel = new WrapperMicrowaveModelRev181010(); + } + + if (onfMicrowaveModel != null) { + return new ONFCoreNetworkElement12Microwave(mountPointNodeName, capabilities, netconfNodeDataBroker, + webSocketService, databaseService, dcaeProvider, aotsmClient, maintenanceService, + notificationDelayService, onfMicrowaveModel); + } else { + return new ONFCoreNetworkElement12(mountPointNodeName, capabilities, netconfNodeDataBroker, + webSocketService, databaseService, dcaeProvider, aotsmClient, maintenanceService, + notificationDelayService); + } + } + return null; + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementRepresentation.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementRepresentation.java index c4fc9d01f..3e7a9caa7 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementRepresentation.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementRepresentation.java @@ -6,9 +6,9 @@ * ================================================================================================= * 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 @@ -18,38 +18,28 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm; import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitoredNe; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.MicrowaveModelPerformanceDataProvider; import org.opendaylight.controller.md.sal.binding.api.MountPoint; -public interface ONFCoreNetworkElementRepresentation extends DeviceMonitoredNe { +public interface ONFCoreNetworkElementRepresentation + extends DeviceMonitoredNe, MicrowaveModelPerformanceDataProvider, ONFCoreNetworkElementCoreData { - /** - * Read during startup all relevant structure and status parameters from device. - * Remove all currentAlarms, read structure from networkElement with all interfacePacs, read current alarm status - */ - public void initialReadFromNetworkElement(); + /** + * Read during startup all relevant structure and status parameters from device. + * Remove all currentAlarms, read structure from networkElement with all + * interfacePacs, read current alarm status + */ + public void initialReadFromNetworkElement(); - public String getMountPointNodeName(); + public String getMountPointNodeName(); - public void resetPMIterator(); + public int removeAllCurrentProblemsOfNode(); - public boolean hasNext(); + public void doRegisterMicrowaveEventListener(MountPoint mountPoint); - public void next(); + public InventoryInformation getInventoryInformation(); - public AllPm getHistoricalPM(); - - public String pmStatusToString(); - - public int removeAllCurrentProblemsOfNode(); - - public void doRegisterMicrowaveEventListener(MountPoint mountPoint); - - public void initSynchronizationExtension(); - - public InventoryInformation getInventoryInformation(); - - public InventoryInformation getInventoryInformation(String layerProtocolFilter); + public InventoryInformation getInventoryInformation(String layerProtocolFilter); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java index 403ba0ad4..1cfe10f08 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java @@ -116,6 +116,7 @@ public final class GenericTransactionUtils { data = optionalData.orNull(); statusIndicator.set("Read transaction done"); noErrorIndication.set(true); + LOG.debug("Read done with no error. Data:[{}]", data); } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java index 0dc6f0304..94913c40e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java @@ -18,16 +18,20 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util; import java.text.ParseException; -import java.text.SimpleDateFormat; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.Date; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; + import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** + * 2019/06/17 Redesign to ZonedDateTime because of sync problems. + * * Function is handling the NETCONF and the format used by database and restconf communication. * * Input supported for the formats used in NETCONF messages: @@ -70,16 +74,19 @@ public class NetconfTimeStamp { private static final NetconfTimeStamp CONVERTER = new NetconfTimeStamp(); - private final SimpleDateFormat dateFormatResult = init("yyyy-MM-dd'T'HH:mm:ss.S'Z'", TimeZone.getTimeZone("GMT")); - private final SimpleDateFormat dateFormatConvert = init("yyyy-MM-dd HH:mm:ss.S", TimeZone.getTimeZone("GMT")); - private static int MILLISECONDSDIGITS = 3; // Digits of milliseconds in dateFormatResult - private static String MILLISECONDZEROS = "000"; // String with zeros for milliseconds in dateFormatResult - private static final Pattern dateNetconfPatter = Pattern.compile( - "(\\d{4})-?(\\d{2})-?(\\d{2})T?(\\d{2}):?(\\d{2})(?:(?::?)(\\d{2}))?(?:.(\\d+))?(?:(Z)|([+-]\\d{2}):?(\\d{2}))"); - - /* - * ------------------------------------ Public function + /** + * Specify the input format expected from netconf, and from specific devices. */ + private static DateTimeFormatter formatterInput = DateTimeFormatter.ofPattern("" + + "[yyyy-MM-dd'T'HH:mm[:ss][.SSS][.SS][.S][xxx][xx][X][Z]]" + + "[yyyyMMddHHmmss[.SSS][.SS][.S][xxx][xx][X][Z]]" + ).withZone(ZoneOffset.UTC); + + /** + * Specify output format that is used internally + */ + private static DateTimeFormatter formatterOutput = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.S'Z'") + .withZone(ZoneOffset.UTC); /** * Use static access @@ -87,6 +94,10 @@ public class NetconfTimeStamp { private NetconfTimeStamp() { } + /* + * ------------------------------------ Public function + */ + /** * Use this function to get the converter * @return global converter @@ -101,7 +112,7 @@ public class NetconfTimeStamp { * @return String with Date in NETCONF/YANG Format Version 1.0. */ public String getTimeStampAsNetconfString() { - return this.getRightFormattedDate(new Date().getTime()); + return ZonedDateTime.now(ZoneOffset.UTC).format(formatterOutput); } /** @@ -110,8 +121,11 @@ public class NetconfTimeStamp { * @return String with Date in NETCONF/YANG Format Version 1.0. */ public String getTimeStampAsNetconfString(Date date) { - return getRightFormattedDate(date.getTime()); + return ZonedDateTime.ofInstant(date.toInstant(),ZoneOffset.UTC).format(formatterOutput); } + + + /** * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format in GMT * @@ -139,136 +153,40 @@ public class NetconfTimeStamp { * @throws IllegalArgumentException In case of no compliant time format definition for the string * @throws ParseException Time parsing failed */ - public long getTimeStampFromNetconfAsMilliseconds(String netconfTime) - throws IllegalArgumentException, ParseException { - Matcher m = dateNetconfPatter.matcher(netconfTime); - // According to spezified matches there have to be 10 parameter - if (m.matches() && m.groupCount() == 10) { - // Convert now - long utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime() - - getTimezoneOffsetMilliseconds(m.group(9), m.group(10)); - return utcMillis; - } else { - throw new IllegalArgumentException("No pattern for NETCONF data string: " + netconfTime); - } - } + public long getTimeStampFromNetconfAsMilliseconds(String netconfTime) throws IllegalArgumentException { + try { + long utcMillis = doParse(netconfTime).toInstant().toEpochMilli(); + return utcMillis; + } catch (DateTimeParseException e) { + throw new IllegalArgumentException( + "No pattern for NETCONF data string: " + netconfTime + " Msg:" + e.getMessage()); + } + } /** * Deliver String result. * * @param netconfTime as String according the formats given above * @return If successful: String in ISO8601 Format for database and presentation. If "wrong formed - * input" the Input string with the prefix "Mailformed date" is delivered back. + * input" the Input string with the prefix "Maleformed date" is delivered back. */ public String getTimeStampFromNetconf(String netconfTime) { - Matcher m = dateNetconfPatter.matcher(netconfTime); - // According to spezified matches there have to be 10 parameter - if (m.matches() && m.groupCount() == 10) { - // Convert now - try { - long utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime() - - getTimezoneOffsetMilliseconds(m.group(9), m.group(10)); - return getRightFormattedDate(utcMillis); - } catch (ParseException e) { - LOG.info(e.getMessage()); - } catch (IllegalArgumentException e) { - LOG.info(e.getMessage()); - } - } + try { + String inputUTC = doParse(netconfTime).format(formatterOutput); + return inputUTC; + } catch (Exception e) { + LOG.info(e.getMessage()); + } LOG.debug("No pattern for NETCONF data string: {}", netconfTime); return "Malformed date: " + netconfTime; // Error handling } - /*------------------------------------------- - * Private and static functions - */ - /** - * Convert timeZone parameter in format [+-]/d/d:/d/d into milliseconds - * - * @param m Index 9 with "+/-" and hour string or null for UTZ, Index 10 with minutes - * @return long milliseconds of TimeZoneOffset - * @throws IllegalArgumentException If parameters are wrong - */ - private static long getTimezoneOffsetMilliseconds(String timeZoneHour, String timeZoneMinute) - throws IllegalArgumentException { - // -- Calculate timezone specific offset - long timeZoneOffsetMilliseconds = 0; - if (timeZoneHour != null) { - // Time zone offset in hours and minutes - int tzHour = 0; - int tzMinutes = 0; - tzHour = Integer.valueOf(timeZoneHour); - if (timeZoneMinute != null) { - tzMinutes = Integer.valueOf(timeZoneMinute); - } else { - throw new IllegalArgumentException("Problem in Netconf Time format timeZone minutes parameter."); - } - timeZoneOffsetMilliseconds = (tzHour * 60 + (tzHour > 0 ? tzMinutes : -tzMinutes)) * 60000L; - } - return timeZoneOffsetMilliseconds; - } - - /** - * Convert parameters to String with year .. minutes and optional Seconds and .. milliseconds - * - * @param m Matcher with parsed date - * @param secString Seconds as String or null - * @param msString Milliseconds as String or null - * @return Normalized time string + /*---------------------------------------------------- + * Private functions */ - private static String getTimeAsNormalizedString(Matcher m, String secString, String msString) { - // -- Create time as normalized string - StringBuffer sb = new StringBuffer(); - sb.append(m.group(1)); // year - sb.append('-'); - sb.append(m.group(2)); // Month - sb.append('-'); - sb.append(m.group(3)); // Day - sb.append(' '); - sb.append(m.group(4)); // Hour 0-23 - sb.append(':'); - sb.append(m.group(5)); // Minute - sb.append(':'); - sb.append(secString != null ? secString : "00"); // Seconds (optional) - sb.append('.'); - if (msString == null) { // Milliseconds optional - sb.append(MILLISECONDZEROS); - } else if (msString.length() <= MILLISECONDSDIGITS) { - sb.append(msString); // Millisecond - sb.append(MILLISECONDZEROS.substring(0, MILLISECONDSDIGITS - msString.length())); - } else { - sb.append(msString.substring(0, MILLISECONDSDIGITS)); // Only first Three - } - return sb.toString(); - } - - /** - * Deliver format in a way that milliseconds are correct. - * - * @param dateMillis Date as milliseconds in Java definition - * @return String - */ - private String getRightFormattedDate(long dateMillis) { - long tenthOfSeconds = dateMillis % 1000 / 100L; // Extract 100 milliseconds - long base = dateMillis / 1000L * 1000L; // Cut milliseconds to 000 - Date newDate = new Date(base + tenthOfSeconds); - return dateFormatResult.format(newDate); - } - - /** - * Static initialization - */ - private static SimpleDateFormat init(String format, TimeZone zone) { - if (zone == null) { - throw new ExceptionInInitializerError(); - } else { - SimpleDateFormat dateFormat; - dateFormat = new SimpleDateFormat(format); - dateFormat.setTimeZone(zone); - return dateFormat; - } - } - + private OffsetDateTime doParse(String netconfTime) { + return OffsetDateTime.parse(netconfTime, formatterInput); + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModel.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModel.java index 637caa44b..d716a01bc 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModel.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModel.java @@ -18,7 +18,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc; import java.util.List; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementCoreData; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; @@ -29,7 +29,7 @@ import org.opendaylight.yangtools.yang.common.QName; public interface OnfMicrowaveModel { - public void setCoreData(ONFCOreNetworkElementCoreData coreData); + public void setCoreData(ONFCoreNetworkElementCoreData coreData); public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid, List<ProblemNotificationXml> resultList); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java index aeda48ea7..3ee0c91ad 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java @@ -25,7 +25,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementCoreData; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -42,9 +42,9 @@ public class WrapperEquipmentPacRev170402 implements OnfInterfacePac { private static final Logger LOG = LoggerFactory.getLogger(WrapperEquipmentPacRev170402.class); public static final QName QNAME = EquipmentPac.QNAME; - ONFCOreNetworkElementCoreData coreData; + ONFCoreNetworkElementCoreData coreData; - public WrapperEquipmentPacRev170402(ONFCOreNetworkElementCoreData coreData) { + public WrapperEquipmentPacRev170402(ONFCoreNetworkElementCoreData coreData) { this.coreData = coreData; } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java index 5c7e8d261..32fb095b4 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementCoreData; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType12; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; @@ -83,7 +83,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw public static final QName QNAME = MwAirInterfacePac.QNAME; - private ONFCOreNetworkElementCoreData coreData; + private ONFCoreNetworkElementCoreData coreData; private OnfMicrowaveModelNotification microwaveModelListener; /*----------------------------------------------------------------------------- @@ -91,11 +91,11 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw */ @Override - public void setCoreData(ONFCOreNetworkElementCoreData coreData) { + public void setCoreData(ONFCoreNetworkElementCoreData coreData) { this.coreData = coreData; } - public ONFCOreNetworkElementCoreData getCoreData() { + public ONFCoreNetworkElementCoreData getCoreData() { return coreData; } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java index 0328d79de..27583f8ac 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java @@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.binding.NotificationListener; import org.opendaylight.yangtools.yang.common.QName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementCoreData; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType1211; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; @@ -86,7 +86,7 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw public static final QName QNAME = MwAirInterfacePac.QNAME; - private ONFCOreNetworkElementCoreData coreData; + private ONFCoreNetworkElementCoreData coreData; private OnfMicrowaveModelNotification microwaveModelListener; @@ -96,11 +96,11 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw */ @Override - public void setCoreData(ONFCOreNetworkElementCoreData coreData) { + public void setCoreData(ONFCoreNetworkElementCoreData coreData) { this.coreData = coreData; } - public ONFCOreNetworkElementCoreData getCoreData() { + public ONFCoreNetworkElementCoreData getCoreData() { return coreData; } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java index 9a6b42589..86358072e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java @@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.binding.NotificationListener; import org.opendaylight.yangtools.yang.common.QName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementCoreData; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType1211p; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; @@ -86,7 +86,7 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw public static final QName QNAME = MwAirInterfacePac.QNAME; - private ONFCOreNetworkElementCoreData coreData; + private ONFCoreNetworkElementCoreData coreData; private OnfMicrowaveModelNotification microwaveModelListener; @@ -95,11 +95,11 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw */ @Override - public void setCoreData(ONFCOreNetworkElementCoreData coreData) { + public void setCoreData(ONFCoreNetworkElementCoreData coreData) { this.coreData = coreData; } - public ONFCOreNetworkElementCoreData getCoreData() { + public ONFCoreNetworkElementCoreData getCoreData() { return coreData; } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperPTPModelRev170208.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperPTPModelRev170208.java new file mode 100644 index 000000000..d02ca12fb --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperPTPModelRev170208.java @@ -0,0 +1,85 @@ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc; + +import java.util.List; + +import javax.annotation.Nullable; + +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentity; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Reading PTP specific information from networkelement and creating log-trace output. + * + * @author herbert + */ +@SuppressWarnings("deprecation") +public class WrapperPTPModelRev170208 { + + private static final Logger LOG = LoggerFactory.getLogger(WrapperPTPModelRev170208.class); + + protected static final InstanceIdentifier<InstanceList> PTPINSTANCES_IID = InstanceIdentifier + .builder(InstanceList.class, new InstanceListKey(1)).build(); + + /** + * Query synchronization information out of NE + */ + + public static void initSynchronizationExtension(String mountPointNodeName, DataBroker netconfNodeDataBroker, + Capabilities capabilities) { + try { + if (!capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)) { + LOG.debug("Mountpoint {} does not support PTP", mountPointNodeName); + } else { + StringBuffer sb = new StringBuffer(); + sb.append("NE "); + sb.append(mountPointNodeName); + sb.append(" does support synchronisation.\n"); + InstanceList ptpInstance = readPTPClockInstances(netconfNodeDataBroker); + if (ptpInstance != null) { + List<PortDsList> dsList = ptpInstance.getPortDsList(); + if (dsList != null) { + int t = 0; + for (PortDsList portDs : ptpInstance.getPortDsList()) { + PortIdentity portId = portDs.getPortIdentity(); + if (portId != null) { + sb.append("Port["); + sb.append(portId.getPortNumber()); + sb.append("]{ ClockId: "); + sb.append(portId.getClockIdentity()); + sb.append(", Portstate: "); + sb.append(portDs.getPortState()); + sb.append("}, "); + } else { + sb.append("Incomplete port #" + t + ", "); + } + t++; + } + } else { + sb.append("dsList contains null"); + } + } else { + sb.append("ptpInstance equals null"); + } + LOG.trace(sb.toString()); + } + } catch (Exception e) { + LOG.info("Inconsistent synchronisation structure: " + e.getMessage()); + } + } + + @Nullable + private static InstanceList readPTPClockInstances(DataBroker netconfNodeDataBroker) { + return GenericTransactionUtils.readData(netconfNodeDataBroker, LogicalDatastoreType.OPERATIONAL, + PTPINSTANCES_IID); + } + +} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java index 5f3c1aaca..e9da90945 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java @@ -28,11 +28,12 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; -import java.text.ParseException; + import javax.annotation.Nullable; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; + import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementRepresentation; @@ -331,7 +332,7 @@ public class DcaeMessages { long microseconds = -1; try { microseconds = NETCONFTIME_CONVERTER.getTimeStampFromNetconfAsMilliseconds(timeAsString) * 1000; - } catch (IllegalArgumentException | ParseException e) { + } catch (IllegalArgumentException e) { LOG.info("Can not convert timeAsString", e); } return String.valueOf(microseconds); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java index fc9fb75c4..0149d6fca 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java @@ -26,11 +26,9 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayFilter; import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.HtDevicemanagerConfiguration; import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.IConfigChangedListener; import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.DmConfig; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.ToggleAlarmConfig; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.ODLEventListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.slf4j.Logger; 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 e305face3..e5e3d6e48 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 @@ -45,7 +45,6 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificatio import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientDummyImpl; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientImpl2; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.index.impl.IndexConfigService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.index.impl.IndexMwtnService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.index.impl.IndexUpdateService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceServiceImpl; @@ -114,7 +113,7 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R private @Nullable AaiProviderClient aaiProviderClient = null; private @Nullable DeviceMonitor deviceMonitor = new DeviceMonitorEmptyImpl(); private IndexUpdateService updateService; - private IndexConfigService configService; + //private IndexConfigService configService; issue#1 private IndexMwtnService mwtnService; private HtDatabaseNode htDatabase; private Boolean devicemanagerInitializationOk = false; @@ -195,7 +194,7 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R if (akkaConfig == null || akkaConfig.isClusterAndFirstNode()) { // Create DB index if not existing and if database is running try { - this.configService = new IndexConfigService(htDatabase); + //this.configService = new IndexConfigService(htDatabase);issue#1 this.mwtnService = new IndexMwtnService(htDatabase); } catch (Exception e) { LOG.warn("Can not start ES access clients to provide database index config, mwtn. ", e); @@ -281,7 +280,8 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R close(aaiProviderClient); close(aotsMProvider); close(deviceMonitor); - close(updateService, configService, mwtnService); + //close(updateService, configService, mwtnService); issue#1 + close(updateService, mwtnService); close(htDatabase); close(netconfChangeListener); close(maintenanceService); @@ -419,7 +419,6 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R // -- Read data from NE ne.initialReadFromNetworkElement(); - ne.initSynchronizationExtension(); sendUpdateNotification(mountPointNodeName, nNode.getConnectionStatus()); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/MicrowaveEventListener12.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfEventListener12.java index 6612f626b..ae05da943 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/MicrowaveEventListener12.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfEventListener12.java @@ -35,18 +35,19 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNoti import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceService; -import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ProblemNotification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Important: Websocket notification must be the last action. - * @author herbert + * At the beginning intended to handle notifications of type <code>OnfMicrowaveModelNotification</code>. + * Today an abstract class for processing notifications independent of model. * - */ //OnfMicrowaveModelNotification // -public class MicrowaveEventListener12 implements OnfMicrowaveModelNotification, NotificationDelayedListener<ProblemNotificationXml> { + * @author herbert + */ +public class NetconfEventListener12 implements OnfMicrowaveModelNotification, NotificationDelayedListener<ProblemNotificationXml> { - private static final Logger LOG = LoggerFactory.getLogger(MicrowaveEventListener12.class); + private static final Logger LOG = LoggerFactory.getLogger(NetconfEventListener12.class); private final String nodeName; private final WebSocketServiceClient webSocketService; @@ -61,7 +62,7 @@ public class MicrowaveEventListener12 implements OnfMicrowaveModelNotification, private final NotificationDelayFilter<ProblemNotificationXml> delayFilter; private final ONFCoreNetworkElementCallback ne; - public MicrowaveEventListener12(String nodeName, WebSocketServiceClient webSocketService, + public NetconfEventListener12(String nodeName, WebSocketServiceClient webSocketService, HtDatabaseEventsService databaseService, ProviderClient dcaeProvider,@Nullable ProviderClient aotsmClient, MaintenanceService maintenanceService2,NotificationDelayService<ProblemNotificationXml> notificationDelayService, ONFCoreNetworkElementCallback ne) { @@ -135,7 +136,7 @@ public class MicrowaveEventListener12 implements OnfMicrowaveModelNotification, @Override public void onNotificationDelay(ProblemNotificationXml notificationXml) { - LOG.debug("Got delayed event of type :: {}", ProblemNotification.class.getSimpleName()); + LOG.debug("Got delayed event of type :: {}", ProblemNotificationXml.class.getSimpleName()); this.pushAlarmIfNotInMaintenance(notificationXml); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java index 282c1bad9..26757170b 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java @@ -18,12 +18,15 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml; import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; +import org.slf4j.Logger; @XmlRootElement(name = "ProblemNotification") public class ProblemNotificationXml extends MwtNotificationBase implements GetEventType { @@ -102,6 +105,7 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv return strBuf.toString(); } + @Override public String toString() { return "ProblemNotificationXml [problem=" + problem + ", severity=" + severity + ", toString()=" @@ -112,4 +116,24 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv public String getEventType() { return EVENTTYPE; } + + /** + * LOG the newly added problems of the interface pac + * @param idxStart + * @param uuid + * @param resultList + */ + public static void debugResultList(Logger log, String uuid, List<ProblemNotificationXml> resultList, int idxStart) { + if (log.isDebugEnabled()) { + StringBuffer sb = new StringBuffer(); + int idx = 0; + for (int t = idxStart; t < resultList.size(); t++) { + sb.append(idx++); + sb.append(":{"); + sb.append(resultList.get(t)); + sb.append('}'); + } + log.debug("Found problems {} {}", uuid, sb.toString()); + } + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexConfigService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexConfigService.java deleted file mode 100644 index 25e18eb23..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexConfigService.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 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========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.index.impl; - -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseClientAbstract; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.IndexClientBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Setup index mwtn in the database - * @author herbert - * - */ -public class IndexConfigService implements AutoCloseable { - - private static final Logger LOG = LoggerFactory.getLogger(IndexConfigService.class); - - /** Index name to be used */ - private static final String INDEX = "config"; - /** Location of configuration data **/ - private static final String MODELDATA = "/elasticsearch/index/config"; - - private final HtDatabaseClientAbstract client; - - // --- Construct and initialize - - public IndexConfigService(HtDatabaseNode database) throws Exception { - LOG.info("Create {} start", this.getClass().getSimpleName()); - - IndexClientBuilder clientBuilder = IndexClientBuilder.getBuilder(INDEX).setModelDataDirectory(MODELDATA); - client = clientBuilder.create(database); - clientBuilder.close(); - LOG.info("Create {} finished. DB Service sucessfully started.", this.getClass().getSimpleName()); - } - - @Override - public void close() throws Exception { - client.close(); - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java index 0e6b03291..4f3469759 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java @@ -44,7 +44,6 @@ public class IndexMwtnService implements AutoCloseable, ArchiveCleanProvider { /** Location of mapping data **/ private static final String MAPPING = "elasticsearch/index/mwtn/mwtnMapping.json"; /** Location of configuration data **/ - private static final String MODELDATA = "elasticsearch/index/mwtn/modelDescription"; private final HtDataBaseReaderAndWriter<EsEventOdluxLog> eventRWOdluxLog; @@ -58,8 +57,7 @@ public class IndexMwtnService implements AutoCloseable, ArchiveCleanProvider { IndexClientBuilder clientBuilder = IndexClientBuilder.getBuilder(INDEX) - .setMappingSettingJsonFileName(MAPPING) - .setModelDataDirectory(MODELDATA); + .setMappingSettingJsonFileName(MAPPING); client = clientBuilder.create(database); clientBuilder.close(); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/MicrowaveModelPerformanceDataProvider.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/MicrowaveModelPerformanceDataProvider.java new file mode 100644 index 000000000..d6391aabd --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/MicrowaveModelPerformanceDataProvider.java @@ -0,0 +1,24 @@ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl; + +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm; + + +/** + * Identify the NE as provider for performance data according to microwave model. + * + * @author herbert + */ + +public interface MicrowaveModelPerformanceDataProvider { + + public void resetPMIterator(); + + public boolean hasNext(); + + public void next(); + + public AllPm getHistoricalPM(); + + public String pmStatusToString(); + +} |