registration of outbound queue handler simplified 44/20944/1
authorMartin Bobak <mbobak@cisco.com>
Thu, 21 May 2015 15:32:27 +0000 (17:32 +0200)
committerMartin Bobak <mbobak@cisco.com>
Fri, 22 May 2015 09:18:50 +0000 (11:18 +0200)
Change-Id: Idfd809354c9f9cd6455662b6ea4de7b5ea449439
Signed-off-by: Martin Bobak <mbobak@cisco.com>
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java

index de5669500b410af82038d45793aa07b6212c123b..e5de49b17297b163764ca03e3bf1bb6c6c755f29 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginTimer;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextClosedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
@@ -175,10 +176,14 @@ public interface DeviceContext extends AutoCloseable,
 
 
     /**
-     * Method registers outbound queue handler that should be invalidated when device context is closed.s
-     * @param outboundQueueHandlerRegistration
+     * Method registers outbound queue provider into current device context's primary connection adapter.
+     *
+     * @param outboundQueueProvider
+     * @param maxQueueDepth
+     * @param barrierNanos
      */
-    void registerOutboundQueueHandler(OutboundQueueHandlerRegistration outboundQueueHandlerRegistration);
+    void registerOutboundQueueProvider(OutboundQueueProvider outboundQueueProvider, int maxQueueDepth, long barrierNanos);
+
 
 }
 
index de860f7e18dacd5a24627275a40153d86ed9e16e..099fbc50d5f03f92d7815474541903985977e296 100644 (file)
@@ -30,6 +30,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
@@ -101,7 +102,7 @@ public class DeviceContextImpl implements DeviceContext {
     private DeviceDisconnectedHandler deviceDisconnectedHandler;
     private final Collection<DeviceContextClosedHandler> closeHandlers = new HashSet<>();
     private NotificationPublishService notificationPublishService;
-    private final OutboundQueue outboundQueueProvider;
+    private OutboundQueue outboundQueueProvider;
     private final MultiMsgCollector multiMsgCollector = new MultiMsgCollectorImpl();
 
     private volatile int outstandingNotificationsAmount = 0;
@@ -116,7 +117,7 @@ public class DeviceContextImpl implements DeviceContext {
     }
 
     @Override
-    public Long getReservedXid() {
+        public Long getReservedXid() {
         return outboundQueueProvider.reserveEntry();
     }
 
@@ -137,7 +138,6 @@ public class DeviceContextImpl implements DeviceContext {
         deviceMeterRegistry = new DeviceMeterRegistryImpl();
         messageSpy = _messageSpy;
         multiMsgCollector.setDeviceReplyProcessor(this);
-        outboundQueueProvider = Preconditions.checkNotNull(primaryConnectionContext.getOutboundQueueProvider());
     }
 
     /**
@@ -444,7 +444,11 @@ public class DeviceContextImpl implements DeviceContext {
     }
 
     @Override
-    public void registerOutboundQueueHandler(final OutboundQueueHandlerRegistration outboundQueueHandlerRegistration) {
-        this.outboundQueueHandlerRegistration = outboundQueueHandlerRegistration;
+    public void registerOutboundQueueProvider(final OutboundQueueProvider outboundQueueProvider, final int maxQueueDepth, final long barrierNanos) {
+        final ConnectionAdapter primaryConnectionAdapter = primaryConnectionContext.getConnectionAdapter();
+        outboundQueueHandlerRegistration = primaryConnectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, maxQueueDepth, barrierNanos);
+        this.outboundQueueProvider = outboundQueueProvider;
+        primaryConnectionContext.setOutboundQueueProvider(outboundQueueProvider);
     }
+
 }
index 358473e3283db983221723db30616f74dae1bf01..754d73c8ec58cf3379d1658aa762293939e9e930 100644 (file)
@@ -168,13 +168,10 @@ public class DeviceManagerImpl implements DeviceManager, AutoCloseable {
         final Short version = connectionContext.getFeatures().getVersion();
         OutboundQueueProvider outboundQueueProvider = new OutboundQueueProviderImpl(version);
 
-        final OutboundQueueHandlerRegistration outboundQueueHandlerRegistration = connectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, maxQueueDepth, barrierNanos);
-        connectionContext.setOutboundQueueProvider(outboundQueueProvider);
-
         final DeviceState deviceState = new DeviceStateImpl(connectionContext.getFeatures(), connectionContext.getNodeId());
 
         final DeviceContext deviceContext = new DeviceContextImpl(connectionContext, deviceState, dataBroker, hashedWheelTimer, messageIntelligenceAgency);
-        deviceContext.registerOutboundQueueHandler(outboundQueueHandlerRegistration);
+        deviceContext.registerOutboundQueueProvider(outboundQueueProvider, maxQueueDepth, barrierNanos);
         deviceContext.setNotificationService(notificationService);
         deviceContext.setNotificationPublishService(notificationPublishService);
         NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceState.getNodeId()).setNodeConnector(Collections.<NodeConnector>emptyList());