aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr')
-rw-r--r--sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/DOMNotificationOutput.java82
-rw-r--r--sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/INotificationOutput.java31
-rw-r--r--sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/NotificationOutput.java5
-rw-r--r--sdnr/wt/websocketmanager/model/src/main/yang/websocketmanager.yang51
-rw-r--r--sdnr/wt/websocketmanager/provider/pom.xml1
-rw-r--r--sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerProvider.java32
-rw-r--r--sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java11
-rw-r--r--sdnr/wt/websocketmanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/TestSerializer.java59
8 files changed, 252 insertions, 20 deletions
diff --git a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/DOMNotificationOutput.java b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/DOMNotificationOutput.java
new file mode 100644
index 000000000..62229b33c
--- /dev/null
+++ b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/DOMNotificationOutput.java
@@ -0,0 +1,82 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data;
+
+import org.opendaylight.mdsal.dom.api.DOMNotification;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yangtools.yang.common.QName;
+
+public class DOMNotificationOutput implements INotificationOutput{
+
+ private DateAndTime eventTime;
+ private DOMNotification data;
+ private String nodeId;
+ private ReducedSchemaInfo type;
+
+
+ public DOMNotificationOutput() {
+
+ }
+
+ @Override
+ public DateAndTime getEventTime() {
+ return eventTime;
+ }
+
+ public void setEventTime(DateAndTime eventTime) {
+ this.eventTime = eventTime;
+ }
+
+ public DOMNotification getData() {
+ return data;
+ }
+
+ @Override
+ public String getNodeId() {
+ return this.nodeId;
+ }
+
+ @Override
+ public ReducedSchemaInfo getType() {
+ return this.type;
+ }
+
+ public void setData(DOMNotification data) {
+ this.data = data;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public void setType(ReducedSchemaInfo type) {
+ this.type = type;
+ }
+
+ public DOMNotificationOutput(DOMNotification notification, String nodeId, QName type, DateAndTime eventTime) {
+ this.data = notification;
+ this.nodeId = nodeId;
+ this.eventTime = eventTime;
+ this.type = new ReducedSchemaInfo(type);
+ }
+
+}
diff --git a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/INotificationOutput.java b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/INotificationOutput.java
new file mode 100644
index 000000000..c16b4205d
--- /dev/null
+++ b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/INotificationOutput.java
@@ -0,0 +1,31 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+
+public interface INotificationOutput {
+
+ public DateAndTime getEventTime();
+ public String getNodeId();
+ public ReducedSchemaInfo getType();
+}
diff --git a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/NotificationOutput.java b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/NotificationOutput.java
index 5b966ef1e..7e0ba728c 100644
--- a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/NotificationOutput.java
+++ b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/NotificationOutput.java
@@ -25,7 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.QName;
-public class NotificationOutput {
+public class NotificationOutput implements INotificationOutput{
private DateAndTime eventTime;
private Notification data;
@@ -37,6 +37,7 @@ public class NotificationOutput {
}
+ @Override
public DateAndTime getEventTime() {
return eventTime;
}
@@ -49,10 +50,12 @@ public class NotificationOutput {
return data;
}
+ @Override
public String getNodeId() {
return this.nodeId;
}
+ @Override
public ReducedSchemaInfo getType() {
return this.type;
}
diff --git a/sdnr/wt/websocketmanager/model/src/main/yang/websocketmanager.yang b/sdnr/wt/websocketmanager/model/src/main/yang/websocketmanager.yang
new file mode 100644
index 000000000..18d7bd27a
--- /dev/null
+++ b/sdnr/wt/websocketmanager/model/src/main/yang/websocketmanager.yang
@@ -0,0 +1,51 @@
+module websocketmanager {
+
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:websocketmanager";
+ prefix websocketmanager;
+
+ import ietf-yang-types {
+ prefix yang;
+ }
+ organization
+ "highstreet technologies GmbH";
+ contact
+ "Web: <https://highstreet-technologies.com>
+ ONAP: <https://wiki.onap.org/display/DW/SDN-R+Websocketmanager+Upgrade>";
+
+ description
+ "Websocketmanager Api Module
+
+ Copyright 2021 highstreet technologies GmbH Intellectual Property.
+ All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an 'AS IS' BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.";
+
+ revision 2021-03-22 {
+ description
+ "Initial revision";
+ }
+
+ notification items-dropped-notification {
+ uses items-dropped-notification-g;
+ description "none";
+ }
+ grouping items-dropped-notification-g {
+ leaf amount {
+ type uint32;
+ default 0;
+ description "Counts of notifications that were dropped.";
+ }
+ description "To be sent when notifications were dropped in fact of a set ratio limit.";
+ }
+}
diff --git a/sdnr/wt/websocketmanager/provider/pom.xml b/sdnr/wt/websocketmanager/provider/pom.xml
index 746803f62..f078c7fc3 100644
--- a/sdnr/wt/websocketmanager/provider/pom.xml
+++ b/sdnr/wt/websocketmanager/provider/pom.xml
@@ -49,7 +49,6 @@
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
diff --git a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerProvider.java b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerProvider.java
index 610001775..8af5cb1ee 100644
--- a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerProvider.java
+++ b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerProvider.java
@@ -20,6 +20,7 @@ package org.onap.ccsdk.features.sdnr.wt.websocketmanager;
import java.time.Instant;
import javax.servlet.ServletException;
import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService;
+import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.DOMNotificationOutput;
import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.NotificationOutput;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper;
import org.opendaylight.mdsal.dom.api.DOMNotification;
@@ -83,31 +84,30 @@ public class WebSocketManagerProvider implements WebsocketManagerService, AutoCl
this.wsServlet = wsServlet;
}
-
- @Override
- public void sendNotification(Notification notification, NodeId nodeId, QName eventType) {
- if(!assertNotificationType(notification, eventType)){
- return;
- }
- this.sendNotification(notification, nodeId, eventType, YangToolsMapperHelper.getTime(notification,Instant.now()));
- }
-
public static boolean assertNotificationType(Notification notification, QName eventType) {
final String yangTypeName = eventType.getLocalName();
final Class<?> cls = notification.getClass();
final String clsNameToTest = YangToolsMapperHelper.toCamelCaseClassName(yangTypeName);
- if(cls.getSimpleName().equals(clsNameToTest)) {
+ if (cls.getSimpleName().equals(clsNameToTest)) {
return true;
}
Class<?>[] ifs = cls.getInterfaces();
- for(Class<?> clsif:ifs) {
- if(clsif.getSimpleName().equals(clsNameToTest)) {
+ for (Class<?> clsif : ifs) {
+ if (clsif.getSimpleName().equals(clsNameToTest)) {
return true;
}
}
return false;
}
+ @Override
+ public void sendNotification(Notification notification, NodeId nodeId, QName eventType) {
+ if (!assertNotificationType(notification, eventType)) {
+ return;
+ }
+ this.sendNotification(notification, nodeId, eventType,
+ YangToolsMapperHelper.getTime(notification, Instant.now()));
+ }
@Override
public void sendNotification(Notification notification, NodeId nodeId, QName eventType, DateAndTime eventTime) {
@@ -117,14 +117,14 @@ public class WebSocketManagerProvider implements WebsocketManagerService, AutoCl
@Override
public void sendNotification(DOMNotification notification, NodeId nodeId, QName eventType) {
- LOG.warn("not yet implemented");
-
+ WebSocketManagerSocket.broadCast(new DOMNotificationOutput(notification, nodeId.getValue(), eventType,
+ YangToolsMapperHelper.getTime(notification, Instant.now())));
}
@Override
public void sendNotification(DOMNotification notification, NodeId nodeId, QName eventType, DateAndTime eventTime) {
- LOG.warn("not yet implemented");
-
+ WebSocketManagerSocket
+ .broadCast(new DOMNotificationOutput(notification, nodeId.getValue(), eventType, eventTime));
}
}
diff --git a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java
index a642bda69..7c12c4baa 100644
--- a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java
+++ b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java
@@ -33,6 +33,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
+import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.DOMNotificationOutput;
+import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.INotificationOutput;
import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.NotificationOutput;
import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.ReducedSchemaInfo;
import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.ScopeRegistration;
@@ -247,7 +249,7 @@ public class WebSocketManagerSocket extends WebSocketAdapter {
return this.myUniqueSessionId;
}
- private void sendToAll(NotificationOutput output) {
+ private void sendToAll(INotificationOutput output) {
try {
sendToAll(output.getNodeId(), output.getType(), mapper.writeValueAsString(output));
} catch (JsonProcessingException e) {
@@ -281,7 +283,7 @@ public class WebSocketManagerSocket extends WebSocketAdapter {
}
}
- public static void broadCast(NotificationOutput output) {
+ public static void broadCast(INotificationOutput output) {
if (clientList.size() > 0) {
Set<Entry<String, WebSocketManagerSocket>> e = clientList.entrySet();
WebSocketManagerSocket s = e.iterator().next().getValue();
@@ -291,4 +293,9 @@ public class WebSocketManagerSocket extends WebSocketAdapter {
}
}
+ public static void broadCast(DOMNotificationOutput domNotificationOutput) {
+ // TODO Auto-generated method stub
+
+ }
+
}
diff --git a/sdnr/wt/websocketmanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/TestSerializer.java b/sdnr/wt/websocketmanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/TestSerializer.java
new file mode 100644
index 000000000..962838489
--- /dev/null
+++ b/sdnr/wt/websocketmanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/TestSerializer.java
@@ -0,0 +1,59 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.NotificationOutput;
+import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ObjectCreationNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ObjectCreationNotificationBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestSerializer {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TestSerializer.class);
+ private static final YangToolsMapper mapper = new YangToolsMapper();
+ private static final String TIMESTAMP = "2020-04-01T10:20:40.0Z";
+ private static final String NODEID = "node1";
+
+ @Test
+ public void test1() {
+ ObjectCreationNotification notification = new ObjectCreationNotificationBuilder().setCounter(Integer.valueOf(5)).build();
+ NotificationOutput output = new NotificationOutput(notification, NODEID, ObjectCreationNotification.QNAME,DateAndTime.getDefaultInstance(TIMESTAMP));
+ String sOutput=null;
+ try {
+ sOutput = mapper.writeValueAsString(output);
+ LOG.debug(sOutput);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertNotNull(sOutput);
+ assertTrue(sOutput.contains("\"type\""));
+ }
+}