<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-binding-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>yang-binding</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.openflowplugin.model</groupId>
<artifactId>model-flow-service</artifactId>
*/
package org.opendaylight.openflowplugin.test;
+import java.util.Set;
+import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
+import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener.Component;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Dummy implementation flushing events into log.
*/
-public class FlowEventListenerLoggingImpl implements SalFlowListener {
+@Deprecated
+public final class FlowEventListenerLoggingImpl {
private static final Logger LOG = LoggerFactory.getLogger(FlowEventListenerLoggingImpl.class);
- @Override
- @Deprecated
- public void onFlowAdded(final FlowAdded notification) {
- LOG.info("flow to be added {}", notification.toString());
- LOG.info("added flow Xid {}", notification.getTransactionId().getValue());
+ private FlowEventListenerLoggingImpl() {
+ // Hidden on purpose
}
- @Override
- @Deprecated
- public void onFlowRemoved(final FlowRemoved notification) {
- LOG.debug("removed flow {}", notification.toString());
- LOG.debug("remove flow Xid {}", notification.getTransactionId().getValue());
- }
-
- @Override
- @Deprecated
- public void onFlowUpdated(final FlowUpdated notification) {
- LOG.debug("updated flow {}", notification.toString());
- LOG.debug("updated flow Xid {}", notification.getTransactionId().getValue());
- }
-
- @Override
- @Deprecated
- public void onNodeErrorNotification(final NodeErrorNotification notification) {
- //commenting as we have a NodeErrorListener
- /* LOG.error("Error notification flow Xid........................."
- + notification.getTransactionId().getValue());
- LOG.debug("notification Begin-Transaction:"
- + notification.getTransactionUri()
- + "-----------------------------------------------------------------------------------");
- */
- }
-
- @Override
- @Deprecated
- public void onNodeExperimenterErrorNotification(final NodeExperimenterErrorNotification notification) {
- // TODO Auto-generated method stub
- }
-
- @Override
- @Deprecated
- public void onSwitchFlowRemoved(final SwitchFlowRemoved notification) {
- LOG.debug("Switch flow removed : Cookies {}", notification.getCookie().toString());
+ static CompositeListener newListener() {
+ return new CompositeListener(Set.of(
+ new Component<>(FlowAdded.class, notification -> {
+ LOG.info("flow to be added {}", notification);
+ LOG.info("added flow Xid {}", notification.getTransactionId().getValue());
+ }),
+ new Component<>(FlowRemoved.class, notification -> {
+ LOG.debug("removed flow {}", notification);
+ LOG.debug("remove flow Xid {}", notification.getTransactionId().getValue());
+ }),
+ new Component<>(FlowUpdated.class, notification -> {
+ LOG.debug("updated flow {}", notification);
+ LOG.debug("updated flow Xid {}", notification.getTransactionId().getValue());
+ }),
+ new Component<>(NodeErrorNotification.class, notification -> {
+ //commenting as we have a NodeErrorListener
+ /* LOG.error("Error notification flow Xid........................."
+ + notification.getTransactionId().getValue());
+ LOG.debug("notification Begin-Transaction:"
+ + notification.getTransactionUri()
+ + "-----------------------------------------------------------------------------------");
+ */
+ }),
+ new Component<>(SwitchFlowRemoved.class, notification -> {
+ LOG.debug("Switch flow removed : Cookies {}", notification.getCookie().toString());
+ })));
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
private static final String IPV4_PREFIX = "10.0.0.1/24";
private static final String DEST_MAC_ADDRESS = "ff:ff:ff:ff:ff:ff";
private static final String SRC_MAC_ADDRESS = "00:00:00:00:23:ae";
- private final SalFlowListener flowEventListener = new FlowEventListenerLoggingImpl();
+
private final NotificationService notificationService;
public OpenflowpluginTestCommandProvider(final DataBroker dataBroker, final NotificationService notificationService,
public void init() {
// For switch events
- notificationService.registerNotificationListener(flowEventListener);
+ notificationService.registerCompositeListener(FlowEventListenerLoggingImpl.newListener());
+
ctx.registerService(CommandProvider.class.getName(), this, null);
createTestFlow(createTestNode(null), null, null);
}
TestFlowThread(final int numberOfSwtiches, final int numberOfFlows, final CommandInterpreter ci,
final int threadNumber, final int tableID) {
- this.numberOfSwitches = numberOfSwtiches;
+ numberOfSwitches = numberOfSwtiches;
this.numberOfFlows = numberOfFlows;
this.ci = ci;
- this.theadNumber = threadNumber;
+ theadNumber = threadNumber;
this.tableID = tableID;
}
FlowBuilder tf;
//String tableId = "0";
- ci.println("New Thread started with id: ID_"
- + this.theadNumber);
+ ci.println("New Thread started with id: ID_" + theadNumber);
int totalNumberOfFlows = 0;
final long startTime = System.currentTimeMillis();
- for (int i = 1; i <= this.numberOfSwitches; i++) {
+ for (int i = 1; i <= numberOfSwitches; i++) {
dataPath = "openflow:" + i;
tn = createTestNode(dataPath);
- for (int flow2 = 1; flow2 <= this.numberOfFlows; flow2++) {
- tf = createTestFlowPerfTest("f1", "" + this.tableID, flow2);
- writeFlow(this.ci, tf, tn);
+ for (int flow2 = 1; flow2 <= numberOfFlows; flow2++) {
+ tf = createTestFlowPerfTest("f1", "" + tableID, flow2);
+ writeFlow(ci, tf, tn);
totalNumberOfFlows++;
}
}
final long endTime = System.currentTimeMillis();
final long timeInSeconds = Math.round((endTime - startTime) / 1000.0F);
if (timeInSeconds > 0) {
- ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::"
+ ci.println("Total flows added in Thread:" + theadNumber + ": Flows/Sec::"
+ Math.round((float)totalNumberOfFlows / timeInSeconds));
} else {
- ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + totalNumberOfFlows);
+ ci.println("Total flows added in Thread:" + theadNumber + ": Flows/Sec::" + totalNumberOfFlows);
}
}
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
+import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener.Component;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public void init() {
// For switch events
- notificationService.registerNotificationListener(portEventListener);
+ notificationService.registerCompositeListener(portEventListener.toListener());
}
- private static final class PortEventListener implements OpendaylightInventoryListener {
-
+ private static final class PortEventListener {
List<NodeUpdated> nodeUpdated = new ArrayList<>();
List<NodeRemoved> nodeRemoved = new ArrayList<>();
List<NodeConnectorUpdated> nodeConnectorUpdated = new ArrayList<>();
List<NodeConnectorRemoved> nodeConnectorRemoved = new ArrayList<>();
- @Override
- @Deprecated
- public void onNodeConnectorRemoved(final NodeConnectorRemoved notification) {
- LOG.debug("NodeConnectorRemoved Notification");
- LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
- nodeConnectorRemoved.add(notification);
- }
-
- @Override
- @Deprecated
- public void onNodeConnectorUpdated(final NodeConnectorUpdated notification) {
- LOG.debug("NodeConnectorUpdated Notification");
- LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
- nodeConnectorUpdated.add(notification);
- }
-
- @Override
- @Deprecated
- public void onNodeRemoved(final NodeRemoved notification) {
- LOG.debug("NodeRemoved Notification");
- LOG.debug("NodeRef {}", notification.getNodeRef());
- nodeRemoved.add(notification);
- }
-
- @Override
- @Deprecated
- public void onNodeUpdated(final NodeUpdated notification) {
- LOG.debug("NodeUpdated Notification");
- LOG.debug("NodeRef {}", notification.getNodeRef());
- nodeUpdated.add(notification);
+ CompositeListener toListener() {
+ return new CompositeListener(Set.of(
+ new Component<>(NodeConnectorRemoved.class, notification -> {
+ LOG.debug("NodeConnectorRemoved Notification");
+ LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
+ nodeConnectorRemoved.add(notification);
+ }),
+ new Component<>(NodeConnectorUpdated.class, notification -> {
+ LOG.debug("NodeConnectorUpdated Notification");
+ LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
+ nodeConnectorUpdated.add(notification);
+ }),
+ new Component<>(NodeRemoved.class, notification -> {
+ LOG.debug("NodeRemoved Notification");
+ LOG.debug("NodeRef {}", notification.getNodeRef());
+ nodeRemoved.add(notification);
+ }),
+ new Component<>(NodeUpdated.class, notification -> {
+ LOG.debug("NodeUpdated Notification");
+ LOG.debug("NodeRef {}", notification.getNodeRef());
+ nodeUpdated.add(notification);
+ })));
}
}
}
package org.opendaylight.openflowplugin.test;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.Set;
import org.opendaylight.mdsal.binding.api.NotificationService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryListener;
+import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
+import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener.Component;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkOverutilized;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkUtilizationNormal;
+import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OpenflowpluginTestTopologyNotification {
-
private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestTopologyNotification.class);
- private final TopologyEventListener topologyEventListener = new TopologyEventListener();
private final NotificationService notificationService;
public OpenflowpluginTestTopologyNotification(final NotificationService notificationService) {
public void init() {
// For switch events
- notificationService.registerNotificationListener(topologyEventListener);
+ notificationService.registerCompositeListener(new CompositeListener(Set.of(
+ new Component<>(LinkDiscovered.class, this::onNotification),
+ new Component<>(LinkOverutilized.class, this::onNotification),
+ new Component<>(LinkRemoved.class, this::onNotification),
+ new Component<>(LinkUtilizationNormal.class, this::onNotification))));
}
- private static final class TopologyEventListener implements FlowTopologyDiscoveryListener {
- @Override
- @Deprecated
- @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT")
- public void onLinkDiscovered(final LinkDiscovered notification) {
- LOG.debug("-------------------------------------------");
- LOG.debug("LinkDiscovered notification ........");
- LOG.debug("-------------------------------------------");
- }
-
- @Override
- @Deprecated
- @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT")
- public void onLinkOverutilized(final LinkOverutilized notification) {
- LOG.debug("-------------------------------------------");
- LOG.debug("LinkOverutilized notification ........");
- LOG.debug("-------------------------------------------");
- }
-
- @Override
- @Deprecated
- @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT")
- public void onLinkRemoved(final LinkRemoved notification) {
- LOG.debug("-------------------------------------------");
- LOG.debug("LinkRemoved notification ........");
- LOG.debug("-------------------------------------------");
- }
-
- @Override
- @Deprecated
- @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT")
- public void onLinkUtilizationNormal(final LinkUtilizationNormal notification) {
- LOG.debug("-------------------------------------------");
- LOG.debug("LinkUtilizationNormal notification ........");
- LOG.debug("-------------------------------------------");
- }
-
+ @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT")
+ private void onNotification(Notification<?> notification) {
+ LOG.debug("-------------------------------------------");
+ LOG.debug("{} notification ........", notification.getClass().getSimpleName());
+ LOG.debug("-------------------------------------------");
}
}