From 95264d6d078e4d07e147369b007ae2c9791769c8 Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Wed, 3 Feb 2021 15:03:14 +0100 Subject: Migrate common-yang and devicemanager Migrate common-yang and devicemanager to Aluminium Issue-ID: CCSDK-3132 Signed-off-by: Ravi Pendurty Change-Id: I441029206fc41e2207d20e0c62f1d6a3a1254def Signed-off-by: Ravi Pendurty --- .../archiveservice/ArchiveCleanService.java | 10 ++++---- .../ConnectionStatusHousekeepingService.java | 5 ++-- .../wt/devicemanager/impl/DeviceManagerImpl.java | 3 +-- .../impl/xml/WebSocketServiceClientImpl2.java | 21 +++++++++-------- .../sdnr/wt/devicemanager/impl/xml/XmlMapper.java | 27 +++++++++------------- 5 files changed, 29 insertions(+), 37 deletions(-) (limited to 'sdnr/wt/devicemanager/provider/src/main/java') 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 d84764e89..e15a577b7 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 @@ -17,12 +17,13 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import java.util.Date; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; - import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.ArchiveCleanProvider; @@ -34,9 +35,6 @@ import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; import org.slf4j.Logger; 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 { private static final Logger LOG = LoggerFactory.getLogger(ArchiveCleanService.class); @@ -132,7 +130,8 @@ public class ArchiveCleanService implements AutoCloseable, IConfigChangedListene public void close() throws Exception { this.esConfig.unregisterConfigChangedListener(this); this.scheduler.shutdown(); - this.cssRegistration.close(); + if (this.cssRegistration != null) + this.cssRegistration.close(); } @Override @@ -141,7 +140,6 @@ public class ArchiveCleanService implements AutoCloseable, IConfigChangedListene + "ArchiveLifetimeSeconds=" + esConfig.getArchiveLifetimeSeconds() + "]"; } - @SuppressWarnings("null") @Override public @NonNull ServiceGroupIdentifier getIdentifier() { return IDENT; 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 4fe7d180e..49c678ebc 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 @@ -23,7 +23,6 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; - import java.util.List; import java.util.NoSuchElementException; import java.util.Optional; @@ -228,10 +227,10 @@ public class ConnectionStatusHousekeepingService this.cfg.unregisterConfigChangedListener(this); } this.scheduler.shutdown(); - this.cssRegistration2.close(); + if (this.cssRegistration2 != null) + this.cssRegistration2.close(); } - @SuppressWarnings("null") @Override public @NonNull ServiceGroupIdentifier getIdentifier() { return IDENT; 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 f3112fbe3..fd2929f1a 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 @@ -278,7 +278,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa } @Override - public @NonNull FactoryRegistration registerNetworkElementFactory( + public @NonNull FactoryRegistration registerBindingNetworkElementFactory( @NonNull L factory) { LOG.info("Factory registration {}", factory.getClass().getName()); @@ -419,5 +419,4 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa return this.vesCollectorClient; } - } 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 81a740305..bc44543e8 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 @@ -17,8 +17,9 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; - +import javax.xml.bind.JAXBException; import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketEventInputBuilder; @@ -40,7 +41,7 @@ public class WebSocketServiceClientImpl2 implements WebSocketServiceClientIntern /** * New: Implementation of Websocket notification processor. - * + * * @param websocketmanagerService2 to be used */ public WebSocketServiceClientImpl2(WebsocketmanagerService websocketmanagerService2) { @@ -52,18 +53,18 @@ public class WebSocketServiceClientImpl2 implements WebSocketServiceClientIntern @Override public void sendViaWebsockets(@NonNull String nodeName, @NonNull T notificationXml) { - LOG.info("Send websocket event {} for mountpoint {}", notificationXml.getClass().getSimpleName(), nodeName); + LOG.debug("Send websocket event {} for mountpoint {}", notificationXml.getClass().getSimpleName(), nodeName); + WebsocketEventInputBuilder wsBuilder = new WebsocketEventInputBuilder(); + wsBuilder.setNodeName(nodeName); + wsBuilder.setEventType(notificationXml.getEventType()); try { - WebsocketEventInputBuilder wsBuilder = new WebsocketEventInputBuilder(); - wsBuilder.setNodeName(nodeName); - wsBuilder.setEventType(notificationXml.getEventType()); wsBuilder.setXmlEvent(xmlMapper.getXmlString(notificationXml)); Future> result = websocketmanagerService.websocketEvent(wsBuilder.build()); - LOG.info("Send websocket result: {}", result.get().getResult().getResponse()); - } catch (Exception e) { - LOG.warn("Can not send websocket event {} for mountpoint {} {}", notificationXml.getClass().getSimpleName(), - nodeName, e.toString()); + if (result != null) + LOG.trace("Send websocket result: {}", result == null ? "null" : result.get().getResult().getResponse()); + } catch (JAXBException | InterruptedException | ExecutionException e) { + LOG.warn("Can not send websocket event {} for mountpoint {} {}", notificationXml, nodeName, e.toString()); } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/XmlMapper.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/XmlMapper.java index 8a2b9f1fa..62bd50de5 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/XmlMapper.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/XmlMapper.java @@ -6,9 +6,9 @@ * ================================================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under @@ -25,25 +25,20 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class XmlMapper { + @SuppressWarnings("unused") private static final Logger LOG = LoggerFactory.getLogger(XmlMapper.class); - public String getXmlString(MwtNotificationBase base) { + public String getXmlString(MwtNotificationBase base) throws JAXBException { String xml; JAXBContext jaxbContext; - try { - jaxbContext = JAXBContext.newInstance(AttributeValueChangedNotificationXml.class, - ObjectCreationNotificationXml.class, ObjectDeletionNotificationXml.class, - ProblemNotificationXml.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); - jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbContext = JAXBContext.newInstance(AttributeValueChangedNotificationXml.class, + ObjectCreationNotificationXml.class, ObjectDeletionNotificationXml.class, ProblemNotificationXml.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); + jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - StringWriter stringWriter = new StringWriter(); - jaxbMarshaller.marshal(base, stringWriter); - xml = stringWriter.toString(); - } catch (JAXBException e) { - LOG.warn("Problem in marshalling xml file {}", e); - xml = null; - } + StringWriter stringWriter = new StringWriter(); + jaxbMarshaller.marshal(base, stringWriter); + xml = stringWriter.toString(); return xml; } } -- cgit 1.2.3-korg