diff options
Diffstat (limited to 'sdnr')
79 files changed, 1755 insertions, 1709 deletions
diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/factory/NetworkElementFactory.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/factory/NetworkElementFactory.java index 08fe56f31..4b3881e0b 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/factory/NetworkElementFactory.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/factory/NetworkElementFactory.java @@ -26,6 +26,7 @@ import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; public interface NetworkElementFactory { - Optional<NetworkElement> create(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider); + Optional<NetworkElement> create(@NonNull NetconfAccessor acessor, + @NonNull DeviceManagerServiceProvider serviceProvider); } diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/DeviceMonitoredNe.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/DeviceMonitoredNe.java index 5d47c0cc1..e86559cd4 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/DeviceMonitoredNe.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/DeviceMonitoredNe.java @@ -33,12 +33,14 @@ public interface DeviceMonitoredNe extends NetworkElementService { /** * Test connection to mediator, by getting data that have to be called from NE + * * @return true if connection working, false if not */ public boolean checkIfConnectionToMediatorIsOk(); /** * Test connection to NE via mediator, by getting data that have to be called from NE + * * @return true if connection working, false if not */ public boolean checkIfConnectionToNeIsOk(); diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/InventoryProvider.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/InventoryProvider.java index d6dea7dc5..27c2e3b2d 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/InventoryProvider.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/InventoryProvider.java @@ -21,6 +21,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationD /** * Provide Inventory information + * * @author herbert * */ diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/NetworkElement.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/NetworkElement.java index e6ebfdcd5..7c3841ee9 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/NetworkElement.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ne/service/NetworkElement.java @@ -39,10 +39,8 @@ public interface NetworkElement extends NetworkElementService { /** self selected device type **/ NetworkElementDeviceType getDeviceType(); - /** Provide optional service interface. - * Services: - * InventoryProvider.class - * DeviceMonitoredNe.class + /** + * Provide optional service interface. Services: InventoryProvider.class DeviceMonitoredNe.class **/ <L extends NetworkElementService> Optional<L> getService(Class<L> clazz); diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/DeviceManagerServiceProvider.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/DeviceManagerServiceProvider.java index efccdf0a4..741123b87 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/DeviceManagerServiceProvider.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/DeviceManagerServiceProvider.java @@ -23,23 +23,29 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; public interface DeviceManagerServiceProvider { - /** @return Get a dataprovider**/ - @NonNull DataProvider getDataProvider(); + /** @return Get a dataprovider **/ + @NonNull + DataProvider getDataProvider(); /** @return Get notification service **/ - @NonNull NotificationService getNotificationService(); + @NonNull + NotificationService getNotificationService(); /** @return Get service for handling fault **/ - @NonNull FaultService getFaultService(); + @NonNull + FaultService getFaultService(); /** @return Get service for handling fault **/ - @NonNull EquipmentService getEquipmentService(); + @NonNull + EquipmentService getEquipmentService(); /** @return Get Active and available inventory service */ - @NonNull AaiService getAaiService(); + @NonNull + AaiService getAaiService(); /** @return MaintenanceService object for maintenance service */ - @NonNull MaintenanceService getMaintenanceService(); + @NonNull + MaintenanceService getMaintenanceService(); /** @return related service instance */ @NonNull @@ -50,5 +56,6 @@ public interface DeviceManagerServiceProvider { EventHandlingService getEventHandlingService(); /** @return Get configuration descriptor */ - @NonNull ConfigurationFileRepresentation getConfigurationFileRepresentation(); + @NonNull + ConfigurationFileRepresentation getConfigurationFileRepresentation(); } diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/EquipmentService.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/EquipmentService.java index a809e6774..10a3aa670 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/EquipmentService.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/EquipmentService.java @@ -30,6 +30,7 @@ public interface EquipmentService extends DeviceManagerService { /** * Write equipment to database + * * @param equipment with all equipment entities (card, subrack) of device */ void writeEquipment(@NonNull EquipmentData equipment); diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/FaultService.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/FaultService.java index dc2ce93db..d8a175036 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/FaultService.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/FaultService.java @@ -30,13 +30,16 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. */ public interface FaultService extends DeviceManagerService { - /** Notify fault information to devicemanager + /** + * Notify fault information to devicemanager + * * @param faultNotification to send */ void faultNotification(@NonNull FaultlogEntity faultNotification); /** * Fault notification + * * @param nodeId of node * @param counter provided * @param timeStamp provided @@ -44,11 +47,12 @@ public interface FaultService extends DeviceManagerService { * @param problem provided * @param severity provided */ - void faultNotification(@NonNull NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, @Nullable String objectId, - @Nullable String problem, @Nullable SeverityType severity); + void faultNotification(@NonNull NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, + @Nullable String objectId, @Nullable String problem, @Nullable SeverityType severity); /** * Remove current problems of node + * * @param nodeId of node * @return number of removed entries */ @@ -56,6 +60,7 @@ public interface FaultService extends DeviceManagerService { /** * Write initial list of problems of node + * * @param nodeId of node * @param resultList */ diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/MaintenanceService.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/MaintenanceService.java index d0eab3550..8a2ffd880 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/MaintenanceService.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/MaintenanceService.java @@ -20,9 +20,9 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.service; public interface MaintenanceService extends DeviceManagerService { /** - * Verify maintenance state of given object according to the filter settings. - * The object is specified by the criteria provided in the parameters. - * The data _id (uuid) is equal to the mountpointReference. + * Verify maintenance state of given object according to the filter settings. The object is specified by the + * criteria provided in the parameters. The data _id (uuid) is equal to the mountpointReference. + * * @param mountpointReference used as reference, to query the data from database. * @param objectIdRef first level id in onf core model, delivered by notification objectid * @param problem problem name of device, delivered in problem notification diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NetconfNetworkElementService.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NetconfNetworkElementService.java index d2d4cd5ff..80a7e2f07 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NetconfNetworkElementService.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NetconfNetworkElementService.java @@ -25,7 +25,8 @@ import org.opendaylight.yangtools.concepts.Registration; public interface NetconfNetworkElementService extends Registration, DeviceManagerService { /** Register factory class for network-element handler **/ - @NonNull <L extends NetworkElementFactory> FactoryRegistration<L> registerNetworkElementFactory(@NonNull L factory); + @NonNull + <L extends NetworkElementFactory> FactoryRegistration<L> registerNetworkElementFactory(@NonNull L factory); /** Get Devicemanager service **/ DeviceManagerServiceProvider getServiceProvider(); diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationService.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationService.java index f3f82caca..3e1589a4d 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationService.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationService.java @@ -33,13 +33,16 @@ public interface NotificationService extends DeviceManagerService { void eventNotification(@NonNull EventlogEntity eventNotification); /** create notification for an object **/ - void creationNotification(NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, @Nullable String objectId); + void creationNotification(NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, + @Nullable String objectId); /** create notification of object **/ void deletionNotification(NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, @Nullable String objectId); - /** change notification of attribute of object + /** + * change notification of attribute of object + * * @param nodeId of device * @param counter provided * @param timeStamp provided diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/EquipmentData.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/EquipmentData.java index cb251cbd4..f4ae48fe7 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/EquipmentData.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/EquipmentData.java @@ -62,6 +62,7 @@ public class EquipmentData { /** * Get list with all equipment + * * @return list with equipment */ public List<Inventory> getList() { diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/FaultData.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/FaultData.java index c2c1706dd..51cf2680f 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/FaultData.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/FaultData.java @@ -79,8 +79,7 @@ public class FaultData { /** * */ - public void clear() { - } + public void clear() {} /** * @param idx of element to get @@ -92,6 +91,7 @@ public class FaultData { /** * Provide list with all problems of node + * * @return list */ public List<Faultlog> getProblemList() { diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/FaultNotificationBuilder2.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/FaultNotificationBuilder2.java index 62ba644e1..facf142a5 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/FaultNotificationBuilder2.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/FaultNotificationBuilder2.java @@ -30,7 +30,8 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. public class FaultNotificationBuilder2 extends FaultlogBuilder { public FaultNotificationBuilder2(NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, - @Nullable String objectId, @Nullable String problem, @Nullable SeverityType severity, SourceType sourceType) { + @Nullable String objectId, @Nullable String problem, @Nullable SeverityType severity, + SourceType sourceType) { setNodeId(nodeId.getValue()); if (counter != null) { diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InternalConnectionStatus.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InternalConnectionStatus.java index bc6f3c554..ae1b5c88c 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InternalConnectionStatus.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InternalConnectionStatus.java @@ -22,16 +22,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionLogStatus; public class InternalConnectionStatus { - public static ConnectionLogStatus statusFromNodeStatus(ConnectionStatus nodeStatus) { - switch(nodeStatus) { - case Connected: - return ConnectionLogStatus.Connected; - case Connecting: - return ConnectionLogStatus.Connecting; - case UnableToConnect: - return ConnectionLogStatus.UnableToConnect; - default: - return ConnectionLogStatus.Undefined; - } - } + public static ConnectionLogStatus statusFromNodeStatus(ConnectionStatus nodeStatus) { + switch (nodeStatus) { + case Connected: + return ConnectionLogStatus.Connected; + case Connecting: + return ConnectionLogStatus.Connecting; + case UnableToConnect: + return ConnectionLogStatus.UnableToConnect; + default: + return ConnectionLogStatus.Undefined; + } + } } diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InventoryInformationDcae.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InventoryInformationDcae.java index 7e25f6035..cf43a5735 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InventoryInformationDcae.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InventoryInformationDcae.java @@ -36,28 +36,26 @@ public class InventoryInformationDcae { private String deviceIpv6; private List<String> interfaceUuidList; - public InventoryInformationDcae() - { - this.type=UNKNOWN; - this.model=UNKNOWN; - this.vendor=UNKNOWN; - this.deviceIpv4=UNKNOWN; - this.deviceIpv6=UNKNOWN; - this.interfaceUuidList=EMPTY; + public InventoryInformationDcae() { + this.type = UNKNOWN; + this.model = UNKNOWN; + this.vendor = UNKNOWN; + this.deviceIpv4 = UNKNOWN; + this.deviceIpv6 = UNKNOWN; + this.interfaceUuidList = EMPTY; } public InventoryInformationDcae(InventoryInformationDcae inventoryInformation) { - this.type=inventoryInformation.type; - this.model=inventoryInformation.model; - this.vendor=inventoryInformation.vendor; - this.deviceIpv4=inventoryInformation.deviceIpv4; - this.deviceIpv6=inventoryInformation.deviceIpv6; - this.interfaceUuidList=new ArrayList<>(inventoryInformation.interfaceUuidList); + this.type = inventoryInformation.type; + this.model = inventoryInformation.model; + this.vendor = inventoryInformation.vendor; + this.deviceIpv4 = inventoryInformation.deviceIpv4; + this.deviceIpv6 = inventoryInformation.deviceIpv6; + this.interfaceUuidList = new ArrayList<>(inventoryInformation.interfaceUuidList); } - public InventoryInformationDcae( - String type, String model, String vendor, String deviceIpv4, - String deviceIpv6, List<String> interfaceUuidList) { + public InventoryInformationDcae(String type, String model, String vendor, String deviceIpv4, String deviceIpv6, + List<String> interfaceUuidList) { setType(type); setModel(model); setVendor(vendor); @@ -111,7 +109,7 @@ public class InventoryInformationDcae { } public InventoryInformationDcae setDeviceIpv6(String deviceIpv6) { - this.deviceIpv6 = deviceIpv6 != null ? deviceIpv6 : UNKNOWN ; + this.deviceIpv6 = deviceIpv6 != null ? deviceIpv6 : UNKNOWN; return this; } diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/util/UnkownDevicemanagerServiceException.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/util/UnkownDevicemanagerServiceException.java index d47961607..b5193689e 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/util/UnkownDevicemanagerServiceException.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/util/UnkownDevicemanagerServiceException.java @@ -22,7 +22,7 @@ public class UnkownDevicemanagerServiceException extends Exception { private static final long serialVersionUID = 1L; public UnkownDevicemanagerServiceException(String string, Class<?> serviceInterface) { - super(string+" "+serviceInterface.getName()); + super(string + " " + serviceInterface.getName()); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiWebApiClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiWebApiClient.java index 9b38c1143..44a5c9688 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiWebApiClient.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiWebApiClient.java @@ -77,6 +77,7 @@ public class AaiWebApiClient extends BaseHTTPClient { /** * Create and specify defition parametrs of pnf + * * @param pnfId name * @param type type * @param model model @@ -94,6 +95,7 @@ public class AaiWebApiClient extends BaseHTTPClient { /** * Unregister + * * @param pnfId name * @return true if http response code was 200 or false if not. */ @@ -104,6 +106,7 @@ public class AaiWebApiClient extends BaseHTTPClient { /** * Send registration request + * * @param pnfId name * @return error accoring to http response code or -1 */ diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiClientPropertiesFile.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiClientPropertiesFile.java index ee4871710..8329ec0e9 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiClientPropertiesFile.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiClientPropertiesFile.java @@ -33,59 +33,59 @@ public class AaiClientPropertiesFile { private int mConnectionTimeout; private int mReadTimeout; - public String getFilename() { - return this.mFile.getAbsolutePath(); - } + public String getFilename() { + return this.mFile.getAbsolutePath(); + } - public String getPCKS12CertFilename() { - return this.mPCKS12CertFilename; - } + public String getPCKS12CertFilename() { + return this.mPCKS12CertFilename; + } - public String getPCKS12Passphrase() { - return this.mPCKS12Passphrase; - } + public String getPCKS12Passphrase() { + return this.mPCKS12Passphrase; + } - public boolean trustInsecureSSL() { - return this.mTrustInsecureSSL; - } + public boolean trustInsecureSSL() { + return this.mTrustInsecureSSL; + } - public String getApplicationIdentifier() { - return this.mApplicationIdentifier; - } + public String getApplicationIdentifier() { + return this.mApplicationIdentifier; + } - public String getRemoteUrl() { - return this.mRemoteUrl; - } + public String getRemoteUrl() { + return this.mRemoteUrl; + } - public int getConnectionTimeout() { - return this.mConnectionTimeout; - } + public int getConnectionTimeout() { + return this.mConnectionTimeout; + } - public int getReadTimeout() { - return this.mReadTimeout; - } + public int getReadTimeout() { + return this.mReadTimeout; + } - public boolean exists() { - return this.mFile.exists(); - } + public boolean exists() { + return this.mFile.exists(); + } - public AaiClientPropertiesFile(String filename) { - this.mFile = new File(filename); - } + public AaiClientPropertiesFile(String filename) { + this.mFile = new File(filename); + } - public void load() throws IOException, NumberFormatException { - Properties defaultProps = new Properties(); - FileInputStream in = new FileInputStream(this.mFile); - defaultProps.load(in); - this.mPCKS12CertFilename = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key", null); - this.mPCKS12Passphrase = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd", null); - this.mTrustInsecureSSL = defaultProps - .getProperty("org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore", "false").equals("true"); - this.mApplicationIdentifier = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.application", null); - this.mRemoteUrl = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.uri", null); - this.mConnectionTimeout = Integer.parseInt(defaultProps.getProperty("connection.timeout", "60000")); - this.mReadTimeout = Integer.parseInt(defaultProps.getProperty("read.timeout", "60000")); - in.close(); - } + public void load() throws IOException, NumberFormatException { + Properties defaultProps = new Properties(); + FileInputStream in = new FileInputStream(this.mFile); + defaultProps.load(in); + this.mPCKS12CertFilename = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key", null); + this.mPCKS12Passphrase = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd", null); + this.mTrustInsecureSSL = defaultProps + .getProperty("org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore", "false").equals("true"); + this.mApplicationIdentifier = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.application", null); + this.mRemoteUrl = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.uri", null); + this.mConnectionTimeout = Integer.parseInt(defaultProps.getProperty("connection.timeout", "60000")); + this.mReadTimeout = Integer.parseInt(defaultProps.getProperty("read.timeout", "60000")); + in.close(); + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java index ed88f8959..e590d7faf 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java @@ -36,242 +36,246 @@ import org.slf4j.LoggerFactory; public class AaiConfig implements Configuration { - private static Logger LOG = LoggerFactory.getLogger(AaiConfig.class); - - private static final String SECTION_MARKER_AAI = "aai"; - - private enum Config { - AAIPROP_FILE("aaiPropertiesFile", "null"), BASEURL("aaiUrl", "off", "org.onap.ccsdk.sli.adaptors.aai.uri"), - USERCREDENTIALS("aaiUserCredentials", ""), HEADERS("aaiHeaders", "[\"X-TransactionId: 9999\"]"), - DELETEONMOUNTPOINTREMOVED("aaiDeleteOnMountpointRemove", false), - TRUSTALLCERTS("aaiTrustAllCerts", false, "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore"), - APIVERSION("aaiApiVersion", "aai/v13"), - PCKS12CERTFILENAME("aaiPcks12ClientCertFile", "", "org.onap.ccsdk.sli.adaptors.aai.ssl.key"), - PCKS12PASSPHRASE("aaiPcks12ClientCertPassphrase", "", "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd"), - CONNECTIONTIMEOUT("aaiClientConnectionTimeout", String.valueOf(DEFAULT_VALUE_CONNECTION_TIMEOUT), - "connection.timeout"), //in ms; - APPLICATIONID("aaiApplicationId", "SDNR", "org.onap.ccsdk.sli.adaptors.aai.application"), - HTTPREADTIMEOUT("aaiReadTimeout", "60000", "read.timeout"); - - private String propertyKey; - private String propertyValue; - private Optional<String> propertyKeySecondFile; - - Config(String propertyKey, Object propertyValue) { - this.propertyKey = propertyKey; - this.propertyValue = propertyValue.toString(); - this.propertyKeySecondFile = Optional.empty(); - } - - Config(String propertyKey, Object propertyValue, String propertyKeySecondFile) { - this(propertyKey, propertyValue); - this.propertyKeySecondFile = Optional.of(propertyKeySecondFile); - } - } - - private static final long DEFAULT_VALUE_CONNECTION_TIMEOUT = 30000; //in ms - private static final String HEADER_KEY_APPLICATION = "X-FromAppId"; - - private final ConfigurationFileRepresentation configuration; - - public AaiConfig(ConfigurationFileRepresentation configuration) { - HtAssert.nonnull(configuration); - this.configuration = configuration; - this.configuration.addSection(SECTION_MARKER_AAI); - defaults(); - } - - /* - * Getter - */ - - public boolean doDeleteOnMountPointRemoved() { - return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.DELETEONMOUNTPOINTREMOVED.propertyKey); - } - - public boolean getTrustAll() { - return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.TRUSTALLCERTS.propertyKey); - } - - public String getPcks12CertificateFilename() { - return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12CERTFILENAME.propertyKey); - } - - public String getPcks12CertificatePassphrase() { - return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12PASSPHRASE.propertyKey); - } - - public int getConnectionTimeout() { - long res = configuration.getPropertyLong(SECTION_MARKER_AAI, Config.CONNECTIONTIMEOUT.propertyKey) - .orElse(DEFAULT_VALUE_CONNECTION_TIMEOUT); - return (int) res; - } - - public boolean isOff() { - return configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey).equalsIgnoreCase("off"); - } - - public String getBaseUri() { - String res = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey); - if (!res.startsWith("/")) { - res = "/" + res; - } - return res; - } - - public String getBaseUrl() { - if (isOff()) { - return ""; - } - - String url = configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey); - if (!url.endsWith("/")) { - url += "/"; - } - String apiVersion = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey); - if (apiVersion.startsWith("/")) { - apiVersion = apiVersion.substring(1); - } - return url + apiVersion; - - } - - public Map<String, String> getHeaders() { - - Map<String, String> headers = _parseHeadersMap( - configuration.getProperty(SECTION_MARKER_AAI, Config.HEADERS.propertyKey)); - headers.put(HEADER_KEY_APPLICATION, - configuration.getProperty(SECTION_MARKER_AAI, Config.APPLICATIONID.propertyKey)); - - String credentials = configuration.getProperty(SECTION_MARKER_AAI, Config.USERCREDENTIALS.propertyKey); - if (!nullorempty(credentials)) { - String credentialParts[] = credentials.split(":"); - if (credentialParts.length == 2) { - // 0:username 1:password - String s = headers.getOrDefault("Authorization", null); - if (nullorempty(s) && !nullorempty(credentialParts[0]) && !nullorempty(credentialParts[1])) { - headers.put("Authorization", - "Basic " + new String(Base64.getEncoder().encode(credentials.getBytes()))); - } - } - } - return headers; - } - - @Override - public String getSectionName() { - return SECTION_MARKER_AAI; - } - - @Override - public void defaults() { - for (Config conf : Config.values()) { - configuration.setPropertyIfNotAvailable(SECTION_MARKER_AAI, conf.propertyKey, conf.propertyValue); - } - // If file is available, the content is assigned to related parameters. - getAaiPropertiesFile(); - } - - @Override - public String toString() { - return "AaiConfig [doDeleteOnMountPointRemoved()=" + doDeleteOnMountPointRemoved() + ", getTrustAll()=" - + getTrustAll() + ", getPcks12CertificateFilename()=" + getPcks12CertificateFilename() - + ", getPcks12CertificatePassphrase()=" + getPcks12CertificatePassphrase() + ", getConnectionTimeout()=" - + getConnectionTimeout() + ", isOff()=" + isOff() + ", getBaseUri()=" + getBaseUri() + ", getBaseUrl()=" - + getBaseUrl() + ", getHeaders()=" + getHeaders() + ", getSectionName()=" + getSectionName() + "]"; - } - - /* - * Private - */ - - private boolean nullorempty(String s) { - return s == null || s.isEmpty(); - } - - /** - * Convert headers to configuration string. - * @param headers - * @return - */ - @SuppressWarnings("unused") - private static String _printHeadersMap(Map<String, String> headers) { - String r = "["; - if (headers != null) { - int i = 0; - for (Entry<String, String> entry : headers.entrySet()) { - if (i > 0) { - r += ","; - } - r += "\"" + entry.getKey() + ":" + entry.getValue() + "\""; - i++; - } - } - r += "]"; - return r; - } - - private static Map<String, String> _parseHeadersMap(String s) { - - LOG.info("Parse: '{}'", s); - Map<String, String> r = new HashMap<>(); - if (s != null) { - s = s.trim(); - if (!s.isEmpty()) { - JSONArray a; - try { - a = new JSONArray(s); - if (a.length() > 0) { - for (int i = 0; i < a.length(); i++) { - String item = a.getString(i); - String[] hlp = item.split(":"); - if (hlp.length > 1) { - r.put(hlp[0], hlp[1]); - } - } - } - } catch (Exception e) { - LOG.debug("Unparsable '{}'", s); - } - } - } - return r; - } - - /** - * Read file if available and assign to configuration - */ - private void getAaiPropertiesFile() { - String aaiPropertiesFileName = configuration.getProperty(SECTION_MARKER_AAI, Config.AAIPROP_FILE.propertyKey); - File f = new File(aaiPropertiesFileName); - if (f.exists()) { - InputStream in = null; - try { - in = new FileInputStream(f); - Properties defaultProps = new Properties(); - defaultProps.load(in); - - for (Config conf : Config.values()) { - if (conf.propertyKeySecondFile.isPresent()) { - String config = defaultProps.getProperty(conf.propertyKeySecondFile.get(), - conf.propertyValue); - LOG.debug("Property file assign {} = {} ", conf.propertyKey, config); - configuration.setProperty(SECTION_MARKER_AAI, conf.propertyKey, config); - } - } - - } catch (IOException e) { - LOG.warn("Problem during file read {} {}", f.getAbsoluteFile(), e); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - LOG.warn("problem closing file string for {}: {}",f.getAbsoluteFile(),e); - } - } - } - } - } + private static Logger LOG = LoggerFactory.getLogger(AaiConfig.class); + + private static final String SECTION_MARKER_AAI = "aai"; + + private enum Config { + // @formatter:off + AAIPROP_FILE("aaiPropertiesFile", "null"), + BASEURL("aaiUrl", "off", "org.onap.ccsdk.sli.adaptors.aai.uri"), + USERCREDENTIALS("aaiUserCredentials", ""), + HEADERS("aaiHeaders", "[\"X-TransactionId: 9999\"]"), + DELETEONMOUNTPOINTREMOVED("aaiDeleteOnMountpointRemove", false), + TRUSTALLCERTS("aaiTrustAllCerts", false, "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore"), + APIVERSION("aaiApiVersion", "aai/v13"), + PCKS12CERTFILENAME("aaiPcks12ClientCertFile", "", "org.onap.ccsdk.sli.adaptors.aai.ssl.key"), + PCKS12PASSPHRASE("aaiPcks12ClientCertPassphrase", "", "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd"), + CONNECTIONTIMEOUT("aaiClientConnectionTimeout", + String.valueOf(DEFAULT_VALUE_CONNECTION_TIMEOUT), "connection.timeout"), //in ms; + APPLICATIONID("aaiApplicationId", "SDNR", "org.onap.ccsdk.sli.adaptors.aai.application"), + HTTPREADTIMEOUT("aaiReadTimeout", "60000", "read.timeout"); + // @formatter:on + + private String propertyKey; + private String propertyValue; + private Optional<String> propertyKeySecondFile; + + Config(String propertyKey, Object propertyValue) { + this.propertyKey = propertyKey; + this.propertyValue = propertyValue.toString(); + this.propertyKeySecondFile = Optional.empty(); + } + + Config(String propertyKey, Object propertyValue, String propertyKeySecondFile) { + this(propertyKey, propertyValue); + this.propertyKeySecondFile = Optional.of(propertyKeySecondFile); + } + } + + private static final long DEFAULT_VALUE_CONNECTION_TIMEOUT = 30000; //in ms + private static final String HEADER_KEY_APPLICATION = "X-FromAppId"; + + private final ConfigurationFileRepresentation configuration; + + public AaiConfig(ConfigurationFileRepresentation configuration) { + HtAssert.nonnull(configuration); + this.configuration = configuration; + this.configuration.addSection(SECTION_MARKER_AAI); + defaults(); + } + + /* + * Getter + */ + + public boolean doDeleteOnMountPointRemoved() { + return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.DELETEONMOUNTPOINTREMOVED.propertyKey); + } + + public boolean getTrustAll() { + return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.TRUSTALLCERTS.propertyKey); + } + + public String getPcks12CertificateFilename() { + return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12CERTFILENAME.propertyKey); + } + + public String getPcks12CertificatePassphrase() { + return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12PASSPHRASE.propertyKey); + } + + public int getConnectionTimeout() { + long res = configuration.getPropertyLong(SECTION_MARKER_AAI, Config.CONNECTIONTIMEOUT.propertyKey) + .orElse(DEFAULT_VALUE_CONNECTION_TIMEOUT); + return (int) res; + } + + public boolean isOff() { + return configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey).equalsIgnoreCase("off"); + } + + public String getBaseUri() { + String res = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey); + if (!res.startsWith("/")) { + res = "/" + res; + } + return res; + } + + public String getBaseUrl() { + if (isOff()) { + return ""; + } + + String url = configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey); + if (!url.endsWith("/")) { + url += "/"; + } + String apiVersion = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey); + if (apiVersion.startsWith("/")) { + apiVersion = apiVersion.substring(1); + } + return url + apiVersion; + + } + + public Map<String, String> getHeaders() { + + Map<String, String> headers = + _parseHeadersMap(configuration.getProperty(SECTION_MARKER_AAI, Config.HEADERS.propertyKey)); + headers.put(HEADER_KEY_APPLICATION, + configuration.getProperty(SECTION_MARKER_AAI, Config.APPLICATIONID.propertyKey)); + + String credentials = configuration.getProperty(SECTION_MARKER_AAI, Config.USERCREDENTIALS.propertyKey); + if (!nullorempty(credentials)) { + String credentialParts[] = credentials.split(":"); + if (credentialParts.length == 2) { + // 0:username 1:password + String s = headers.getOrDefault("Authorization", null); + if (nullorempty(s) && !nullorempty(credentialParts[0]) && !nullorempty(credentialParts[1])) { + headers.put("Authorization", + "Basic " + new String(Base64.getEncoder().encode(credentials.getBytes()))); + } + } + } + return headers; + } + + @Override + public String getSectionName() { + return SECTION_MARKER_AAI; + } + + @Override + public void defaults() { + for (Config conf : Config.values()) { + configuration.setPropertyIfNotAvailable(SECTION_MARKER_AAI, conf.propertyKey, conf.propertyValue); + } + // If file is available, the content is assigned to related parameters. + getAaiPropertiesFile(); + } + + @Override + public String toString() { + return "AaiConfig [doDeleteOnMountPointRemoved()=" + doDeleteOnMountPointRemoved() + ", getTrustAll()=" + + getTrustAll() + ", getPcks12CertificateFilename()=" + getPcks12CertificateFilename() + + ", getPcks12CertificatePassphrase()=" + getPcks12CertificatePassphrase() + ", getConnectionTimeout()=" + + getConnectionTimeout() + ", isOff()=" + isOff() + ", getBaseUri()=" + getBaseUri() + ", getBaseUrl()=" + + getBaseUrl() + ", getHeaders()=" + getHeaders() + ", getSectionName()=" + getSectionName() + "]"; + } + + /* + * Private + */ + + private boolean nullorempty(String s) { + return s == null || s.isEmpty(); + } + + /** + * Convert headers to configuration string. + * + * @param headers + * @return + */ + @SuppressWarnings("unused") + private static String _printHeadersMap(Map<String, String> headers) { + String r = "["; + if (headers != null) { + int i = 0; + for (Entry<String, String> entry : headers.entrySet()) { + if (i > 0) { + r += ","; + } + r += "\"" + entry.getKey() + ":" + entry.getValue() + "\""; + i++; + } + } + r += "]"; + return r; + } + + private static Map<String, String> _parseHeadersMap(String s) { + + LOG.info("Parse: '{}'", s); + Map<String, String> r = new HashMap<>(); + if (s != null) { + s = s.trim(); + if (!s.isEmpty()) { + JSONArray a; + try { + a = new JSONArray(s); + if (a.length() > 0) { + for (int i = 0; i < a.length(); i++) { + String item = a.getString(i); + String[] hlp = item.split(":"); + if (hlp.length > 1) { + r.put(hlp[0], hlp[1]); + } + } + } + } catch (Exception e) { + LOG.debug("Unparsable '{}'", s); + } + } + } + return r; + } + + /** + * Read file if available and assign to configuration + */ + private void getAaiPropertiesFile() { + String aaiPropertiesFileName = configuration.getProperty(SECTION_MARKER_AAI, Config.AAIPROP_FILE.propertyKey); + File f = new File(aaiPropertiesFileName); + if (f.exists()) { + InputStream in = null; + try { + in = new FileInputStream(f); + Properties defaultProps = new Properties(); + defaultProps.load(in); + + for (Config conf : Config.values()) { + if (conf.propertyKeySecondFile.isPresent()) { + String config = defaultProps.getProperty(conf.propertyKeySecondFile.get(), conf.propertyValue); + LOG.debug("Property file assign {} = {} ", conf.propertyKey, config); + configuration.setProperty(SECTION_MARKER_AAI, conf.propertyKey, config); + } + } + + } catch (IOException e) { + LOG.warn("Problem during file read {} {}", f.getAbsoluteFile(), e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + LOG.warn("problem closing file string for {}: {}", f.getAbsoluteFile(), e); + } + } + } + } + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanService.java index e79f0ed5f..88848a5c3 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanService.java @@ -36,10 +36,11 @@ import org.slf4j.LoggerFactory; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -public class ArchiveCleanService implements AutoCloseable, IConfigChangedListener, Runnable,ClusterSingletonService { +public class ArchiveCleanService implements AutoCloseable, IConfigChangedListener, Runnable, ClusterSingletonService { private static final Logger LOG = LoggerFactory.getLogger(ArchiveCleanService.class); - private static final ServiceGroupIdentifier IDENT = ServiceGroupIdentifier.create("ElasticSearchArchiveCleanService"); + private static final ServiceGroupIdentifier IDENT = + ServiceGroupIdentifier.create("ElasticSearchArchiveCleanService"); private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); private final ArchiveCleanProvider[] indexCleanList; @@ -65,17 +66,16 @@ public class ArchiveCleanService implements AutoCloseable, IConfigChangedListene if (taskReference != null) { taskReference.cancel(false); } - if(this.isMaster) { - if (this.esConfig.getArchiveCheckIntervalSeconds() > 0) { - LOG.info("DBCleanService is turned on for entries older than {} seconds", - this.esConfig.getArchiveLifetimeSeconds()); - taskReference = this.scheduler.scheduleAtFixedRate(doClean, 0, - this.esConfig.getArchiveCheckIntervalSeconds(), TimeUnit.SECONDS); + if (this.isMaster) { + if (this.esConfig.getArchiveCheckIntervalSeconds() > 0) { + LOG.info("DBCleanService is turned on for entries older than {} seconds", + this.esConfig.getArchiveLifetimeSeconds()); + taskReference = this.scheduler.scheduleAtFixedRate(doClean, 0, + this.esConfig.getArchiveCheckIntervalSeconds(), TimeUnit.SECONDS); + } else { + LOG.info("DBCleanService is turned off"); + } } else { - LOG.info("DBCleanService is turned off"); - } - } - else { LOG.info("service is inactive on this node. active on another node."); } } @@ -109,7 +109,7 @@ public class ArchiveCleanService implements AutoCloseable, IConfigChangedListene } } if (removed > 0) { - LOG.trace("Removed elements: {}",removed); + LOG.trace("Removed elements: {}", removed); } } catch (Exception e) { LOG.warn("problem executing dbclean", e); @@ -136,20 +136,20 @@ public class ArchiveCleanService implements AutoCloseable, IConfigChangedListene @SuppressWarnings("null") @Override public @NonNull ServiceGroupIdentifier getIdentifier() { - return IDENT; + return IDENT; } @Override public void instantiateServiceInstance() { LOG.info("We take Leadership"); - this.isMaster=true; + this.isMaster = true; this.reinit(); } @Override public ListenableFuture<? extends Object> closeServiceInstance() { LOG.info("We lost Leadership"); - this.isMaster=false; + this.isMaster = false; this.reinit(); return Futures.immediateFuture(null); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderImpl.java index 32e7e3c6a..8e091bef5 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderImpl.java @@ -57,8 +57,8 @@ public class DcaeForwarderImpl implements DcaeForwarderInternal, AutoCloseable { this.aotsmClient.sendProblemNotification(nodeId, notificationXml); } } else { - LOG.debug("Notification will not be sent to external services. Device " + nodeId - + " is in maintenance mode"); + LOG.debug( + "Notification will not be sent to external services. Device " + nodeId + " is in maintenance mode"); } } @@ -66,17 +66,16 @@ public class DcaeForwarderImpl implements DcaeForwarderInternal, AutoCloseable { public void sendProblemNotification(String nodeId, ProblemNotificationXml notificationXml) { //to prevent push alarms on reconnect //=> only pushed alarms are forwared to dcae - if(dcaeProvider!=null) { - dcaeProvider.sendProblemNotification(nodeId, notificationXml); - } - if(aotsmClient!=null) { + if (dcaeProvider != null) { + dcaeProvider.sendProblemNotification(nodeId, notificationXml); + } + if (aotsmClient != null) { aotsmClient.sendProblemNotification(nodeId, notificationXml); } } @Override - public void close() throws Exception { - } + public void close() throws Exception {} } 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 993348720..a79e4ad05 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 @@ -48,11 +48,11 @@ public class DcaeMessages { private static final Logger LOG = LoggerFactory.getLogger(DcaeSenderImpl.class); - private static final String DCAE_NORMAL = "NORMAL"; - private static final String DCAE_MINOR = "MINOR"; - private static final String DCAE_WARNING = "WARNING"; - private static final String DCAE_CRITICAL = "CRITICAL"; - private static final String DCAE_MAJOR = "MAJOR"; + private static final String DCAE_NORMAL = "NORMAL"; + private static final String DCAE_MINOR = "MINOR"; + private static final String DCAE_WARNING = "WARNING"; + private static final String DCAE_CRITICAL = "CRITICAL"; + private static final String DCAE_MAJOR = "MAJOR"; private static final String eventNamePrefix = "fault_Microwave_Radio_Alarms"; private static final String eventType = "Microwave_Radio_Alarms"; @@ -75,7 +75,8 @@ public class DcaeMessages { //Variables private int heartbeatsequence = 0; - public DcaeMessages(DcaeSender ecompSender, String entityName, Integer heartbeatIntervallSeconds, DeviceManagerImpl deviceManager) { + public DcaeMessages(DcaeSender ecompSender, String entityName, Integer heartbeatIntervallSeconds, + DeviceManagerImpl deviceManager) { this.dcaeSender = ecompSender; this.entityName = entityName; this.deviceManager = deviceManager; @@ -84,19 +85,19 @@ public class DcaeMessages { /** * Create a heartbeat message. + * * @return Result string with answer from server */ public String postHeartBeat() { String epochTimeMicrosecondsString = getEpochTimeMicroseconds(); - String body = assembleHeartbeatFromTemplate(null, - epochTimeMicrosecondsString, - heartbeatsequence++, + String body = assembleHeartbeatFromTemplate(null, epochTimeMicrosecondsString, heartbeatsequence++, NETCONFTIME_CONVERTER.getTimeStampAsNetconfString()).toString(); - return dcaeSender.sendDcaePost( body); + return dcaeSender.sendDcaePost(body); } /** * ONF 1.2 Problem Notification + * * @param mountPointName self-explaining * @param notification Notification input * @return String with answer @@ -107,18 +108,18 @@ public class DcaeMessages { String problemName = notification.getProblem(); String sequence = notification.getCounter(); String objId = notification.getObjectId(); - String severity = convert( notification.getSeverity()); - String timeStamp = convert( notification.getTimeStamp() ); + String severity = convert(notification.getSeverity()); + String timeStamp = convert(notification.getTimeStamp()); - String body = assembleEventNotificationFromTemplate(null, - timeStamp, sequence, - mountPointName, objId, problemName, severity, notification.getTimeStamp() ).toString(); + String body = assembleEventNotificationFromTemplate(null, timeStamp, sequence, mountPointName, objId, + problemName, severity, notification.getTimeStamp()).toString(); - return dcaeSender.sendDcaePost( body); + return dcaeSender.sendDcaePost(body); } /** * Setup a connection to URL with authorisation header + * * @param url e.g. "https://plan.fritz.box:9092/ux/#" or " * @param basicAuth authorisation header like "Basic SGVyYmVydDpIZXJiZXJ0" * @param insertContentHeader @@ -126,7 +127,8 @@ public class DcaeMessages { * @throws IOException * @throws MalformedURLException */ - static @Nullable HttpURLConnection openConnection( URL url, String basicAuth, boolean insertContentHeader, @Nullable SSLContext sc) throws MalformedURLException, IOException { + static @Nullable HttpURLConnection openConnection(URL url, String basicAuth, boolean insertContentHeader, + @Nullable SSLContext sc) throws MalformedURLException, IOException { //Prepare the connection HttpURLConnection newHttpConnection = null; @@ -135,7 +137,7 @@ public class DcaeMessages { if (newConnection instanceof HttpURLConnection) { LOG.debug("Setup connection to {} ", url.toString()); - newHttpConnection = (HttpURLConnection)newConnection; + newHttpConnection = (HttpURLConnection) newConnection; newHttpConnection.setDoOutput(true); // Triggers POST. newHttpConnection.setRequestProperty("Accept-Charset", charset); @@ -148,7 +150,7 @@ public class DcaeMessages { if (newHttpConnection instanceof HttpsURLConnection) { LOG.debug("SSL connection setup with trust all."); - HttpsURLConnection newHttpsConnection = (HttpsURLConnection)newHttpConnection; + HttpsURLConnection newHttpsConnection = (HttpsURLConnection) newHttpConnection; if (sc != null) { newHttpsConnection.setSSLSocketFactory(sc.getSocketFactory()); } else { @@ -169,6 +171,7 @@ public class DcaeMessages { /** * Get actual microseconds + * * @return String */ private String getEpochTimeMicroseconds() { @@ -178,57 +181,57 @@ public class DcaeMessages { /** * Assemble heartbeat message + * * @param sb StringBuffer to be used or null to allocate * @param epochTimeMicrosecondsString Text with time stamp * @param sequence integer sequence number * @param eventTimeValueNetconfFormatString like this: 2018-05-14T05:32:17.292Z * @return StringBuffer with result */ - private StringBuffer assembleHeartbeatFromTemplate( - StringBuffer sb, - String epochTimeMicrosecondsString, - int sequence, - String eventTimeValueNetconfFormatString) { + private StringBuffer assembleHeartbeatFromTemplate(StringBuffer sb, String epochTimeMicrosecondsString, + int sequence, String eventTimeValueNetconfFormatString) { if (sb == null) { - sb = new StringBuffer(); + sb = new StringBuffer(); } - sb.append("{\n" + - " \"event\": {\n" + - " \"commonEventHeader\": {\n" + - " \"domain\": \"heartbeat\",\n" + - " \"eventId\": \"testpattern-ab305d54-85b4-a31b-7db2-fb6b9e546015\",\n" + - " \"eventName\": \"heartbeat_Controller\",\n" + - " \"eventType\": \"Controller\",\n" + - " \"priority\": \"Low\",\n" + - " \"reportingEntityId\": \"\",\n" + - " \"reportingEntityName\": \""+entityName+"\",\n" + - " \"sequence\": "+String.valueOf(sequence)+",\n" + - " \"sourceId\": \"\",\n" + - " \"sourceName\": \""+entityName+"\",\n" + - " \"startEpochMicrosec\": "+epochTimeMicrosecondsString+",\n" + - " \"lastEpochMicrosec\": "+epochTimeMicrosecondsString+",\n" + - " \"version\": 3.0\n" + - " },\n" + - " \"heartbeatFields\": {\n" + - " \"additionalFields\": [\n" + - " {\n" + - " \"name\": \"eventTime\",\n" + - " \"value\": \""+eventTimeValueNetconfFormatString+"\"\n" + - " }\n" + - " ],\n" + - " \"heartbeatFieldsVersion\": 1.0,\n" + - " \"heartbeatInterval\": "+heartbeatIntervallSeconds+"\n" + - " }\n" + - " }\n" + - "}\n" - ); + // @formatter:off + sb.append("{\n" + + " \"event\": {\n" + + " \"commonEventHeader\": {\n" + + " \"domain\": \"heartbeat\",\n" + + " \"eventId\": \"testpattern-ab305d54-85b4-a31b-7db2-fb6b9e546015\",\n" + + " \"eventName\": \"heartbeat_Controller\",\n" + + " \"eventType\": \"Controller\",\n" + + " \"priority\": \"Low\",\n" + + " \"reportingEntityId\": \"\",\n" + + " \"reportingEntityName\": \"" + entityName + "\",\n" + + " \"sequence\": " + String.valueOf(sequence) + ",\n" + + " \"sourceId\": \"\",\n" + + " \"sourceName\": \"" + entityName + "\",\n" + + " \"startEpochMicrosec\": " + epochTimeMicrosecondsString + ",\n" + + " \"lastEpochMicrosec\": " + epochTimeMicrosecondsString + ",\n" + + " \"version\": 3.0\n" + + " },\n" + + " \"heartbeatFields\": {\n" + + " \"additionalFields\": [\n" + + " {\n" + + " \"name\": \"eventTime\",\n" + + " \"value\": \"" + eventTimeValueNetconfFormatString + "\"\n" + + " }\n" + + " ],\n" + + " \"heartbeatFieldsVersion\": 1.0,\n" + + " \"heartbeatInterval\": " + heartbeatIntervallSeconds + "\n" + + " }\n" + + " }\n" + + "}\n"); + // @formatter:on return sb; } /** * Assemble notification message + * * @param sb StringBuffer to be used or null to allocate * @param epochTimeMicrosecondsString Text with time stamp * @param sequence integer sequence number @@ -239,16 +242,16 @@ public class DcaeMessages { * @return StringBuffer with result */ - private StringBuffer assembleEventNotificationFromTemplate(StringBuffer sb, - String epochTimeMicrosecondsString, String sequence, - String mountpointName, String objId, String problemName, String severity, String eventTimeValueNetconfFormatString - ) { + private StringBuffer assembleEventNotificationFromTemplate(StringBuffer sb, String epochTimeMicrosecondsString, + String sequence, String mountpointName, String objId, String problemName, String severity, + String eventTimeValueNetconfFormatString) { if (sb == null) { sb = new StringBuffer(); } - NetworkElement optionalNe = deviceManager != null ? deviceManager.getNeByMountpoint(mountpointName) : null; + NetworkElement optionalNe = + deviceManager != null ? deviceManager.getNeByMountpoint(mountpointName) : null; InventoryInformationDcae neInventory = InventoryInformationDcae.getDefault(); if (optionalNe != null) { Optional<InventoryProvider> inventoryProvider = optionalNe.getService(InventoryProvider.class); @@ -257,53 +260,53 @@ public class DcaeMessages { } } - sb.append("{\n" + - " \"event\": {\n" + - " \"commonEventHeader\": {\n" + - " \"domain\": \"fault\",\n" + - " \"eventId\": \""+mountpointName+"_"+objId+"_"+problemName+"\",\n" + - " \"eventName\": \""+eventNamePrefix+"_"+problemName+"\",\n" + - " \"eventType\": \""+eventType+"\",\n" + - " \"sequence\": "+sequence+",\n" + - " \"priority\": \"High\",\n" + - " \"reportingEntityId\": \"\",\n" + - " \"reportingEntityName\": \""+entityName+"\",\n" + - " \"sourceId\": \"\",\n" + - " \"sourceName\": \""+mountpointName+"\",\n" + - " \"startEpochMicrosec\": "+epochTimeMicrosecondsString+",\n" + - " \"lastEpochMicrosec\": "+epochTimeMicrosecondsString+",\n" + - " \"version\": 3.0\n" + - " },\n" + - " \"faultFields\": {\n" + - " \"alarmAdditionalInformation\": [\n" + - " {\n" + - " \"name\": \"eventTime\",\n" + - " \"value\": \""+eventTimeValueNetconfFormatString+"\"\n" + - " },\n" + - " {\n" + - " \"name\": \"equipType\",\n" + - " \"value\": \""+neInventory.getType()+"\"\n" + - " },\n" + - " {\n" + - " \"name\": \"vendor\",\n" + - " \"value\": \""+neInventory.getVendor()+"\"\n" + - " },\n" + - " {\n" + - " \"name\": \"model\",\n" + - " \"value\": \""+neInventory.getModel()+"\"\n" + - " }\n" + - " ],\n" + - " \"faultFieldsVersion\":2.0,\n" + - " \"eventSourceType\": \""+eventSourceType+"\",\n" + - " \"alarmCondition\": \""+problemName+"\",\n" + - " \"alarmInterfaceA\": \""+objId+"\",\n" + - " \"specificProblem\": \""+problemName+"\",\n" + - " \"eventSeverity\": \""+severity+"\",\n" + - " \"vfStatus\": \"Active\"\n" + - " }\n" + - " }\n" + - "}\n" - ); + // @formatter:off + sb.append("{\n" + + " \"event\": {\n" + + " \"commonEventHeader\": {\n" + + " \"domain\": \"fault\",\n" + + " \"eventId\": \"" + mountpointName + "_" + objId + "_" + problemName + "\",\n" + + " \"eventName\": \"" + eventNamePrefix + "_" + problemName + "\",\n" + + " \"eventType\": \"" + eventType + "\",\n" + + " \"sequence\": " + sequence + ",\n" + + " \"priority\": \"High\",\n" + + " \"reportingEntityId\": \"\",\n" + + " \"reportingEntityName\": \"" + entityName + "\",\n" + + " \"sourceId\": \"\",\n" + + " \"sourceName\": \"" + mountpointName + "\",\n" + + " \"startEpochMicrosec\": " + epochTimeMicrosecondsString + ",\n" + + " \"lastEpochMicrosec\": " + epochTimeMicrosecondsString + ",\n" + + " \"version\": 3.0\n" + + " },\n" + + " \"faultFields\": {\n" + + " \"alarmAdditionalInformation\": [\n" + + " {\n" + + " \"name\": \"eventTime\",\n" + + " \"value\": \"" + eventTimeValueNetconfFormatString + "\"\n" + + " },\n" + + " {\n" + + " \"name\": \"equipType\",\n" + + " \"value\": \"" + neInventory.getType() + "\"\n" + + " },\n" + + " {\n" + + " \"name\": \"vendor\",\n" + + " \"value\": \"" + neInventory.getVendor() + "\"\n" + + " },\n" + " {\n" + + " \"name\": \"model\",\n" + + " \"value\": \"" + neInventory.getModel() + "\"\n" + + " }\n" + + " ],\n" + + " \"faultFieldsVersion\":2.0,\n" + + " \"eventSourceType\": \"" + eventSourceType + "\",\n" + + " \"alarmCondition\": \"" + problemName + "\",\n" + + " \"alarmInterfaceA\": \"" + objId + "\",\n" + + " \"specificProblem\": \"" + problemName + "\",\n" + + " \"eventSeverity\": \"" + severity + "\",\n" + + " \"vfStatus\": \"Active\"\n" + + " }\n" + + " }\n" + + "}\n"); + // @formatter:on return sb; } @@ -312,8 +315,8 @@ public class DcaeMessages { * Convert internal type formats into the Ecomp format */ - private String convert(InternalSeverity severity ) { - switch( severity ) { + private String convert(InternalSeverity severity) { + switch (severity) { case NonAlarmed: break; case Warning: @@ -331,6 +334,7 @@ public class DcaeMessages { /** * Time has to be converted into milliseconds + * * @param timeAsString time as string * @return as string */ diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java index fcc8f6fea..7ceafcb46 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java @@ -40,36 +40,37 @@ public class DcaeProviderClient implements AutoCloseable, ProviderClient { public DcaeProviderClient(ConfigurationFileRepresentation cfg, String entityName, DeviceManagerImpl deviceManager) { LOG.info("Create"); - this.htConfig=cfg; + this.htConfig = cfg; this.config = new DcaeConfig(cfg); worker = new DcaeProviderWorker(config, entityName, deviceManager); this.configChangedListener = () -> { LOG.info("Configuration change. Worker exchanged"); - synchronized(lock) { + synchronized (lock) { worker.close(); worker = new DcaeProviderWorker(this.config, entityName, deviceManager); } }; - this.htConfig.registerConfigChangedListener(configChangedListener ); + this.htConfig.registerConfigChangedListener(configChangedListener); } @Override public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification) { - synchronized(lock) { + synchronized (lock) { worker.sendProblemNotification(mountPointName, notification); } } @Override - public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification, boolean neDeviceAlarm) { + public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification, + boolean neDeviceAlarm) { sendProblemNotification(mountPointName, notification); } @Override public void close() { this.htConfig.unregisterConfigChangedListener(configChangedListener); - synchronized(lock) { + synchronized (lock) { worker.close(); } } @@ -81,4 +82,3 @@ public class DcaeProviderClient implements AutoCloseable, ProviderClient { } - diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderTask.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderTask.java index f596701c0..18a36f7d6 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderTask.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderTask.java @@ -26,7 +26,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -class DcaeProviderTask implements Runnable { +class DcaeProviderTask implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(DcaeProviderTask.class); @@ -39,7 +39,7 @@ class DcaeProviderTask implements Runnable { } private void sendHeartbeat() { - dcaeMessages.postHeartBeat(); + dcaeMessages.postHeartBeat(); } @Override diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java index 02ce79ac2..1ef50c3e9 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java @@ -42,11 +42,11 @@ class DcaeProviderWorker implements AutoCloseable { public DcaeProviderWorker(DcaeConfig configuration, String entityName, DeviceManagerImpl deviceManager) { //Start services - LOG.info("Configuration: "+configuration); + LOG.info("Configuration: " + configuration); int heartbeatSeconds = configuration.getTimerPeriodSeconds(); - if ( heartbeatSeconds < MIN_HEARTBEAT_TIME_SECONDS ) { + if (heartbeatSeconds < MIN_HEARTBEAT_TIME_SECONDS) { heartbeatSeconds = MIN_HEARTBEAT_TIME_SECONDS; - LOG.info("Adjust heartbeat intervall to minimum of { } seconds.",heartbeatSeconds); + LOG.info("Adjust heartbeat intervall to minimum of { } seconds.", heartbeatSeconds); } dcaepClient = new DcaeSenderImpl(configuration.getEventReveicerUrl(), configuration.getUserCredentials()); @@ -57,7 +57,7 @@ class DcaeProviderWorker implements AutoCloseable { this.scheduler = Executors.newSingleThreadScheduledExecutor(); Runnable task = new DcaeProviderTask(dcaeMessages); - LOG.info("Fault task created with "+heartbeatSeconds+" Seconds"); + LOG.info("Fault task created with " + heartbeatSeconds + " Seconds"); this.taskReference = this.scheduler.scheduleAtFixedRate(task, 0, heartbeatSeconds, TimeUnit.SECONDS); LOG.info("Fault task scheduled"); } @@ -73,7 +73,7 @@ class DcaeProviderWorker implements AutoCloseable { this.scheduler.shutdown(); this.scheduler.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException | SecurityException e) { - LOG.debug("Schedler shutdown interrupted with exception: ",e); + LOG.debug("Schedler shutdown interrupted with exception: ", e); if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/config/DcaeConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/config/DcaeConfig.java index 714e85522..883c74399 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/config/DcaeConfig.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/config/DcaeConfig.java @@ -32,12 +32,12 @@ public class DcaeConfig implements Configuration { private static final String DEFAULT_VALUE_USERCREDENTIALS = "admin:admin"; private static final long DEFAULT_VALUE_TIMERPERIOD = 120; - private final ConfigurationFileRepresentation configuration; + private final ConfigurationFileRepresentation configuration; - public DcaeConfig(ConfigurationFileRepresentation configuration) { - this.configuration = configuration; - this.configuration.addSection(SECTION_MARKER_DCAE); - defaults(); + public DcaeConfig(ConfigurationFileRepresentation configuration) { + this.configuration = configuration; + this.configuration.addSection(SECTION_MARKER_DCAE); + defaults(); } /* *********************** @@ -45,35 +45,39 @@ public class DcaeConfig implements Configuration { */ public String getEventReveicerUrl() { - return configuration.getProperty(SECTION_MARKER_DCAE, PROPERTY_KEY_EVENTRECEIVERURL); + return configuration.getProperty(SECTION_MARKER_DCAE, PROPERTY_KEY_EVENTRECEIVERURL); } public String getUserCredentials() { - return configuration.getProperty(SECTION_MARKER_DCAE, PROPERTY_KEY_USERCREDENTIALS); + return configuration.getProperty(SECTION_MARKER_DCAE, PROPERTY_KEY_USERCREDENTIALS); } public Integer getTimerPeriodSeconds() { - long res = configuration.getPropertyLong(SECTION_MARKER_DCAE, PROPERTY_KEY_TIMERPERIOD).orElse(DEFAULT_VALUE_TIMERPERIOD); - return (int)res; + long res = configuration.getPropertyLong(SECTION_MARKER_DCAE, PROPERTY_KEY_TIMERPERIOD) + .orElse(DEFAULT_VALUE_TIMERPERIOD); + return (int) res; } - @Override - public String getSectionName() { - return SECTION_MARKER_DCAE; - } + @Override + public String getSectionName() { + return SECTION_MARKER_DCAE; + } - @Override - public void defaults() { - this.configuration.setPropertyIfNotAvailable(SECTION_MARKER_DCAE, PROPERTY_KEY_EVENTRECEIVERURL, DEFAULT_VALUE_EVENTRECEIVERURL); - this.configuration.setPropertyIfNotAvailable(SECTION_MARKER_DCAE, PROPERTY_KEY_USERCREDENTIALS, DEFAULT_VALUE_USERCREDENTIALS); - this.configuration.setPropertyIfNotAvailable(SECTION_MARKER_DCAE, PROPERTY_KEY_TIMERPERIOD, DEFAULT_VALUE_TIMERPERIOD); - } + @Override + public void defaults() { + this.configuration.setPropertyIfNotAvailable(SECTION_MARKER_DCAE, PROPERTY_KEY_EVENTRECEIVERURL, + DEFAULT_VALUE_EVENTRECEIVERURL); + this.configuration.setPropertyIfNotAvailable(SECTION_MARKER_DCAE, PROPERTY_KEY_USERCREDENTIALS, + DEFAULT_VALUE_USERCREDENTIALS); + this.configuration.setPropertyIfNotAvailable(SECTION_MARKER_DCAE, PROPERTY_KEY_TIMERPERIOD, + DEFAULT_VALUE_TIMERPERIOD); + } - @Override - public String toString() { - return "DcaeConfig [getEventReveicerUrl()=" + getEventReveicerUrl() + ", getUserCredentials()=" - + getUserCredentials() + ", getTimerPeriodSeconds()=" + getTimerPeriodSeconds() + ", getSectionName()=" - + getSectionName() + "]"; - } + @Override + public String toString() { + return "DcaeConfig [getEventReveicerUrl()=" + getEventReveicerUrl() + ", getUserCredentials()=" + + getUserCredentials() + ", getTimerPeriodSeconds()=" + getTimerPeriodSeconds() + ", getSectionName()=" + + getSectionName() + "]"; + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/Checker.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/Checker.java index f67364364..9d64a3b5a 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/Checker.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/Checker.java @@ -33,12 +33,14 @@ abstract class Checker { /** * Check action. + * * @return true if reachable, false if not */ abstract boolean isReachableOnce(); /** * Procedure to check the connection of one mountpoint + * * @return true if reachable, false if not */ boolean isConnected() { diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitor.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitor.java index ecfab4d96..18fcba714 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitor.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitor.java @@ -29,19 +29,21 @@ public interface DeviceMonitor extends AutoCloseable { /** * removeMountpointIndication deregisters a mountpoint for registration services + * * @param mountPointNodeName to deregister */ void removeMountpointIndication(String mountPointNodeName); - /** - * Notify of device state change to "disconnected" - * Mount point supervision - * @param mountPointNodeName to deregister - */ + /** + * Notify of device state change to "disconnected" Mount point supervision + * + * @param mountPointNodeName to deregister + */ void deviceDisconnectIndication(String mountPointNodeName); /** * Notify of device state changes to "connected" + * * @param mountPointNodeName name of mount point * @param ne to monitor */ @@ -49,6 +51,7 @@ public interface DeviceMonitor extends AutoCloseable { /** * Notify of device state changes to "connected" + * * @param mountPointNodeName name of mount point * @param ne to monitor */ @@ -56,6 +59,7 @@ public interface DeviceMonitor extends AutoCloseable { /** * Notify of device state changes to "connected" for slave nodes + * * @param mountPointNodeName name of mount point */ void deviceConnectSlaveIndication(String mountPointNodeName); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorEmptyImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorEmptyImpl.java index 5615ef95f..2b9a18ccc 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorEmptyImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorEmptyImpl.java @@ -23,32 +23,25 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; public class DeviceMonitorEmptyImpl implements DeviceMonitor { @Override - public void refreshAlarmsInDb() { - } + public void refreshAlarmsInDb() {} @Override - public void removeMountpointIndication(String mountPointNodeName) { - } + public void removeMountpointIndication(String mountPointNodeName) {} @Override - public void deviceConnectMasterIndication(String mountPointNodeName, DeviceMonitoredNe ne) { - } + public void deviceConnectMasterIndication(String mountPointNodeName, DeviceMonitoredNe ne) {} @Override - public void deviceDisconnectIndication(String mountPointNodeName) { - } + public void deviceDisconnectIndication(String mountPointNodeName) {} @Override - public void deviceConnectSlaveIndication(String mountPointNodeName) { - } + public void deviceConnectSlaveIndication(String mountPointNodeName) {} @Override - public void close() throws Exception { - } + public void close() throws Exception {} @Override - public void deviceConnectMasterIndication(String mountPointNodeName, NetworkElement ne) { - } + public void deviceConnectMasterIndication(String mountPointNodeName, NetworkElement ne) {} } 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 d6714b8cb..3f5fdac6b 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 @@ -38,33 +38,34 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Implementation of concept "Active monitoring" of a device.<br> - * <br> - * For each existing mountpoint a task runs with 120s cycle time. Every 120 seconds the check actions are performed. - * The request is handled by the NETCONF layer with a (default)configured time-out of 60 seconds.<br> - * Generated alarms, by the object/node "SDN-Controller" are (enum DeviceMonitorProblems):<br> - * - notConnected(InternalSeverity.Warning)<br> - * - noConnectionMediator(InternalSeverity.Minor)<br> - * - noConnectionNe(InternalSeverity.Critical)<br> - * <br> - * 1. Mountpoint does not exist<br> - * If the mountpoint does not exists there are no related current alarms in the database.<br> - * <br> - * 2. Created mountpoint with state "Connecting" or "UnableToConnect"<br> - * If the Mountpoint is created and connection status is "Connecting" or "UnableToConnect".<br> - * - After about 2..4 Minutes ... raise alarm "notConnected" with severity warning<br> - * <br> - * 3. Created mountpoint with state "Connection"<br> - * There are two monitor activities.<br> - * 3a. Check of Mediator connection by requesting (typical) cached data.<br> - * - After about 60 seconds raise alarm: connection-loss-mediator with severity minor<br> - * - Request from Mediator: network-element<br> - * <br> - * 3b. Check connection to NEby requesting (typical) non-cached data.<br> - * - Only if AirInterface available. The first one is used.<br> - * - Requested are the currentAlarms<br> - * - After about 60 seconds raise alarm: connection-loss-network-element with severity critical<br> - * <br> + * Implementation of concept "Active monitoring" of a device.<br> + * <br> + * For each existing mountpoint a task runs with 120s cycle time. Every 120 seconds the check actions are performed. The + * request is handled by the NETCONF layer with a (default)configured time-out of 60 seconds.<br> + * Generated alarms, by the object/node "SDN-Controller" are (enum DeviceMonitorProblems):<br> + * - notConnected(InternalSeverity.Warning)<br> + * - noConnectionMediator(InternalSeverity.Minor)<br> + * - noConnectionNe(InternalSeverity.Critical)<br> + * <br> + * 1. Mountpoint does not exist<br> + * If the mountpoint does not exists there are no related current alarms in the database.<br> + * <br> + * 2. Created mountpoint with state "Connecting" or "UnableToConnect"<br> + * If the Mountpoint is created and connection status is "Connecting" or "UnableToConnect".<br> + * - After about 2..4 Minutes ... raise alarm "notConnected" with severity warning<br> + * <br> + * 3. Created mountpoint with state "Connection"<br> + * There are two monitor activities.<br> + * 3a. Check of Mediator connection by requesting (typical) cached data.<br> + * - After about 60 seconds raise alarm: connection-loss-mediator with severity minor<br> + * - Request from Mediator: network-element<br> + * <br> + * 3b. Check connection to NEby requesting (typical) non-cached data.<br> + * - Only if AirInterface available. The first one is used.<br> + * - Requested are the currentAlarms<br> + * - After about 60 seconds raise alarm: connection-loss-network-element with severity critical<br> + * <br> + * * @author herbert */ @@ -86,9 +87,11 @@ public class DeviceMonitorImpl implements DeviceMonitor, IConfigChangedListener /** * Basic implementation of devicemonitoring + * * @param odlEventListener as destination for problems */ - public DeviceMonitorImpl(DataBroker dataBroker, ODLEventListenerHandler odlEventListener, ConfigurationFileRepresentation htconfig) { + public DeviceMonitorImpl(DataBroker dataBroker, ODLEventListenerHandler odlEventListener, + ConfigurationFileRepresentation htconfig) { LOG.info("Construct {}", this.getClass().getSimpleName()); this.odlEventListener = odlEventListener; @@ -135,57 +138,62 @@ public class DeviceMonitorImpl implements DeviceMonitor, IConfigChangedListener /** * Notify of device state changes to "connected" for slave nodes + * * @param mountPointNodeName name of mount point */ @Override synchronized public void deviceConnectSlaveIndication(String mountPointNodeName) { - deviceConnectMasterIndication(mountPointNodeName, (DeviceMonitoredNe)null); + deviceConnectMasterIndication(mountPointNodeName, (DeviceMonitoredNe) null); } @Override public void deviceConnectMasterIndication(String mountPointNodeName, NetworkElement networkElement) { Optional<DeviceMonitoredNe> monitoredNe = networkElement.getService(DeviceMonitoredNe.class); - deviceConnectMasterIndication(mountPointNodeName, monitoredNe.isPresent() ? monitoredNe.get() : dummyNe); + deviceConnectMasterIndication(mountPointNodeName, monitoredNe.isPresent() ? monitoredNe.get() : dummyNe); } /** * Notify of device state changes to "connected" + * * @param mountPointNodeName name of mount point * @param ne to monitor */ @Override synchronized public void deviceConnectMasterIndication(String mountPointNodeName, DeviceMonitoredNe ne) { - LOG.debug("ne changes to connected state {}",mountPointNodeName); + LOG.debug("ne changes to connected state {}", mountPointNodeName); createMonitoringTask(mountPointNodeName); if (queue.containsKey(mountPointNodeName)) { DeviceMonitorTask task = queue.get(mountPointNodeName); task.deviceConnectIndication(ne); } else { - LOG.warn("Monitoring task not in queue: {} {} {}", mountPointNodeName, mountPointNodeName.hashCode(), queue.size()); + LOG.warn("Monitoring task not in queue: {} {} {}", mountPointNodeName, mountPointNodeName.hashCode(), + queue.size()); } } - /** - * Notify of device state change to "disconnected" - * Mount point supervision - * @param mountPointNodeName to deregister - */ + /** + * Notify of device state change to "disconnected" Mount point supervision + * + * @param mountPointNodeName to deregister + */ @Override synchronized public void deviceDisconnectIndication(String mountPointNodeName) { - LOG.debug("State changes to not connected state {}",mountPointNodeName); + LOG.debug("State changes to not connected state {}", mountPointNodeName); createMonitoringTask(mountPointNodeName); if (queue.containsKey(mountPointNodeName)) { DeviceMonitorTask task = queue.get(mountPointNodeName); task.deviceDisconnectIndication(); } else { - LOG.warn("Monitoring task not in queue: {} {} {}", mountPointNodeName, mountPointNodeName.hashCode(), queue.size()); + LOG.warn("Monitoring task not in queue: {} {} {}", mountPointNodeName, mountPointNodeName.hashCode(), + queue.size()); } } /** * removeMountpointIndication deregisters a mountpoint for registration services + * * @param mountPointNodeName to deregister */ @Override @@ -208,7 +216,7 @@ public class DeviceMonitorImpl implements DeviceMonitor, IConfigChangedListener */ @Override public void refreshAlarmsInDb() { - synchronized(queue) { + synchronized (queue) { for (DeviceMonitorTask task : queue.values()) { task.refreshAlarms(); } @@ -219,7 +227,7 @@ public class DeviceMonitorImpl implements DeviceMonitor, IConfigChangedListener * For test run the tasks */ public void taskTestRun() { - synchronized(queue) { + synchronized (queue) { for (DeviceMonitorTask task : queue.values()) { task.run(); } @@ -232,12 +240,13 @@ public class DeviceMonitorImpl implements DeviceMonitor, IConfigChangedListener /** * createMountpoint registers a new mountpoint monitoring service + * * @param mountPointNodeName name of mountpoint */ synchronized private DeviceMonitorTask createMonitoringTask(String mountPointNodeName) { DeviceMonitorTask task; - LOG.debug("Register for monitoring {} {}",mountPointNodeName, mountPointNodeName.hashCode()); + LOG.debug("Register for monitoring {} {}", mountPointNodeName, mountPointNodeName.hashCode()); if (queue.containsKey(mountPointNodeName)) { LOG.info("Monitoring task exists"); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorProblems.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorProblems.java index 646b30b95..ecc62cfd2 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorProblems.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorProblems.java @@ -36,13 +36,13 @@ public enum DeviceMonitorProblems { connectionLossOAM(InternalSeverity.Major), /** - * Mountpoint is connected via Netconf to Mediator, but mediator is not responding. - * Connection state to NE is unknown. + * Mountpoint is connected via Netconf to Mediator, but mediator is not responding. Connection state to NE is + * unknown. */ connectionLossMediator(InternalSeverity.Major), - /** Mountpoint is connected via Netconf to Mediator. - * This connection is OK, but mediator <-> NE Connection is not OK + /** + * Mountpoint is connected via Netconf to Mediator. This connection is OK, but mediator <-> NE Connection is not OK */ connectionLossNeOAM(InternalSeverity.Major); @@ -61,7 +61,7 @@ public enum DeviceMonitorProblems { public void setSeverity(InternalSeverity severity) { LOG.info("Change severity for {} from {} to {}", name(), this.severity, severity); - this.severity=severity; + this.severity = severity; } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java index 73ce1b4d5..e967317d2 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java @@ -51,7 +51,7 @@ public class DeviceMonitorTask implements Runnable { private int tickCounter; //Added for each tick. Not relevant for internal status private ScheduledFuture<?> taskHandle; - private final Object lockNe = new Object(); //USe top lock access to member ne + private final Object lockNe = new Object(); //USe top lock access to member ne private @Nullable DeviceMonitoredNe ne; //Indication if in status connect or disconnect private @NonNull Boolean mountpointConnectingStateSupervision; //Indication of mountpoint supervision @@ -65,6 +65,7 @@ public class DeviceMonitorTask implements Runnable { /** * Setup monitoring task + * * @param mountPointName to monitor * @param odlEventListener to forward problems to */ @@ -77,7 +78,7 @@ public class DeviceMonitorTask implements Runnable { this.checkConnectionToMediator = new Checker() { @Override boolean isReachableOnce() { - synchronized(lockNe) { + synchronized (lockNe) { //mountpoint state "Connected" //If for any reason the mountpoint is Connected, but Notconf messages are not received return ne == null ? true : ne.checkIfConnectionToMediatorIsOk(); @@ -87,7 +88,7 @@ public class DeviceMonitorTask implements Runnable { this.checkConnectionToNe = new Checker() { @Override boolean isReachableOnce() { - synchronized(lockNe) { + synchronized (lockNe) { //mountpoint state "Connected" //If netconf mediator (netconf application software for NE) has connection loss to managed device. //The networkelement object is available, but there is no interfacepack available. @@ -111,6 +112,7 @@ public class DeviceMonitorTask implements Runnable { /** * Start for each object an own instance of the thread. + * * @param scheduler for all the threads. */ public void start(ScheduledExecutorService scheduler) { @@ -125,15 +127,15 @@ public class DeviceMonitorTask implements Runnable { } /** - * Call after NE change state to connected. - * Mountpoint exists. Status is Connecting. + * Call after NE change state to connected. Mountpoint exists. Status is Connecting. + * * @param neParam that connected */ public void deviceConnectIndication(DeviceMonitoredNe neParam) { LOG.info("{} {} Connect {} and stop.", LOGMARKER, tickCounter, mountPointName); clear(DeviceMonitorProblems.connectionLossOAM); - synchronized(lockNe) { + synchronized (lockNe) { this.ne = neParam; this.mountpointConnectingStateSupervision = false; } @@ -141,14 +143,13 @@ public class DeviceMonitorTask implements Runnable { } /** - * If ne is disconnected do the related actions. - * - Mountpoint exists. Status is Connecting or UnableToConnect + * If ne is disconnected do the related actions. - Mountpoint exists. Status is Connecting or UnableToConnect */ public void deviceDisconnectIndication() { LOG.info("{} {} Disconnect {} and start.", LOGMARKER, tickCounter, mountPointName); clear(DeviceMonitorProblems.connectionLossOAM); - synchronized(lockNe) { + synchronized (lockNe) { this.ne = null; this.mountpointConnectingStateSupervision = true; } @@ -156,36 +157,36 @@ public class DeviceMonitorTask implements Runnable { } /** - * Do all actions to clean up the log if mountpoint has been deleted. - * - Mountpoint removed - * Prepare cancellation of the task and cancel task + * Do all actions to clean up the log if mountpoint has been deleted. - Mountpoint removed Prepare cancellation of + * the task and cancel task */ public void removeMountpointIndication() { - for (DeviceMonitorProblems problem : DeviceMonitorProblems.values()) { + for (DeviceMonitorProblems problem : DeviceMonitorProblems.values()) { clear(problem); } - //Cancel the task - if (this.taskHandle != null) { - this.taskHandle.cancel(false); - LOG.info("{} {} DeviceMonitor task canceled for {}", LOGMARKER, tickCounter, mountPointName); - } else { - LOG.error("{} {} Task already stopped", LOGMARKER, tickCounter); - } + //Cancel the task + if (this.taskHandle != null) { + this.taskHandle.cancel(false); + LOG.info("{} {} DeviceMonitor task canceled for {}", LOGMARKER, tickCounter, mountPointName); + } else { + LOG.error("{} {} Task already stopped", LOGMARKER, tickCounter); + } } /** * Referesh Alarms */ public void refreshAlarms() { - LOG.debug("{} Start refresh of all problems",LOGMARKER); - synchronized(currentProblems) { - for (DeviceMonitorProblems problem : currentProblems) { - LOG.debug("{} Refresh problem {} Raised-status {}",LOGMARKER, problem.name(), currentProblems.contains(problem)); + LOG.debug("{} Start refresh of all problems", LOGMARKER); + synchronized (currentProblems) { + for (DeviceMonitorProblems problem : currentProblems) { + LOG.debug("{} Refresh problem {} Raised-status {}", LOGMARKER, problem.name(), + currentProblems.contains(problem)); odlEventListener.onProblemNotification(mountPointName, problem.name(), problem.getSeverity()); } } - LOG.debug("{} Finish refresh of all problems",LOGMARKER); + LOG.debug("{} Finish refresh of all problems", LOGMARKER); } /*------------------------------------------------------------ @@ -194,12 +195,13 @@ public class DeviceMonitorTask implements Runnable { /** * Raise a problem, but only once + * * @param problem */ private void raise(DeviceMonitorProblems problem) { - LOG.debug("{} Raise problem {} Raised-status {}",LOGMARKER, problem.name(), currentProblems.contains(problem)); - synchronized(currentProblems) { - if (! currentProblems.contains(problem)) { + LOG.debug("{} Raise problem {} Raised-status {}", LOGMARKER, problem.name(), currentProblems.contains(problem)); + synchronized (currentProblems) { + if (!currentProblems.contains(problem)) { currentProblems.add(problem); odlEventListener.onProblemNotification(mountPointName, problem.name(), problem.getSeverity()); } @@ -208,11 +210,12 @@ public class DeviceMonitorTask implements Runnable { /** * Raise a problem, but only once + * * @param problem */ private void clear(DeviceMonitorProblems problem) { - LOG.debug("{} Clear problem {} Raised-status {}",LOGMARKER, problem.name(), currentProblems.contains(problem)); - synchronized(currentProblems) { + LOG.debug("{} Clear problem {} Raised-status {}", LOGMARKER, problem.name(), currentProblems.contains(problem)); + synchronized (currentProblems) { if (currentProblems.contains(problem)) { currentProblems.remove(problem); odlEventListener.onProblemNotification(mountPointName, problem.name(), InternalSeverity.NonAlarmed); @@ -222,17 +225,20 @@ public class DeviceMonitorTask implements Runnable { /** * Process problem notification cascade + * * @param isReachable * @param problem */ private void clearRaiseIfConnected(Checker checker, DeviceMonitorProblems problem) { - LOG.debug("{} check start {} problem {} Raised-status {}",LOGMARKER, tickCounter, problem.name(), currentProblems.contains(problem)); + LOG.debug("{} check start {} problem {} Raised-status {}", LOGMARKER, tickCounter, problem.name(), + currentProblems.contains(problem)); if (checker.isConnected()) { clear(problem); } else { raise(problem); } - LOG.debug("{} check end {} problem {} Raised-status {}",LOGMARKER, tickCounter, problem.name(), currentProblems.contains(problem)); + LOG.debug("{} check end {} problem {} Raised-status {}", LOGMARKER, tickCounter, problem.name(), + currentProblems.contains(problem)); } /*------------------------------------------------------------ @@ -240,19 +246,19 @@ public class DeviceMonitorTask implements Runnable { */ private void startDisconnectSupervision() { - synchronized(lockDisconnectSupervisionTickout) { + synchronized (lockDisconnectSupervisionTickout) { this.disconnectSupervisionTickout = 2; } } private void stopDisconnectSupervision() { - synchronized(lockDisconnectSupervisionTickout) { + synchronized (lockDisconnectSupervisionTickout) { this.disconnectSupervisionTickout = 0; } } private boolean processDisconnectSupervisionAndCheckExceeded() { - synchronized(lockDisconnectSupervisionTickout) { + synchronized (lockDisconnectSupervisionTickout) { if (disconnectSupervisionTickout == 0) { return true; } else if (disconnectSupervisionTickout > 0) { @@ -267,53 +273,48 @@ public class DeviceMonitorTask implements Runnable { */ /** - * Task to monitor connectivity to Network Elements. - * Connectivity problems lead to alarm indication. + * Task to monitor connectivity to Network Elements. Connectivity problems lead to alarm indication. */ @Override public void run() { try { - LOG.debug("{} UTCTime {} START mountpoint {} tick {} connecting supervision {} tickout {}", - LOGMARKER, - NETCONFTIME_CONVERTER.getTimeStamp(), - mountPointName, - tickCounter, - mountpointConnectingStateSupervision, - disconnectSupervisionTickout); - - if (mountpointConnectingStateSupervision) { - LOG.debug("{} {} Mountpoint supervision {}", LOGMARKER, tickCounter, mountPointName); - if (processDisconnectSupervisionAndCheckExceeded()) { - raise(DeviceMonitorProblems.connectionLossOAM); - } - - } else { + LOG.debug("{} UTCTime {} START mountpoint {} tick {} connecting supervision {} tickout {}", LOGMARKER, + NETCONFTIME_CONVERTER.getTimeStamp(), mountPointName, tickCounter, + mountpointConnectingStateSupervision, disconnectSupervisionTickout); + + if (mountpointConnectingStateSupervision) { + LOG.debug("{} {} Mountpoint supervision {}", LOGMARKER, tickCounter, mountPointName); + if (processDisconnectSupervisionAndCheckExceeded()) { + raise(DeviceMonitorProblems.connectionLossOAM); + } + + } else { synchronized (lockNe) { - if (ne != null) { - //checks during "Connected" - clear(DeviceMonitorProblems.connectionLossOAM); //Always cleared never raised - LOG.debug("{} {} Prepare check", LOGMARKER, tickCounter); - ne.prepareCheck(); // Prepare ne check - // Mediator check - LOG.debug("{} {} Mediator check", LOGMARKER, tickCounter); - clearRaiseIfConnected(checkConnectionToMediator, DeviceMonitorProblems.connectionLossMediator); - - // NE check - LOG.debug("{} {} Ne check", LOGMARKER, tickCounter); - clearRaiseIfConnected(checkConnectionToNe, DeviceMonitorProblems.connectionLossNeOAM); - } else { - //Monitor switch off. - LOG.debug("{} {} Monitor switch off state", LOGMARKER, tickCounter); - clear(DeviceMonitorProblems.connectionLossOAM); //Always cleared never raised - clear(DeviceMonitorProblems.connectionLossMediator); //Always cleared never raised - clear(DeviceMonitorProblems.connectionLossNeOAM); //Always cleared never raised - } - } + if (ne != null) { + //checks during "Connected" + clear(DeviceMonitorProblems.connectionLossOAM); //Always cleared never raised + LOG.debug("{} {} Prepare check", LOGMARKER, tickCounter); + ne.prepareCheck(); // Prepare ne check + // Mediator check + LOG.debug("{} {} Mediator check", LOGMARKER, tickCounter); + clearRaiseIfConnected(checkConnectionToMediator, DeviceMonitorProblems.connectionLossMediator); + + // NE check + LOG.debug("{} {} Ne check", LOGMARKER, tickCounter); + clearRaiseIfConnected(checkConnectionToNe, DeviceMonitorProblems.connectionLossNeOAM); + } else { + //Monitor switch off. + LOG.debug("{} {} Monitor switch off state", LOGMARKER, tickCounter); + clear(DeviceMonitorProblems.connectionLossOAM); //Always cleared never raised + clear(DeviceMonitorProblems.connectionLossMediator); //Always cleared never raised + clear(DeviceMonitorProblems.connectionLossNeOAM); //Always cleared never raised + } + } } } catch (Exception e) { //Prevent stopping the task - LOG.warn("{} {} During DeviceMontoring task",LOGMARKER, tickCounter, e); + LOG.warn("{} {} During DeviceMontoring task", LOGMARKER, tickCounter, e); } LOG.debug("{} {} END", LOGMARKER, tickCounter++); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/config/DmConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/config/DmConfig.java index 84474b5df..80e865990 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/config/DmConfig.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/config/DmConfig.java @@ -23,10 +23,8 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMo import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity; /** - * Configuration of devicemonitor, section [devicemonitor] - * SeverityConnectionlossNeOAM=minor - * SeverityConnectionlossOAM=major - * SeverityConnectionlossMediator=critical + * Configuration of devicemonitor, section [devicemonitor] SeverityConnectionlossNeOAM=minor + * SeverityConnectionlossOAM=major SeverityConnectionlossMediator=critical */ public class DmConfig implements Configuration { @@ -34,34 +32,35 @@ public class DmConfig implements Configuration { private static final String PROPERTY_KEY_PREFIX_Severity = "Severity"; - private final ConfigurationFileRepresentation configuration; + private final ConfigurationFileRepresentation configuration; - public DmConfig(ConfigurationFileRepresentation configuration) { - this.configuration = configuration; - this.configuration.addSection(SECTION_MARKER_TA); - defaults(); - } + public DmConfig(ConfigurationFileRepresentation configuration) { + this.configuration = configuration; + this.configuration.addSection(SECTION_MARKER_TA); + defaults(); + } - public InternalSeverity getSeverity(DeviceMonitorProblems problem) { - String severityString = configuration.getProperty(SECTION_MARKER_TA, getPropertyName(problem)); - InternalSeverity result = InternalSeverity.valueOfString(severityString); - return result != null ? result : InternalSeverity.Major; - } + public InternalSeverity getSeverity(DeviceMonitorProblems problem) { + String severityString = configuration.getProperty(SECTION_MARKER_TA, getPropertyName(problem)); + InternalSeverity result = InternalSeverity.valueOfString(severityString); + return result != null ? result : InternalSeverity.Major; + } - @Override - public String getSectionName() { - return SECTION_MARKER_TA; - } + @Override + public String getSectionName() { + return SECTION_MARKER_TA; + } - @Override - public void defaults() { + @Override + public void defaults() { for (DeviceMonitorProblems problem : DeviceMonitorProblems.values()) { - configuration.setPropertyIfNotAvailable(SECTION_MARKER_TA, getPropertyName(problem), problem.getSeverity().name()); + configuration.setPropertyIfNotAvailable(SECTION_MARKER_TA, getPropertyName(problem), + problem.getSeverity().name()); } - } + } - private String getPropertyName(DeviceMonitorProblems problem) { - return PROPERTY_KEY_PREFIX_Severity+problem.name(); - } + private String getPropertyName(DeviceMonitorProblems problem) { + return PROPERTY_KEY_PREFIX_Severity + problem.name(); + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java index 2cccd391b..e4a7829c2 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java @@ -52,32 +52,32 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DeviceManagerDatabaseNotificationService implements NotificationService, EquipmentService, FaultService,NotificationDelayedListener<ProblemNotificationXml> { +public class DeviceManagerDatabaseNotificationService implements NotificationService, EquipmentService, FaultService, + NotificationDelayedListener<ProblemNotificationXml> { - private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerDatabaseNotificationService.class); + private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerDatabaseNotificationService.class); - private final @NonNull DataProvider databaseService; + private final @NonNull DataProvider databaseService; private final @NonNull WebSocketServiceClientInternal webSocketService; - private @NonNull - final DevicemanagerNotificationDelayService notificationDelayService; - private @NonNull - final DcaeForwarderInternal aotsDcaeForwarder; + private @NonNull final DevicemanagerNotificationDelayService notificationDelayService; + private @NonNull final DcaeForwarderInternal aotsDcaeForwarder; - private final @NonNull MaintenanceServiceImpl maintenanceService; + private final @NonNull MaintenanceServiceImpl maintenanceService; /** - * @param databaseService to access database + * @param databaseService to access database * @param maintenanceService * @param webSocketService to send notifications * @param notificationDelayService filter to prevent toggle alarms * @param aotsDcaeForwarder */ public DeviceManagerDatabaseNotificationService(@NonNull DataProvider databaseService, - @NonNull MaintenanceServiceImpl maintenanceService, @NonNull WebSocketServiceClientInternal webSocketService, + @NonNull MaintenanceServiceImpl maintenanceService, + @NonNull WebSocketServiceClientInternal webSocketService, @NonNull DevicemanagerNotificationDelayService notificationDelayService, @NonNull DcaeForwarderInternal aotsDcaeForwarder) { super(); - HtAssert.nonnull(databaseService, maintenanceService,webSocketService, notificationDelayService); + HtAssert.nonnull(databaseService, maintenanceService, webSocketService, notificationDelayService); this.databaseService = databaseService; this.maintenanceService = maintenanceService; @@ -99,7 +99,8 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer @Override public void changeNotification(NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, @Nullable String objectId, @Nullable String attributeName, @Nullable String newValue) { - EventlogEntity eventlogEntity = new EventlogNotificationBuilder(nodeId, counter, timeStamp, objectId, attributeName, newValue).build(); + EventlogEntity eventlogEntity = + new EventlogNotificationBuilder(nodeId, counter, timeStamp, objectId, attributeName, newValue).build(); databaseService.writeEventLog(eventlogEntity); webSocketService.sendViaWebsockets(nodeId.getValue(), new AttributeValueChangedNotificationXml(eventlogEntity)); } @@ -107,7 +108,8 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer @Override public void creationNotification(NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, @Nullable String objectId) { - EventlogEntity eventlogEntity = new EventlogNotificationBuilder(nodeId, counter, timeStamp, objectId, "creation", null).build(); + EventlogEntity eventlogEntity = + new EventlogNotificationBuilder(nodeId, counter, timeStamp, objectId, "creation", null).build(); databaseService.writeEventLog(eventlogEntity); webSocketService.sendViaWebsockets(nodeId.getValue(), new ObjectCreationNotificationXml(eventlogEntity)); } @@ -116,7 +118,8 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer @Override public void deletionNotification(NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, @Nullable String objectId) { - EventlogEntity eventlogEntity = new EventlogNotificationBuilder(nodeId, counter, timeStamp, objectId, "deletion", null).build(); + EventlogEntity eventlogEntity = + new EventlogNotificationBuilder(nodeId, counter, timeStamp, objectId, "deletion", null).build(); databaseService.writeEventLog(eventlogEntity); webSocketService.sendViaWebsockets(nodeId.getValue(), new ObjectDeletionNotificationXml(eventlogEntity)); } @@ -139,44 +142,42 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer ProblemNotificationXml notificationXml = new ProblemNotificationXml(faultNotification); String nodeName = faultNotification.getNodeId(); - if(NotificationDelayFilter.isEnabled()) - { - if(notificationXml.getSeverity() == InternalSeverity.NonAlarmed) { + if (NotificationDelayFilter.isEnabled()) { + if (notificationXml.getSeverity() == InternalSeverity.NonAlarmed) { this.notificationDelayService.getInstance(nodeName, this).clearAlarmNotification(notificationXml); } else { - this.notificationDelayService.getInstance(nodeName, this).pushAlarmNotification(notificationXml); + this.notificationDelayService.getInstance(nodeName, this).pushAlarmNotification(notificationXml); } - } - else - { - this.pushAlarmIfNotInMaintenance(nodeName,notificationXml); + } else { + this.pushAlarmIfNotInMaintenance(nodeName, notificationXml); } // ToggleAlarmFilter functionality -// if (notificationDelayService.processNotification(notificationXml.getSeverity() == InternalSeverity.NonAlarmed, -// notificationXml.getProblem(), notificationXml)) { -// if (notificationDelayService.processNotification(notificationXml)) { -// aotsDcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(nodeName, notificationXml); -// } -// } + // if (notificationDelayService.processNotification(notificationXml.getSeverity() == InternalSeverity.NonAlarmed, + // notificationXml.getProblem(), notificationXml)) { + // if (notificationDelayService.processNotification(notificationXml)) { + // aotsDcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(nodeName, notificationXml); + // } + // } // end of ToggleAlarmFilter this.webSocketService.sendViaWebsockets(nodeName, notificationXml); } - private void pushAlarmIfNotInMaintenance(String nodeName,ProblemNotificationXml notificationXml) - { - if(!this.maintenanceService.isONFObjectInMaintenance(nodeName, notificationXml.getObjectId(), notificationXml.getProblem())) - { - this.aotsDcaeForwarder.sendProblemNotification(nodeName, notificationXml); - } - else - { - LOG.debug("Notification will not be sent to external services. Device "+nodeName+" is in maintenance mode"); - } + + private void pushAlarmIfNotInMaintenance(String nodeName, ProblemNotificationXml notificationXml) { + if (!this.maintenanceService.isONFObjectInMaintenance(nodeName, notificationXml.getObjectId(), + notificationXml.getProblem())) { + this.aotsDcaeForwarder.sendProblemNotification(nodeName, notificationXml); + } else { + LOG.debug("Notification will not be sent to external services. Device " + nodeName + + " is in maintenance mode"); + } } + @Override public void faultNotification(@NonNull NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, @Nullable String objectId, @Nullable String problem, @Nullable SeverityType severity) { - FaultNotificationBuilder2 bFaultlog = new FaultNotificationBuilder2(nodeId, counter, timeStamp, objectId, problem, severity, SourceType.Netconf); + FaultNotificationBuilder2 bFaultlog = new FaultNotificationBuilder2(nodeId, counter, timeStamp, objectId, + problem, severity, SourceType.Netconf); faultNotification(bFaultlog.build()); } @@ -193,7 +194,7 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer FaultcurrentBuilder bFaultcurrent = new FaultcurrentBuilder(); bFaultcurrent.fieldsFrom(problem); databaseService.updateFaultCurrent(bFaultcurrent.build()); - }); + }); } @Override @@ -209,9 +210,9 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer } - @Override - public void onNotificationDelay(String nodeName,ProblemNotificationXml notification) { - LOG.debug("Got delayed event of type :: {}", ProblemNotificationXml.class.getSimpleName()); - this.pushAlarmIfNotInMaintenance(nodeName,notification); - } + @Override + public void onNotificationDelay(String nodeName, ProblemNotificationXml notification) { + LOG.debug("Got delayed event of type :: {}", ProblemNotificationXml.class.getSimpleName()); + this.pushAlarmIfNotInMaintenance(nodeName, notification); + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java index 9f1b2b266..68177d373 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java @@ -41,10 +41,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Responsible class for documenting changes in the ODL itself. The occurence of such an event is - * documented in the database and to clients. Specific example here is the registration or - * deregistration of a netconf device. This service has an own eventcounter to apply to the ONF - * Coremodel netconf behaviour. + * Responsible class for documenting changes in the ODL itself. The occurence of such an event is documented in the + * database and to clients. Specific example here is the registration or deregistration of a netconf device. This + * service has an own eventcounter to apply to the ONF Coremodel netconf behaviour. * * Important: Websocket notification must be the last action. * @@ -96,16 +95,17 @@ public class ODLEventListenerHandler implements EventHandlingService { /** * A registration of a mountpoint occured, that is in connect state + * * @param registrationName of device (mountpoint name) * @param nNode with mountpoint data */ @Override public void registration(String registrationName, NetconfNode nNode) { - ObjectCreationNotificationXml cNotificationXml = - new ObjectCreationNotificationXml(ownKeyName, popEvntNumber(), - InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()), registrationName); - NetworkElementConnectionEntity e = NetworkElementConnectionEntitiyUtil.getNetworkConnection(registrationName, nNode); + ObjectCreationNotificationXml cNotificationXml = new ObjectCreationNotificationXml(ownKeyName, popEvntNumber(), + InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()), registrationName); + NetworkElementConnectionEntity e = + NetworkElementConnectionEntitiyUtil.getNetworkConnection(registrationName, nNode); LOG.debug("registration networkelement-connection for {} with status {}", registrationName, e.getStatus()); // Write first to prevent missing entries @@ -116,15 +116,18 @@ public class ODLEventListenerHandler implements EventHandlingService { /** * mountpoint created, connection state not connected - * @param mountpointNodeName uuid that is nodeId or mountpointId - * @param netconfNode - */ - public void mountpointCreatedIndication(String mountpointNodeName, NetconfNode netconfNode) { - LOG.debug("mountpoint create indication for {}", mountpointNodeName); - this.registration(mountpointNodeName, netconfNode); - } + * + * @param mountpointNodeName uuid that is nodeId or mountpointId + * @param netconfNode + */ + public void mountpointCreatedIndication(String mountpointNodeName, NetconfNode netconfNode) { + LOG.debug("mountpoint create indication for {}", mountpointNodeName); + this.registration(mountpointNodeName, netconfNode); + } + /** * After registration + * * @param mountpointNodeName uuid that is nodeId or mountpointId * @param deviceType according to assessement */ @@ -132,38 +135,41 @@ public class ODLEventListenerHandler implements EventHandlingService { public void connectIndication(String mountpointNodeName, NetworkElementDeviceType deviceType) { // Write first to prevent missing entries - LOG.debug("updating networkelement-connection devicetype for {} with {}",mountpointNodeName, deviceType); - NetworkElementConnectionEntity e = NetworkElementConnectionEntitiyUtil.getNetworkConnectionDeviceTpe(deviceType); + LOG.debug("updating networkelement-connection devicetype for {} with {}", mountpointNodeName, deviceType); + NetworkElementConnectionEntity e = + NetworkElementConnectionEntitiyUtil.getNetworkConnectionDeviceTpe(deviceType); databaseService.updateNetworkConnectionDeviceType(e, mountpointNodeName); AttributeValueChangedNotificationXml notificationXml = new AttributeValueChangedNotificationXml(ownKeyName, - popEvntNumber(), InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()), - mountpointNodeName, "deviceType", deviceType.name()); + popEvntNumber(), InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()), mountpointNodeName, + "deviceType", deviceType.name()); webSocketService.sendViaWebsockets(mountpointNodeName, notificationXml); } /** * mountpoint state changed - * @param mountpointNodeName - * @param netconfNode - */ - public void onStateChangeIndication(String mountpointNodeName, NetconfNode netconfNode) { - LOG.debug("mountpoint state changed indication for {}", mountpointNodeName); - ConnectionStatus csts = netconfNode.getConnectionStatus(); - this.updateRegistration(mountpointNodeName, ConnectionStatus.class.getSimpleName(), + * + * @param mountpointNodeName + * @param netconfNode + */ + public void onStateChangeIndication(String mountpointNodeName, NetconfNode netconfNode) { + LOG.debug("mountpoint state changed indication for {}", mountpointNodeName); + ConnectionStatus csts = netconfNode.getConnectionStatus(); + this.updateRegistration(mountpointNodeName, ConnectionStatus.class.getSimpleName(), csts != null ? csts.getName() : "null", netconfNode); - - } + + } + /** * A deregistration of a mountpoint occured. + * * @param registrationName Name of the event that is used as key in the database. */ @Override public void deRegistration(String registrationName) { - ObjectDeletionNotificationXml dNotificationXml = - new ObjectDeletionNotificationXml(ownKeyName, popEvntNumber(), - InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()), registrationName); + ObjectDeletionNotificationXml dNotificationXml = new ObjectDeletionNotificationXml(ownKeyName, popEvntNumber(), + InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()), registrationName); // Write first to prevent missing entries databaseService.removeNetworkConnection(registrationName); @@ -174,14 +180,17 @@ public class ODLEventListenerHandler implements EventHandlingService { /** * Mountpoint state changed .. from connected -> connecting or unable-to-connect or vis-e-versa. + * * @param registrationName Name of the event that is used as key in the database. */ @Override - public void updateRegistration(String registrationName, String attribute, String attributeNewValue, NetconfNode nNode) { + public void updateRegistration(String registrationName, String attribute, String attributeNewValue, + NetconfNode nNode) { AttributeValueChangedNotificationXml notificationXml = new AttributeValueChangedNotificationXml(ownKeyName, - popEvntNumber(), InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()), - registrationName, attribute, attributeNewValue); - NetworkElementConnectionEntity e = NetworkElementConnectionEntitiyUtil.getNetworkConnection(registrationName, nNode); + popEvntNumber(), InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()), registrationName, + attribute, attributeNewValue); + NetworkElementConnectionEntity e = + NetworkElementConnectionEntitiyUtil.getNetworkConnection(registrationName, nNode); LOG.debug("updating networkelement-connection for {} with status {}", registrationName, e.getStatus()); databaseService.updateNetworkConnection22(e, registrationName); @@ -220,8 +229,8 @@ public class ODLEventListenerHandler implements EventHandlingService { LOG.debug("Got startComplete"); EventlogBuilder eventlogBuilder = new EventlogBuilder(); eventlogBuilder.setNodeId(ownKeyName).setTimestamp(new DateAndTime(NETCONFTIME_CONVERTER.getTimeStamp())) - .setObjectId(objectId).setAttributeName(msg).setNewValue(value).setCounter(popEvntNumber()) - .setSourceType(SourceType.Controller); + .setObjectId(objectId).setAttributeName(msg).setNewValue(value).setCounter(popEvntNumber()) + .setSourceType(SourceType.Controller); databaseService.writeEventLog(eventlogBuilder.build()); } @@ -258,8 +267,6 @@ public class ODLEventListenerHandler implements EventHandlingService { return eventNumber++; } - - } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java index d63ff5d09..0761299b0 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java @@ -60,15 +60,16 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ConnectionStatusHousekeepingService implements ClusterSingletonService,AutoCloseable { +public class ConnectionStatusHousekeepingService implements ClusterSingletonService, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(ConnectionStatusHousekeepingService.class); private static final long INTERVAL_SECONDS = 30; - private static final InstanceIdentifier<Topology> NETCONF_TOPO_IID = InstanceIdentifier - .create(NetworkTopology.class) - .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()))); - private static final ServiceGroupIdentifier IDENT = ServiceGroupIdentifier.create("ConnectionStatusHousekeepingService"); + private static final InstanceIdentifier<Topology> NETCONF_TOPO_IID = + InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, + new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()))); + private static final ServiceGroupIdentifier IDENT = + ServiceGroupIdentifier.create("ConnectionStatusHousekeepingService"); private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(3); private final DataBroker dataBroker; @@ -88,13 +89,13 @@ public class ConnectionStatusHousekeepingService implements ClusterSingletonServ if (taskReference != null) { taskReference.cancel(false); } - if(!isMaster) { + if (!isMaster) { LOG.info("do not start. not the master node"); return; } LOG.info("starting scheduler with interval {}", INTERVAL_SECONDS); - this.taskReference = this.scheduler.scheduleAtFixedRate(runner, INTERVAL_SECONDS, INTERVAL_SECONDS, - TimeUnit.SECONDS); + this.taskReference = + this.scheduler.scheduleAtFixedRate(runner, INTERVAL_SECONDS, INTERVAL_SECONDS, TimeUnit.SECONDS); } private void doClean() { @@ -108,102 +109,103 @@ public class ConnectionStatusHousekeepingService implements ClusterSingletonServ String nodeId; if (list == null || list.size() <= 0) { LOG.trace("no items in list."); + } else { + //check all db entries and sync connection status + for (NetworkElementConnectionEntity item : list) { + + // compare with MD-SAL + nodeId = item.getNodeId(); + LOG.trace("check status of {}", nodeId); + dbStatus = item.getStatus(); + mdsalStatus = this.getMDSalConnectionStatus(nodeId); + if (mdsalStatus == null) { + LOG.trace("unable to get connection status. jump over"); + continue; + } + // if different then update db + if (dbStatus != mdsalStatus) { + LOG.trace("status is inconsistent db={}, mdsal={}. updating db", dbStatus, mdsalStatus); + if ((item.isIsRequired() == null || item.isIsRequired() == false) + && mdsalStatus == ConnectionLogStatus.Disconnected) { + LOG.info("removing entry for node {} ({}) from database due missing MD-SAL entry", + item.getNodeId(), mdsalStatus); + this.dataProvider.removeNetworkConnection(nodeId); + } else { + this.dataProvider.updateNetworkConnectionDeviceType( + new NetworkElementConnectionBuilder().setStatus(mdsalStatus).build(), nodeId); + } + } else { + LOG.trace("no difference"); + } + + } } - else { - //check all db entries and sync connection status - for (NetworkElementConnectionEntity item : list) { - - // compare with MD-SAL - nodeId = item.getNodeId(); - LOG.trace("check status of {}", nodeId); - dbStatus = item.getStatus(); - mdsalStatus = this.getMDSalConnectionStatus(nodeId); - if (mdsalStatus == null) { - LOG.trace("unable to get connection status. jump over"); - continue; - } - // if different then update db - if (dbStatus != mdsalStatus) { - LOG.trace("status is inconsistent db={}, mdsal={}. updating db", dbStatus, mdsalStatus); - if((item.isIsRequired()==null || item.isIsRequired()==false) && mdsalStatus==ConnectionLogStatus.Disconnected) { - LOG.info("removing entry for node {} ({}) from database due missing MD-SAL entry",item.getNodeId(),mdsalStatus); - this.dataProvider.removeNetworkConnection(nodeId); - } - else { - this.dataProvider.updateNetworkConnectionDeviceType( - new NetworkElementConnectionBuilder().setStatus(mdsalStatus).build(), nodeId); - } - } else { - LOG.trace("no difference"); - } - - } - } - //check all md-sal entries and add non-existing to db -// List<Node> mdsalNodes = this.getMDSalNodes(); -// NodeId nid; -// for (Node mdsalNode : mdsalNodes) { -// nid = mdsalNode.getNodeId(); -// if (nid == null) { -// continue; -// } -// nodeId = nid.getValue(); -// if (nodeId == null) { -// continue; -// } -// if (contains(list, nodeId)) { -// LOG.debug("found mountpoint for {} without db entry. creating.",nodeId); -// this.dataProvider.updateNetworkConnection22(NetworkElementConnectionEntitiyUtil -// .getNetworkConnection(nodeId, mdsalNode.augmentation(NetconfNode.class)), nodeId); -// } -// } - - } catch (Exception e) { + //check all md-sal entries and add non-existing to db + // List<Node> mdsalNodes = this.getMDSalNodes(); + // NodeId nid; + // for (Node mdsalNode : mdsalNodes) { + // nid = mdsalNode.getNodeId(); + // if (nid == null) { + // continue; + // } + // nodeId = nid.getValue(); + // if (nodeId == null) { + // continue; + // } + // if (contains(list, nodeId)) { + // LOG.debug("found mountpoint for {} without db entry. creating.",nodeId); + // this.dataProvider.updateNetworkConnection22(NetworkElementConnectionEntitiyUtil + // .getNetworkConnection(nodeId, mdsalNode.augmentation(NetconfNode.class)), nodeId); + // } + // } + + } catch (Exception e) { LOG.warn("problem executing housekeeping task: {}", e); } LOG.debug("finish housekeeping"); } - /** - * @param list - * @param nodeId - * @return - */ -// private boolean contains(List<NetworkElementConnectionEntity> list, @NonNull String nodeId) { -// if(list==null || list.size()<=0) { -// return false; -// } -// for(NetworkElementConnectionEntity item:list) { -// if(item!=null && nodeId.equals(item.getNodeId())) { -// return true; -// } -// } -// return false; -// } -// -// private List<Node> getMDSalNodes(){ -// ReadTransaction trans = this.dataBroker.newReadOnlyTransaction(); -// FluentFuture<Optional<Topology>> optionalTopology =trans.read(LogicalDatastoreType.OPERATIONAL, NETCONF_TOPO_IID); -// List<Node> nodes = new ArrayList<>(); -// try { -// Topology topo = optionalTopology.get(20, TimeUnit.SECONDS).get(); -// List<Node> topoNodes=topo.getNode(); -// if(topoNodes!=null){ -// nodes.addAll(topoNodes); -// } -// } -// catch(Exception e) { -// LOG.warn("unable to read netconf topology for housekeeping: {}",e); -// } -// return nodes; -// } + /** + * @param list + * @param nodeId + * @return + */ + // private boolean contains(List<NetworkElementConnectionEntity> list, @NonNull String nodeId) { + // if(list==null || list.size()<=0) { + // return false; + // } + // for(NetworkElementConnectionEntity item:list) { + // if(item!=null && nodeId.equals(item.getNodeId())) { + // return true; + // } + // } + // return false; + // } + // + // private List<Node> getMDSalNodes(){ + // ReadTransaction trans = this.dataBroker.newReadOnlyTransaction(); + // FluentFuture<Optional<Topology>> optionalTopology =trans.read(LogicalDatastoreType.OPERATIONAL, NETCONF_TOPO_IID); + // List<Node> nodes = new ArrayList<>(); + // try { + // Topology topo = optionalTopology.get(20, TimeUnit.SECONDS).get(); + // List<Node> topoNodes=topo.getNode(); + // if(topoNodes!=null){ + // nodes.addAll(topoNodes); + // } + // } + // catch(Exception e) { + // LOG.warn("unable to read netconf topology for housekeeping: {}",e); + // } + // return nodes; + // } private ConnectionLogStatus getMDSalConnectionStatus(String nodeId) { @SuppressWarnings("null") - @NonNull InstanceIdentifier<Node> instanceIdentifier = NETCONF_TOPO_IID.child(Node.class, - new NodeKey(new NodeId(nodeId))); - ReadTransaction trans = this.dataBroker.newReadOnlyTransaction(); - FluentFuture<Optional<Node>> optionalNode =trans.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); + @NonNull + InstanceIdentifier<Node> instanceIdentifier = + NETCONF_TOPO_IID.child(Node.class, new NodeKey(new NodeId(nodeId))); + ReadTransaction trans = this.dataBroker.newReadOnlyTransaction(); + FluentFuture<Optional<Node>> optionalNode = trans.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); try { Node node = optionalNode.get(5, TimeUnit.SECONDS).get(); LOG.debug("node is {}", node); @@ -216,9 +218,8 @@ public class ConnectionStatusHousekeepingService implements ClusterSingletonServ return ConnectionLogStatus.Disconnected; } catch (ExecutionException | InterruptedException | TimeoutException e) { LOG.warn("unable to get node info: {}", e); - } - finally { - trans.close(); + } finally { + trans.close(); } return null; @@ -232,24 +233,24 @@ public class ConnectionStatusHousekeepingService implements ClusterSingletonServ this.scheduler.shutdown(); } - @SuppressWarnings("null") - @Override - public @NonNull ServiceGroupIdentifier getIdentifier() { - return IDENT; - } - - @Override - public void instantiateServiceInstance() { - LOG.info("We take Leadership"); - this.isMaster = true; - this.start(); - } - - @Override - public ListenableFuture<? extends Object> closeServiceInstance() { - LOG.info("We lost Leadership"); - this.isMaster = false; - this.start(); - return Futures.immediateFuture(null); - } + @SuppressWarnings("null") + @Override + public @NonNull ServiceGroupIdentifier getIdentifier() { + return IDENT; + } + + @Override + public void instantiateServiceInstance() { + LOG.info("We take Leadership"); + this.isMaster = true; + this.start(); + } + + @Override + public ListenableFuture<? extends Object> closeServiceInstance() { + LOG.info("We lost Leadership"); + this.isMaster = false; + this.start(); + return Futures.immediateFuture(null); + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java index 96369308d..4b9c32021 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java @@ -71,10 +71,9 @@ public class ResyncNetworkElementHouskeepingService implements ResyncNetworkElem * @param databaseClientEvents database to clean * @param deviceMonitor devicemonitor */ - public ResyncNetworkElementHouskeepingService( - DeviceManagerImpl deviceManager, - MountPointService mountPointService, ODLEventListenerHandler odlEventListenerHandler, - DataProvider databaseClientEvents, DeviceMonitor deviceMonitor) { + public ResyncNetworkElementHouskeepingService(DeviceManagerImpl deviceManager, MountPointService mountPointService, + ODLEventListenerHandler odlEventListenerHandler, DataProvider databaseClientEvents, + DeviceMonitor deviceMonitor) { super(); this.deviceManager = deviceManager; this.mountPointService = mountPointService; @@ -103,8 +102,8 @@ public class ResyncNetworkElementHouskeepingService implements ResyncNetworkElem if (nodeNames == null || nodeNames.size() <= 0) { nodeNamesInput = this.databaseClientEvents.getAllNodesWithCurrentAlarms(); } else { - nodeNamesInput = nodeNames; - } + nodeNamesInput = nodeNames; + } // Filter all mountpoints from input that were found and are known to this Cluster-node instance of // DeviceManager diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementsListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementsListener.java index cb6845a25..652d543f0 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementsListener.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementsListener.java @@ -22,14 +22,15 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; -public interface ResyncNetworkElementsListener -{ +public interface ResyncNetworkElementsListener { /** - * Handle API Request and clean up current alarms according to the list of mountpoint id's/devices - * Implement RPC function "clear-current-fault-by-nodename" + * Handle API Request and clean up current alarms according to the list of mountpoint id's/devices Implement RPC + * function "clear-current-fault-by-nodename" + * * @return List with * @throws IllegalStateException Illegal state exception */ - public @NonNull List<String> doClearCurrentFaultByNodename(@Nullable List<String> nodeNamesInput) throws IllegalStateException; + public @NonNull List<String> doClearCurrentFaultByNodename(@Nullable List<String> nodeNamesInput) + throws IllegalStateException; } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java index 218eba069..266bb04ba 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java @@ -60,12 +60,9 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl private static final Logger LOG = LoggerFactory.getLogger(DevicemanagerService.class); private final ObjectRegistration<DevicemanagerService> rpcReg; - private @Nullable - final MaintenanceRPCServiceAPI maintenanceService; - private @Nullable - final PushNotifications pushNotificationsListener; - private @Nullable - final ResyncNetworkElementsListener resyncCallbackListener; + private @Nullable final MaintenanceRPCServiceAPI maintenanceService; + private @Nullable final PushNotifications pushNotificationsListener; + private @Nullable final ResyncNetworkElementsListener resyncCallbackListener; public DeviceManagerApiServiceImpl(final RpcProviderService rpcProviderRegistry, MaintenanceServiceImpl maintenanceService, ResyncNetworkElementsListener listener, @@ -75,7 +72,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl this.resyncCallbackListener = listener; // Register ourselves as the REST API RPC implementation - LOG.info("Register RPC Service "+DevicemanagerService.class.getSimpleName()); + LOG.info("Register RPC Service " + DevicemanagerService.class.getSimpleName()); this.rpcReg = rpcProviderRegistry.registerRpcImplementation(DevicemanagerService.class, this); } @@ -103,8 +100,9 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl LOG.info("RPC Request: getRequiredNetworkElementKeys"); RpcResultBuilder<GetRequiredNetworkElementKeysOutput> result; try { - GetRequiredNetworkElementKeysOutputBuilder outputBuilder = maintenanceService.getRequiredNetworkElementKeys(); - result = RpcResultBuilder.success(outputBuilder); + GetRequiredNetworkElementKeysOutputBuilder outputBuilder = + maintenanceService.getRequiredNetworkElementKeys(); + result = RpcResultBuilder.success(outputBuilder); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -120,8 +118,9 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl RpcResultBuilder<ShowRequiredNetworkElementOutput> result; try { - ShowRequiredNetworkElementOutputBuilder outputBuilder = maintenanceService.showRequiredNetworkElement(input); - result = RpcResultBuilder.success(outputBuilder); + ShowRequiredNetworkElementOutputBuilder outputBuilder = + maintenanceService.showRequiredNetworkElement(input); + result = RpcResultBuilder.success(outputBuilder); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -137,7 +136,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { SetMaintenanceModeOutputBuilder outputBuilder = maintenanceService.setMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -156,7 +155,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { GetMaintenanceModeOutputBuilder outputBuilder = maintenanceService.getMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -172,7 +171,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { TestMaintenanceModeOutputBuilder outputBuilder = maintenanceService.testMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -188,16 +187,17 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl LOG.info("RPC Request: clearNetworkElementAlarms input: {}", input.getNodenames()); RpcResultBuilder<ClearCurrentFaultByNodenameOutput> result; try { - if(this.resyncCallbackListener!=null) { - List<String> nodeNames= this.resyncCallbackListener.doClearCurrentFaultByNodename(input.getNodenames()); + if (this.resyncCallbackListener != null) { + List<String> nodeNames = + this.resyncCallbackListener.doClearCurrentFaultByNodename(input.getNodenames()); ClearCurrentFaultByNodenameOutputBuilder outputBuilder = new ClearCurrentFaultByNodenameOutputBuilder(); outputBuilder.setNodenames(nodeNames); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder); } else { result = RpcResultBuilder.failed(); - result.withError(ErrorType.APPLICATION, "Startup running" ); + result.withError(ErrorType.APPLICATION, "Startup running"); } - } catch(Exception e) { + } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); } @@ -211,7 +211,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl RpcResultBuilder<PushFaultNotificationOutput> result; try { pushNotificationsListener.pushFaultNotification(input); - result = RpcResultBuilder.success(); + result = RpcResultBuilder.success(); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -226,7 +226,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl RpcResultBuilder<PushAttributeChangeNotificationOutput> result; try { pushNotificationsListener.pushAttributeChangeNotification(input); - result = RpcResultBuilder.success(); + result = RpcResultBuilder.success(); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); 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 86cbe5274..53ba09a45 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 @@ -87,9 +87,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Devicemanager - * - Handles startup and closedown of network element handlers for netconf session - * - Provide common services for network element specific components + * Devicemanager - Handles startup and closedown of network element handlers for netconf session - Provide common + * services for network element specific components */ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceManagerServiceProvider, AutoCloseable { @@ -97,7 +96,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa private static final String APPLICATION_NAME = "DeviceManager"; private static final String MYDBKEYNAMEBASE = "SDN-Controller"; private static final String CONFIGURATIONFILE = "etc/devicemanager.properties"; - public static final long DATABASE_TIMEOUT_MS = 120*1000L; + public static final long DATABASE_TIMEOUT_MS = 120 * 1000L; @SuppressWarnings("unused") private static final String STARTUPLOG_FILENAME = "etc/devicemanager.startup.log"; @@ -166,21 +165,24 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa this.rpcProviderRegistry = rpcProviderRegistry; } - public void setNotificationPublishService(NotificationPublishService notificationPublishService) { - } + public void setNotificationPublishService(NotificationPublishService notificationPublishService) {} public void setMountPointService(MountPointService mountPointService) { this.mountPointService = mountPointService; } + public void setClusterSingletonService(ClusterSingletonServiceProvider clusterSingletonService) { this.clusterSingletonServiceProvider = clusterSingletonService; } + public void setNetconfNodeStateService(NetconfNodeStateService netconfNodeStateService) { this.netconfNodeStateService = netconfNodeStateService; } + public void setWebsocketmanagerService(WebsocketmanagerService websocketmanagerService) { this.websocketmanagerService = websocketmanagerService; } + public void setEntityDataProvider(IEntityDataProvider iEntityDataProvider) { this.iEntityDataProvider = iEntityDataProvider; } @@ -217,17 +219,16 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa this.deviceManagerDatabaseAndNotificationService = new DeviceManagerDatabaseNotificationService(dataProvider, maintenanceService, webSocketService, notificationDelayService, aotsDcaeForwarder); - RpcPushNotificationsHandler rpcPushNotificationsHandler = new RpcPushNotificationsHandler(webSocketService, - dataProvider, aotsDcaeForwarder); - this.odlEventListenerHandler = new ODLEventListenerHandler(myDbKeyNameExtended, webSocketService, - dataProvider, aotsDcaeForwarder); + RpcPushNotificationsHandler rpcPushNotificationsHandler = + new RpcPushNotificationsHandler(webSocketService, dataProvider, aotsDcaeForwarder); + this.odlEventListenerHandler = + new ODLEventListenerHandler(myDbKeyNameExtended, webSocketService, dataProvider, aotsDcaeForwarder); this.archiveCleanService = new ArchiveCleanService(iEntityDataProvider.getEsConfig(), dataProvider); - this.housekeepingService = new ConnectionStatusHousekeepingService(this.dataBroker, - dataProvider); - this.cssRegistration = this.clusterSingletonServiceProvider - .registerClusterSingletonService(this.archiveCleanService); - this.cssRegistration2 = this.clusterSingletonServiceProvider - .registerClusterSingletonService(this.housekeepingService); + this.housekeepingService = new ConnectionStatusHousekeepingService(this.dataBroker, dataProvider); + this.cssRegistration = + this.clusterSingletonServiceProvider.registerClusterSingletonService(this.archiveCleanService); + this.cssRegistration2 = + this.clusterSingletonServiceProvider.registerClusterSingletonService(this.housekeepingService); // PM this.performanceManager = new PerformanceManagerImpl(60, this, dataProvider, config); // DM @@ -237,9 +238,8 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa this.deviceMonitor = new DeviceMonitorImpl(dataBroker, odlEventListenerHandler, config); // ResyncNetworkElementHouskeepingService - this.resyncNetworkElementHouskeepingService = new ResyncNetworkElementHouskeepingService( - this, mountPointService, odlEventListenerHandler, - dataProvider, deviceMonitor); + this.resyncNetworkElementHouskeepingService = new ResyncNetworkElementHouskeepingService(this, + mountPointService, odlEventListenerHandler, dataProvider, deviceMonitor); // RPC Service for specific services // Start RPC Service @@ -281,7 +281,8 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa } @Override - public @NonNull <L extends NetworkElementFactory> FactoryRegistration<L> registerNetworkElementFactory(@NonNull L factory) { + public @NonNull <L extends NetworkElementFactory> FactoryRegistration<L> registerNetworkElementFactory( + @NonNull L factory) { LOG.info("Factory registration {}", factory.getClass().getName()); factoryList.add(factory); @@ -358,6 +359,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa /** * Used to close all Services, that should support AutoCloseable Pattern + * * @param toClose */ private void close(AutoCloseable... toCloseList) { @@ -391,6 +393,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa /** * Indication if init() of devicemanager successfully done. + * * @return true if init() was sucessfull. False if not done or not successfull. */ public boolean isDevicemanagerInitializationOk() { @@ -399,6 +402,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa /** * Get NE object. Used by DCAE Service + * * @param mountpoint mount point name * @return null or NE specific data */ diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java index 5f9911ba8..fbcded801 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java @@ -56,8 +56,7 @@ public class DeviceManagerNetconfConnectHandler implements NetconfNodeConnectLis public DeviceManagerNetconfConnectHandler(@NonNull NetconfNodeStateService netconfNodeStateService, @NonNull ODLEventListenerHandler odlEventListenerHandler, @NonNull DeviceMonitor deviceMonitor, - @NonNull DeviceManagerServiceProvider serviceProvider, - @NonNull List<NetworkElementFactory> factoryList) { + @NonNull DeviceManagerServiceProvider serviceProvider, @NonNull List<NetworkElementFactory> factoryList) { HtAssert.nonnull(netconfNodeStateService, this.odlEventListenerHandler = odlEventListenerHandler, this.deviceMonitor = deviceMonitor, this.serviceProvider = serviceProvider, @@ -95,7 +94,7 @@ public class DeviceManagerNetconfConnectHandler implements NetconfNodeConnectLis NetconfNode netconfNode = acessor.getNetconfNode(); sendUpdateNotification(mountPointNodeName, netconfNode.getConnectionStatus(), netconfNode); - for ( NetworkElementFactory f : factoryList) { + for (NetworkElementFactory f : factoryList) { Optional<NetworkElement> optionalNe = f.create(acessor, serviceProvider); if (optionalNe.isPresent()) { // sendUpdateNotification(mountPointNodeName, nNode.getConnectionStatus(), nNode); @@ -131,13 +130,13 @@ public class DeviceManagerNetconfConnectHandler implements NetconfNodeConnectLis public void onCreated(NodeId nNodeId, NetconfNode netconfNode) { LOG.info("onCreated {}", nNodeId); odlEventListenerHandler.mountpointCreatedIndication(nNodeId.getValue(), netconfNode); - + } @Override public void onStateChange(NodeId nNodeId, NetconfNode netconfNode) { LOG.info("onStateChange {}", nNodeId); - odlEventListenerHandler.onStateChangeIndication(nNodeId.getValue(),netconfNode); + odlEventListenerHandler.onStateChangeIndication(nNodeId.getValue(), netconfNode); } @Override @@ -166,10 +165,11 @@ public class DeviceManagerNetconfConnectHandler implements NetconfNodeConnectLis /** * Do all tasks necessary to move from mountpoint state connected -> connecting + * * @param mountPointNodeName provided * @param ne representing the device connected to mountpoint */ - private void stopListenerOnNodeForConnectedState( String mountPointNodeName) { + private void stopListenerOnNodeForConnectedState(String mountPointNodeName) { NetworkElement ne = networkElementRepresentations.remove(mountPointNodeName); if (ne != null) { ne.deregister(); @@ -184,7 +184,7 @@ public class DeviceManagerNetconfConnectHandler implements NetconfNodeConnectLis if (result != null) { LOG.warn("NE list was not empty as expected, but contained {} ", result.getNodeId()); } else { - LOG.debug("refresh necon entry for {} with type {}",mountPointNodeName,ne.getDeviceType()); + LOG.debug("refresh necon entry for {} with type {}", mountPointNodeName, ne.getDeviceType()); odlEventListenerHandler.connectIndication(mountPointNodeName, ne.getDeviceType()); } } @@ -192,7 +192,7 @@ public class DeviceManagerNetconfConnectHandler implements NetconfNodeConnectLis private void sendUpdateNotification(String mountPointNodeName, ConnectionStatus csts, NetconfNode nNode) { LOG.info("update ConnectedState for device :: Name : {} ConnectionStatus {}", mountPointNodeName, csts); odlEventListenerHandler.updateRegistration(mountPointNodeName, ConnectionStatus.class.getSimpleName(), - csts != null ? csts.getName() : "null", nNode); + csts != null ? csts.getName() : "null", nNode); } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/NetconfNodeService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/NetconfNodeService.java index 9c10ac084..cc73fc791 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/NetconfNodeService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/NetconfNodeService.java @@ -16,23 +16,23 @@ * ============LICENSE_END========================================================================== */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl; + import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; public interface NetconfNodeService { public enum Action { - CREATE, - REMOVE, - UPDATE + CREATE, REMOVE, UPDATE } /** * MountpointChangeHandler, called to indicate change to DeviceManager + * * @param action provided * @param csts provided * @param nodeId provided * @param nnode provided */ - void netconfNodeChangeHandler(Action action, NodeId nodeId, NetconfNode nnode); + void netconfNodeChangeHandler(Action action, NodeId nodeId, NetconfNode nnode); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java index 0086bc752..82519e48b 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java @@ -21,19 +21,22 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificatio public interface ProviderClient extends AutoCloseable { - /** - * Send out problem notification, that was created by a device/ or NE - * @param mountPointName related - * @param notification xml description - */ + /** + * Send out problem notification, that was created by a device/ or NE + * + * @param mountPointName related + * @param notification xml description + */ public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification); - /** - * Send out problem notification - * @param mountPointName related - * @param notification xml description - * @param neDeviceAlarm true indicates an NE originated alarm, false an sdncontroller generated alarm - */ - public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification, boolean neDeviceAlarm); + /** + * Send out problem notification + * + * @param mountPointName related + * @param notification xml description + * @param neDeviceAlarm true indicates an NE originated alarm, false an sdncontroller generated alarm + */ + public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification, + boolean neDeviceAlarm); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/PushNotifications.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/PushNotifications.java index 545d97440..f424878f8 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/PushNotifications.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/PushNotifications.java @@ -23,8 +23,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicema public interface PushNotifications { - void pushAttributeChangeNotification(PushAttributeChangeNotificationInput input); + void pushAttributeChangeNotification(PushAttributeChangeNotificationInput input); - void pushFaultNotification(PushFaultNotificationInput input); + void pushFaultNotification(PushFaultNotificationInput input); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java index a99f5cda7..3a5224bbd 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java @@ -23,8 +23,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStamp import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; /** - * Converts time stamps into internal format according to ONF1.2 and ISO 8601. - * To be replaced by NetconfTimeStampImpl + * Converts time stamps into internal format according to ONF1.2 and ISO 8601. To be replaced by NetconfTimeStampImpl */ @Deprecated public class InternalDateAndTime { @@ -42,16 +41,18 @@ public class InternalDateAndTime { /** * Static builder ONF1.0 + * * @param time in ONF1.0 yang format - * @return InternalDateAndTime + * @return InternalDateAndTime */ - public static InternalDateAndTime valueOf(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) { + public static InternalDateAndTime valueOf( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) { return new InternalDateAndTime(time); } /** - * @return Getter with String representation + * @return Getter with String representation */ public String getValue() { return internalDateAndTime; @@ -59,6 +60,7 @@ public class InternalDateAndTime { /** * Get a testpattern + * * @return testpattern */ public static InternalDateAndTime getTestpattern() { @@ -78,9 +80,11 @@ public class InternalDateAndTime { /** * Convert ONF 1.2 DateAndTime to String + * * @param time as input */ - private InternalDateAndTime(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) { + private InternalDateAndTime( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) { if (time != null) { internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue()); } else { @@ -90,6 +94,7 @@ public class InternalDateAndTime { /** * Setup static TEST + * * @param internalDateAndTime */ private InternalDateAndTime(String internalDateAndTime) { diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalSeverity.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalSeverity.java index 72ffd969b..bbc980531 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalSeverity.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalSeverity.java @@ -27,11 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro public enum InternalSeverity { - NonAlarmed, - Warning, - Minor, - Major, - Critical; + NonAlarmed, Warning, Minor, Major, Critical; public boolean isNoAlarmIndication() { return this == NonAlarmed; @@ -48,117 +44,118 @@ public enum InternalSeverity { public String toNetconfString() { switch (this) { - case NonAlarmed: - return "non-alarmed"; - case Warning: - return "warning"; - case Minor: - return "minor"; - case Major: - return "major"; - case Critical: - return "critical"; + case NonAlarmed: + return "non-alarmed"; + case Warning: + return "warning"; + case Minor: + return "minor"; + case Major: + return "major"; + case Critical: + return "critical"; } return "not-specified"; } public SeverityType toDataProviderSeverityType() { switch (this) { - case NonAlarmed: - return SeverityType.NonAlarmed; - case Warning: - return SeverityType.Warning; - case Minor: - return SeverityType.Minor; - case Major: - return SeverityType.Major; - case Critical: - return SeverityType.Critical; + case NonAlarmed: + return SeverityType.NonAlarmed; + case Warning: + return SeverityType.Warning; + case Minor: + return SeverityType.Minor; + case Major: + return SeverityType.Major; + case Critical: + return SeverityType.Critical; } return null; //Should never happen } -// /** -// * convert ONF 1.2 Severity -// * @param severity as input -// * @return String with related output -// */ -// public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType severity ) { -// switch( severity ) { -// case NonAlarmed: -// return InternalSeverity.NonAlarmed; -// case Warning: -// return InternalSeverity.Warning; -// case Minor: -// return InternalSeverity.Minor; -// case Major: -// return InternalSeverity.Major; -// case Critical: -// return InternalSeverity.Critical; -// } -// return null; -// } -// -// /** -// * convert ONF 1.2.1.1 Severity -// * @param severity as input -// * @return String with related output -// */ -// public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.SeverityType severity ) { -// switch( severity ) { -// case NonAlarmed: -// return InternalSeverity.NonAlarmed; -// case Warning: -// return InternalSeverity.Warning; -// case Minor: -// return InternalSeverity.Minor; -// case Major: -// return InternalSeverity.Major; -// case Critical: -// return InternalSeverity.Critical; -// } -// return null; -// } -// -// /** -// * convert ONF 1.2.1.1p Severity -// * @param severity as input -// * @return String with related output -// */ -// public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType severity ) { -// switch( severity ) { -// case NonAlarmed: -// return InternalSeverity.NonAlarmed; -// case Warning: -// return InternalSeverity.Warning; -// case Minor: -// return InternalSeverity.Minor; -// case Major: -// return InternalSeverity.Major; -// case Critical: -// return InternalSeverity.Critical; -// } -// return null; -// } + // /** + // * convert ONF 1.2 Severity + // * @param severity as input + // * @return String with related output + // */ + // public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType severity ) { + // switch( severity ) { + // case NonAlarmed: + // return InternalSeverity.NonAlarmed; + // case Warning: + // return InternalSeverity.Warning; + // case Minor: + // return InternalSeverity.Minor; + // case Major: + // return InternalSeverity.Major; + // case Critical: + // return InternalSeverity.Critical; + // } + // return null; + // } + // + // /** + // * convert ONF 1.2.1.1 Severity + // * @param severity as input + // * @return String with related output + // */ + // public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.SeverityType severity ) { + // switch( severity ) { + // case NonAlarmed: + // return InternalSeverity.NonAlarmed; + // case Warning: + // return InternalSeverity.Warning; + // case Minor: + // return InternalSeverity.Minor; + // case Major: + // return InternalSeverity.Major; + // case Critical: + // return InternalSeverity.Critical; + // } + // return null; + // } + // + // /** + // * convert ONF 1.2.1.1p Severity + // * @param severity as input + // * @return String with related output + // */ + // public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType severity ) { + // switch( severity ) { + // case NonAlarmed: + // return InternalSeverity.NonAlarmed; + // case Warning: + // return InternalSeverity.Warning; + // case Minor: + // return InternalSeverity.Minor; + // case Major: + // return InternalSeverity.Major; + // case Critical: + // return InternalSeverity.Critical; + // } + // return null; + // } /** * convert a text string into Severity - * @param severityString with textes: warning minor major critical non[-]alarmed. (Capital or lowercase) + * + * @param severityString with textes: warning minor major critical non[-]alarmed. (Capital or lowercase) * @return related enum. Unknown oe illegal are converted to NonAlarm */ public static @Nullable InternalSeverity valueOfString(String severityString) { - switch( severityString.toLowerCase().trim() ) { - case "warning": - return InternalSeverity.Warning; - case "minor": - return InternalSeverity.Minor; - case "major": - return InternalSeverity.Major; - case "critical": - return InternalSeverity.Critical; + switch (severityString.toLowerCase().trim()) { + case "warning": + return InternalSeverity.Warning; + case "minor": + return InternalSeverity.Minor; + case "major": + return InternalSeverity.Major; + case "critical": + return InternalSeverity.Critical; } return InternalSeverity.NonAlarmed; @@ -166,22 +163,23 @@ public enum InternalSeverity { /** * Convert to InternalSeverity + * * @param severity to be converted * @return InternalSeverity, null converted to NonAlarmed */ public static InternalSeverity valueOf(@org.eclipse.jdt.annotation.Nullable SeverityType severity) { if (severity != null) { switch (severity) { - case NonAlarmed: - return InternalSeverity.NonAlarmed; - case Warning: - return InternalSeverity.Warning; - case Minor: - return InternalSeverity.Minor; - case Major: - return InternalSeverity.Major; - case Critical: - return InternalSeverity.Critical; + case NonAlarmed: + return InternalSeverity.NonAlarmed; + case Warning: + return InternalSeverity.Warning; + case Minor: + return InternalSeverity.Minor; + case Major: + return InternalSeverity.Major; + case Critical: + return InternalSeverity.Critical; } } return InternalSeverity.NonAlarmed; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java index e5356203c..61ab2df6e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java @@ -42,11 +42,13 @@ public class NetworkElementConnectionEntitiyUtil { private static final Logger LOG = LoggerFactory.getLogger(NetworkElementConnectionEntitiyUtil.class); - private static final QName QNAME_COREMODEL = QName.create("urn:onf:params:xml:ns:yang:core-model", "2017-03-20", "core-model").intern(); + private static final QName QNAME_COREMODEL = + QName.create("urn:onf:params:xml:ns:yang:core-model", "2017-03-20", "core-model").intern(); /** * Update devicetype and let all other field empty + * * @param deviceType that should be updated * @return NetworkElementConnectionEntity with related parameter */ @@ -58,6 +60,7 @@ public class NetworkElementConnectionEntitiyUtil { /** * Provide device specific data + * * @param nodeId mountpoint id * @param nNode data * @return NetworkElementConnectionEntity specific information @@ -78,9 +81,9 @@ public class NetworkElementConnectionEntitiyUtil { eb.setCoreModelCapability(availableCapabilities.getRevisionForNamespace(QNAME_COREMODEL)); - NodeDetailsBuilder nodeDetails = new NodeDetailsBuilder() - .setAvailableCapabilities(availableCapabilities.getCapabilities()) - .setUnavailableCapabilities(unAvailableCapabilities.getCapabilities()); + NodeDetailsBuilder nodeDetails = + new NodeDetailsBuilder().setAvailableCapabilities(availableCapabilities.getCapabilities()) + .setUnavailableCapabilities(unAvailableCapabilities.getCapabilities()); eb.setNodeDetails(nodeDetails.build()); // -- host information Host host = nNode.getHost(); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/AttributeValueChangedNotificationXml.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/AttributeValueChangedNotificationXml.java index 59512665f..f316686d6 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/AttributeValueChangedNotificationXml.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/AttributeValueChangedNotificationXml.java @@ -28,7 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro @XmlRootElement(name = "AttributeValueChangedNotification") public class AttributeValueChangedNotificationXml extends MwtNotificationBase implements GetEventType { - private static String EVENTTYPE = "AttributeValueChangedNotification"; + private static String EVENTTYPE = "AttributeValueChangedNotification"; @XmlElement(name = "attributeName") private String attributeName; @@ -42,6 +42,7 @@ public class AttributeValueChangedNotificationXml extends MwtNotificationBase im /** * Normalized notification + * * @param nodeName name of mountpoint * @param counter of notification * @param timeStamp from ne @@ -49,8 +50,8 @@ public class AttributeValueChangedNotificationXml extends MwtNotificationBase im * @param attributeName from ne * @param newValue from ne */ - public AttributeValueChangedNotificationXml(String nodeName, Integer counter, InternalDateAndTime timeStamp, String objectIdRef, - String attributeName, String newValue) { + public AttributeValueChangedNotificationXml(String nodeName, Integer counter, InternalDateAndTime timeStamp, + String objectIdRef, String attributeName, String newValue) { super(nodeName, counter, timeStamp, objectIdRef); this.attributeName = attributeName; this.newValue = newValue; @@ -78,9 +79,9 @@ public class AttributeValueChangedNotificationXml extends MwtNotificationBase im public EventlogEntity getEventlogEntity() { return new EventlogBuilder().setAttributeName(attributeName).setNewValue(newValue) - .setCounter(Integer.valueOf(this.getCounter())) - .setNodeId(this.getNodeName()).setObjectId(this.getObjectId()) - .setTimestamp(new DateAndTime(this.getTimeStamp())).setSourceType(SourceType.Netconf).build(); + .setCounter(Integer.valueOf(this.getCounter())).setNodeId(this.getNodeName()) + .setObjectId(this.getObjectId()).setTimestamp(new DateAndTime(this.getTimeStamp())) + .setSourceType(SourceType.Netconf).build(); } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java index 25ac8ae62..d6ce6253e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java @@ -28,18 +28,18 @@ public class FaultEntityManager { private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]"); /** - * The leading indication for notification or events that are not in the - * currentProblem data of the ONF Coremodel + * The leading indication for notification or events that are not in the currentProblem data of the ONF Coremodel */ private static final String NOCURRENTPROBLEMINDICATION = "#"; /** * Specific problems are not moving into current problem list + * * @param problemName to be verified * @return true if problem is current */ public static boolean isManagedAsCurrentProblem(String problemName) { - return ! problemName.startsWith(NOCURRENTPROBLEMINDICATION); + return !problemName.startsWith(NOCURRENTPROBLEMINDICATION); } public static boolean isManagedAsCurrentProblem(Fault problem) { @@ -48,6 +48,7 @@ public class FaultEntityManager { /** * Specific problems are not moving into current problem list + * * @param fault to be verified * @return true if cleared indication */ @@ -58,9 +59,10 @@ public class FaultEntityManager { /** * Create a specific ES id for the current log. + * * @return a string with the generated ES Id */ - public static String genSpecificEsId(String nodeName, String objectId, String problemName) { + public static String genSpecificEsId(String nodeName, String objectId, String problemName) { String uuId; @@ -82,6 +84,7 @@ public class FaultEntityManager { /** * Create Es id + * * @param fault used to create uuid for faultcurrent * @return String with Id */ diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java index 9982196ab..e3923c9cc 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java @@ -38,7 +38,7 @@ public class MwtNotificationBase { public MwtNotificationBase() { // For Jaxb - this.objectId = EMPTY; + this.objectId = EMPTY; } public MwtNotificationBase(String nodeName, Integer counter, InternalDateAndTime timeStamp, String objectId) { @@ -73,19 +73,18 @@ public class MwtNotificationBase { /** * Provide ConnectionlogEntity type + * * @return ConnectionlogEntity */ public ConnectionlogEntity getConnectionlogEntity() { - return new ConnectionlogBuilder() - .setNodeId(objectId) - .setStatus(getStatus()) - .setTimestamp(new DateAndTime(timeStamp)) - .build(); + return new ConnectionlogBuilder().setNodeId(objectId).setStatus(getStatus()) + .setTimestamp(new DateAndTime(timeStamp)).build(); } /** - * Provide connection status for mountpoint log. - * TODO Add status disconnected if mountpoint is required, but does not exists. + * Provide connection status for mountpoint log. TODO Add status disconnected if mountpoint is required, but does + * not exists. + * * @return */ private ConnectionLogStatus getStatus() { @@ -97,7 +96,7 @@ public class MwtNotificationBase { return ConnectionLogStatus.Unmounted; } else if (this instanceof AttributeValueChangedNotificationXml) { - String pnx = ((AttributeValueChangedNotificationXml)this).getNewValue(); + String pnx = ((AttributeValueChangedNotificationXml) this).getNewValue(); if (pnx.equals(ConnectionStatus.Connected.getName())) { return ConnectionLogStatus.Connected; @@ -113,6 +112,7 @@ public class MwtNotificationBase { /** * Type for the Database to document the the same name that is used in the websockets. + * * @return String with type name of child class */ @JsonProperty("type") @@ -122,8 +122,8 @@ public class MwtNotificationBase { @Override public String toString() { - return "MwtNotificationBase [getType()="+ getType() + ", nodeName=" + nodeName + ", counter=" + counter + ", timeStamp=" + timeStamp - + ", objectId=" + objectId + "]"; + return "MwtNotificationBase [getType()=" + getType() + ", nodeName=" + nodeName + ", counter=" + counter + + ", timeStamp=" + timeStamp + ", objectId=" + objectId + "]"; } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectCreationNotificationXml.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectCreationNotificationXml.java index 1787b451b..e901e3b7c 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectCreationNotificationXml.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectCreationNotificationXml.java @@ -27,7 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro @XmlRootElement(name = "ObjectCreationNotification") public class ObjectCreationNotificationXml extends MwtNotificationBase implements GetEventType { - private static String EVENTTYPE = "ObjectCreationNotification"; + private static String EVENTTYPE = "ObjectCreationNotification"; private static String ACTION = "creation"; public ObjectCreationNotificationXml() { @@ -36,13 +36,15 @@ public class ObjectCreationNotificationXml extends MwtNotificationBase implement /** * Normalized notification + * * @param nodeName name of mountpoint or instance that owns the problem * @param counter of notification * @param timeStamp from ne * @param objectIdRef from ne */ - public ObjectCreationNotificationXml(String nodeName, Integer counter, InternalDateAndTime timeStamp, String objectIdRef) { - super(nodeName, counter, timeStamp, objectIdRef); + public ObjectCreationNotificationXml(String nodeName, Integer counter, InternalDateAndTime timeStamp, + String objectIdRef) { + super(nodeName, counter, timeStamp, objectIdRef); } public ObjectCreationNotificationXml(EventlogEntity el) { @@ -56,9 +58,9 @@ public class ObjectCreationNotificationXml extends MwtNotificationBase implement public EventlogEntity getEventlogEntity() { return new EventlogBuilder().setAttributeName(ACTION).setNewValue(ACTION) - .setCounter(Integer.valueOf(this.getCounter())) - .setNodeId(this.getNodeName()).setObjectId(this.getObjectId()) - .setTimestamp(new DateAndTime(this.getTimeStamp())).setSourceType(SourceType.Netconf).build(); + .setCounter(Integer.valueOf(this.getCounter())).setNodeId(this.getNodeName()) + .setObjectId(this.getObjectId()).setTimestamp(new DateAndTime(this.getTimeStamp())) + .setSourceType(SourceType.Netconf).build(); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectDeletionNotificationXml.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectDeletionNotificationXml.java index 934a65caa..41150164e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectDeletionNotificationXml.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectDeletionNotificationXml.java @@ -27,7 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro @XmlRootElement(name = "ObjectDeletionNotification") public class ObjectDeletionNotificationXml extends MwtNotificationBase implements GetEventType { - private static String EVENTTYPE = "ObjectDeletionNotification"; + private static String EVENTTYPE = "ObjectDeletionNotification"; private static String ACTION = "deletion"; public ObjectDeletionNotificationXml() { @@ -36,13 +36,15 @@ public class ObjectDeletionNotificationXml extends MwtNotificationBase implement /** * Normalized notification + * * @param nodeName name of mountpoint or instance that owns the problem * @param counter of notification * @param timeStamp from ne * @param objectIdRef from ne */ - public ObjectDeletionNotificationXml(String nodeName, Integer counter, InternalDateAndTime timeStamp, String objectIdRef) { - super(nodeName, counter, timeStamp, objectIdRef); + public ObjectDeletionNotificationXml(String nodeName, Integer counter, InternalDateAndTime timeStamp, + String objectIdRef) { + super(nodeName, counter, timeStamp, objectIdRef); } public ObjectDeletionNotificationXml(EventlogEntity el) { @@ -56,9 +58,9 @@ public class ObjectDeletionNotificationXml extends MwtNotificationBase implement public EventlogEntity getEventlogEntity() { return new EventlogBuilder().setAttributeName(ACTION).setNewValue(ACTION) - .setCounter(Integer.valueOf(this.getCounter())) - .setNodeId(this.getNodeName()).setObjectId(this.getObjectId()) - .setTimestamp(new DateAndTime(this.getTimeStamp())).setSourceType(SourceType.Netconf).build(); + .setCounter(Integer.valueOf(this.getCounter())).setNodeId(this.getNodeName()) + .setObjectId(this.getObjectId()).setTimestamp(new DateAndTime(this.getTimeStamp())) + .setSourceType(SourceType.Netconf).build(); } } 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 98a0f9d52..5eeb70b2a 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 @@ -49,14 +49,13 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv } /** - * Generic Problem. All the parameters are of type Strings according to YANG - * specification. + * Generic Problem. All the parameters are of type Strings according to YANG specification. * - * @param nodeName Name of mountpoint - * @param uuId Name of Interface Pac - * @param problemNameString Name of the problem - * @param problemSeverityString Severitycode of the problem - * @param counter Counter from device + * @param nodeName Name of mountpoint + * @param uuId Name of Interface Pac + * @param problemNameString Name of the problem + * @param problemSeverityString Severitycode of the problem + * @param counter Counter from device * @param internaltimeStampString Timestamp according to internal format. */ public ProblemNotificationXml(String nodeName, String uuId, String problemNameString, @@ -80,7 +79,7 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv } public boolean isNotManagedAsCurrentProblem() { - return ! FaultEntityManager.isManagedAsCurrentProblem(getProblem()); + return !FaultEntityManager.isManagedAsCurrentProblem(getProblem()); } public boolean isNoAlarmIndication() { @@ -100,6 +99,7 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv /** * Create a specific ES id for the current log. + * * @return a string with the generated ES Id */ @JsonIgnore @@ -137,6 +137,7 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv /** * LOG the newly added problems of the interface pac + * * @param log of logger * @param uuid as log info * @param resultList with all problems diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java index 747c80069..d927b8995 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java @@ -29,16 +29,16 @@ public class WebSocketServiceClientDummyImpl implements WebSocketServiceClientIn private static final Logger LOG = LoggerFactory.getLogger(ODLEventListenerHandler.class); - public WebSocketServiceClientDummyImpl() { - } + public WebSocketServiceClientDummyImpl() {} @Override - public <T extends MwtNotificationBase & GetEventType> void sendViaWebsockets(@NonNull String nodeName, @NonNull T notificationXml) { - LOG.info("Dummy to send websocket event {} for mountpoint {}", notificationXml.getClass().getSimpleName(), nodeName); + public <T extends MwtNotificationBase & GetEventType> void sendViaWebsockets(@NonNull String nodeName, + @NonNull T notificationXml) { + LOG.info("Dummy to send websocket event {} for mountpoint {}", notificationXml.getClass().getSimpleName(), + nodeName); } @Override - public void close() throws Exception { - } + public void close() throws Exception {} } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java index eec63e9f9..878e22613 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java @@ -30,8 +30,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Wrapper for forwarding web-socket notifications to the web-socket service, that is running as - * bundle. + * Wrapper for forwarding web-socket notifications to the web-socket service, that is running as bundle. */ @SuppressWarnings("deprecation") public class WebSocketServiceClientImpl2 implements WebSocketServiceClientInternal { @@ -43,6 +42,7 @@ public class WebSocketServiceClientImpl2 implements WebSocketServiceClientIntern /** * Implementation of Websocket notification processor. + * * @param rpcProviderRegistry to get MDSAL services. */ @Deprecated @@ -54,6 +54,7 @@ public class WebSocketServiceClientImpl2 implements WebSocketServiceClientIntern /** * New: Implementation of Websocket notification processor. + * * @param websocketmanagerService2 to be used */ public WebSocketServiceClientImpl2(WebsocketmanagerService websocketmanagerService2) { @@ -63,7 +64,8 @@ public class WebSocketServiceClientImpl2 implements WebSocketServiceClientIntern } @Override - public <T extends MwtNotificationBase & GetEventType> void sendViaWebsockets(@NonNull String nodeName, @NonNull T notificationXml) { + public <T extends MwtNotificationBase & GetEventType> void sendViaWebsockets(@NonNull String nodeName, + @NonNull T notificationXml) { LOG.info("Send websocket event {} for mountpoint {}", notificationXml.getClass().getSimpleName(), nodeName); try { @@ -80,7 +82,6 @@ public class WebSocketServiceClientImpl2 implements WebSocketServiceClientIntern } @Override - public void close() throws Exception { - } + public void close() throws Exception {} } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientInternal.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientInternal.java index a1b805422..1af2d893a 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientInternal.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientInternal.java @@ -24,10 +24,12 @@ import org.eclipse.jdt.annotation.NonNull; /** * Wrapper for forwarding websocket notifications to the websocket service, that is running as container. + * * @author herbert */ public interface WebSocketServiceClientInternal extends AutoCloseable { - public <T extends MwtNotificationBase & GetEventType> void sendViaWebsockets(@NonNull String nodeName, @NonNull T notificationXml); + public <T extends MwtNotificationBase & GetEventType> void sendViaWebsockets(@NonNull String nodeName, + @NonNull T notificationXml); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java index bce8f52de..db218552b 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java @@ -33,114 +33,117 @@ import org.slf4j.LoggerFactory; public class MaintenanceCalculator { - private static final Logger LOG = LoggerFactory.getLogger(MaintenanceCalculator.class); - - private static ZoneId EsMaintenanceFilterTimeZone = ZoneId.of("UTC"); - //private static DateTimeFormatter FORMAT = DateTimeFormatter.ISO_DATE_TIME; // "1986-04-08T12:30:00" - private static DateTimeFormatter FORMAT = DateTimeFormatter.ISO_OFFSET_DATE_TIME; // 2011-12-03T10:15:30+01:00 - private static ZonedDateTime EMPTYDATETIME = ZonedDateTime.ofInstant(Instant.EPOCH, EsMaintenanceFilterTimeZone); - - /** Intended to be used static **/ - private MaintenanceCalculator() { - } - - /** - * Verify maintenance status - * @param maintenance if null false, else according to settings - * @param objectIdRef NETCONF object id - * @param problem name that was provided - * @param now time to verify with - * @return true if in maintenance status - */ - public static boolean isONFObjectInMaintenance(MaintenanceEntity maintenance, String objectIdRef, String problem, - ZonedDateTime now) { - - if (maintenance != null) { - Boolean isActive = maintenance.isActive(); - if (isActive != null && isActive && isInMaintenance(maintenance, objectIdRef, problem, now)) { - return true; - } - - } - return false; - } - - /** Shortcut **/ - public static boolean isONFObjectInMaintenance(MaintenanceEntity maintenance, String objectIdRef, String problem) { - return isONFObjectInMaintenance(maintenance, objectIdRef, problem, getNow()); - } - - /*--------------------------------------------- - * private static helper functions to verify - */ - - /** - * Get the actual time in the Filter time zone. - * @return actual Time - */ - private static ZonedDateTime getNow() { - return ZonedDateTime.now(EsMaintenanceFilterTimeZone); - } - - /** - * Verify if the filter is active for an object - * - * @param now point of time to verify - * @return if the object is covered by filter and now within point of time - */ - private static boolean isInMaintenance(MaintenanceEntity maintenance, String objectIdRef, String problem, - ZonedDateTime now) { - return appliesToObjectReference(maintenance, objectIdRef, problem) - && isInPeriod(maintenance.getStart(), maintenance.getEnd(), now); - } - - /** - * Compare the if probe is within the range of start and end. - * - * @param start of range - * @param end of range - * @param probe time to verify - * @return boolean result true if (start <= probe <= end) - */ - public static boolean isInPeriod(DateAndTime start, DateAndTime end, ZonedDateTime probe) { - HtAssert.nonnull(start,end,probe); - ZonedDateTime startZT = valueOf(start.getValue()); - ZonedDateTime endZT = valueOf(end.getValue()); - return startZT.compareTo(endZT) < 0 && startZT.compareTo(probe) <= 0 && endZT.compareTo(probe) >= 0; - } - - /** - * Verify if the definied object is matching to the referenced object - * @param definition definition with parameters - * @param pObjectIdRef object-id-ref of fault notification - * @param pProblem problem of fault notification - * @return true if if referenced - */ - private static boolean appliesToObjectReference(@Nonnull MaintenanceEntity definition, @Nonnull String pObjectIdRef, - @Nonnull String pProblem) { - HtAssert.nonnull(definition,pObjectIdRef,pProblem); - boolean res = (definition.getObjectIdRef()==null || pObjectIdRef.contains(definition.getObjectIdRef())) - && (definition.getProblem()==null || pProblem.contains(definition.getProblem())); - LOG.debug("Check result applies {}: {} {} against: {}", res, pObjectIdRef, pProblem, definition); - return res; - } - - /** - * Convert String to time value - * @param zoneTimeString with time - * @return ZonedDateTime string - */ - public static ZonedDateTime valueOf(String zoneTimeString) { - if (zoneTimeString == null || zoneTimeString.isEmpty()) { - LOG.warn("Null or empty zoneTimeString"); - return EMPTYDATETIME; - } - try { - return ZonedDateTime.parse(zoneTimeString, FORMAT); - } catch (DateTimeParseException e) { - LOG.warn("Can not parse zoneTimeString '{}'", zoneTimeString); - return EMPTYDATETIME; - } - } + private static final Logger LOG = LoggerFactory.getLogger(MaintenanceCalculator.class); + + private static ZoneId EsMaintenanceFilterTimeZone = ZoneId.of("UTC"); + //private static DateTimeFormatter FORMAT = DateTimeFormatter.ISO_DATE_TIME; // "1986-04-08T12:30:00" + private static DateTimeFormatter FORMAT = DateTimeFormatter.ISO_OFFSET_DATE_TIME; // 2011-12-03T10:15:30+01:00 + private static ZonedDateTime EMPTYDATETIME = ZonedDateTime.ofInstant(Instant.EPOCH, EsMaintenanceFilterTimeZone); + + /** Intended to be used static **/ + private MaintenanceCalculator() {} + + /** + * Verify maintenance status + * + * @param maintenance if null false, else according to settings + * @param objectIdRef NETCONF object id + * @param problem name that was provided + * @param now time to verify with + * @return true if in maintenance status + */ + public static boolean isONFObjectInMaintenance(MaintenanceEntity maintenance, String objectIdRef, String problem, + ZonedDateTime now) { + + if (maintenance != null) { + Boolean isActive = maintenance.isActive(); + if (isActive != null && isActive && isInMaintenance(maintenance, objectIdRef, problem, now)) { + return true; + } + + } + return false; + } + + /** Shortcut **/ + public static boolean isONFObjectInMaintenance(MaintenanceEntity maintenance, String objectIdRef, String problem) { + return isONFObjectInMaintenance(maintenance, objectIdRef, problem, getNow()); + } + + /*--------------------------------------------- + * private static helper functions to verify + */ + + /** + * Get the actual time in the Filter time zone. + * + * @return actual Time + */ + private static ZonedDateTime getNow() { + return ZonedDateTime.now(EsMaintenanceFilterTimeZone); + } + + /** + * Verify if the filter is active for an object + * + * @param now point of time to verify + * @return if the object is covered by filter and now within point of time + */ + private static boolean isInMaintenance(MaintenanceEntity maintenance, String objectIdRef, String problem, + ZonedDateTime now) { + return appliesToObjectReference(maintenance, objectIdRef, problem) + && isInPeriod(maintenance.getStart(), maintenance.getEnd(), now); + } + + /** + * Compare the if probe is within the range of start and end. + * + * @param start of range + * @param end of range + * @param probe time to verify + * @return boolean result true if (start <= probe <= end) + */ + public static boolean isInPeriod(DateAndTime start, DateAndTime end, ZonedDateTime probe) { + HtAssert.nonnull(start, end, probe); + ZonedDateTime startZT = valueOf(start.getValue()); + ZonedDateTime endZT = valueOf(end.getValue()); + return startZT.compareTo(endZT) < 0 && startZT.compareTo(probe) <= 0 && endZT.compareTo(probe) >= 0; + } + + /** + * Verify if the definied object is matching to the referenced object + * + * @param definition definition with parameters + * @param pObjectIdRef object-id-ref of fault notification + * @param pProblem problem of fault notification + * @return true if if referenced + */ + private static boolean appliesToObjectReference(@Nonnull MaintenanceEntity definition, @Nonnull String pObjectIdRef, + @Nonnull String pProblem) { + HtAssert.nonnull(definition, pObjectIdRef, pProblem); + boolean res = (definition.getObjectIdRef() == null || pObjectIdRef.contains(definition.getObjectIdRef())) + && (definition.getProblem() == null || pProblem.contains(definition.getProblem())); + LOG.debug("Check result applies {}: {} {} against: {}", res, pObjectIdRef, pProblem, definition); + return res; + } + + /** + * Convert String to time value + * + * @param zoneTimeString with time + * @return ZonedDateTime string + */ + public static ZonedDateTime valueOf(String zoneTimeString) { + if (zoneTimeString == null || zoneTimeString.isEmpty()) { + LOG.warn("Null or empty zoneTimeString"); + return EMPTYDATETIME; + } + try { + return ZonedDateTime.parse(zoneTimeString, FORMAT); + } catch (DateTimeParseException e) { + LOG.warn("Can not parse zoneTimeString '{}'", zoneTimeString); + return EMPTYDATETIME; + } + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java index 03584b299..55d94c9f2 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java @@ -48,7 +48,8 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP LOG.info("Create {} start", MaintenanceServiceImpl.class); database = client; - LOG.info("Create {} finished. DB Service {} started.", MaintenanceServiceImpl.class, client != null ? "sucessfully" : "not" ); + LOG.info("Create {} finished. DB Service {} started.", MaintenanceServiceImpl.class, + client != null ? "sucessfully" : "not"); } @@ -67,8 +68,7 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP */ @Override - public void close() throws Exception { - } + public void close() throws Exception {} /*------------------------------------------------- * Interface MaintenanceRPCServiceAPI @@ -96,11 +96,12 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP RequiredNetworkElementBuilder valueBuilder = new RequiredNetworkElementBuilder(); valueBuilder.setMountpointName(maintenanceMode.getNodeId()); - valueBuilder.setStatus(String.valueOf(MaintenanceCalculator.isONFObjectInMaintenance(maintenanceMode, "",""))); + valueBuilder + .setStatus(String.valueOf(MaintenanceCalculator.isONFObjectInMaintenance(maintenanceMode, "", ""))); valueBuilder.setDescription("Pretty description here"); outputBuilder.setRequiredNetworkElement(valueBuilder.build()); } else { - LOG.warn("No info in database for {}",input.getMountpointName()); + LOG.warn("No info in database for {}", input.getMountpointName()); } return outputBuilder; } @@ -113,7 +114,7 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP if (maintenanceMode != null) { outputBuilder = new GetMaintenanceModeOutputBuilder(maintenanceMode); } else { - throw new IllegalArgumentException("No info in database for "+input.getMountpointName()); + throw new IllegalArgumentException("No info in database for " + input.getMountpointName()); } return outputBuilder; } @@ -145,9 +146,9 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP input.getProblemName(), now)); resultString.append(" at Timestamp: "); resultString.append(now); - TestMaintenanceModeOutputBuilder outputBuilder = maintenanceMode != null - ? new TestMaintenanceModeOutputBuilder(maintenanceMode) - : new TestMaintenanceModeOutputBuilder(); + TestMaintenanceModeOutputBuilder outputBuilder = + maintenanceMode != null ? new TestMaintenanceModeOutputBuilder(maintenanceMode) + : new TestMaintenanceModeOutputBuilder(); outputBuilder.setResultString(resultString.toString()); return outputBuilder; @@ -161,7 +162,8 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP public boolean isONFObjectInMaintenance(String mountpointReference, String objectIdRef, String problem) { MaintenanceEntity maintenanceMode = database.getMaintenance(mountpointReference); boolean res = MaintenanceCalculator.isONFObjectInMaintenance(maintenanceMode, objectIdRef, problem); - LOG.debug("inMaintenance={} for mountpoint/id/problem:{} {} {} Definition: {}",res, mountpointReference, objectIdRef, problem, this ); + LOG.debug("inMaintenance={} for mountpoint/id/problem:{} {} {} Definition: {}", res, mountpointReference, + objectIdRef, problem, this); return res; } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java index e36dd34b4..22098675b 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java @@ -33,8 +33,7 @@ public class PerformanceManagerImpl implements PerformanceManager, AutoCloseable private PerformanceManagerTask task; public PerformanceManagerImpl(long seconds, NetconfNetworkElementService netconfNetworkElementService, - DataProvider microwaveHistoricalPerformanceWriterService, - ConfigurationFileRepresentation config) { + DataProvider microwaveHistoricalPerformanceWriterService, ConfigurationFileRepresentation config) { LOG.info("Construct {}", PerformanceManagerImpl.class.getSimpleName()); @@ -48,7 +47,8 @@ public class PerformanceManagerImpl implements PerformanceManager, AutoCloseable } else { LOG.info("{} Seconds", seconds); LOG.info("Start of PM task"); - task = new PerformanceManagerTask(seconds, microwaveHistoricalPerformanceWriterService, netconfNetworkElementService); + task = new PerformanceManagerTask(seconds, microwaveHistoricalPerformanceWriterService, + netconfNetworkElementService); task.start(); LOG.info("PM task scheduled"); } @@ -66,7 +66,7 @@ public class PerformanceManagerImpl implements PerformanceManager, AutoCloseable @Override public void registration(String mountPointNodeName, NetworkElement ne) { - LOG.debug("Register {}",mountPointNodeName); + LOG.debug("Register {}", mountPointNodeName); if (task != null) { task.registration(mountPointNodeName, ne); } @@ -74,7 +74,7 @@ public class PerformanceManagerImpl implements PerformanceManager, AutoCloseable @Override public void deRegistration(String mountPointNodeName) { - LOG.debug("Deregister {}",mountPointNodeName); + LOG.debug("Deregister {}", mountPointNodeName); if (task != null) { task.deRegistration(mountPointNodeName); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerTask.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerTask.java index a85df63a3..8fe6b9565 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerTask.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerTask.java @@ -51,13 +51,13 @@ public class PerformanceManagerTask implements Runnable { /** * Constructor of PM Task + * * @param seconds seconds to call PM Task * @param microwaveHistoricalPerformanceWriterService DB Service to load PM data to * @param netconfNetworkElementService to write into log */ - public PerformanceManagerTask(long seconds, - DataProvider microwaveHistoricalPerformanceWriterService, + public PerformanceManagerTask(long seconds, DataProvider microwaveHistoricalPerformanceWriterService, NetconfNetworkElementService netconfNetworkElementService) { LOG.debug("Init task {}", PerformanceManagerTask.class.getSimpleName()); @@ -86,16 +86,17 @@ public class PerformanceManagerTask implements Runnable { taskHandle.cancel(true); try { scheduler.awaitTermination(10, TimeUnit.SECONDS); - } catch (InterruptedException e) { - LOG.debug("Schdule stopped.",e); - // Restore interrupted state... - Thread.currentThread().interrupt(); - } + } catch (InterruptedException e) { + LOG.debug("Schdule stopped.", e); + // Restore interrupted state... + Thread.currentThread().interrupt(); + } } } /** * Add NE/Mountpoint to PM Processig + * * @param mountPointNodeName to be added * @param ne that is connected to the mountpoint */ @@ -109,14 +110,15 @@ public class PerformanceManagerTask implements Runnable { /** * Remove mountpoint/NE from PM process + * * @param mountPointNodeName that has to be removed */ public void deRegistration(String mountPointNodeName) { - LOG.debug("Deregister {}",mountPointNodeName); + LOG.debug("Deregister {}", mountPointNodeName); PerformanceDataProvider removedNE = queue.remove(mountPointNodeName); - if ( removedNE == null) { - LOG.warn("Couldn't delete {}",mountPointNodeName); + if (removedNE == null) { + LOG.warn("Couldn't delete {}", mountPointNodeName); } } @@ -126,8 +128,8 @@ public class PerformanceManagerTask implements Runnable { */ /** - * Task runner to read all performance data from Network Elements. - * Catch exceptions to make sure, that the Task is not stopped. + * Task runner to read all performance data from Network Elements. Catch exceptions to make sure, that the Task is + * not stopped. */ @Override public void run() { @@ -136,7 +138,7 @@ public class PerformanceManagerTask implements Runnable { if (actualNE != null && actualNE.getAcessor().isPresent()) { mountpointName = actualNE.getAcessor().get().getNodeId().getValue(); } - LOG.debug("{} start {} Start with mountpoint {}",LOGMARKER, tickCounter, mountpointName); + LOG.debug("{} start {} Start with mountpoint {}", LOGMARKER, tickCounter, mountpointName); //Proceed to next NE/Interface getNextInterface(mountpointName); @@ -166,7 +168,7 @@ public class PerformanceManagerTask implements Runnable { } } - LOG.debug("{} end {}",LOGMARKER, tickCounter); + LOG.debug("{} end {}", LOGMARKER, tickCounter); tickCounter++; } @@ -179,10 +181,8 @@ public class PerformanceManagerTask implements Runnable { } /** - * Get then next interface in the list. - * First try to find a next on the actual NE. - * If not available search next interface at a NE - * Special Situations to handle: Empty queue, NEs, but no interfaces + * Get then next interface in the list. First try to find a next on the actual NE. If not available search next + * interface at a NE Special Situations to handle: Empty queue, NEs, but no interfaces */ private void getNextInterface(String mountpointName) { boolean started = false; @@ -191,7 +191,7 @@ public class PerformanceManagerTask implements Runnable { LOG.debug("{} {} getNextInterface enter. Queue size {} ", LOGMARKER, tickCounter, queue.size()); if (actualNE != null && !queue.containsValue(actualNE)) { - LOG.debug("{} {} NE Removed duringprocessing A",LOGMARKER, tickCounter); + LOG.debug("{} {} NE Removed duringprocessing A", LOGMARKER, tickCounter); resetQueue(); } @@ -203,17 +203,13 @@ public class PerformanceManagerTask implements Runnable { break; } - LOG.debug("{} {} Loop ne {}:neiterator {}:Interfaceiterator:{} Loop:{}", - LOGMARKER, - tickCounter, - actualNE == null? "null" : mountpointName, - neIterator == null ? "null" : neIterator.hasNext(), - actualNE == null ? "null" : actualNE.hasNext(), - loopCounter); + LOG.debug("{} {} Loop ne {}:neiterator {}:Interfaceiterator:{} Loop:{}", LOGMARKER, tickCounter, + actualNE == null ? "null" : mountpointName, neIterator == null ? "null" : neIterator.hasNext(), + actualNE == null ? "null" : actualNE.hasNext(), loopCounter); if (actualNE != null && actualNE.hasNext()) { // Yes, there is an interface, deliver back - LOG.debug("{} {} getNextInterface yes A",LOGMARKER, tickCounter); + LOG.debug("{} {} getNextInterface yes A", LOGMARKER, tickCounter); actualNE.next(); break; @@ -221,24 +217,24 @@ public class PerformanceManagerTask implements Runnable { // No element in neInterfaceInterator .. get next NE and try if (neIterator != null && neIterator.hasNext()) { // Set a new NE - LOG.debug("{} {} Next NE A",LOGMARKER, tickCounter); + LOG.debug("{} {} Next NE A", LOGMARKER, tickCounter); actualNE = neIterator.next(); actualNE.resetPMIterator(); } else { // Goto start condition 1) first entry 2) end of queue reached - LOG.debug("{} {} Reset",LOGMARKER, tickCounter); + LOG.debug("{} {} Reset", LOGMARKER, tickCounter); resetQueue(); if (queue.isEmpty()) { - LOG.debug("{} {} no nextInterfac. queue empty",LOGMARKER, tickCounter); + LOG.debug("{} {} no nextInterfac. queue empty", LOGMARKER, tickCounter); break; - } else if (!started){ - LOG.debug("{} {} getNextInterface start condition. Get interator.",LOGMARKER, tickCounter); + } else if (!started) { + LOG.debug("{} {} getNextInterface start condition. Get interator.", LOGMARKER, tickCounter); neIterator = queue.values().iterator(); started = true; } else { - LOG.debug("{} {} no nextInterface",LOGMARKER, tickCounter); + LOG.debug("{} {} no nextInterface", LOGMARKER, tickCounter); break; } } @@ -246,7 +242,7 @@ public class PerformanceManagerTask implements Runnable { } //while if (actualNE != null && !queue.containsValue(actualNE)) { - LOG.debug("{} {} NE Removed duringprocessing B",LOGMARKER, tickCounter); + LOG.debug("{} {} NE Removed duringprocessing B", LOGMARKER, tickCounter); resetQueue(); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/config/PmConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/config/PmConfig.java index 18d24fe16..bbe854339 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/config/PmConfig.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/config/PmConfig.java @@ -28,27 +28,27 @@ public class PmConfig implements Configuration { private static final String DEFAULT_VALUE_ENABLED = String.valueOf(true); - private final ConfigurationFileRepresentation configuration; + private final ConfigurationFileRepresentation configuration; - public PmConfig(ConfigurationFileRepresentation configuration) { - this.configuration = configuration; - this.configuration.addSection(SECTION_MARKER_PM); - defaults(); - } + public PmConfig(ConfigurationFileRepresentation configuration) { + this.configuration = configuration; + this.configuration.addSection(SECTION_MARKER_PM); + defaults(); + } public boolean isPerformanceManagerEnabled() { return configuration.getPropertyBoolean(SECTION_MARKER_PM, PROPERTY_KEY_ENABLED); } - @Override - public String getSectionName() { - return SECTION_MARKER_PM; - } + @Override + public String getSectionName() { + return SECTION_MARKER_PM; + } - @Override - public void defaults() { - //Add default if not available - configuration.setPropertyIfNotAvailable(SECTION_MARKER_PM, PROPERTY_KEY_ENABLED, DEFAULT_VALUE_ENABLED); - } + @Override + public void defaults() { + //Add default if not available + configuration.setPropertyIfNotAvailable(SECTION_MARKER_PM, PROPERTY_KEY_ENABLED, DEFAULT_VALUE_ENABLED); + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/DevicemanagerNotificationDelayService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/DevicemanagerNotificationDelayService.java index 3e464f47d..5157aad53 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/DevicemanagerNotificationDelayService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/DevicemanagerNotificationDelayService.java @@ -24,7 +24,8 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServic /** * Devicemanager service */ -public class DevicemanagerNotificationDelayService extends NotificationDelayService<ProblemNotificationXml> implements DeviceManagerService { +public class DevicemanagerNotificationDelayService extends NotificationDelayService<ProblemNotificationXml> + implements DeviceManagerService { public DevicemanagerNotificationDelayService(ConfigurationFileRepresentation htconfig) { super(htconfig); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java index be3b6158d..fd288c3c0 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java @@ -33,8 +33,8 @@ public class NotificationDelayFilter<T extends ToggleAlarmFilterable> implements private static long delay; private static boolean enabled; - private final ConcurrentHashMap <String, NotificationWithServerTimeStamp<T>> problemItems; -// private final HashMap<String, NotificationWithServerTimeStamp<T>> nonProblemItems; + private final ConcurrentHashMap<String, NotificationWithServerTimeStamp<T>> problemItems; + // private final HashMap<String, NotificationWithServerTimeStamp<T>> nonProblemItems; private final NotificationDelayedListener<T> timeoutListener; private final ScheduledExecutorService scheduler; @@ -44,7 +44,7 @@ public class NotificationDelayFilter<T extends ToggleAlarmFilterable> implements public NotificationDelayFilter(String nodeName, NotificationDelayedListener<T> timeoutListener) { this.nodeName = nodeName; this.timeoutListener = timeoutListener; - this.problemItems = new ConcurrentHashMap <>(); + this.problemItems = new ConcurrentHashMap<>(); this.scheduler = Executors.newScheduledThreadPool(1); this.startTimer(); } @@ -67,6 +67,7 @@ public class NotificationDelayFilter<T extends ToggleAlarmFilterable> implements /** * If process the notification + * * @return true if other processing is required, false if not */ public boolean processNotification(@NonNull T notificationXml) { @@ -86,6 +87,7 @@ public class NotificationDelayFilter<T extends ToggleAlarmFilterable> implements /** * Push notification with a specific severity (everything except non-alarmed) + * * @param notification related notification */ public void pushAlarmNotification(@NonNull T notification) { @@ -94,13 +96,12 @@ public class NotificationDelayFilter<T extends ToggleAlarmFilterable> implements boolean cp = this.problemItems.containsKey(problemName); if (!cp) { // no alarm in entries => create entry and push the alarm currently - NotificationWithServerTimeStamp<T> item = new NotificationWithServerTimeStamp<>( - notification); + NotificationWithServerTimeStamp<T> item = new NotificationWithServerTimeStamp<>(notification); LOG.debug("add event into list for node " + this.nodeName + " for alarm " + problemName + ": " + item.toString()); this.problemItems.put(problemName, item); if (this.timeoutListener != null) { - this.timeoutListener.onNotificationDelay(this.nodeName,notification); + this.timeoutListener.onNotificationDelay(this.nodeName, notification); } } else { LOG.debug("clear contra event for node " + this.nodeName + " for alarm " + problemName); @@ -112,6 +113,7 @@ public class NotificationDelayFilter<T extends ToggleAlarmFilterable> implements /** * Push notification with severity non-alarmed + * * @param notification related notification */ public void clearAlarmNotification(@NonNull T notification) { @@ -124,7 +126,7 @@ public class NotificationDelayFilter<T extends ToggleAlarmFilterable> implements } else { // not in list => push directly through if (this.timeoutListener != null) { - this.timeoutListener.onNotificationDelay(this.nodeName,notification); + this.timeoutListener.onNotificationDelay(this.nodeName, notification); } } } @@ -147,18 +149,18 @@ public class NotificationDelayFilter<T extends ToggleAlarmFilterable> implements synchronized (problemItems) { - for (Entry<String, NotificationWithServerTimeStamp<T>> entry : problemItems - .entrySet()) { + for (Entry<String, NotificationWithServerTimeStamp<T>> entry : problemItems.entrySet()) { NotificationWithServerTimeStamp<T> value = entry.getValue(); if (value.isStable(now)) { // send contra Alarm if exists if (value.getContraAlarmNotification() != null) { if (this.timeoutListener != null) { - this.timeoutListener.onNotificationDelay(this.nodeName,value.getContraAlarmNotification()); + this.timeoutListener.onNotificationDelay(this.nodeName, + value.getContraAlarmNotification()); } } problemItems.remove(entry.getKey()); - LOG.debug("removing entry for "+this.nodeName+" for alarm " + entry.getKey()); + LOG.debug("removing entry for " + this.nodeName + " for alarm " + entry.getKey()); } else { LOG.trace("currently state is still unstable for alarm " + entry.getKey()); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java index 1cbc8c23b..ce92da0cf 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java @@ -26,7 +26,8 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.conf.Togg import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NotificationDelayService<T extends ToggleAlarmFilterable> implements DeviceManagerService, AutoCloseable, IConfigChangedListener { +public class NotificationDelayService<T extends ToggleAlarmFilterable> + implements DeviceManagerService, AutoCloseable, IConfigChangedListener { private static final Logger LOG = LoggerFactory.getLogger(NotificationDelayService.class); private final HashMap<String, NotificationDelayFilter<T>> filters; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java index a64a3b92d..26402b28b 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java @@ -19,7 +19,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter; public interface NotificationDelayedListener<T> { - public void onNotificationDelay(String nodeName,T notification); + public void onNotificationDelay(String nodeName, T notification); } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationWithServerTimeStamp.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationWithServerTimeStamp.java index b3c8fb129..8e1bf9189 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationWithServerTimeStamp.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationWithServerTimeStamp.java @@ -31,13 +31,14 @@ public class NotificationWithServerTimeStamp<T2> { this.alarmNotification = n; this.contraAlarmNotification = null; this.timestamp = ts; - this.timestampStart=ts; + this.timestampStart = ts; } @SuppressWarnings("unused") public long getStartTime() { return this.timestampStart; } + public void refresh() { this.refresh(System.currentTimeMillis()); } @@ -71,8 +72,7 @@ public class NotificationWithServerTimeStamp<T2> { @Override public String toString() { - return "NotificationWithServerTimeStamp [alarmNotification=" + alarmNotification - + ", contraAlarmNotification=" + contraAlarmNotification + ", timestampStart=" + timestampStart - + ", timestamp=" + timestamp + "]"; + return "NotificationWithServerTimeStamp [alarmNotification=" + alarmNotification + ", contraAlarmNotification=" + + contraAlarmNotification + ", timestampStart=" + timestampStart + ", timestamp=" + timestamp + "]"; } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java index 9a865f0c2..0231201e1 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java @@ -24,8 +24,9 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter; public interface ToggleAlarmFilterable { - /** Provide id for toggle alarm filter that is unique for the mountpoint/nodeId**/ + /** Provide id for toggle alarm filter that is unique for the mountpoint/nodeId **/ String getUuidForMountpoint(); + /** Provide indication if cleared **/ boolean isCleared(); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/conf/ToggleAlarmConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/conf/ToggleAlarmConfig.java index 1bf59b68a..3450e8c3b 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/conf/ToggleAlarmConfig.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/conf/ToggleAlarmConfig.java @@ -28,32 +28,33 @@ public class ToggleAlarmConfig implements Configuration { private static final String PROPERTY_KEY_DELAY = "taDelay"; private static final boolean DEFAULT_VALUE_ENABLED = true; - private static final long DEFAULT_VALUE_DELAY = 3000; //in ms + private static final long DEFAULT_VALUE_DELAY = 3000; //in ms - private final ConfigurationFileRepresentation configuration; + private final ConfigurationFileRepresentation configuration; public ToggleAlarmConfig(ConfigurationFileRepresentation configuration) { - this.configuration = configuration; - this.configuration.addSection(SECTION_MARKER_TA); - defaults(); + this.configuration = configuration; + this.configuration.addSection(SECTION_MARKER_TA); + defaults(); } public boolean isEnabled() { return configuration.getPropertyBoolean(SECTION_MARKER_TA, PROPERTY_KEY_ENABLED); } + public long getDelay() { return configuration.getPropertyLong(SECTION_MARKER_TA, PROPERTY_KEY_DELAY).orElse(DEFAULT_VALUE_DELAY); } - @Override - public String getSectionName() { - return SECTION_MARKER_TA; - } - - @Override - public void defaults() { - //Add default if not available - configuration.setPropertyIfNotAvailable(SECTION_MARKER_TA, PROPERTY_KEY_ENABLED, DEFAULT_VALUE_ENABLED); - configuration.setPropertyIfNotAvailable(SECTION_MARKER_TA, PROPERTY_KEY_DELAY, DEFAULT_VALUE_DELAY); - } + @Override + public String getSectionName() { + return SECTION_MARKER_TA; + } + + @Override + public void defaults() { + //Add default if not available + configuration.setPropertyIfNotAvailable(SECTION_MARKER_TA, PROPERTY_KEY_ENABLED, DEFAULT_VALUE_ENABLED); + configuration.setPropertyIfNotAvailable(SECTION_MARKER_TA, PROPERTY_KEY_DELAY, DEFAULT_VALUE_DELAY); + } } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java index 5528e1c76..cc49ea9bf 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java @@ -50,228 +50,228 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationD public class TestAai { - private static final String CONFIGURATIONTESTFILE = "test.properties"; // for - private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties"; - private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME); - private static final int AAI_SERVER_PORT = 45454; - private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=off\n" - + "dcaeHeartbeatPeriodSeconds=120\n" + "dcaeTestCollector=no\n" + "\n" + "[aots]\n" - + "userPassword=passwd\n" + "soapurladd=off\n" + "soapaddtimeout=10\n" + "soapinqtimeout=20\n" - + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n" + "assignedto=userid\n" - + "addtemplate=addreq.tmpl.xml\n" + "severitypassthrough=critical,major,minor,warning\n" - + "systemuser=user\n" + "prt-offset=1200\n" + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n" - + "#smtpUsername=\n" + "#smtpPassword=\n" + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n" - + "esCluster=sendateodl5\n" + "\n" + "[aai]\n" + "#keep comment\n" - + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n" - + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n" - + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n" - + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" - + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n" - + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + ""; - - private static final String EXT_TEST_URL="https://testaai.onap.org:8443"; - private static final String EXT_TEST_KEY="test.key"; - private static final String EXT_TEST_PASSWD="test123"; - private static final String EXT_TEST_APPLICATIONID="SDNC"; - private static final long EXT_TEST_CONN_TIMEOUT=6000; - - - private static final CharSequence TESTCONFIG_CONTENT_EXT = "[aai]\n" + "#keep comment\n" - + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n" - + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n" - + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + - // "aaiApplicationId=SDNR\n" + - // "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" + - // "aaiPcks12ClientCertPassphrase=adminadmin\n" + - // "aaiClientConnectionTimeout=30000\n" + - "\n"; - private static final CharSequence TESTCONFIG_CONTENT_EXT2 = "org.onap.ccsdk.sli.adaptors.aai.ssl.key="+EXT_TEST_KEY+"\n" - + "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd="+EXT_TEST_PASSWD+"\n" - + "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=false\n" - + "org.onap.ccsdk.sli.adaptors.aai.application="+EXT_TEST_APPLICATIONID+"\n" - + "org.onap.ccsdk.sli.adaptors.aai.uri="+EXT_TEST_URL+"\n" - + "connection.timeout="+EXT_TEST_CONN_TIMEOUT+"\n"; - private static HttpServer server; - private static ExecutorService httpThreadPool; - private static ConfigurationFileRepresentation globalCfg; + private static final String CONFIGURATIONTESTFILE = "test.properties"; // for + private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties"; + private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME); + private static final int AAI_SERVER_PORT = 45454; + private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=off\n" + + "dcaeHeartbeatPeriodSeconds=120\n" + "dcaeTestCollector=no\n" + "\n" + "[aots]\n" + + "userPassword=passwd\n" + "soapurladd=off\n" + "soapaddtimeout=10\n" + "soapinqtimeout=20\n" + + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n" + "assignedto=userid\n" + + "addtemplate=addreq.tmpl.xml\n" + "severitypassthrough=critical,major,minor,warning\n" + + "systemuser=user\n" + "prt-offset=1200\n" + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n" + + "#smtpUsername=\n" + "#smtpPassword=\n" + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n" + + "esCluster=sendateodl5\n" + "\n" + "[aai]\n" + "#keep comment\n" + + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n" + + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n" + + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n" + + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" + + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n" + + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + ""; - @Test - public void test() { + private static final String EXT_TEST_URL = "https://testaai.onap.org:8443"; + private static final String EXT_TEST_KEY = "test.key"; + private static final String EXT_TEST_PASSWD = "test123"; + private static final String EXT_TEST_APPLICATIONID = "SDNC"; + private static final long EXT_TEST_CONN_TIMEOUT = 6000; - String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath(); - ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName); - AaiProviderClient provider = new AaiProviderClient(cfg, null); + private static final CharSequence TESTCONFIG_CONTENT_EXT = "[aai]\n" + "#keep comment\n" + + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n" + + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n" + + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + + // "aaiApplicationId=SDNR\n" + + // "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" + + // "aaiPcks12ClientCertPassphrase=adminadmin\n" + + // "aaiClientConnectionTimeout=30000\n" + + "\n"; + private static final CharSequence TESTCONFIG_CONTENT_EXT2 = "org.onap.ccsdk.sli.adaptors.aai.ssl.key=" + + EXT_TEST_KEY + "\n" + "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd=" + EXT_TEST_PASSWD + "\n" + + "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=false\n" + + "org.onap.ccsdk.sli.adaptors.aai.application=" + EXT_TEST_APPLICATIONID + "\n" + + "org.onap.ccsdk.sli.adaptors.aai.uri=" + EXT_TEST_URL + "\n" + "connection.timeout=" + + EXT_TEST_CONN_TIMEOUT + "\n"; + private static HttpServer server; + private static ExecutorService httpThreadPool; + private static ConfigurationFileRepresentation globalCfg; - String mountPointName = "testDevice 01"; - String type = "Unit"; - String model = "Horizon Compact+"; - String vendor = "DragonWave-X"; - String ipv4 = "127.0.0.1"; - String ipv6 = "::1"; - List<String> ifInfos = new ArrayList<>(); - ifInfos.add("LP-MWPS-RADIO"); - InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); - System.out.println("registering device"); - provider.onDeviceRegistered(mountPointName, ii); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("unregistering device"); - provider.onDeviceUnregistered(mountPointName); - System.out.println("finished"); - try { - provider.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } + @Test + public void test() { - @Test - public void test2() { - try { - Thread.sleep(3000); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - AaiProviderClient provider = new AaiProviderClient(globalCfg, null); + String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath(); + ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName); - String mountPointName = "testDevice 01"; - String type = "Unit"; - String model = "Horizon Compact+"; - String vendor = "DragonWave-X"; - String ipv4 = "127.0.0.1"; - String ipv6 = "::1"; - List<String> ifInfos = new ArrayList<>(); - ifInfos.add("LP-MWPS-RADIO"); - InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); - System.out.println("registering device"); - provider.onDeviceRegistered(mountPointName); - provider.onDeviceRegistered(mountPointName, ii); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("unregistering device"); - provider.onDeviceUnregistered(mountPointName); - System.out.println("finished"); - try { - provider.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } + AaiProviderClient provider = new AaiProviderClient(cfg, null); - @Test - public void testExtendedProperties() { - File testConfigurationFileName = new File("abbsads.properties"); - File extfile = new File("aaiclient.properties"); - if (testConfigurationFileName.exists()) { - testConfigurationFileName.delete(); - } - if (extfile.exists()) { - extfile.delete(); - } - try { - Files.asCharSink(testConfigurationFileName, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT); - } catch (IOException e) { - e.printStackTrace(); - fail("problem writing a test config file: " + e.getMessage()); - } - try { - Files.asCharSink(extfile, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT2); - } catch (IOException e) { - e.printStackTrace(); - fail("problem writing a second test config file: " + e.getMessage()); - } + String mountPointName = "testDevice 01"; + String type = "Unit"; + String model = "Horizon Compact+"; + String vendor = "DragonWave-X"; + String ipv4 = "127.0.0.1"; + String ipv6 = "::1"; + List<String> ifInfos = new ArrayList<>(); + ifInfos.add("LP-MWPS-RADIO"); + InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); + System.out.println("registering device"); + provider.onDeviceRegistered(mountPointName, ii); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("unregistering device"); + provider.onDeviceUnregistered(mountPointName); + System.out.println("finished"); + try { + provider.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } - ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName); - AaiConfig config = new AaiConfig(cfg); - System.out.println(config.toString()); + @Test + public void test2() { + try { + Thread.sleep(3000); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + AaiProviderClient provider = new AaiProviderClient(globalCfg, null); - assertTrue(config.getBaseUrl().startsWith(EXT_TEST_URL)); - assertEquals(EXT_TEST_KEY,config.getPcks12CertificateFilename()); - assertEquals(EXT_TEST_PASSWD,config.getPcks12CertificatePassphrase()); - assertEquals(EXT_TEST_APPLICATIONID,config.getHeaders().get("X-FromAppId")); - assertEquals(EXT_TEST_CONN_TIMEOUT,config.getConnectionTimeout()); - - if (testConfigurationFileName.exists()) { - testConfigurationFileName.delete(); - } - if (extfile.exists()) { - extfile.delete(); - } + String mountPointName = "testDevice 01"; + String type = "Unit"; + String model = "Horizon Compact+"; + String vendor = "DragonWave-X"; + String ipv4 = "127.0.0.1"; + String ipv6 = "::1"; + List<String> ifInfos = new ArrayList<>(); + ifInfos.add("LP-MWPS-RADIO"); + InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); + System.out.println("registering device"); + provider.onDeviceRegistered(mountPointName); + provider.onDeviceRegistered(mountPointName, ii); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("unregistering device"); + provider.onDeviceUnregistered(mountPointName); + System.out.println("finished"); + try { + provider.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } - } + @Test + public void testExtendedProperties() { + File testConfigurationFileName = new File("abbsads.properties"); + File extfile = new File("aaiclient.properties"); + if (testConfigurationFileName.exists()) { + testConfigurationFileName.delete(); + } + if (extfile.exists()) { + extfile.delete(); + } + try { + Files.asCharSink(testConfigurationFileName, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT); + } catch (IOException e) { + e.printStackTrace(); + fail("problem writing a test config file: " + e.getMessage()); + } + try { + Files.asCharSink(extfile, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT2); + } catch (IOException e) { + e.printStackTrace(); + fail("problem writing a second test config file: " + e.getMessage()); + } - @BeforeClass - public static void initAaiTestWebserver() throws IOException { - try { - Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); - } catch (IOException e1) { - fail(e1.getMessage()); - } - //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true); - globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME); - server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0); - httpThreadPool = Executors.newFixedThreadPool(5); - server.setExecutor(httpThreadPool); - AaiConfig config = new AaiConfig(globalCfg); - server.createContext(config.getBaseUri(), new MyHandler()); - //server.createContext("/", new MyRootHandler()); - server.setExecutor(null); // creates a default executor - server.start(); - System.out.println("http server started"); - } + ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName); + AaiConfig config = new AaiConfig(cfg); + System.out.println(config.toString()); - @AfterClass - public static void stopTestWebserver() { - if (server != null) { - server.stop(0); - httpThreadPool.shutdownNow(); - System.out.println("http server stopped"); - } - if (ENABLEDAAI_TESTCONFIG_FILE.exists()) { - ENABLEDAAI_TESTCONFIG_FILE.delete(); - } + assertTrue(config.getBaseUrl().startsWith(EXT_TEST_URL)); + assertEquals(EXT_TEST_KEY, config.getPcks12CertificateFilename()); + assertEquals(EXT_TEST_PASSWD, config.getPcks12CertificatePassphrase()); + assertEquals(EXT_TEST_APPLICATIONID, config.getHeaders().get("X-FromAppId")); + assertEquals(EXT_TEST_CONN_TIMEOUT, config.getConnectionTimeout()); - } + if (testConfigurationFileName.exists()) { + testConfigurationFileName.delete(); + } + if (extfile.exists()) { + extfile.delete(); + } - static class MyHandler implements HttpHandler { - @Override - public void handle(HttpExchange t) throws IOException { - String method = t.getRequestMethod(); - System.out.println("req method: " + method); - OutputStream os = null; - try { - String res = ""; - if (method.equals("GET")) { - t.sendResponseHeaders(404, res.length()); - os = t.getResponseBody(); - os.write(res.getBytes()); - } else if (method.equals("DELETE")) { - t.sendResponseHeaders(200, res.length()); - os = t.getResponseBody(); - os.write(res.getBytes()); - } else if (method.equals("PUT")) { - t.sendResponseHeaders(200, res.length()); - os = t.getResponseBody(); - os.write(res.getBytes()); - } else { - t.sendResponseHeaders(404, 0); - } - System.out.println("req handled successful"); + } - } catch (Exception e) { - System.out.println(e.getMessage()); - } finally { - if (os != null) { - os.close(); - } - } - } - } + @BeforeClass + public static void initAaiTestWebserver() throws IOException { + try { + Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + } catch (IOException e1) { + fail(e1.getMessage()); + } + //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true); + globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME); + server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0); + httpThreadPool = Executors.newFixedThreadPool(5); + server.setExecutor(httpThreadPool); + AaiConfig config = new AaiConfig(globalCfg); + server.createContext(config.getBaseUri(), new MyHandler()); + //server.createContext("/", new MyRootHandler()); + server.setExecutor(null); // creates a default executor + server.start(); + System.out.println("http server started"); + } + + @AfterClass + public static void stopTestWebserver() { + if (server != null) { + server.stop(0); + httpThreadPool.shutdownNow(); + System.out.println("http server stopped"); + } + if (ENABLEDAAI_TESTCONFIG_FILE.exists()) { + ENABLEDAAI_TESTCONFIG_FILE.delete(); + } + + } + + static class MyHandler implements HttpHandler { + @Override + public void handle(HttpExchange t) throws IOException { + String method = t.getRequestMethod(); + System.out.println("req method: " + method); + OutputStream os = null; + try { + String res = ""; + if (method.equals("GET")) { + t.sendResponseHeaders(404, res.length()); + os = t.getResponseBody(); + os.write(res.getBytes()); + } else if (method.equals("DELETE")) { + t.sendResponseHeaders(200, res.length()); + os = t.getResponseBody(); + os.write(res.getBytes()); + } else if (method.equals("PUT")) { + t.sendResponseHeaders(200, res.length()); + os = t.getResponseBody(); + os.write(res.getBytes()); + } else { + t.sendResponseHeaders(404, 0); + } + System.out.println("req handled successful"); + + } catch (Exception e) { + System.out.println(e.getMessage()); + } finally { + if (os != null) { + os.close(); + } + } + } + } } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java index bba7d7889..ff01f9a2b 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java @@ -51,56 +51,22 @@ public class TestDcae { private static final String ENABLEDDCAE_TESTCONFIG_FILENAME = "test2.properties"; private static final File ENABLEDDCAE_TESTCONFIG_FILE = new File(ENABLEDDCAE_TESTCONFIG_FILENAME); - private static final int DCAE_SERVER_PORT=45451; + private static final int DCAE_SERVER_PORT = 45451; private static final String URI = "/abc"; - private static final String TESTCONFIG_CONTENT="[dcae]\n" + - "dcaeUserCredentials=admin:admin\n" + - "dcaeUrl=http://localhost:"+DCAE_SERVER_PORT+URI+"\n" + - "dcaeHeartbeatPeriodSeconds=120\n" + - "dcaeTestCollector=no\n" + - "\n" + - "[aots]\n" + - "userPassword=passwd\n" + - "soapurladd=off\n" + - "soapaddtimeout=10\n" + - "soapinqtimeout=20\n" + - "userName=user\n" + - "inqtemplate=inqreq.tmpl.xml\n" + - "assignedto=userid\n" + - "addtemplate=addreq.tmpl.xml\n" + - "severitypassthrough=critical,major,minor,warning\n" + - "systemuser=user\n" + - "prt-offset=1200\n" + - "soapurlinq=off\n" + - "#smtpHost=\n" + - "#smtpPort=\n" + - "#smtpUsername=\n" + - "#smtpPassword=\n" + - "#smtpSender=\n" + - "#smtpReceivers=\n" + - "\n" + - "[es]\n" + - "esCluster=sendateodl5\n" + - "\n" + - "[aai]\n" + - "#keep comment\n" + - "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + - "aaiUrl=off\n" + - "aaiUserCredentials=AAI:AAI\n" + - "aaiDeleteOnMountpointRemove=true\n" + - "aaiTrustAllCerts=false\n" + - "aaiApiVersion=aai/v13\n" + - "aaiPropertiesFile=aaiclient.properties\n" + - "aaiApplicationId=SDNR\n" + - "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" + - "aaiPcks12ClientCertPassphrase=adminadmin\n" + - "aaiClientConnectionTimeout=30000\n" + - "\n" + - "[pm]\n" + - "pmCluster=sendateodl5\n" + - "pmEnabled=true\n" + - "\n" + - ""; + private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + + "dcaeUrl=http://localhost:" + DCAE_SERVER_PORT + URI + "\n" + "dcaeHeartbeatPeriodSeconds=120\n" + + "dcaeTestCollector=no\n" + "\n" + "[aots]\n" + "userPassword=passwd\n" + "soapurladd=off\n" + + "soapaddtimeout=10\n" + "soapinqtimeout=20\n" + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n" + + "assignedto=userid\n" + "addtemplate=addreq.tmpl.xml\n" + + "severitypassthrough=critical,major,minor,warning\n" + "systemuser=user\n" + "prt-offset=1200\n" + + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n" + "#smtpUsername=\n" + "#smtpPassword=\n" + + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n" + "esCluster=sendateodl5\n" + "\n" + "[aai]\n" + + "#keep comment\n" + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=off\n" + + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n" + + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n" + + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" + + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n" + + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + ""; private HttpServer server; private ExecutorService httpThreadPool; private ConfigurationFileRepresentation cfg; @@ -112,20 +78,21 @@ public class TestDcae { } catch (InterruptedException e1) { e1.printStackTrace(); } - DcaeProviderClient provider = new DcaeProviderClient(cfg,"mountpoint",null); + DcaeProviderClient provider = new DcaeProviderClient(cfg, "mountpoint", null); String mountPointName = "testDevice 01"; - String type="Unit"; - String model="Horizon Compact+"; - String vendor="DragonWave-X"; - String ipv4="127.0.0.1"; - String ipv6="::1"; + String type = "Unit"; + String model = "Horizon Compact+"; + String vendor = "DragonWave-X"; + String ipv4 = "127.0.0.1"; + String ipv6 = "::1"; List<String> ifInfos = new ArrayList<>(); ifInfos.add("LP-MWPS-RADIO"); new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); System.out.println("registering device"); boolean neDeviceAlarm = false; - ProblemNotificationXml notification = new ProblemNotificationXml(mountPointName, "network-element", "problemName", InternalSeverity.Critical,123, InternalDateAndTime.getTestpattern()); + ProblemNotificationXml notification = new ProblemNotificationXml(mountPointName, "network-element", + "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern()); provider.sendProblemNotification(mountPointName, notification, neDeviceAlarm); try { diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java index ebcd51376..9b533b554 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java @@ -23,11 +23,10 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - +import com.google.common.io.Files; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -40,14 +39,12 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.conf.Togg import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.io.Files; - public class TestDevMgrPropertiesFile { private static final Logger LOG = LoggerFactory.getLogger(ArchiveCleanService.class); private static final File FILENAME = new File("testdevmgrpropertiesfile.properties"); - private static final File AAIPROP_FILE=new File("testdevmgrpropertiesfileaaiclient.properties"); + private static final File AAIPROP_FILE = new File("testdevmgrpropertiesfileaaiclient.properties"); private int hasChanged; @Before @@ -55,6 +52,7 @@ public class TestDevMgrPropertiesFile { delete(FILENAME); delete(AAIPROP_FILE); } + @After public void deinit() { this.init(); @@ -94,7 +92,7 @@ public class TestDevMgrPropertiesFile { hasChanged = 0; cfg2.registerConfigChangedListener(() -> { hasChanged++; - LOG.info("file changed listener triggered: {}",hasChanged); + LOG.info("file changed listener triggered: {}", hasChanged); }); AaiConfig aaiConfig = new AaiConfig(cfg2); @@ -106,17 +104,17 @@ public class TestDevMgrPropertiesFile { ToggleAlarmConfig toggleAlarmConfig = new ToggleAlarmConfig(cfg2); assertNotNull(toggleAlarmConfig); - LOG.info("Write new content. Changes {}",hasChanged); + LOG.info("Write new content. Changes {}", hasChanged); writeFile(FILENAME, this.getContent2()); - int i=10; - while(hasChanged == 0 && i-- > 0) { + int i = 10; + while (hasChanged == 0 && i-- > 0) { LOG.info("Wait for Change indication."); sleep(1000); } - LOG.info("Changes {}",hasChanged); + LOG.info("Changes {}", hasChanged); - assertTrue("fileChanged counter "+hasChanged, hasChanged > 0); + assertTrue("fileChanged counter " + hasChanged, hasChanged > 0); LOG.info("Test done"); } @@ -130,22 +128,23 @@ public class TestDevMgrPropertiesFile { } public static void writeFile(File f, String content) { - try { + try { Files.asCharSink(f, StandardCharsets.UTF_8).write(content); } catch (IOException e) { fail(e.getMessage()); - }; + } ; sleep(500); } private void delete(File f) { - if(f.exists()) { + if (f.exists()) { f.delete(); } } private String getContent2() { + // @formatter:off return "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=http://localhost:45451/abc\n" + @@ -196,9 +195,11 @@ public class TestDevMgrPropertiesFile { "taEnabled=true\n" + "taDelay=5555\n" + ""; + // @formatter:on } private String getContent1() { + // @formatter:off return "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=http://localhost:45/abc\n" + @@ -245,8 +246,11 @@ public class TestDevMgrPropertiesFile { "taEnabled=false\n" + "taDelay=5555\n" + ""; + // @formatter:on } + private String getAaiPropertiesConfig() { + // @formatter:off return "org.onap.ccsdk.sli.adaptors.aai.ssl.key=keykey\"\"\n" + "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd=psswdpsswd\"\"\n" + "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=\"false\"\n" + @@ -254,6 +258,7 @@ public class TestDevMgrPropertiesFile { "org.onap.ccsdk.sli.adaptors.aai.uri=uriu\"\"\n" + "connection.timeout=60000\n" + "read.timeout=60000"; + // @formatter:on } } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java index fe0e37ae3..0dbac340b 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java @@ -70,7 +70,7 @@ public class TestDeviceMonitor extends Mockito { deviceMonitor.close(); File f = new File(CONFIGURATIONTESTFILE); if (f.exists()) - f.delete(); + f.delete(); } } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java index 03dfd763e..33373fb43 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java @@ -80,12 +80,14 @@ public class TestDevicemanager extends Mockito { @SuppressWarnings("unchecked") ListenerRegistration<NetconfNodeConnectListener> lr1 = mock(ListenerRegistration.class); //doNothing().when(lr1).close(); - when(netconfNodeStateService.registerNetconfNodeConnectListener(mock(NetconfNodeConnectListener.class))).thenReturn(lr1); + when(netconfNodeStateService.registerNetconfNodeConnectListener(mock(NetconfNodeConnectListener.class))) + .thenReturn(lr1); @SuppressWarnings("unchecked") ListenerRegistration<NetconfNodeStateListener> lr2 = mock(ListenerRegistration.class); //doNothing().when(lr2).close(); - when(netconfNodeStateService.registerNetconfNodeStateListener(mock(NetconfNodeStateListener.class))).thenReturn(lr2); + when(netconfNodeStateService.registerNetconfNodeStateListener(mock(NetconfNodeStateListener.class))) + .thenReturn(lr2); WebsocketmanagerService websocketmanagerService = mock(WebsocketmanagerService.class); @@ -113,7 +115,7 @@ public class TestDevicemanager extends Mockito { deviceManager.init(); - apiService = rpcProviderRegistry.getDeviceManagerApiService(); + apiService = rpcProviderRegistry.getDeviceManagerApiService(); } @@ -129,7 +131,8 @@ public class TestDevicemanager extends Mockito { n.creationNotification(new NodeId("NodeTest1"), 1, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1"); - n.changeNotification(new NodeId("NodeTest1"), 2, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1", "AtrributeTest1", "NewTest1"); + n.changeNotification(new NodeId("NodeTest1"), 2, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1", + "AtrributeTest1", "NewTest1"); n.deletionNotification(new NodeId("NodeTest1"), 3, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1"); @@ -140,9 +143,7 @@ public class TestDevicemanager extends Mockito { log.info("testFaultNotification"); MaintenanceBuilder mb = new MaintenanceBuilder(); - when(htDataBaseMaintenance - .getMaintenance("")) - .thenReturn(mb.build()); + when(htDataBaseMaintenance.getMaintenance("")).thenReturn(mb.build()); FaultService n = deviceManager.getFaultService(); FaultlogBuilder faultLogEntityBuilder = new FaultlogBuilder(); diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java index 5bef21e03..1102e91c1 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java @@ -30,8 +30,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro public class TestMaintenanceTimeFilter { - private static String DEFAULT1 = "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=1970-01-01T00:00Z[UTC], definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]"; - private static String DEFAULT2 = "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=2018-01-01T10:00+05:00, definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]"; + private static String DEFAULT1 = + "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=1970-01-01T00:00Z[UTC], definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]"; + private static String DEFAULT2 = + "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=2018-01-01T10:00+05:00, definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]"; @Test public void testBasic() { @@ -50,7 +52,7 @@ public class TestMaintenanceTimeFilter { now = ZonedDateTime.parse("2018-05-01T10:00:00+05:00"); res = MaintenanceCalculator.isInPeriod(start, end, now); System.out.println("Within: " + res); - assertTrue("within period",res); + assertTrue("within period", res); now = ZonedDateTime.parse("2019-05-01T10:00:00+05:00"); res = MaintenanceCalculator.isInPeriod(start, end, now); @@ -76,11 +78,11 @@ public class TestMaintenanceTimeFilter { now = MaintenanceCalculator.valueOf("2000-01-01T00:00Z"); res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "Interface1", "Problem1", now); - assertTrue("within period",res); + assertTrue("within period", res); now = MaintenanceCalculator.valueOf("2002-01-01T00:00Z"); res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "", "", now); - assertFalse("outside period",res); + assertFalse("outside period", res); } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java index f134012e3..bee1acaa4 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java @@ -28,18 +28,19 @@ import org.opendaylight.yangtools.yang.common.QName; public class TestNameSpace { private static final String QNAME_COREMODEL_NAMESPACE = "urn:onf:params:xml:ns:yang:core-model"; - private static final QName QNAME_COREMODEL = QName.create(QNAME_COREMODEL_NAMESPACE, "2017-03-20", "core-model").intern(); + private static final QName QNAME_COREMODEL = + QName.create(QNAME_COREMODEL_NAMESPACE, "2017-03-20", "core-model").intern(); @Test public void test() throws URISyntaxException { QName qname = QName.create("(urn:o-ran:hardware:1.0?revision=2019-03-28)o-ran-hardware"); - System.out.println("QName getNamespace"+qname.getNamespace()); - assertEquals(qname.getNamespace().toString(),"urn:o-ran:hardware:1.0"); + System.out.println("QName getNamespace" + qname.getNamespace()); + assertEquals(qname.getNamespace().toString(), "urn:o-ran:hardware:1.0"); - System.out.println("QName getRevision"+qname.getRevision()); - assertEquals(qname.getRevision().get().toString(),"2019-03-28"); + System.out.println("QName getRevision" + qname.getRevision()); + assertEquals(qname.getRevision().get().toString(), "2019-03-28"); System.out.println(QNAME_COREMODEL.getNamespace().toString()); assertEquals(QNAME_COREMODEL.getNamespace().toString(), QNAME_COREMODEL_NAMESPACE); diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java index c900397b1..eab30a0ac 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java @@ -58,13 +58,13 @@ public class TestXmlNotification { public void testNoAlarm() { ProblemNotificationXml notification; - notification = new ProblemNotificationXml("TestMointpoint", "network-element", - "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern()); + notification = new ProblemNotificationXml("TestMointpoint", "network-element", "problemName", + InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern()); assertFalse("Critical", notification.isNoAlarmIndication()); - notification = new ProblemNotificationXml("TestMointpoint", "network-element", - "problemName", InternalSeverity.NonAlarmed, 123, InternalDateAndTime.getTestpattern()); + notification = new ProblemNotificationXml("TestMointpoint", "network-element", "problemName", + InternalSeverity.NonAlarmed, 123, InternalDateAndTime.getTestpattern()); assertTrue("NonAlarm", notification.isNoAlarmIndication()); @@ -74,7 +74,8 @@ public class TestXmlNotification { public void testObjectCreationNotification() { ObjectCreationNotificationXml notification; - notification = new ObjectCreationNotificationXml("TestMointpoint1", 1, InternalDateAndTime.getTestpattern(), "Id1"); + notification = + new ObjectCreationNotificationXml("TestMointpoint1", 1, InternalDateAndTime.getTestpattern(), "Id1"); } @@ -82,7 +83,8 @@ public class TestXmlNotification { public void testDeletionCreationNotification() { ObjectDeletionNotificationXml notification; - notification = new ObjectDeletionNotificationXml("TestMointpoint2", 2, InternalDateAndTime.getTestpattern(), "Id2"); + notification = + new ObjectDeletionNotificationXml("TestMointpoint2", 2, InternalDateAndTime.getTestpattern(), "Id2"); } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java index 6cbb561ee..62f440a4e 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java @@ -31,19 +31,10 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.test.util.NetconfTimeStampO public class TestsNectconfDateTime { - private static String[] testPatterPostive = { - "2017-01-18T11:44:49.482-0500", - "2017-01-18T11:44:49.482-05:00", - "20170118114449.123Z", - "20170118114449.1Z", - "20170118114449.1-0500", - "2017-01-23T13:32:38-05:00", - "2017-01-23T13:32-05:00", - "2017-01-18T11:44:49Z" - }; - private static String[] testPatterProblem = { - "2017-01-18T11:44:49" - }; + private static String[] testPatterPostive = {"2017-01-18T11:44:49.482-0500", "2017-01-18T11:44:49.482-05:00", + "20170118114449.123Z", "20170118114449.1Z", "20170118114449.1-0500", "2017-01-23T13:32:38-05:00", + "2017-01-23T13:32-05:00", "2017-01-18T11:44:49Z"}; + private static String[] testPatterProblem = {"2017-01-18T11:44:49"}; private final static NetconfTimeStampOld netconfTimeConverterOld = NetconfTimeStampOld.getConverter(); @@ -58,24 +49,24 @@ public class TestsNectconfDateTime { timeNew = netconfTimeConverterNew.getTimeStampFromNetconf(testTime); timeOld = netconfTimeConverterOld.getTimeStampFromNetconf(testTime); - System.out.println("No "+t+++" Pattern: "+testTime); - System.out.println(" to old "+timeOld); - System.out.println(" to new "+timeNew); + System.out.println("No " + t++ + " Pattern: " + testTime); + System.out.println(" to old " + timeOld); + System.out.println(" to new " + timeNew); System.out.println(); - assertTrue("Old/New implementation not same "+timeOld+"/"+timeNew, timeOld.equals(timeNew)); + assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew)); } for (String testTime : testPatterProblem) { timeNew = netconfTimeConverterNew.getTimeStampFromNetconf(testTime); timeOld = netconfTimeConverterOld.getTimeStampFromNetconf(testTime); - System.out.println("No "+t+++" Pattern: "+testTime); - System.out.println(" to old "+timeOld); - System.out.println(" to new "+timeNew); + System.out.println("No " + t++ + " Pattern: " + testTime); + System.out.println(" to old " + timeOld); + System.out.println(" to new " + timeNew); System.out.println(); - assertTrue("Old/New implementation not same "+timeOld+"/"+timeNew, timeOld.equals(timeNew)); + assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew)); } } @@ -88,12 +79,12 @@ public class TestsNectconfDateTime { timeNew = netconfTimeConverterNew.getTimeStampFromNetconfAsMilliseconds(testTime); timeOld = netconfTimeConverterOld.getTimeStampFromNetconfAsMilliseconds(testTime); - System.out.println("No "+t+++" Pattern: "+testTime); - System.out.println(" to old "+timeOld); - System.out.println(" to new "+timeNew); + System.out.println("No " + t++ + " Pattern: " + testTime); + System.out.println(" to old " + timeOld); + System.out.println(" to new " + timeNew); System.out.println(); - assertTrue("Old/New implementation not same "+timeOld+"/"+timeNew, timeOld.equals(timeNew)); + assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew)); } } @@ -106,9 +97,9 @@ public class TestsNectconfDateTime { String timeNew = netconfTimeConverterNew.getTimeStampAsNetconfString(now); String timeOld = netconfTimeConverterOld.getTimeStampAsNetconfString(now); - System.out.println("Old/New: "+timeOld+"/"+timeNew); + System.out.println("Old/New: " + timeOld + "/" + timeNew); - assertTrue("Old/New implementation not same "+timeOld+"/"+timeNew, timeOld.equals(timeNew)); + assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew)); } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java index b05f7767c..14484d08b 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java @@ -34,9 +34,9 @@ public class RpcProviderServiceMock implements RpcProviderService { @Override public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type, T implementation) { - System.out.println("Register class "+implementation); + System.out.println("Register class " + implementation); if (implementation instanceof DevicemanagerService) { - deviceManagerApi = (DevicemanagerService)implementation; + deviceManagerApi = (DevicemanagerService) implementation; } return null; } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java index c2bd1fbf8..104ad0364 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java @@ -37,32 +37,25 @@ import org.slf4j.LoggerFactory; * Format2 NETCONF - pattern from ietf-yang-types "2013-07-15" Pattern: * "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-](\d{2}):(\d{2}))" * - * Format3 NETCONF DateAndTime CoreModel-CoreFoundationModule-TypeDefinitions vom - * 2016-07-01 Example1: 20170118114449.1Z Example2: 20170118114449.1-0500 Pattern: - * "\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}.\d+?(Z|[\+\-](\d{2})(\d{2}))" typedef DateAndTime { description - * "This primitive type defines the date and time according to the following structure: - * 'yyyyMMddhhmmss.s[Z|{+|-}HHMm]' where: yyyy '0000'..'9999' year MM '01'..'12' month dd '01'..'31' - * day hh '00'..'23' hour mm '00'..'59' minute ss '00'..'59' second s '.0'..'.9' tenth of second - * (set to '.0' if EMS or NE cannot support this granularity) Z 'Z' indicates UTC (rather than local - * time) {+|-} '+' or '-' delta from UTC HH '00'..'23' time zone difference in hours Mm '00'..'59' - * time zone difference in minutes."; type string; } Format4 E/// specific Example1: - * 2017-01-23T13:32:38-05:00 Example2: 2017-01-23T13:32-05:00 + * Format3 NETCONF DateAndTime CoreModel-CoreFoundationModule-TypeDefinitions vom 2016-07-01 Example1: 20170118114449.1Z + * Example2: 20170118114449.1-0500 Pattern: "\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}.\d+?(Z|[\+\-](\d{2})(\d{2}))" typedef + * DateAndTime { description "This primitive type defines the date and time according to the following structure: + * 'yyyyMMddhhmmss.s[Z|{+|-}HHMm]' where: yyyy '0000'..'9999' year MM '01'..'12' month dd '01'..'31' day hh '00'..'23' + * hour mm '00'..'59' minute ss '00'..'59' second s '.0'..'.9' tenth of second (set to '.0' if EMS or NE cannot support + * this granularity) Z 'Z' indicates UTC (rather than local time) {+|-} '+' or '-' delta from UTC HH '00'..'23' time + * zone difference in hours Mm '00'..'59' time zone difference in minutes."; type string; } Format4 E/// specific + * Example1: 2017-01-23T13:32:38-05:00 Example2: 2017-01-23T13:32-05:00 * * Input formats netconfTime as String according the formats given above * * Return format is String in ISO8601 Format for database and presentation. * - * Example formats: - * 1) ISO8601. Example 2017-01-18T11:44:49.482-05:00 - * 2) Microwave ONF. Examples 20170118114449.1Z, 20170118114449.1-0500 - * 3.1) Ericson. Example: 2017-01-23T13:32:38-05:00 - * 3.2) Ericson. Example: 2017-01-23T13:32-05:00 - * Always 10 Groups, - * 1:Year 2:Month 3:day 4:Hour 5:minute 6:optional sec 7:optional ms 8:optional Z or 9:offset - * signedhour 10:min + * Example formats: 1) ISO8601. Example 2017-01-18T11:44:49.482-05:00 2) Microwave ONF. Examples 20170118114449.1Z, + * 20170118114449.1-0500 3.1) Ericson. Example: 2017-01-23T13:32:38-05:00 3.2) Ericson. Example: 2017-01-23T13:32-05:00 + * Always 10 Groups, 1:Year 2:Month 3:day 4:Hour 5:minute 6:optional sec 7:optional ms 8:optional Z or 9:offset + * signedhour 10:min * - * Template: - * private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter(); + * Template: private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter(); */ public class NetconfTimeStampOld { @@ -75,7 +68,7 @@ public class NetconfTimeStampOld { 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}))"); + "(\\d{4})-?(\\d{2})-?(\\d{2})T?(\\d{2}):?(\\d{2})(?:(?::?)(\\d{2}))?(?:.(\\d+))?(?:(Z)|([+-]\\d{2}):?(\\d{2}))"); /* * ------------------------------------ Public function @@ -84,11 +77,11 @@ public class NetconfTimeStampOld { /** * Use static access */ - private NetconfTimeStampOld() { - } + private NetconfTimeStampOld() {} /** * Use this function to get the converter + * * @return global converter */ public static NetconfTimeStampOld getConverter() { @@ -106,12 +99,13 @@ public class NetconfTimeStampOld { /** * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format - + * * @return String with Date in NETCONF/YANG Format Version 1.0. */ public String getTimeStampAsNetconfString(Date date) { return getRightFormattedDate(date.getTime()); } + /** * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format in GMT * @@ -123,6 +117,7 @@ public class NetconfTimeStampOld { /** * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT + * * @param date specifying the date and time * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0. */ @@ -139,22 +134,21 @@ public class NetconfTimeStampOld { * @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 { + public long getTimeStampFromNetconfAsMilliseconds(String netconfTime) throws IllegalArgumentException { Matcher m = dateNetconfPatter.matcher(netconfTime); // According to specified matches there have to be 10 parameter if (m.matches() && m.groupCount() == 10) { // Convert now - synchronized(dateFormatConvert) { - long utcMillis; - try { - utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime() - - getTimezoneOffsetMilliseconds(m.group(9), m.group(10)); - return utcMillis; - } catch (ParseException e) { - throw new IllegalArgumentException("Parse problem for NETCONF data string: " + netconfTime); - } - } + synchronized (dateFormatConvert) { + long utcMillis; + try { + utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime() + - getTimezoneOffsetMilliseconds(m.group(9), m.group(10)); + return utcMillis; + } catch (ParseException e) { + throw new IllegalArgumentException("Parse problem for NETCONF data string: " + netconfTime); + } + } } else { throw new IllegalArgumentException("No pattern for NETCONF data string: " + netconfTime); } @@ -164,8 +158,8 @@ public class NetconfTimeStampOld { * 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. + * @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. */ public String getTimeStampFromNetconf(String netconfTime) { Matcher m = dateNetconfPatter.matcher(netconfTime); @@ -173,11 +167,12 @@ public class NetconfTimeStampOld { if (m.matches() && m.groupCount() == 10) { // Convert now try { - synchronized(dateFormatConvert) { - long utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime() - - getTimezoneOffsetMilliseconds(m.group(9), m.group(10)); - return getRightFormattedDate(utcMillis); - } + synchronized (dateFormatConvert) { + 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) { @@ -261,8 +256,8 @@ public class NetconfTimeStampOld { long tenthOfSeconds = dateMillis % 1000 / 100L; // Extract 100 milliseconds long base = dateMillis / 1000L * 1000L; // Cut milliseconds to 000 Date newDate = new Date(base + tenthOfSeconds); - synchronized(dateFormatResult) { - return dateFormatResult.format(newDate); + synchronized (dateFormatResult) { + return dateFormatResult.format(newDate); } } |