DeviceState changes 23/40023/8
authorJozef Bacigal <jbacigal@cisco.com>
Wed, 8 Jun 2016 12:01:50 +0000 (14:01 +0200)
committerJozef Bacigal <jbacigal@cisco.com>
Fri, 17 Jun 2016 11:29:49 +0000 (13:29 +0200)
- basic device info removed from device state
- in device context added method to return device info
- jeopardy flag added to tests

Change-Id: I466f87c595033c72cb588ca3f00d2c222b46070d
Signed-off-by: Jozef Bacigal <jbacigal@cisco.com>
91 files changed:
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceManager.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceState.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/MessageTranslator.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/lifecycle/DeviceContextChangeListener.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/lifecycle/LifecycleConductor.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/lifecycle/RoleChangeListener.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/lifecycle/ServiceChangeListener.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/LifecycleConductorImpl.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
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceStateImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManager.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractMultipartOnTheFlyService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallback.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalGroupServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalMeterServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AggregateFlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInAllTablesService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllGroupsStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterConfigStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesAllPortsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllQueuesOnePortService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/FlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupDescriptionService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupFeaturesService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterFeaturesService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MeterStatsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OneQueueOnePortService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/FlowStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/GroupStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/MeterStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/NodeConnectorStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/QueueStatisticsToNotificationTransformer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/FlowDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/GroupDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/MeterDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/NodeConnectorDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/QueueDirectStatisticsService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/AggregatedFlowStatisticsTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedV10Translator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtils.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/LifecycleConductorImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceStateImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/FlowCapableTransactionServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/PacketProcessingServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalExperimenterMessageServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalRoleServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractStatsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl2Test.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringOnTheFlyServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/AbstractDirectStatisticsServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/AggregatedFlowStatisticsTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilsTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java

index 81c2ce6f454a3b9eba016b85a769f998965e8ab6..0a38e6e9c6330f948345f62443fa76c67a8133c9 100644 (file)
@@ -103,6 +103,8 @@ public interface DeviceContext extends AutoCloseable,
      */
     DeviceState getDeviceState();
 
+    DeviceInfo getDeviceInfo();
+
     /**
      * Method has to activate (MASTER) or deactivate (SLAVE) TransactionChainManager.
      * TransactionChainManager represents possibility to write or delete Node subtree data
index 15d59383eb906dbbaf6f8fc9d0449f99bc6c2df7..0e199c26f8adb591e564a9982342c4241b72d6ba 100644 (file)
@@ -15,7 +15,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitia
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.translator.TranslatorLibrarian;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 
 /**
  * This interface is responsible for instantiating DeviceContext and
@@ -42,10 +41,10 @@ public interface DeviceManager extends DeviceConnectedHandler, DeviceDisconnecte
      * Returning device context from map maintained in device manager
      * This prevent to send whole device context to another context
      * If device context not exists for nodeId it will return null
-     * @param nodeId
-     * @return device context or null
+     *
+     * @param deviceInfo@return device context or null
      */
-    DeviceContext getDeviceContextFromNodeId(NodeId nodeId);
+    DeviceContext getDeviceContextFromNodeId(DeviceInfo deviceInfo);
 
     void setStatisticsRpcEnabled(boolean isStatisticsRpcEnabled);
 }
index 36161c386ad0e7b14d38240d54e1d3f6e23eb384..118ec6684b65bd4cd7950a174643728e37c7f9b3 100644 (file)
@@ -15,25 +15,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
 /**
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
+ * Holder of device's structure
  */
 public interface DeviceState {
 
-    /**
-     * @return id of encapsulated node
-     */
-    NodeId getNodeId();
-
-    /**
-     * @return {@link Node} instance identifier
-     */
-    KeyedInstanceIdentifier<Node, NodeKey> getNodeInstanceIdentifier();
-
-    /**
-     * @return the features of corresponding switch
-     */
-    GetFeaturesOutput getFeatures();
-
     /**
      * @return true if this session is valid
      */
@@ -44,13 +29,6 @@ public interface DeviceState {
      */
     void setValid(boolean valid);
 
-    /**
-     * Return node current OF protocol version
-     *
-     * @return
-     */
-    short getVersion();
-
     /**
      * Return true if we have relevant meter information
      * from device
index 4738218827153ce24a9390523a25dc4cee0a0d1d..2dea3a85ee8a2891f67adc9318757475ebf5dcce 100644 (file)
@@ -18,10 +18,10 @@ public interface MessageTranslator<I, O> {
     /**
      * Translates from input to output
      * @param input
-     * @param deviceState
+     * @param deviceInfo
      * @param connectionDistinguisher
      * @return message of output type
      */
-    O translate(I input, DeviceState deviceState, Object connectionDistinguisher);
+    O translate(I input, DeviceInfo deviceInfo, Object connectionDistinguisher);
 
 }
index 19854c7913a1f91eb6307f08043d7d708f8d916a..33d63b78617a330ad83ba6030325e45ade03a3da 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.openflowplugin.api.openflow.lifecycle;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 
 /**
  * This API is for all listeners who wish to know about device context in cluster
@@ -17,16 +17,16 @@ public interface DeviceContextChangeListener {
 
     /**
      * Notification about start phase in device context, right after successful handshake
-     * @param nodeId
+     * @param deviceInfo
      * @param success or failure
      */
-    void deviceStartInitializationDone(final NodeId nodeId, final boolean success);
+    void deviceStartInitializationDone(final DeviceInfo deviceInfo, final boolean success);
 
     /**
      * Notification about start phase in device context, after all other contexts initialized properly
-     * @param nodeId
+     * @param deviceInfo
      * @param success
      */
-    void deviceInitializationDone(final NodeId nodeId, final boolean success);
+    void deviceInitializationDone(final DeviceInfo deviceInfo, final boolean success);
 
 }
index 879bd63acd20635160c810159ac55ed850263225..05e67d86a838f6ecf4211517be626ca91ae20790 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.api.openflow.lifecycle;
 import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageIntelligenceAgency;
@@ -27,24 +28,24 @@ public interface LifecycleConductor {
 
     /**
      * Returns device context from device manager device contexts maps
-     * @param nodeId node identification
-     * @return null if context doesn't exists
+     *
+     * @param deviceInfo@return null if context doesn't exists
      */
-    DeviceContext getDeviceContext(final NodeId nodeId);
+    DeviceContext getDeviceContext(DeviceInfo deviceInfo);
 
     /**
      * Registers ont time listener for notify when services rpc, statistics are done stop or start
      * @param manager service change listener
-     * @param nodeId node identification
+     * @param deviceInfo node identification
      */
-    void addOneTimeListenerWhenServicesChangesDone(final ServiceChangeListener manager, final NodeId nodeId);
+    void addOneTimeListenerWhenServicesChangesDone(final ServiceChangeListener manager, final DeviceInfo deviceInfo);
 
     /**
      * Returns device of version
-     * @param nodeId node identification
+     * @param deviceInfo node identification
      * @return null if device context doesn't exists
      */
-    Short gainVersionSafely(final NodeId nodeId);
+    Short gainVersionSafely(final DeviceInfo deviceInfo);
 
     /**
      * Set new timeout for {@link io.netty.util.HashedWheelTimer}
@@ -63,9 +64,9 @@ public interface LifecycleConductor {
 
     /**
      * Interrupt connection for the node
-     * @param nodeId node identification
+     * @param deviceInfo node identification
      */
-    void closeConnection(final NodeId nodeId);
+    void closeConnection(final DeviceInfo deviceInfo);
 
     /**
      * Setter for device manager once set it cant be unset or overwritten
@@ -81,8 +82,8 @@ public interface LifecycleConductor {
 
     /**
      * Xid from outboundqueue
-     * @param nodeId
+     * @param deviceInfo
      * @return
      */
-    Long reserveXidForDeviceMessage(final NodeId nodeId);
+    Long reserveXidForDeviceMessage(final DeviceInfo deviceInfo);
 }
index f830966234d3889cff9bef183ebc3e0d54249d88..77ad9fa3e62dc43d626fbbad986eb786808e2262 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.openflowplugin.api.openflow.lifecycle;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 /**
@@ -18,18 +18,18 @@ public interface RoleChangeListener {
 
     /**
      * Notification when initialization for role context is done
-     * @param nodeId
+     * @param deviceInfo
      * @param success or failure
      */
-    void roleInitializationDone(final NodeId nodeId, final boolean success);
+    void roleInitializationDone(final DeviceInfo deviceInfo, final boolean success);
 
     /**
      * Notification when the role change on device is done
-     * @param nodeId
+     * @param deviceInfo
      * @param success
      * @param newRole
      * @param initializationPhase
      */
-    void roleChangeOnDevice(final NodeId nodeId, final boolean success, final OfpRole newRole, final boolean initializationPhase);
+    void roleChangeOnDevice(final DeviceInfo deviceInfo, final boolean success, final OfpRole newRole, final boolean initializationPhase);
 
 }
index 5afe5bba906f3711621ea42a8136bc50df8129d2..ae94d4be7cd5d9fe2b17ff051ba2914090b46543 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.openflowplugin.api.openflow.lifecycle;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 
 /**
  * This API is defined for listening when services (Statistics and RPCs) are fully stopped
@@ -18,9 +18,9 @@ public interface ServiceChangeListener {
 
     /**
      * Notification when services (rpc, statistics) are started or stopped working
-     * @param nodeId
+     * @param deviceInfo
      * @param success
      */
-    void servicesChangeDone(NodeId nodeId, boolean success);
+    void servicesChangeDone(DeviceInfo deviceInfo, boolean success);
 
 }
index d3ce2b7590feba389ca3408d3f5715a5ad80ea86..dfcf5c732778fbb08afe4037ac4111cb6f39323b 100644 (file)
@@ -23,6 +23,7 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.DeviceContextChangeListener;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
@@ -46,7 +47,7 @@ public final class LifecycleConductorImpl implements LifecycleConductor, RoleCha
     private final HashedWheelTimer hashedWheelTimer = new HashedWheelTimer(TICK_DURATION, TimeUnit.MILLISECONDS, TICKS_PER_WHEEL);
     private DeviceManager deviceManager;
     private final MessageIntelligenceAgency messageIntelligenceAgency;
-    private ConcurrentHashMap<NodeId, ServiceChangeListener> serviceChangeListeners = new ConcurrentHashMap<>();
+    private ConcurrentHashMap<DeviceInfo, ServiceChangeListener> serviceChangeListeners = new ConcurrentHashMap<>();
     private StatisticsManager statisticsManager;
 
     public LifecycleConductorImpl(final MessageIntelligenceAgency messageIntelligenceAgency) {
@@ -66,63 +67,63 @@ public final class LifecycleConductorImpl implements LifecycleConductor, RoleCha
         }
     }
 
-    public void addOneTimeListenerWhenServicesChangesDone(final ServiceChangeListener manager, final NodeId nodeId){
-        LOG.debug("Listener {} for service change for node {} registered.", manager, nodeId);
-        serviceChangeListeners.put(nodeId, manager);
+    public void addOneTimeListenerWhenServicesChangesDone(final ServiceChangeListener manager, final DeviceInfo deviceInfo){
+        LOG.debug("Listener {} for service change for node {} registered.", manager, deviceInfo.getNodeId());
+        serviceChangeListeners.put(deviceInfo, manager);
     }
 
     @VisibleForTesting
-    void notifyServiceChangeListeners(final NodeId nodeId, final boolean success){
+    void notifyServiceChangeListeners(final DeviceInfo deviceInfo, final boolean success){
         if (serviceChangeListeners.size() == 0) {
             return;
         }
         LOG.debug("Notifying registered listeners for service change, no. of listeners {}", serviceChangeListeners.size());
-        for (final Map.Entry<NodeId, ServiceChangeListener> nodeIdServiceChangeListenerEntry : serviceChangeListeners.entrySet()) {
-            if (nodeIdServiceChangeListenerEntry.getKey().equals(nodeId)) {
-                LOG.debug("Listener {} for service change for node {} was notified. Success was set on {}", nodeIdServiceChangeListenerEntry.getValue(), nodeId, success);
-                nodeIdServiceChangeListenerEntry.getValue().servicesChangeDone(nodeId, success);
-                serviceChangeListeners.remove(nodeId);
+        for (final Map.Entry<DeviceInfo, ServiceChangeListener> nodeIdServiceChangeListenerEntry : serviceChangeListeners.entrySet()) {
+            if (nodeIdServiceChangeListenerEntry.getKey().equals(deviceInfo)) {
+                LOG.debug("Listener {} for service change for node {} was notified. Success was set on {}", nodeIdServiceChangeListenerEntry.getValue(), deviceInfo, success);
+                nodeIdServiceChangeListenerEntry.getValue().servicesChangeDone(deviceInfo, success);
+                serviceChangeListeners.remove(deviceInfo);
             }
         }
     }
 
     @Override
-    public void roleInitializationDone(final NodeId nodeId, final boolean success) {
+    public void roleInitializationDone(final DeviceInfo deviceInfo, final boolean success) {
         if (!success) {
-            LOG.warn("Initialization phase for node {} in role context was NOT successful, closing connection.", nodeId);
-            closeConnection(nodeId);
+            LOG.warn("Initialization phase for node {} in role context was NOT successful, closing connection.", deviceInfo);
+            closeConnection(deviceInfo);
         } else {
-            LOG.info("initialization phase for node {} in role context was successful, continuing to next context.", nodeId);
+            LOG.info("initialization phase for node {} in role context was successful, continuing to next context.", deviceInfo);
         }
     }
 
-    public void closeConnection(final NodeId nodeId) {
-        LOG.debug("Close connection called for node {}", nodeId);
-        final DeviceContext deviceContext = getDeviceContext(nodeId);
+    public void closeConnection(final DeviceInfo deviceInfo) {
+        LOG.debug("Close connection called for node {}", deviceInfo);
+        final DeviceContext deviceContext = getDeviceContext(deviceInfo);
         if (null != deviceContext) {
             deviceContext.shutdownConnection();
         }
     }
 
     @Override
-    public void roleChangeOnDevice(final NodeId nodeId, final boolean success, final OfpRole newRole, final boolean initializationPhase) {
+    public void roleChangeOnDevice(final DeviceInfo deviceInfo, final boolean success, final OfpRole newRole, final boolean initializationPhase) {
 
-        final DeviceContext deviceContext = getDeviceContext(nodeId);
+        final DeviceContext deviceContext = getDeviceContext(deviceInfo);
 
         if (null == deviceContext) {
             LOG.warn("Something went wrong, device context for nodeId: {} doesn't exists");
             return;
         }
         if (!success) {
-            LOG.warn("Role change to {} in role context for node {} was NOT successful, closing connection", newRole, nodeId);
-            closeConnection(nodeId);
+            LOG.warn("Role change to {} in role context for node {} was NOT successful, closing connection", newRole, deviceInfo);
+            closeConnection(deviceInfo);
         } else {
             if (initializationPhase) {
                 LOG.debug("Initialization phase skipping starting services.");
                 return;
             }
 
-            LOG.info("Role change to {} in role context for node {} was successful, starting/stopping services.", newRole, nodeId);
+            LOG.info("Role change to {} in role context for node {} was successful, starting/stopping services.", newRole, deviceInfo);
 
             if (OfpRole.BECOMEMASTER.equals(newRole)) {
                 statisticsManager.startScheduling(deviceContext.getPrimaryConnectionContext().getDeviceInfo());
@@ -134,14 +135,14 @@ public final class LifecycleConductorImpl implements LifecycleConductor, RoleCha
             Futures.addCallback(onClusterRoleChange, new FutureCallback<Void>() {
                 @Override
                 public void onSuccess(@Nullable final Void aVoid) {
-                    LOG.info("Starting/Stopping services for node {} was successful", nodeId);
-                    if (newRole.equals(OfpRole.BECOMESLAVE)) notifyServiceChangeListeners(nodeId, true);
+                    LOG.info("Starting/Stopping services for node {} was successful", deviceInfo);
+                    if (newRole.equals(OfpRole.BECOMESLAVE)) notifyServiceChangeListeners(deviceInfo, true);
                 }
 
                 @Override
                 public void onFailure(final Throwable throwable) {
-                    LOG.warn("Starting/Stopping services for node {} was NOT successful, closing connection", nodeId);
-                    closeConnection(nodeId);
+                    LOG.warn("Starting/Stopping services for node {} was NOT successful, closing connection", deviceInfo);
+                    closeConnection(deviceInfo);
                 }
             });
         }
@@ -152,43 +153,45 @@ public final class LifecycleConductorImpl implements LifecycleConductor, RoleCha
     }
 
     @Override
-    public DeviceContext getDeviceContext(final NodeId nodeId){
-         return deviceManager.getDeviceContextFromNodeId(nodeId);
+    public DeviceContext getDeviceContext(DeviceInfo deviceInfo){
+         return deviceManager.getDeviceContextFromNodeId(deviceInfo);
     }
 
-    public Short gainVersionSafely(final NodeId nodeId) {
-        return (null != getDeviceContext(nodeId)) ? getDeviceContext(nodeId).getPrimaryConnectionContext().getFeatures().getVersion() : null;
+    @Override
+    public Short gainVersionSafely(final DeviceInfo deviceInfo) {
+        return (null != getDeviceContext(deviceInfo)) ? getDeviceContext(deviceInfo).getPrimaryConnectionContext().getFeatures().getVersion() : null;
     }
 
     public Timeout newTimeout(@Nonnull TimerTask task, long delay, @Nonnull TimeUnit unit) {
         return hashedWheelTimer.newTimeout(task, delay, unit);
     }
 
-    public ConnectionContext.CONNECTION_STATE gainConnectionStateSafely(final NodeId nodeId){
-        return (null != getDeviceContext(nodeId)) ? getDeviceContext(nodeId).getPrimaryConnectionContext().getConnectionState() : null;
+    ConnectionContext.CONNECTION_STATE gainConnectionStateSafely(final DeviceInfo deviceInfo){
+        return (null != getDeviceContext(deviceInfo)) ? getDeviceContext(deviceInfo).getPrimaryConnectionContext().getConnectionState() : null;
     }
 
-    public Long reserveXidForDeviceMessage(final NodeId nodeId){
-        return null != getDeviceContext(nodeId) ? getDeviceContext(nodeId).reserveXidForDeviceMessage() : null;
+    @Override
+    public Long reserveXidForDeviceMessage(final DeviceInfo deviceInfo){
+        return null != getDeviceContext(deviceInfo) ? getDeviceContext(deviceInfo).reserveXidForDeviceMessage() : null;
     }
 
     @Override
-    public void deviceStartInitializationDone(final NodeId nodeId, final boolean success) {
+    public void deviceStartInitializationDone(final DeviceInfo deviceInfo, final boolean success) {
         if (!success) {
-            LOG.warn("Initialization phase for node {} in device context was NOT successful, closing connection.", nodeId);
-            closeConnection(nodeId);
+            LOG.warn("Initialization phase for node {} in device context was NOT successful, closing connection.", deviceInfo);
+            closeConnection(deviceInfo);
         } else {
-            LOG.info("initialization phase for node {} in device context was successful. Continuing to next context.", nodeId);
+            LOG.info("initialization phase for node {} in device context was successful. Continuing to next context.", deviceInfo);
         }
     }
 
     @Override
-    public void deviceInitializationDone(final NodeId nodeId, final boolean success) {
+    public void deviceInitializationDone(final DeviceInfo deviceInfo, final boolean success) {
         if (!success) {
-            LOG.warn("Initialization phase for node {} in device context was NOT successful, closing connection.", nodeId);
-            closeConnection(nodeId);
+            LOG.warn("Initialization phase for node {} in device context was NOT successful, closing connection.", deviceInfo);
+            closeConnection(deviceInfo);
         } else {
-            LOG.info("initialization phase for node {} in device context was successful. All phases initialized OK.", nodeId);
+            LOG.info("initialization phase for node {} in device context was successful. All phases initialized OK.", deviceInfo);
         }
     }
 
index 28f0bf1499ff5e320b61c9bebfac3df61aac5f21..7b0851c789c62ac32e561f139cb766bfbb6eb1e7 100644 (file)
@@ -165,23 +165,25 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
         Preconditions.checkNotNull(conductor);
         this.outboundQueueProvider = Preconditions.checkNotNull(outboundQueueProvider);
-        this.transactionChainManager = new TransactionChainManager(dataBroker, deviceState, conductor);
+        deviceInfo = primaryConnectionContext.getDeviceInfo();
+        this.transactionChainManager = new TransactionChainManager(dataBroker, deviceInfo, conductor);
         auxiliaryConnectionContexts = new HashMap<>();
         deviceFlowRegistry = new DeviceFlowRegistryImpl();
         deviceGroupRegistry = new DeviceGroupRegistryImpl();
         deviceMeterRegistry = new DeviceMeterRegistryImpl();
         messageSpy = conductor.getMessageIntelligenceAgency();
 
+
         packetInLimiter = new PacketInRateLimiter(primaryConnectionContext.getConnectionAdapter(),
                 /*initial*/ 1000, /*initial*/2000, messageSpy, REJECTED_DRAIN_FACTOR);
 
         this.translatorLibrary = translatorLibrary;
         portStatusTranslator = translatorLibrary.lookupTranslator(
-                new TranslatorKey(deviceState.getVersion(), PortGrouping.class.getName()));
+                new TranslatorKey(deviceInfo.getVersion(), PortGrouping.class.getName()));
         packetInTranslator = translatorLibrary.lookupTranslator(
-                new TranslatorKey(deviceState.getVersion(), PacketIn.class.getName()));
+                new TranslatorKey(deviceInfo.getVersion(), PacketIn.class.getName()));
         flowRemovedTranslator = translatorLibrary.lookupTranslator(
-                new TranslatorKey(deviceState.getVersion(), FlowRemoved.class.getName()));
+                new TranslatorKey(deviceInfo.getVersion(), FlowRemoved.class.getName()));
 
 
         nodeConnectorCache = new ConcurrentHashMap<>();
@@ -190,7 +192,6 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         flowLifeCycleKeeper = new ItemLifeCycleSourceImpl();
         itemLifeCycleSourceRegistry.registerLifeCycleSource(flowLifeCycleKeeper);
         deviceCtxState = DEVICE_CONTEXT_STATE.INITIALIZATION;
-        deviceInfo = primaryConnectionContext.getDeviceInfo();
     }
 
     /**
@@ -229,6 +230,11 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         return deviceState;
     }
 
+    @Override
+    public DeviceInfo getDeviceInfo() {
+        return this.deviceInfo;
+    }
+
     @Override
     public ReadOnlyTransaction getReadTransaction() {
         return dataBroker.newReadOnlyTransaction();
@@ -309,13 +315,13 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
             public Void apply(final Boolean input) {
                 if (ConnectionContext.CONNECTION_STATE.RIP.equals(getPrimaryConnectionContext().getConnectionState())) {
                     final String errMsg = String.format("We lost connection for Device %s, context has to be closed.",
-                            getDeviceState().getNodeId());
+                            getDeviceInfo().getNodeId());
                     LOG.warn(errMsg);
                     throw new IllegalStateException(errMsg);
                 }
                 if (!input) {
                     final String errMsg = String.format("Get Initial Device %s information fails",
-                            getDeviceState().getNodeId());
+                            getDeviceInfo().getNodeId());
                     LOG.warn(errMsg);
                     throw new IllegalStateException(errMsg);
                 }
@@ -396,7 +402,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         if (itemLifecycleListener != null) {
             //1. translate to general flow (table, priority, match, cookie)
             final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved flowRemovedNotification =
-                    flowRemovedTranslator.translate(flowRemoved, this.getDeviceState(), null);
+                    flowRemovedTranslator.translate(flowRemoved, deviceInfo, null);
             //2. create registry key
             final FlowRegistryKey flowRegKey = FlowRegistryKeyFactory.create(flowRemovedNotification);
             //3. lookup flowId
@@ -404,7 +410,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
             //4. if flowId present:
             if (flowDescriptor != null) {
                 // a) construct flow path
-                final KeyedInstanceIdentifier<Flow, FlowKey> flowPath = getDeviceState().getNodeInstanceIdentifier()
+                final KeyedInstanceIdentifier<Flow, FlowKey> flowPath = getDeviceInfo().getNodeInstanceIdentifier()
                         .augmentation(FlowCapableNode.class)
                         .child(Table.class, flowDescriptor.getTableKey())
                         .child(Flow.class, new FlowKey(flowDescriptor.getFlowId()));
@@ -414,7 +420,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
                 notificationPublishService.offerNotification(flowRemovedNotification);
             } else {
                 LOG.debug("flow id not found: nodeId={} tableId={}, priority={}",
-                        getDeviceState().getNodeId(), flowRegKey.getTableId(), flowRemovedNotification.getPriority());
+                        getDeviceInfo().getNodeId(), flowRegKey.getTableId(), flowRemovedNotification.getPriority());
             }
         }
     }
@@ -422,7 +428,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     @Override
     public void processPortStatusMessage(final PortStatusMessage portStatus) {
         messageSpy.spyMessage(portStatus.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS);
-        final FlowCapableNodeConnector flowCapableNodeConnector = portStatusTranslator.translate(portStatus, this.getDeviceState(), null);
+        final FlowCapableNodeConnector flowCapableNodeConnector = portStatusTranslator.translate(portStatus, deviceInfo, null);
 
         final KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> iiToNodeConnector = provideIIToNodeConnector(portStatus.getPortNo(), portStatus.getVersion());
         try {
@@ -442,8 +448,8 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     }
 
     private KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> provideIIToNodeConnector(final long portNo, final short version) {
-        final InstanceIdentifier<Node> iiToNodes = deviceState.getNodeInstanceIdentifier();
-        final BigInteger dataPathId = deviceState.getFeatures().getDatapathId();
+        final InstanceIdentifier<Node> iiToNodes = deviceInfo.getNodeInstanceIdentifier();
+        final BigInteger dataPathId = deviceInfo.getDatapathId();
         final NodeConnectorId nodeConnectorId = NodeStaticReplyTranslatorUtil.nodeConnectorId(dataPathId.toString(), portNo, version);
         return iiToNodes.child(NodeConnector.class, new NodeConnectorKey(nodeConnectorId));
     }
@@ -452,7 +458,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     public void processPacketInMessage(final PacketInMessage packetInMessage) {
         messageSpy.spyMessage(packetInMessage.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH);
         final ConnectionAdapter connectionAdapter = getPrimaryConnectionContext().getConnectionAdapter();
-        final PacketReceived packetReceived = packetInTranslator.translate(packetInMessage, this.getDeviceState(), null);
+        final PacketReceived packetReceived = packetInTranslator.translate(packetInMessage, deviceInfo, null);
 
         if (packetReceived == null) {
             LOG.debug("Received a null packet from switch {}", connectionAdapter.getRemoteAddress());
@@ -500,13 +506,13 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         // lookup converter
         final ExperimenterDataOfChoice vendorData = notification.getExperimenterDataOfChoice();
         final MessageTypeKey<? extends ExperimenterDataOfChoice> key = new MessageTypeKey<>(
-                deviceState.getVersion(),
+                deviceInfo.getVersion(),
                 (Class<? extends ExperimenterDataOfChoice>) vendorData.getImplementedInterface());
         final ConvertorMessageFromOFJava<ExperimenterDataOfChoice, MessagePath> messageConverter = extensionConverterProvider.getMessageConverter(key);
         if (messageConverter == null) {
             LOG.warn("custom converter for {}[OF:{}] not found",
                     notification.getExperimenterDataOfChoice().getImplementedInterface(),
-                    deviceState.getVersion());
+                    deviceInfo.getVersion());
             return;
         }
         // build notification
@@ -514,7 +520,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         try {
             messageOfChoice = messageConverter.convert(vendorData, MessagePath.MESSAGE_NOTIFICATION);
             final ExperimenterMessageFromDevBuilder experimenterMessageFromDevBld = new ExperimenterMessageFromDevBuilder()
-                .setNode(new NodeRef(deviceState.getNodeInstanceIdentifier()))
+                .setNode(new NodeRef(deviceInfo.getNodeInstanceIdentifier()))
                     .setExperimenterMessageOfChoice(messageOfChoice);
             // publish
             notificationPublishService.offerNotification(experimenterMessageFromDevBld.build());
@@ -532,7 +538,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     public synchronized void close() {
         LOG.debug("closing deviceContext: {}, nodeId:{}",
                 getPrimaryConnectionContext().getConnectionAdapter().getRemoteAddress(),
-                getDeviceState().getNodeId());
+                getDeviceInfo().getNodeId());
         // NOOP
         throw new UnsupportedOperationException("Autocloseble.close will be removed soon");
     }
@@ -635,7 +641,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         deviceCtxState = DEVICE_CONTEXT_STATE.TERMINATION;
 
         if (ConnectionContext.CONNECTION_STATE.RIP.equals(getPrimaryConnectionContext().getConnectionState())) {
-            LOG.debug("ConnectionCtx for Node {} is in RIP state.", deviceState.getNodeId());
+            LOG.debug("ConnectionCtx for Node {} is in RIP state.", deviceInfo.getNodeId());
             return;
         }
         /* Terminate Auxiliary Connection */
index f10cedc18161e82b4e6c91a8fa8c6ce66a0aa9c3..988007a475b430f0eeede494ca1b0e3c9ee4e7ad 100644 (file)
@@ -44,7 +44,6 @@ import org.opendaylight.openflowplugin.extension.api.ExtensionConverterProviderK
 import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
 import org.opendaylight.openflowplugin.impl.connection.OutboundQueueProviderImpl;
 import org.opendaylight.openflowplugin.impl.device.listener.OpenflowProtocolListenerFullImpl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
@@ -156,7 +155,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
                 connectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, barrierCountLimit, barrierIntervalNanos);
         connectionContext.setOutboundQueueHandleRegistration(outboundQueueHandlerRegistration);
 
-        final DeviceState deviceState = createDeviceState(connectionContext);
+        final DeviceState deviceState = new DeviceStateImpl();
         final DeviceContext deviceContext = new DeviceContextImpl(connectionContext,
                 deviceState,
                 dataBroker,
@@ -183,10 +182,6 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         return true;
     }
 
-    private static DeviceStateImpl createDeviceState(final @Nonnull ConnectionContext connectionContext) {
-        return new DeviceStateImpl(connectionContext.getFeatures(), connectionContext.getNodeId());
-    }
-
     private void updatePacketInRateLimiters() {
         synchronized (deviceContexts) {
             final int deviceContextsSize = deviceContexts.size();
@@ -236,7 +231,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     @Override
     public void onDeviceContextLevelDown(final DeviceInfo deviceInfo) {
         LOG.debug("onDeviceContextClosed for Node {}", deviceInfo.getNodeId());
-        deviceContexts.remove(deviceInfo.getNodeId());
+        deviceContexts.remove(deviceInfo);
         updatePacketInRateLimiters();
     }
 
@@ -246,8 +241,8 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     }
 
     @Override
-    public DeviceContext getDeviceContextFromNodeId(final NodeId nodeId) {
-        return deviceContexts.get(nodeId);
+    public DeviceContext getDeviceContextFromNodeId(DeviceInfo deviceInfo) {
+        return deviceContexts.get(deviceInfo);
     }
 
     @Override
index 37768bc5e97d2e1592daaa0a2124cd5b6298858f..5372cc0db9bd28583c2a7b85b3355400d2455b88 100644 (file)
@@ -28,16 +28,9 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
  * DeviceState is builded from {@link FeaturesReply} and {@link NodeId}. Both values are inside
  * {@link org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext}
  *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *         <p/>
- *         Created: Mar 29, 2015
  */
 class DeviceStateImpl implements DeviceState {
 
-    private final GetFeaturesOutput featuresOutput;
-    private final NodeId nodeId;
-    private final KeyedInstanceIdentifier<Node, NodeKey> nodeII;
-    private final short version;
     private boolean valid;
     private boolean meterIsAvailable;
     private boolean groupIsAvailable;
@@ -48,31 +41,11 @@ class DeviceStateImpl implements DeviceState {
     private boolean statPollEnabled;
     private boolean queueStatisticsAvailable;
 
-    public DeviceStateImpl(@CheckForNull final FeaturesReply featuresReply, @Nonnull final NodeId nodeId) {
-        Preconditions.checkArgument(featuresReply != null);
-        featuresOutput = new GetFeaturesOutputBuilder(featuresReply).build();
-        this.nodeId = Preconditions.checkNotNull(nodeId);
-        nodeII = DeviceStateUtil.createNodeInstanceIdentifier(nodeId);
-        version = featuresReply.getVersion();
+    DeviceStateImpl() {
         statPollEnabled = false;
         deviceSynchronized = false;
     }
 
-    @Override
-    public NodeId getNodeId() {
-        return nodeId;
-    }
-
-    @Override
-    public KeyedInstanceIdentifier<Node, NodeKey> getNodeInstanceIdentifier() {
-        return nodeII;
-    }
-
-    @Override
-    public GetFeaturesOutput getFeatures() {
-        return featuresOutput;
-    }
-
     @Override
     public boolean isValid() {
         return valid;
@@ -83,11 +56,6 @@ class DeviceStateImpl implements DeviceState {
         this.valid = valid;
     }
 
-    @Override
-    public short getVersion() {
-        return version;
-    }
-
     @Override
     public boolean isMetersAvailable() {
         return meterIsAvailable;
index d85dab8f59632457938b55b0344792df1767e0c4..99f7fd31dedf909d1fba844ecbb46858d2c6fbb3 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
@@ -55,6 +55,7 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
 
     private final Object txLock = new Object();
     private final KeyedInstanceIdentifier<Node, NodeKey> nodeII;
+    private final DeviceInfo deviceInfo;
     private final DataBroker dataBroker;
     private final LifecycleConductor conductor;
 
@@ -77,14 +78,15 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
     private TransactionChainManagerStatus transactionChainManagerStatus = TransactionChainManagerStatus.SLEEPING;
 
     TransactionChainManager(@Nonnull final DataBroker dataBroker,
-                            @Nonnull final DeviceState deviceState,
+                            @Nonnull final DeviceInfo deviceInfo,
                             @Nonnull final LifecycleConductor conductor) {
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
         this.conductor = Preconditions.checkNotNull(conductor);
-        this.nodeII = Preconditions.checkNotNull(deviceState.getNodeInstanceIdentifier());
+        this.deviceInfo = deviceInfo;
+        this.nodeII = deviceInfo.getNodeInstanceIdentifier();
         this.transactionChainManagerStatus = TransactionChainManagerStatus.SLEEPING;
         lastSubmittedFuture = Futures.immediateFuture(null);
-        LOG.debug("created txChainManager for {}", nodeII);
+        LOG.debug("created txChainManager for {}", this.nodeII);
     }
 
     private NodeId nodeId() {
@@ -192,7 +194,7 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable
                     }
                     if (initCommit) {
                         LOG.error("Initial commit failed. {}", t);
-                        conductor.closeConnection(nodeId());
+                        conductor.closeConnection(deviceInfo);
                     }
                 }
             });
index 9950a304921d9d7b637a5642dc6d58394e6653b1..e0392a7cc95dce245b214aaa9b9e2ca55d0e8e26 100644 (file)
@@ -76,7 +76,7 @@ class RoleContextImpl implements RoleContext {
     @Nullable
     @Override
     public <T> RequestContext<T> createRequestContext() {
-        return new AbstractRequestContext<T>(conductor.reserveXidForDeviceMessage(deviceInfo.getNodeId())) {
+        return new AbstractRequestContext<T>(conductor.reserveXidForDeviceMessage(deviceInfo)) {
             @Override
             public void close() {
             }
index d652c1da3e543ad11af03e8768bfb1139dd489d3..f9b30b50bb2ca985050376db60c6362ed4e01883 100644 (file)
@@ -16,7 +16,6 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
-import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
 
 import java.util.ArrayList;
@@ -98,13 +97,13 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
 
     @Override
     public void onDeviceContextLevelUp(@CheckForNull final DeviceInfo deviceInfo) throws Exception {
-        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(deviceInfo.getNodeId()));
+        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(deviceInfo));
         final RoleContext roleContext = new RoleContextImpl(deviceInfo, entityOwnershipService, makeEntity(deviceInfo.getNodeId()), makeTxEntity(deviceInfo.getNodeId()), conductor);
         roleContext.setSalRoleService(new SalRoleServiceImpl(roleContext, deviceContext));
         Verify.verify(contexts.putIfAbsent(deviceInfo.getNodeId(), roleContext) == null, "Role context for master Node %s is still not closed.", deviceInfo.getNodeId());
         makeDeviceRoleChange(OfpRole.BECOMESLAVE, roleContext, true);
         /* First start to watch entity so we don't miss any notification, and then try to register in EOS */
-        notifyListenersRoleInitializationDone(roleContext.getDeviceInfo().getNodeId(), roleContext.initialization());
+        notifyListenersRoleInitializationDone(roleContext.getDeviceInfo(), roleContext.initialization());
         watchingEntities.put(roleContext.getEntity(), roleContext);
         deviceInitializationPhaseHandler.onDeviceContextLevelUp(deviceInfo);
     }
@@ -194,7 +193,7 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
             } else if ((ownershipChange.wasOwner() && !ownershipChange.isOwner()) || (ownershipChange.inJeopardy())) {
                 // MASTER -> SLAVE
                 LOG.debug("MASTER to SLAVE for node {}", roleContext.getDeviceInfo().getNodeId());
-                conductor.addOneTimeListenerWhenServicesChangesDone(this, roleContext.getDeviceInfo().getNodeId());
+                conductor.addOneTimeListenerWhenServicesChangesDone(this, roleContext.getDeviceInfo());
                 makeDeviceRoleChange(OfpRole.BECOMESLAVE, roleContext, false);
             }
         } else {
@@ -212,7 +211,7 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
                 final NodeId nodeId = roleContext.getDeviceInfo().getNodeId();
                 contexts.remove(nodeId, roleContext);
                 roleContext.close();
-                conductor.closeConnection(nodeId);
+                conductor.closeConnection(roleContext.getDeviceInfo());
             }
         }
     }
@@ -250,7 +249,7 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
                         final NodeId nodeId = roleContext.getDeviceInfo().getNodeId();
                         contexts.remove(nodeId, roleContext);
                         roleContext.close();
-                        conductor.closeConnection(nodeId);
+                        conductor.closeConnection(roleContext.getDeviceInfo());
                     }
                 }
             }
@@ -260,7 +259,7 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
             final NodeId nodeId = roleContext.getDeviceInfo().getNodeId();
             contexts.remove(nodeId, roleContext);
             roleContext.close();
-            conductor.closeConnection(nodeId);
+            conductor.closeConnection(roleContext.getDeviceInfo());
         }
     }
 
@@ -271,13 +270,13 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
             @Override
             public void onSuccess(@Nullable final RpcResult<SetRoleOutput> setRoleOutputRpcResult) {
                 LOG.info("Role {} successfully set on device {}", role, roleContext.getDeviceInfo().getNodeId());
-                notifyListenersRoleChangeOnDevice(roleContext.getDeviceInfo().getNodeId(), true, role, init);
+                notifyListenersRoleChangeOnDevice(roleContext.getDeviceInfo(), true, role, init);
             }
 
             @Override
             public void onFailure(@Nonnull final Throwable throwable) {
                 LOG.warn("Unable to set role {} on device {}", role, roleContext.getDeviceInfo().getNodeId());
-                notifyListenersRoleChangeOnDevice(roleContext.getDeviceInfo().getNodeId(), false, role, init);
+                notifyListenersRoleChangeOnDevice(roleContext.getDeviceInfo(), false, role, init);
             }
         });
     }
@@ -286,7 +285,7 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
     ListenableFuture<RpcResult<SetRoleOutput>> sendRoleChangeToDevice(final OfpRole newRole, final RoleContext roleContext) {
         LOG.debug("Sending new role {} to device {}", newRole, roleContext.getDeviceInfo().getNodeId());
         final Future<RpcResult<SetRoleOutput>> setRoleOutputFuture;
-        final Short version = conductor.gainVersionSafely(roleContext.getDeviceInfo().getNodeId());
+        final Short version = conductor.gainVersionSafely(roleContext.getDeviceInfo());
         if (null == version) {
             LOG.debug("Device version is null");
             return Futures.immediateFuture(null);
@@ -298,14 +297,10 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
             final SetRoleInput setRoleInput = (new SetRoleInputBuilder()).setControllerRole(newRole)
                     .setNode(new NodeRef(DeviceStateUtil.createNodeInstanceIdentifier(roleContext.getDeviceInfo().getNodeId()))).build();
             setRoleOutputFuture = roleContext.getSalRoleService().setRole(setRoleInput);
-            final TimerTask timerTask = new TimerTask() {
-
-                @Override
-                public void run(final Timeout timeout) throws Exception {
-                    if (!setRoleOutputFuture.isDone()) {
-                        LOG.warn("New role {} was not propagated to device {} during 10 sec", newRole, roleContext.getDeviceInfo().getNodeId());
-                        setRoleOutputFuture.cancel(true);
-                    }
+            final TimerTask timerTask = timeout -> {
+                if (!setRoleOutputFuture.isDone()) {
+                    LOG.warn("New role {} was not propagated to device {} during 10 sec", newRole, roleContext.getDeviceInfo().getNodeId());
+                    setRoleOutputFuture.cancel(true);
                 }
             };
             conductor.newTimeout(timerTask, 10, TimeUnit.SECONDS);
@@ -349,9 +344,9 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
     }
 
     @Override
-    public void servicesChangeDone(final NodeId nodeId, final boolean success) {
-        LOG.debug("Services stopping done for node {} as " + (success ? "successful" : "unsuccessful"), nodeId);
-        final RoleContext roleContext = contexts.get(nodeId);
+    public void servicesChangeDone(final DeviceInfo deviceInfo, final boolean success) {
+        LOG.debug("Services stopping done for node {} as " + (success ? "successful" : "unsuccessful"), deviceInfo);
+        final RoleContext roleContext = contexts.get(deviceInfo.getNodeId());
         if (null != roleContext) {
             /* Services stopped or failure */
             roleContext.unregisterCandidate(roleContext.getTxEntity());
@@ -380,29 +375,30 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener, Se
 
     /**
      * Invoked when initialization phase is done
-     * @param nodeId node identification
+     * @param deviceInfo node identification
      * @param success true if initialization done ok, false otherwise
      */
     @VisibleForTesting
-    void notifyListenersRoleInitializationDone(final NodeId nodeId, final boolean success){
+    void notifyListenersRoleInitializationDone(final DeviceInfo deviceInfo, final boolean success){
         LOG.debug("Notifying registered listeners for role initialization done, no. of listeners {}", listeners.size());
         for (final RoleChangeListener listener : listeners) {
-            listener.roleInitializationDone(nodeId, success);
+            listener.roleInitializationDone(deviceInfo, success);
         }
     }
 
     /**
      * Notifies registered listener on role change. Role is the new role on device
      * If initialization phase is true, we may skip service starting
+     * @param deviceInfo
      * @param success true if role change on device done ok, false otherwise
      * @param role new role meant to be set on device
      * @param initializationPhase if true, then skipp services start
      */
     @VisibleForTesting
-    void notifyListenersRoleChangeOnDevice(final NodeId nodeId, final boolean success, final OfpRole role, final boolean initializationPhase){
+    void notifyListenersRoleChangeOnDevice(final DeviceInfo deviceInfo, final boolean success, final OfpRole role, final boolean initializationPhase){
         LOG.debug("Notifying registered listeners for role change, no. of listeners {}", listeners.size());
         for (final RoleChangeListener listener : listeners) {
-            listener.roleChangeOnDevice(nodeId, success, role, initializationPhase);
+            listener.roleChangeOnDevice(deviceInfo, success, role, initializationPhase);
         }
     }
 
index 81916fc8ed11bb554be504c0bdd96e67061f2f22..bab33a358fb162f9cfc314f81f745e6d8bbcab2a 100644 (file)
@@ -52,14 +52,14 @@ public class RpcManagerImpl implements RpcManager {
     @Override
     public void onDeviceContextLevelUp(final DeviceInfo deviceInfo) throws Exception {
 
-        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(deviceInfo.getNodeId()));
+        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(deviceInfo));
 
         final RpcContext rpcContext = new RpcContextImpl(
                 rpcProviderRegistry,
                 deviceContext,
                 deviceContext.getMessageSpy(),
                 maxRequestsQuota,
-                deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                deviceInfo.getNodeInstanceIdentifier());
 
         deviceContext.setRpcContext(rpcContext);
 
index 0d7020030500355cfdb59ed37a07cae73f2b83b7..9f6747364ab838aaa7f006cf68cbd180733793ee 100644 (file)
@@ -24,8 +24,8 @@ public abstract class AbstractMultipartOnTheFlyService<I> extends AbstractServic
     @Override
     protected final FutureCallback<OfHeader> createCallback(final RequestContext<List<MultipartReply>> context, final Class<?> requestType) {
         return new MultipartRequestOnTheFlyCallback(context, requestType,
-                getDeviceContext().getMessageSpy(), getEventIdentifier(), getDeviceContext().getDeviceState(),
-                getDeviceContext().getDeviceFlowRegistry(), getDeviceContext());
+                getDeviceContext().getMessageSpy(), getEventIdentifier(), getDeviceContext().getDeviceInfo(),
+                getDeviceContext().getDeviceFlowRegistry(), getDeviceContext(), getDeviceContext().getDeviceState());
     }
 
 
index f1bdbf116da899234e9f5a02b5c49e90875194a6..4f686b447121e829b845b8a441e283c626a99525 100644 (file)
@@ -16,6 +16,7 @@ import java.math.BigInteger;
 import javax.annotation.Nonnull;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -46,15 +47,14 @@ abstract class AbstractService<I, O> {
     private EventIdentifier eventIdentifier;
 
     public AbstractService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-        final DeviceState deviceState = deviceContext.getDeviceState();
-        final GetFeaturesOutput features = deviceState.getFeatures();
+        final DeviceInfo deviceInfo = deviceContext.getDeviceInfo();
 
         this.requestContextStack = requestContextStack;
         this.deviceContext = deviceContext;
-        this.datapathId = features.getDatapathId();
-        this.version = features.getVersion();
+        this.datapathId = deviceInfo.getDatapathId();
+        this.version = deviceInfo.getVersion();
         this.messageSpy = deviceContext.getMessageSpy();
-        this.nodeId = deviceState.getNodeId();
+        this.nodeId = deviceInfo.getNodeId();
     }
 
     public EventIdentifier getEventIdentifier() {
index c00d092f96273335af1233e70141f3213a3a2ce5..d3b34ce520efa9ae2faa4cfcb310812f56b0a91f 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collections;
 import java.util.List;
 
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
@@ -36,29 +37,32 @@ import org.slf4j.LoggerFactory;
 final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<List<MultipartReply>> {
     private static final Logger LOG = LoggerFactory.getLogger(MultipartRequestOnTheFlyCallback.class);
     private static final SinglePurposeMultipartReplyTranslator MULTIPART_REPLY_TRANSLATOR = new SinglePurposeMultipartReplyTranslator();
-    private final DeviceState deviceState;
+    private final DeviceInfo deviceInfo;
     private final DeviceFlowRegistry registry;
     private boolean virgin = true;
     private boolean finished = false;
     private final EventIdentifier doneEventIdentifier;
     private final TxFacade txFacade;
+    private final DeviceState deviceState;
 
 
     public MultipartRequestOnTheFlyCallback(final RequestContext<List<MultipartReply>> context,
                                             final Class<?> requestType,
                                             final MessageSpy messageSpy,
                                             final EventIdentifier eventIdentifier,
-                                            final DeviceState deviceState,
+                                            final DeviceInfo deviceInfo,
                                             final DeviceFlowRegistry registry,
-                                            final TxFacade txFacade) {
+                                            final TxFacade txFacade,
+                                            final DeviceState deviceState) {
         super(context, requestType, messageSpy, eventIdentifier);
 
-        this.deviceState = deviceState;
+        this.deviceInfo = deviceInfo;
         this.registry = registry;
         this.txFacade = txFacade;
+        this.deviceState = deviceState;
 
         //TODO: this is focused on flow stats only - need more general approach if used for more than flow stats
-        doneEventIdentifier = new EventIdentifier(MultipartType.OFPMPFLOW.name(), deviceState.getNodeId().toString());
+        doneEventIdentifier = new EventIdentifier(MultipartType.OFPMPFLOW.name(), deviceInfo.getNodeId().toString());
     }
 
     public EventIdentifier getDoneEventIdentifier() {
@@ -90,13 +94,13 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
 
             final MultipartReply singleReply = multipartReply;
             final List<? extends DataObject> multipartDataList = MULTIPART_REPLY_TRANSLATOR.translate(
-                    deviceState.getFeatures().getDatapathId(), deviceState.getFeatures().getVersion(), singleReply);
+                    deviceInfo.getDatapathId(), deviceInfo.getVersion(), singleReply);
             final Iterable<? extends DataObject> allMultipartData = multipartDataList;
 
             //TODO: following part is focused on flow stats only - need more general approach if used for more than flow stats
             ListenableFuture<Void> future;
             if (virgin) {
-                future = StatisticsGatheringUtils.deleteAllKnownFlows(deviceState, registry, txFacade);
+                future = StatisticsGatheringUtils.deleteAllKnownFlows(deviceInfo, registry, txFacade, deviceState);
                 virgin = false;
             } else {
                 future = Futures.immediateFuture(null);
@@ -107,7 +111,7 @@ final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<Lis
                 @Override
                 public Void apply(final Void input) {
                     StatisticsGatheringUtils.writeFlowStatistics((Iterable<FlowsStatisticsUpdate>) allMultipartData,
-                            deviceState, registry, txFacade);
+                            deviceInfo, registry, txFacade);
 
                     if (!multipartReply.getFlags().isOFPMPFREQMORE()) {
                         endCollecting();
index d89b59781cb53b3e4f6d9655182541062618d11e..cf2a160998321f1077b310cbbf79b142acebecb7 100644 (file)
@@ -97,7 +97,7 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                     }
                     if (itemLifecycleListener != null) {
                         KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
-                                deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
                         final FlowBuilder flowBuilder = new FlowBuilder(input).setId(flowDescriptor.getFlowId());
                         itemLifecycleListener.onAdded(flowPath, flowBuilder.build());
                     }
@@ -136,7 +136,7 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                                 deviceContext.getDeviceFlowRegistry().retrieveIdForFlow(flowRegistryKey);
                         if (flowDescriptor != null) {
                             KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
-                                    deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
                             itemLifecycleListener.onRemoved(flowPath);
                         }
                     }
@@ -203,7 +203,7 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                     final FlowDescriptor flowDescriptor = deviceContext.getDeviceFlowRegistry().retrieveIdForFlow(flowRegistryKey);
                     if (flowDescriptor != null) {
                         KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
-                                deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
                         itemLifecycleListener.onRemoved(flowPath);
                     }
                 }
@@ -215,7 +215,7 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
 
                     if (itemLifecycleListener != null) {
                         KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
-                                deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
                         final FlowBuilder flowBuilder = new FlowBuilder(input.getUpdatedFlow()).setId(flowDescriptor.getFlowId());
                         itemLifecycleListener.onAdded(flowPath, flowBuilder.build());
                     }
index 1ebc5d4b5ac461ef00f09877ac892db02bfd0c3f..4445754b389aca61a237389494b146c3f2deed62 100644 (file)
@@ -144,7 +144,7 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
         if (itemLifecycleListener != null) {
             KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group, GroupKey> groupPath
                     = createGroupPath(groupId,
-                    deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
             itemLifecycleListener.onRemoved(groupPath);
         }
     }
@@ -153,7 +153,7 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
         if (itemLifecycleListener != null) {
             KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group, GroupKey> groupPath
                     = createGroupPath(groupId,
-                    deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
             itemLifecycleListener.onAdded(groupPath, new GroupBuilder(data).build());
         }
     }
index ced8aa4d3659fe16f22025523897d8b889ec7540..d3702446a49950451558fe2271875c03f991fe19 100644 (file)
@@ -149,7 +149,7 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
         if (itemLifecycleListener != null) {
             KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> meterPath
                     = createMeterPath(meterId,
-                    deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
             itemLifecycleListener.onRemoved(meterPath);
         }
     }
@@ -158,7 +158,7 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
         if (itemLifecycleListener != null) {
             KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> groupPath
                     = createMeterPath(meterId,
-                    deviceContext.getDeviceState().getNodeInstanceIdentifier());
+                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
             itemLifecycleListener.onAdded(groupPath, new MeterBuilder(data).build());
         }
     }
index 6257c93b422117d8660dde2a34d3caa723c90472..76ae36a48581afe4b5ad86e4cde3acbbf185918e 100644 (file)
@@ -66,7 +66,7 @@ class StatisticsContextImpl implements StatisticsContext {
     private volatile boolean schedulingEnabled;
 
     StatisticsContextImpl(@CheckForNull final DeviceInfo deviceInfo, final boolean shuttingDownStatisticsPolling, final LifecycleConductor lifecycleConductor) {
-        this.deviceContext = Preconditions.checkNotNull(lifecycleConductor.getDeviceContext(deviceInfo.getNodeId()));
+        this.deviceContext = Preconditions.checkNotNull(lifecycleConductor.getDeviceContext(deviceInfo));
         this.devState = Preconditions.checkNotNull(deviceContext.getDeviceState());
         this.shuttingDownStatisticsPolling = shuttingDownStatisticsPolling;
         emptyFuture = Futures.immediateFuture(false);
@@ -108,7 +108,7 @@ class StatisticsContextImpl implements StatisticsContext {
     @Override
     public ListenableFuture<Boolean> gatherDynamicData() {
         if (shuttingDownStatisticsPolling) {
-            LOG.debug("Statistics for device {} is not enabled.", deviceContext.getDeviceState().getNodeId());
+            LOG.debug("Statistics for device {} is not enabled.", deviceContext.getDeviceInfo().getNodeId());
             return Futures.immediateFuture(Boolean.TRUE);
         }
         final ListenableFuture<Boolean> errorResultFuture = deviceConnectionCheck();
@@ -211,19 +211,19 @@ class StatisticsContextImpl implements StatisticsContext {
     private void statChainFuture(final Iterator<MultipartType> iterator, final SettableFuture<Boolean> resultFuture) {
         if (ConnectionContext.CONNECTION_STATE.RIP.equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
             final String errMsg = String.format("Device connection is closed for Node : %s.",
-                    deviceContext.getDeviceState().getNodeId());
+                    deviceContext.getDeviceInfo().getNodeId());
             LOG.debug(errMsg);
             resultFuture.setException(new IllegalStateException(errMsg));
             return;
         }
         if ( ! iterator.hasNext()) {
             resultFuture.set(Boolean.TRUE);
-            LOG.debug("Stats collection successfully finished for node {}", deviceContext.getDeviceState().getNodeId());
+            LOG.debug("Stats collection successfully finished for node {}", deviceContext.getDeviceInfo().getNodeId());
             return;
         }
 
         final MultipartType nextType = iterator.next();
-        LOG.debug("Stats iterating to next type for node {} of type {}", deviceContext.getDeviceState().getNodeId(), nextType);
+        LOG.debug("Stats iterating to next type for node {} of type {}", deviceContext.getDeviceInfo().getNodeId(), nextType);
 
         final ListenableFuture<Boolean> deviceStatisticsCollectionFuture = chooseStat(nextType);
         Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
index 4933f28374008e089049c67978ba84ae55fe0756..00b824aaf02301b6d45c582e526ecf3bc01b3263 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
@@ -149,7 +150,7 @@ public final class StatisticsGatheringUtils {
             public ListenableFuture<Boolean> apply(final RpcResult<List<MultipartReply>> rpcResult) {
                 boolean isMultipartProcessed = Boolean.TRUE;
                 if (rpcResult.isSuccessful()) {
-                    LOG.debug("Stats reply successfully received for node {} of type {}", deviceContext.getDeviceState().getNodeId(), type);
+                    LOG.debug("Stats reply successfully received for node {} of type {}", deviceContext.getDeviceInfo().getNodeId(), type);
 
                     // TODO: in case the result value is null then multipart data probably got processed on the fly -
                     // TODO: this contract should by clearly stated and enforced - now simple true value is returned
@@ -168,7 +169,7 @@ public final class StatisticsGatheringUtils {
                             }
                         } catch (final Exception e) {
                             LOG.warn("stats processing of type {} for node {} failed during transfomation step",
-                                    type, deviceContext.getDeviceState().getNodeId(), e);
+                                    type, deviceContext.getDeviceInfo().getNodeId(), e);
                             return Futures.immediateFailedFuture(e);
                         }
 
@@ -198,19 +199,19 @@ public final class StatisticsGatheringUtils {
                             }
                         } catch (final Exception e) {
                             LOG.warn("stats processing of type {} for node {} failed during write-to-tx step",
-                                    type, deviceContext.getDeviceState().getNodeId(), e);
+                                    type, deviceContext.getDeviceInfo().getNodeId(), e);
                             return Futures.immediateFailedFuture(e);
                         }
 
-                        LOG.debug("Stats reply added to transaction for node {} of type {}", deviceContext.getDeviceState().getNodeId(), type);
+                        LOG.debug("Stats reply added to transaction for node {} of type {}", deviceContext.getDeviceInfo().getNodeId(), type);
 
                         //TODO : implement experimenter
                     } else {
-                        LOG.debug("Stats reply was empty for node {} of type {}", deviceContext.getDeviceState().getNodeId(), type);
+                        LOG.debug("Stats reply was empty for node {} of type {}", deviceContext.getDeviceInfo().getNodeId(), type);
                     }
 
                 } else {
-                    LOG.debug("Stats reply FAILED for node {} of type {}: {}", deviceContext.getDeviceState().getNodeId(), type, rpcResult.getErrors());
+                    LOG.debug("Stats reply FAILED for node {} of type {}: {}", deviceContext.getDeviceInfo().getNodeId(), type, rpcResult.getErrors());
                     isMultipartProcessed = Boolean.FALSE;
                 }
                 return Futures.immediateFuture(isMultipartProcessed);
@@ -219,7 +220,7 @@ public final class StatisticsGatheringUtils {
     }
 
     private static void processMeterConfigStatsUpdated(final Iterable<MeterConfigStatsUpdated> data, final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceInfo());
         deleteAllKnownMeters(deviceContext, fNodeIdent);
         for (final MeterConfigStatsUpdated meterConfigStatsUpdated : data) {
             for (final MeterConfigStats meterConfigStats : meterConfigStatsUpdated.getMeterConfigStats()) {
@@ -238,13 +239,13 @@ public final class StatisticsGatheringUtils {
 
     private static ListenableFuture<Boolean> processFlowStatistics(final Iterable<FlowsStatisticsUpdate> data,
                                                                    final DeviceContext deviceContext, final EventIdentifier eventIdentifier) {
-        final ListenableFuture<Void> deleFuture = deleteAllKnownFlows(deviceContext.getDeviceState(),
-                deviceContext.getDeviceFlowRegistry(), deviceContext);
+        final ListenableFuture<Void> deleFuture = deleteAllKnownFlows(deviceContext.getDeviceInfo(),
+                deviceContext.getDeviceFlowRegistry(), deviceContext, deviceContext.getDeviceState());
         return Futures.transform(deleFuture, new Function<Void, Boolean>() {
 
             @Override
             public Boolean apply(final Void input) {
-                writeFlowStatistics(data, deviceContext.getDeviceState(), deviceContext.getDeviceFlowRegistry(),
+                writeFlowStatistics(data, deviceContext.getDeviceInfo(), deviceContext.getDeviceFlowRegistry(),
                         deviceContext);
                 deviceContext.submitTransaction();
                 EventsTimeCounter.markEnd(eventIdentifier);
@@ -254,10 +255,10 @@ public final class StatisticsGatheringUtils {
     }
 
     public static void writeFlowStatistics(final Iterable<FlowsStatisticsUpdate> data,
-                                           final DeviceState deviceState,
+                                           final DeviceInfo deviceInfo,
                                            final DeviceFlowRegistry registry,
                                            final TxFacade txFacade) {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceState);
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
         try {
             for (final FlowsStatisticsUpdate flowsStatistics : data) {
                 for (final FlowAndStatisticsMapList flowStat : flowsStatistics.getFlowAndStatisticsMapList()) {
@@ -292,12 +293,14 @@ public final class StatisticsGatheringUtils {
         return flowStatisticsDataBld;
     }
 
-    public static ListenableFuture<Void> deleteAllKnownFlows(final DeviceState deviceState,
+    public static ListenableFuture<Void> deleteAllKnownFlows(final DeviceInfo deviceInfo,
                                                              final DeviceFlowRegistry registry,
-                                                             final TxFacade txFacade) {
+                                                             final TxFacade txFacade,
+                                                             final DeviceState deviceState) {
+        //TODO:Make check for phase from enum
         /* DeviceState.deviceSynchronized is a marker for actual phase - false means initPhase, true means noInitPhase */
         if (deviceState.deviceSynchronized()) {
-            final InstanceIdentifier<FlowCapableNode> flowCapableNodePath = assembleFlowCapableNodeInstanceIdentifier(deviceState);
+            final InstanceIdentifier<FlowCapableNode> flowCapableNodePath = assembleFlowCapableNodeInstanceIdentifier(deviceInfo);
             final ReadOnlyTransaction readTx = txFacade.getReadTransaction();
             final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowCapableNodeFuture = readTx.read(
                     LogicalDatastoreType.OPERATIONAL, flowCapableNodePath);
@@ -338,7 +341,7 @@ public final class StatisticsGatheringUtils {
 
     private static void processQueueStatistics(final Iterable<QueueStatisticsUpdate> data, final DeviceContext deviceContext) throws Exception {
         // TODO: clean all queues of all node-connectors before writing up-to-date stats
-        final InstanceIdentifier<Node> nodeIdent = deviceContext.getDeviceState().getNodeInstanceIdentifier();
+        final InstanceIdentifier<Node> nodeIdent = deviceContext.getDeviceInfo().getNodeInstanceIdentifier();
         for (final QueueStatisticsUpdate queueStatisticsUpdate : data) {
             for (final QueueIdAndStatisticsMap queueStat : queueStatisticsUpdate.getQueueIdAndStatisticsMap()) {
                 if (queueStat.getQueueId() != null) {
@@ -365,7 +368,7 @@ public final class StatisticsGatheringUtils {
     }
 
     private static void processFlowTableStatistics(final Iterable<FlowTableStatisticsUpdate> data, final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceInfo());
         for (final FlowTableStatisticsUpdate flowTableStatisticsUpdate : data) {
 
             for (final FlowTableAndStatisticsMap tableStat : flowTableStatisticsUpdate.getFlowTableAndStatisticsMap()) {
@@ -379,7 +382,7 @@ public final class StatisticsGatheringUtils {
     }
 
     private static void processNodeConnectorStatistics(final Iterable<NodeConnectorStatisticsUpdate> data, final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<Node> nodeIdent = deviceContext.getDeviceState().getNodeInstanceIdentifier();
+        final InstanceIdentifier<Node> nodeIdent = deviceContext.getDeviceInfo().getNodeInstanceIdentifier();
         for (final NodeConnectorStatisticsUpdate nodeConnectorStatisticsUpdate : data) {
             for (final NodeConnectorStatisticsAndPortNumberMap nConnectPort : nodeConnectorStatisticsUpdate.getNodeConnectorStatisticsAndPortNumberMap()) {
                 final FlowCapableNodeConnectorStatistics stats = new FlowCapableNodeConnectorStatisticsBuilder(nConnectPort).build();
@@ -397,7 +400,7 @@ public final class StatisticsGatheringUtils {
 
     private static void processMetersStatistics(final Iterable<MeterStatisticsUpdated> data,
                                                 final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceInfo());
         for (final MeterStatisticsUpdated meterStatisticsUpdated : data) {
             for (final MeterStats mStat : meterStatisticsUpdated.getMeterStats()) {
                 final MeterStatistics stats = new MeterStatisticsBuilder(mStat).build();
@@ -422,7 +425,7 @@ public final class StatisticsGatheringUtils {
 
     private static void processGroupDescStats(final Iterable<GroupDescStatsUpdated> data, final DeviceContext deviceContext) throws Exception {
         final InstanceIdentifier<FlowCapableNode> fNodeIdent =
-                deviceContext.getDeviceState().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+                deviceContext.getDeviceInfo().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
         deleteAllKnownGroups(deviceContext, fNodeIdent);
 
         for (final GroupDescStatsUpdated groupDescStatsUpdated : data) {
@@ -451,7 +454,7 @@ public final class StatisticsGatheringUtils {
     }
 
     private static void processGroupStatistics(final Iterable<GroupStatisticsUpdated> data, final DeviceContext deviceContext) throws Exception {
-        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
+        final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceInfo());
         for (final GroupStatisticsUpdated groupStatistics : data) {
             for (final GroupStats groupStats : groupStatistics.getGroupStats()) {
 
@@ -467,8 +470,8 @@ public final class StatisticsGatheringUtils {
         deviceContext.submitTransaction();
     }
 
-    private static InstanceIdentifier<FlowCapableNode> assembleFlowCapableNodeInstanceIdentifier(final DeviceState deviceState) {
-        return deviceState.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+    private static InstanceIdentifier<FlowCapableNode> assembleFlowCapableNodeInstanceIdentifier(final DeviceInfo deviceInfo) {
+        return deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
     }
 
     /**
@@ -477,7 +480,7 @@ public final class StatisticsGatheringUtils {
      * @param deviceContext txManager + node path keeper
      */
     static void markDeviceStateSnapshotStart(final DeviceContext deviceContext) {
-        final InstanceIdentifier<FlowCapableStatisticsGatheringStatus> statusPath = deviceContext.getDeviceState()
+        final InstanceIdentifier<FlowCapableStatisticsGatheringStatus> statusPath = deviceContext.getDeviceInfo()
                 .getNodeInstanceIdentifier().augmentation(FlowCapableStatisticsGatheringStatus.class);
 
         final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_AND_TIME_FORMAT);
@@ -503,7 +506,7 @@ public final class StatisticsGatheringUtils {
      * @param succeeded     outcome of currently finished gathering
      */
     static void markDeviceStateSnapshotEnd(final DeviceContext deviceContext, final boolean succeeded) {
-        final InstanceIdentifier<SnapshotGatheringStatusEnd> statusEndPath = deviceContext.getDeviceState()
+        final InstanceIdentifier<SnapshotGatheringStatusEnd> statusEndPath = deviceContext.getDeviceInfo()
                 .getNodeInstanceIdentifier().augmentation(FlowCapableStatisticsGatheringStatus.class)
                 .child(SnapshotGatheringStatusEnd.class);
 
index 4b1a151676a857a4140660e40698c3f1ce4cb9a1..9d2df471c08311e2334c561ae047c621dfd7b1c2 100644 (file)
@@ -90,7 +90,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     @Override
     public void onDeviceContextLevelUp(final DeviceInfo deviceInfo) throws Exception {
 
-        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(deviceInfo.getNodeId()));
+        final DeviceContext deviceContext = Preconditions.checkNotNull(conductor.getDeviceContext(deviceInfo));
 
         final StatisticsContext statisticsContext = new StatisticsContextImpl(deviceInfo, shuttingDownStatisticsPolling, conductor);
         Verify.verify(contexts.putIfAbsent(deviceInfo, statisticsContext) == null, "StatisticsCtx still not closed for Node {}", deviceInfo.getNodeId());
@@ -104,7 +104,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
                                 final StatisticsContext statisticsContext,
                                 final TimeCounter timeCounter) {
 
-        final NodeId nodeId = deviceContext.getDeviceState().getNodeId();
+        final NodeId nodeId = deviceContext.getDeviceInfo().getNodeId();
 
         if (!statisticsContext.isSchedulingEnabled()) {
             LOG.debug("Disabling statistics scheduling for device: {}", nodeId);
@@ -141,7 +141,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
                 calculateTimerDelay(timeCounter);
                 if (throwable instanceof CancellationException) {
                     /** This often happens when something wrong with akka or DS, so closing connection will help to restart device **/
-                    conductor.closeConnection(deviceContext.getDeviceState().getNodeId());
+                    conductor.closeConnection(deviceContext.getDeviceInfo());
                 } else {
                     scheduleNextPolling(deviceContext, statisticsContext, timeCounter);
                 }
@@ -163,7 +163,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     private void scheduleNextPolling(final DeviceContext deviceContext,
                                      final StatisticsContext statisticsContext,
                                      final TimeCounter timeCounter) {
-        LOG.debug("SCHEDULING NEXT STATISTICS POLLING for device: {}", deviceContext.getDeviceState().getNodeId());
+        LOG.debug("SCHEDULING NEXT STATISTICS POLLING for device: {}", deviceContext.getDeviceInfo().getNodeId());
         if (!shuttingDownStatisticsPolling) {
             final Timeout pollTimeout = conductor.newTimeout(timeout -> pollStatistics(deviceContext, statisticsContext, timeCounter), currentTimerDelay, TimeUnit.MILLISECONDS);
             statisticsContext.setPollTimeout(pollTimeout);
@@ -272,7 +272,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
         }
 
         LOG.info("Scheduling statistics poll for device: {}", deviceInfo.getNodeId());
-        final DeviceContext deviceContext = conductor.getDeviceContext(deviceInfo.getNodeId());
+        final DeviceContext deviceContext = conductor.getDeviceContext(deviceInfo);
 
         if (deviceContext == null) {
             LOG.warn("Device context not found for device: {}", deviceInfo.getNodeId());
index af49302a778ed1c4fe1d69aae8d01050ec8fcfb3..4c822cd55cd7623790fe34a5b775e901a09a63ad 100644 (file)
@@ -91,9 +91,9 @@ public final class AggregateFlowsInTableService extends AbstractCompatibleStatSe
         final TranslatorKey translatorKey = new TranslatorKey(mpReply.getVersion(), MultipartReplyAggregateCase.class.getName());
         final MessageTranslator<MultipartReply, AggregatedFlowStatistics> messageTranslator = translatorLibrary.lookupTranslator(translatorKey);
 
-        final AggregatedFlowStatistics flowStatistics = messageTranslator.translate(mpReply, getDeviceContext().getDeviceState(), null);
+        final AggregatedFlowStatistics flowStatistics = messageTranslator.translate(mpReply, getDeviceContext().getDeviceInfo(), null);
         final AggregateFlowStatisticsUpdateBuilder notification = new AggregateFlowStatisticsUpdateBuilder(flowStatistics)
-                .setId(getDeviceContext().getDeviceState().getNodeId())
+                .setId(getDeviceContext().getDeviceInfo().getNodeId())
                 .setMoreReplies(Boolean.FALSE)
                 .setTransactionId(emulatedTxId);
 
index 5801f43a6145e152e753b873b7f74784393d16a4..97a83270f2ffbf5b2b446017ce209dd8ef74743e 100644 (file)
@@ -67,6 +67,6 @@ public final class AllFlowsInAllTablesService extends AbstractCompatibleStatServ
 
     @Override
     public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index 8c9262f3996e503a693f23a9e9d56de5e4e58d98..ddf18248df4d3e8acfc4a683d6955ff26ea2235e 100644 (file)
@@ -72,6 +72,6 @@ public class AllFlowsInTableService extends AbstractCompatibleStatService<GetAll
 
     @Override
     public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> mpResult, TransactionId emulatedTxId) {
-        return FlowStatisticsToNotificationTransformer.transformToNotification(mpResult, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return FlowStatisticsToNotificationTransformer.transformToNotification(mpResult, getDeviceContext().getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index e33c2100562fc1b14ee0f3187480c07d27c42726..3bf75abaeccc02706eb0dc1d1ec21d89d2de8f9e 100644 (file)
@@ -71,6 +71,6 @@ final class AllGroupsStatsService extends
 
     @Override
     public GroupStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceInfo(), emulatedTxId);
     }
 }
index f7667e8116432c84efc4228767f1b7d4ba273846..7aa717a5b94708ff40be055c615c32b8b8e2e5a0 100644 (file)
@@ -73,7 +73,7 @@ final class AllMeterConfigStatsService
     @Override
     public MeterConfigStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
         MeterConfigStatsUpdatedBuilder message = new MeterConfigStatsUpdatedBuilder();
-        message.setId(getDeviceContext().getDeviceState().getNodeId());
+        message.setId(getDeviceContext().getDeviceInfo().getNodeId());
         message.setMoreReplies(Boolean.FALSE);
         message.setTransactionId(emulatedTxId);
 
index fb3b2d90fa6641533e65345224b2c24abc3f54ce..7db050703f8163355d1b6b765b59ebc8c8284b7e 100644 (file)
@@ -65,6 +65,6 @@ final class AllMeterStatsService
 
     @Override
     public MeterStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index b9da4288af81f7c1f54004435c9eeba86d5e4e72..91aed6abbf11c7a10f7cdbd07ce5053cad62da99 100644 (file)
@@ -66,6 +66,6 @@ final class AllQueuesAllPortsService
 
     @Override
     public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index 1f6f6b3232d4bf2dd08853f9facb7f68b6b15e5e..fa283bf24fdb76a686076ee78eb76231077c24b2 100644 (file)
@@ -65,6 +65,6 @@ final class AllQueuesOnePortService
 
     @Override
     public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index f063b2ef51d69511fc26f61ba722e84eabb3e2a6..2052d536bf017039a7f464d38bd6c8595a07ffe0 100644 (file)
@@ -93,6 +93,6 @@ public final class FlowsInTableService extends AbstractCompatibleStatService<Get
 
     @Override
     public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index 46e2588be17e56b501b7d3707f8291862354938c..cb971d4a2758e0d85b898b35c46fa92441d67e3f 100644 (file)
@@ -58,7 +58,7 @@ final class GroupDescriptionService
     @Override
     public GroupDescStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
         GroupDescStatsUpdatedBuilder notification = new GroupDescStatsUpdatedBuilder();
-        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setId(getDeviceContext().getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index 22c8d6d465c3e8c07031ed15c1a5840e199839a5..192208d8318b704ac5940e2289046b4c0a8b00ce 100644 (file)
@@ -74,7 +74,7 @@ final class GroupFeaturesService
         Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
 
         GroupFeaturesUpdatedBuilder notification = new GroupFeaturesUpdatedBuilder();
-        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setId(getDeviceContext().getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index e0e04f95c92df1b534b9451ae9c1b105e2885cd2..43d23471d0e18eab2ec7bafd3686f5571b9891c4 100644 (file)
@@ -56,6 +56,6 @@ final class GroupStatsService
 
     @Override
     public GroupStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceInfo(), emulatedTxId);
     }
 }
index 142b3c0c85f6859c05b256e202a285966c3bc8bb..1eb705d62a63407bb23c6f7d5971c9281f237e6c 100644 (file)
@@ -70,7 +70,7 @@ final class MeterFeaturesService
         Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
 
         MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
-        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setId(getDeviceContext().getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index 33d36ffbba9f9ef21cd62865e3d7c336202b9365..9439b7e5c8a794acc40cd70873d36b59691b916a 100644 (file)
@@ -57,6 +57,6 @@ final class MeterStatsService
 
     @Override
     public MeterStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index 867d10b79307e589eaa165ec201d3c9750162dac..cd8bdada265b29e3c99fd6c115ea9ec50fc44f08 100644 (file)
@@ -62,6 +62,6 @@ final class OneQueueOnePortService
 
     @Override
     public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
-        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceState(), getOfVersion(), emulatedTxId);
+        return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext().getDeviceInfo(), getOfVersion(), emulatedTxId);
     }
 }
index cabe1cffa40ced08d7025e5d7264d39d285a590f..15b3f4f60ce51ec5f07eca40e75b2f6838a11f16 100644 (file)
@@ -58,7 +58,7 @@ public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowSt
                         List<AggregatedFlowStatistics> aggregStats = new ArrayList<AggregatedFlowStatistics>();
 
                         for (MultipartReply multipartReply : input.getResult()) {
-                            aggregStats.add(messageTranslator.translate(multipartReply, deviceContext.getDeviceState(), null));
+                            aggregStats.add(messageTranslator.translate(multipartReply, deviceContext.getDeviceInfo(), null));
                         }
 
                         GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder =
index a6f6b2b197455ea1f8fbdb9748f5541553966e6f..7d9bc5ed8fdef06b6afadc9e74644a2145f1fb25 100644 (file)
@@ -85,7 +85,7 @@ public final class OpendaylightFlowTableStatisticsServiceImpl extends
     @Override
     public FlowTableStatisticsUpdate transformToNotification(List<MultipartReply> mpReplyList, TransactionId emulatedTxId) {
         FlowTableStatisticsUpdateBuilder notification = new FlowTableStatisticsUpdateBuilder();
-        notification.setId(getDeviceContext().getDeviceState().getNodeId());
+        notification.setId(getDeviceContext().getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index 6ba60dcbb661fce089eedb11ec65c7f269133a63..ab85159e5a36da19e1526e42b7a70077fd01b987 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowStatsResponseConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
@@ -32,18 +33,18 @@ public class FlowStatisticsToNotificationTransformer {
 
     /**
      * @param mpResult      raw multipart response from device
-     * @param deviceState   device state
+     * @param deviceInfo   device state
      * @param ofVersion     device version
      * @param emulatedTxId
      * @return notification containing flow stats
      */
     public static FlowsStatisticsUpdate transformToNotification(final List<MultipartReply> mpResult,
-                                                                final DeviceState deviceState,
+                                                                final DeviceInfo deviceInfo,
                                                                 final OpenflowVersion ofVersion,
                                                                 final TransactionId emulatedTxId) {
         final FlowsStatisticsUpdateBuilder notification = new FlowsStatisticsUpdateBuilder();
         final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
-        notification.setId(deviceState.getNodeId());
+        notification.setId(deviceInfo.getNodeId());
         notification.setFlowAndStatisticsMapList(statsList);
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
@@ -55,7 +56,7 @@ public class FlowStatisticsToNotificationTransformer {
             MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
             List<FlowAndStatisticsMapList> outStatsItem = flowStatsConvertor.toSALFlowStatsList(
                     replyBody.getFlowStats(),
-                    deviceState.getFeatures().getDatapathId(),
+                    deviceInfo.getDatapathId(),
                     ofVersion);
             statsList.addAll(outStatsItem);
         }
index 2dcef59d0ff855fe0086a6348cb652c44f870fe7..1e565568abf928540b226df170c7b92853118ef1 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
@@ -30,18 +30,16 @@ public class GroupStatisticsToNotificationTransformer {
 
     /**
      * @param mpReplyList   raw multipart response from device
-     * @param deviceState   device state
-     * @param ofVersion     device version
+     * @param deviceInfo   device state
      * @param emulatedTxId
      * @return notification containing flow stats
      */
     public static GroupStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList,
-                                                                 final DeviceState deviceState,
-                                                                 final OpenflowVersion ofVersion,
+                                                                 final DeviceInfo deviceInfo,
                                                                  final TransactionId emulatedTxId) {
 
         GroupStatisticsUpdatedBuilder notification = new GroupStatisticsUpdatedBuilder();
-        notification.setId(deviceState.getNodeId());
+        notification.setId(deviceInfo.getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index 4bf30e29cebfbd197cab9d03b2ff17d3195b1125..8fa0fce0b8744bd781dc117ab580dbabe0f116f6 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
@@ -30,18 +31,18 @@ public class MeterStatisticsToNotificationTransformer {
 
     /**
      * @param mpReplyList   raw multipart response from device
-     * @param deviceState   device state
+     * @param deviceInfo   device state
      * @param ofVersion     device version
      * @param emulatedTxId
      * @return notification containing flow stats
      */
     public static MeterStatisticsUpdated transformToNotification(final List<MultipartReply> mpReplyList,
-                                                                 final DeviceState deviceState,
+                                                                 final DeviceInfo deviceInfo,
                                                                  final OpenflowVersion ofVersion,
                                                                  final TransactionId emulatedTxId) {
 
         MeterStatisticsUpdatedBuilder notification = new MeterStatisticsUpdatedBuilder();
-        notification.setId(deviceState.getNodeId());
+        notification.setId(deviceInfo.getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
index 3649a252988567560be1b328f9da4cfc11e61934..70a0dbbfba6964e579b19cd6c014c8b6165b77d3 100644 (file)
@@ -47,7 +47,7 @@ public class NodeConnectorStatisticsToNotificationTransformer {
                                                                         final TransactionId emulatedTxId) {
 
         NodeConnectorStatisticsUpdateBuilder notification = new NodeConnectorStatisticsUpdateBuilder();
-        notification.setId(deviceContext.getDeviceState().getNodeId());
+        notification.setId(deviceContext.getDeviceInfo().getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
@@ -71,7 +71,7 @@ public class NodeConnectorStatisticsToNotificationTransformer {
                 new NodeConnectorStatisticsAndPortNumberMapBuilder();
         statsBuilder.setNodeConnectorId(
                 InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(
-                        deviceContext.getDeviceState().getFeatures().getDatapathId(),
+                        deviceContext.getDeviceInfo().getDatapathId(),
                         portStats.getPortNo(), ofVersion));
 
         BytesBuilder bytesBuilder = new BytesBuilder();
index fc4f6c08e11b5056d7a9ee327146b168cc7d9f8e..ca6283d191a2488214947c60ebda2de73f12233d 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
@@ -34,18 +35,18 @@ public class QueueStatisticsToNotificationTransformer {
 
     /**
      * @param mpReplyList   raw multipart response from device
-     * @param deviceState   device state
+     * @param deviceInfo   device state
      * @param ofVersion     device version
      * @param emulatedTxId
      * @return notification containing flow stats
      */
     public static QueueStatisticsUpdate transformToNotification(final List<MultipartReply> mpReplyList,
-                                                                final DeviceState deviceState,
+                                                                final DeviceInfo deviceInfo,
                                                                 final OpenflowVersion ofVersion,
                                                                 final TransactionId emulatedTxId) {
 
         QueueStatisticsUpdateBuilder notification = new QueueStatisticsUpdateBuilder();
-        notification.setId(deviceState.getNodeId());
+        notification.setId(deviceInfo.getNodeId());
         notification.setMoreReplies(Boolean.FALSE);
         notification.setTransactionId(emulatedTxId);
 
@@ -61,7 +62,7 @@ public class QueueStatisticsToNotificationTransformer {
                         new QueueIdAndStatisticsMapBuilder();
                 statsBuilder.setNodeConnectorId(
                         InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(
-                                deviceState.getFeatures().getDatapathId(),
+                                deviceInfo.getDatapathId(),
                                 queueStats.getPortNo(), ofVersion));
                 statsBuilder.setTransmissionErrors(new Counter64(queueStats.getTxErrors()));
                 statsBuilder.setTransmittedBytes(new Counter64(queueStats.getTxBytes()));
index 72066b0395f578dc3f72600e121d2b347f04ba93..34f32b9d73a2d27201fd67175756190e2256621e 100644 (file)
@@ -132,7 +132,7 @@ public class FlowDirectStatisticsService extends AbstractDirectStatisticsService
     @Override
     protected void storeStatistics(GetFlowStatisticsOutput output) throws Exception {
         final InstanceIdentifier<FlowCapableNode> nodePath = getDeviceContext()
-                .getDeviceState().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+                .getDeviceInfo().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
 
         for (final FlowAndStatisticsMapList flowStatistics : output.getFlowAndStatisticsMapList()) {
             final FlowId flowId = generateFlowId(flowStatistics);
index b7c650a03a4d8e4e91934aca7b7af3a4d4f96a2a..addbfd98999e8eae1a5a10f7f30789b3e2a3ee4e 100644 (file)
@@ -87,7 +87,7 @@ public class GroupDirectStatisticsService extends AbstractDirectStatisticsServic
     @Override
     protected void storeStatistics(GetGroupStatisticsOutput output) throws Exception {
         final InstanceIdentifier<FlowCapableNode> nodePath = getDeviceContext()
-                .getDeviceState().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+                .getDeviceInfo().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
 
         for (final GroupStats groupStatistics : output.getGroupStats()) {
             final InstanceIdentifier<GroupStatistics> groupStatisticsPath = nodePath
index da6475ec5ce32e26096bc6c9471eaafd310bf6fe..31ca7aa0a58147c7bf8dc9653829a129534621f1 100644 (file)
@@ -87,7 +87,7 @@ public class MeterDirectStatisticsService extends AbstractDirectStatisticsServic
     @Override
     protected void storeStatistics(GetMeterStatisticsOutput output) throws Exception {
         final InstanceIdentifier<FlowCapableNode> nodePath = getDeviceContext()
-                .getDeviceState().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+                .getDeviceInfo().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
 
         for (final MeterStats meterStatistics : output.getMeterStats()) {
             final InstanceIdentifier<MeterStatistics> meterPath = nodePath
index 6f6f496cbe66283a939843aa2340986c9a546bfa..5852c8bc6503a3527126f71f4782b0f877fa4ce1 100644 (file)
@@ -130,7 +130,7 @@ public class NodeConnectorDirectStatisticsService extends AbstractDirectStatisti
 
     @Override
     protected void storeStatistics(GetNodeConnectorStatisticsOutput output) throws Exception {
-        final InstanceIdentifier<Node> nodePath = getDeviceContext().getDeviceState().getNodeInstanceIdentifier();
+        final InstanceIdentifier<Node> nodePath = getDeviceContext().getDeviceInfo().getNodeInstanceIdentifier();
 
         for (final NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatistics : output.getNodeConnectorStatisticsAndPortNumberMap()) {
             final InstanceIdentifier<FlowCapableNodeConnectorStatistics> nodeConnectorPath = nodePath
index 88f97dcbabcf65c7e410e368bb88d4de4442e7f2..a9498af2f12a8e0b31987760f2a63566be088a04 100644 (file)
@@ -116,7 +116,7 @@ public class QueueDirectStatisticsService extends AbstractDirectStatisticsServic
 
     @Override
     protected void storeStatistics(GetQueueStatisticsOutput output) throws Exception {
-        final InstanceIdentifier<Node> nodePath = getDeviceContext().getDeviceState().getNodeInstanceIdentifier();
+        final InstanceIdentifier<Node> nodePath = getDeviceContext().getDeviceInfo().getNodeInstanceIdentifier();
 
         for (final QueueIdAndStatisticsMap queueStatistics : output.getQueueIdAndStatisticsMap()) {
             if (queueStatistics.getQueueId() != null) {
index 6e7626d4954a3c2855b3f860e551c81455de2e12..c00e01bcd3fb7f6b777a2f4f559882fe20274a29 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
@@ -23,7 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class AggregatedFlowStatisticsTranslator implements MessageTranslator<MultipartReply, AggregatedFlowStatistics> {
     @Override
-    public AggregatedFlowStatistics translate(final MultipartReply input, final DeviceState deviceState, final Object connectionDistinguisher) {
+    public AggregatedFlowStatistics translate(final MultipartReply input, final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
         AggregatedFlowStatisticsBuilder aggregatedFlowStatisticsBuilder = new AggregatedFlowStatisticsBuilder();
 
         MultipartReplyAggregateCase caseBody = (MultipartReplyAggregateCase)input.getMultipartReplyBody();
index 4aa08b00288f215fe1ec111544d5600e9e025941..c5683d2ebc171a071b446bbae668efa65be1a9e5 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
@@ -23,20 +23,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved> {
 
     @Override
-    public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceState deviceState, Object connectionDistinguisher) {
+    public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceInfo deviceInfo, Object connectionDistinguisher) {
         FlowRemovedBuilder flowRemovedBld = new FlowRemovedBuilder()
-                .setMatch(translateMatch(input, deviceState).build())
+                .setMatch(translateMatch(input, deviceInfo).build())
                 .setCookie(new FlowCookie(input.getCookie()))
-                .setNode(new NodeRef(deviceState.getNodeInstanceIdentifier()))
+                .setNode(new NodeRef(deviceInfo.getNodeInstanceIdentifier()))
                 .setPriority(input.getPriority())
                 .setTableId(translateTableId(input));
 
         return flowRemovedBld.build();
     }
 
-    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceState deviceState) {
+    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) {
         return MatchConvertorImpl.fromOFMatchToSALMatch(flowRemoved.getMatch(),
-                deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF13);
+                deviceInfo.getDatapathId(), OpenflowVersion.OF13);
     }
 
     /**
index 23efec2ed636a1c5f06feb76987e7b5278c901e1..e5904310c5288618b29f0a8529834a91d5391fd0 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
@@ -20,9 +20,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class FlowRemovedV10Translator extends FlowRemovedTranslator {
 
     @Override
-    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceState deviceState) {
+    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) {
         return MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowRemoved.getMatchV10(),
-                deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF10);
+                deviceInfo.getDatapathId(), OpenflowVersion.OF10);
     }
 
     /**
index 08862300d76327896cc993a80abbb34882a90b04..56913f3782b06597bc51b169cc06c4504285c594 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowplugin.impl.translator;
 
 import com.google.common.annotations.VisibleForTesting;
 import java.math.BigInteger;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
@@ -33,10 +34,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Table
  */
 public class PacketReceivedTranslator implements MessageTranslator<PacketInMessage, PacketReceived> {
     @Override
-    public PacketReceived translate(final PacketInMessage input, final DeviceState deviceState, final Object connectionDistinguisher) {
+    public PacketReceived translate(final PacketInMessage input, final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
 
         PacketReceivedBuilder packetReceivedBuilder = new PacketReceivedBuilder();
-        BigInteger datapathId = deviceState.getFeatures().getDatapathId();
+        BigInteger datapathId = deviceInfo.getDatapathId();
 
         // TODO: connection cookie from connection distinguisher
         // packetReceivedBuilder.setConnectionCookie(new ConnectionCookie(input.getCookie().longValue()));
@@ -49,7 +50,7 @@ public class PacketReceivedTranslator implements MessageTranslator<PacketInMessa
         }
 
         // Try to create the NodeConnectorRef
-        BigInteger dataPathId = deviceState.getFeatures().getDatapathId();
+        BigInteger dataPathId = deviceInfo.getDatapathId();
         NodeConnectorRef nodeConnectorRef = NodeConnectorRefToPortTranslator.toNodeConnectorRef(input, dataPathId);
 
         // If we was able to create NodeConnectorRef, use it
index 54a2b4c8d6e2baf25899d40e754bb82bda946dd2..61ef3344851a38b1fc5a5658003a26f699989064 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.openflowplugin.impl.translator;
 
 import java.util.Collections;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.openflow.md.util.PortTranslatorUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
@@ -24,17 +24,17 @@ public class PortUpdateTranslator implements MessageTranslator<PortGrouping, Flo
 
     @Override
     public FlowCapableNodeConnector translate(final PortGrouping input,
-                                              final DeviceState deviceState, final Object connectionDistinguisher) {
+                                              final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
         final FlowCapableNodeConnectorBuilder builder = new FlowCapableNodeConnectorBuilder();
         //OF1.0
-        if (deviceState.getVersion() == OFConstants.OFP_VERSION_1_0) {
+        if (deviceInfo.getVersion() == OFConstants.OFP_VERSION_1_0) {
             builder.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(input.getAdvertisedFeaturesV10()));
             builder.setConfiguration(PortTranslatorUtil.translatePortConfig(input.getConfigV10()));
             builder.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(input.getCurrentFeaturesV10()));
             builder.setPeerFeatures(PortTranslatorUtil.translatePortFeatures(input.getPeerFeaturesV10()));
             builder.setState(PortTranslatorUtil.translatePortState(input.getStateV10()));
             builder.setSupported(PortTranslatorUtil.translatePortFeatures(input.getSupportedFeaturesV10()));
-        } else if (deviceState.getVersion() == OFConstants.OFP_VERSION_1_3) {
+        } else if (deviceInfo.getVersion() == OFConstants.OFP_VERSION_1_3) {
             builder.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(input.getAdvertisedFeatures()));
             builder.setConfiguration(PortTranslatorUtil.translatePortConfig(input.getConfig()));
             builder.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(input.getCurrentFeatures()));
index a9a6e190af485f630958d0df2fd1cf479767f1fc..f7f74c9a56d330df0f666bd2d8486e1c6bc689c6 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.openflowplugin.api.ConnectionException;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
@@ -97,9 +98,10 @@ public class DeviceInitializationUtils {
     public static ListenableFuture<Void> initializeNodeInformation(final DeviceContext deviceContext, final boolean switchFeaturesMandatory) {
         Preconditions.checkArgument(deviceContext != null);
         final DeviceState deviceState = Preconditions.checkNotNull(deviceContext.getDeviceState());
+        final DeviceInfo deviceInfo = deviceContext.getDeviceInfo();
         final ConnectionContext connectionContext = Preconditions.checkNotNull(deviceContext.getPrimaryConnectionContext());
-        final short version = deviceState.getVersion();
-        LOG.trace("initalizeNodeInformation for node {}", deviceState.getNodeId());
+        final short version = deviceInfo.getVersion();
+        LOG.trace("initalizeNodeInformation for node {}", deviceInfo.getNodeId());
         final SettableFuture<Void> returnFuture = SettableFuture.<Void>create();
         addNodeToOperDS(deviceContext, returnFuture);
         final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture;
@@ -112,14 +114,14 @@ public class DeviceInitializationUtils {
             // create empty tables after device description is processed
             chainTableTrunkWriteOF10(deviceContext, deviceFeaturesFuture);
 
-            final short ofVersion = deviceContext.getDeviceState().getVersion();
+            final short ofVersion = deviceInfo.getVersion();
             final TranslatorKey translatorKey = new TranslatorKey(ofVersion, PortGrouping.class.getName());
             final MessageTranslator<PortGrouping, FlowCapableNodeConnector> translator = deviceContext.oook()
                     .lookupTranslator(translatorKey);
             final BigInteger dataPathId = deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId();
 
             for (final PortGrouping port : connectionContext.getFeatures().getPhyPort()) {
-                final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, deviceContext.getDeviceState(), null);
+                final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, deviceContext.getDeviceInfo(), null);
 
                 final NodeConnectorId nodeConnectorId = NodeStaticReplyTranslatorUtil.nodeConnectorId(
                         dataPathId.toString(), port.getPortNo(), ofVersion);
@@ -128,19 +130,19 @@ public class DeviceInitializationUtils {
                 ncBuilder.addAugmentation(FlowCapableNodeConnectorStatisticsData.class,
                         new FlowCapableNodeConnectorStatisticsDataBuilder().build());
                 final NodeConnector connector = ncBuilder.build();
-                final InstanceIdentifier<NodeConnector> connectorII = deviceState.getNodeInstanceIdentifier().child(
+                final InstanceIdentifier<NodeConnector> connectorII = deviceInfo.getNodeInstanceIdentifier().child(
                         NodeConnector.class, connector.getKey());
                 try {
                     deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, connectorII, connector);
                 } catch (final Exception e) {
-                    LOG.debug("Failed to write node {} to DS ", deviceContext.getDeviceState().getNodeId().toString(),
+                    LOG.debug("Failed to write node {} to DS ", deviceInfo.getNodeId().toString(),
                             e);
                 }
 
             }
         } else if (OFConstants.OFP_VERSION_1_3 == version) {
             final Capabilities capabilities = connectionContext.getFeatures().getCapabilities();
-            LOG.debug("Setting capabilities for device {}", deviceContext.getDeviceState().getNodeId());
+            LOG.debug("Setting capabilities for device {}", deviceInfo.getNodeId());
             DeviceStateUtil.setDeviceStateBasedOnV13Capabilities(deviceState, capabilities);
             deviceFeaturesFuture = createDeviceFeaturesForOF13(deviceContext, deviceState, switchFeaturesMandatory);
         } else {
@@ -151,7 +153,7 @@ public class DeviceInitializationUtils {
         Futures.addCallback(deviceFeaturesFuture, new FutureCallback<List<RpcResult<List<MultipartReply>>>>() {
             @Override
             public void onSuccess(final List<RpcResult<List<MultipartReply>>> result) {
-                LOG.debug("All init data for node {} is in submited.", deviceState.getNodeId());
+                LOG.debug("All init data for node {} is in submited.", deviceInfo.getNodeId());
                 returnFuture.set(null);
             }
 
@@ -160,7 +162,7 @@ public class DeviceInitializationUtils {
                 // FIXME : remove session
                 LOG.trace("Device capabilities gathering future failed.");
                 LOG.trace("more info in exploration failure..", t);
-                LOG.debug("All init data for node {} was not submited correctly - connection has to go down.", deviceState.getNodeId());
+                LOG.debug("All init data for node {} was not submited correctly - connection has to go down.", deviceInfo.getNodeId());
                 returnFuture.setException(t);
             }
         });
@@ -170,13 +172,13 @@ public class DeviceInitializationUtils {
     private static void addNodeToOperDS(final DeviceContext deviceContext, final SettableFuture<Void> future) {
         Preconditions.checkArgument(deviceContext != null);
         final DeviceState deviceState = deviceContext.getDeviceState();
-        final NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceState.getNodeId()).setNodeConnector(
+        final NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceContext.getDeviceInfo().getNodeId()).setNodeConnector(
                 Collections.<NodeConnector>emptyList());
         try {
-            deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceState.getNodeInstanceIdentifier(),
+            deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(),
                     nodeBuilder.build());
         } catch (final Exception e) {
-            LOG.warn("Failed to write node {} to DS ", deviceState.getNodeId(), e);
+            LOG.warn("Failed to write node {} to DS ", deviceContext.getDeviceInfo().getNodeId(), e);
             future.cancel(true);
         }
     }
@@ -184,7 +186,7 @@ public class DeviceInitializationUtils {
     private static ListenableFuture<List<RpcResult<List<MultipartReply>>>> createDeviceFeaturesForOF10(
             final DeviceContext deviceContext, final DeviceState deviceState) {
         final ListenableFuture<RpcResult<List<MultipartReply>>> replyDesc = getNodeStaticInfo(MultipartType.OFPMPDESC,
-                deviceContext, deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
+                deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
 
         return Futures.allAsList(Arrays.asList(replyDesc));
     }
@@ -193,7 +195,7 @@ public class DeviceInitializationUtils {
             final DeviceContext deviceContext, final DeviceState deviceState, final boolean switchFeaturesMandatory) {
 
         final ListenableFuture<RpcResult<List<MultipartReply>>> replyDesc = getNodeStaticInfo(MultipartType.OFPMPDESC,
-                deviceContext, deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
+                deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
 
         //first process description reply, write data to DS and write consequent data if successful
         return Futures.transform(replyDesc,
@@ -203,32 +205,32 @@ public class DeviceInitializationUtils {
                             final RpcResult<List<MultipartReply>> rpcResult) throws Exception {
 
                         translateAndWriteReply(MultipartType.OFPMPDESC, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), rpcResult.getResult());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), rpcResult.getResult());
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyMeterFeature = getNodeStaticInfo(
                                 MultipartType.OFPMPMETERFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
 
                         createSuccessProcessingCallback(MultipartType.OFPMPMETERFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), replyMeterFeature);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyMeterFeature);
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyGroupFeatures = getNodeStaticInfo(
                                 MultipartType.OFPMPGROUPFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
                         createSuccessProcessingCallback(MultipartType.OFPMPGROUPFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), replyGroupFeatures);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyGroupFeatures);
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyTableFeatures = getNodeStaticInfo(
                                 MultipartType.OFPMPTABLEFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), deviceState.getVersion());
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), deviceContext.getDeviceInfo().getVersion());
                         createSuccessProcessingCallback(MultipartType.OFPMPTABLEFEATURES, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), replyTableFeatures);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyTableFeatures);
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyPortDescription = getNodeStaticInfo(
-                                MultipartType.OFPMPPORTDESC, deviceContext, deviceState.getNodeInstanceIdentifier(),
-                                deviceState.getVersion());
+                                MultipartType.OFPMPPORTDESC, deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(),
+                                deviceContext.getDeviceInfo().getVersion());
                         createSuccessProcessingCallback(MultipartType.OFPMPPORTDESC, deviceContext,
-                                deviceState.getNodeInstanceIdentifier(), replyPortDescription);
+                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier(), replyPortDescription);
                         if (switchFeaturesMandatory) {
                             return Futures.allAsList(Arrays.asList(replyMeterFeature, replyGroupFeatures,
                                     replyTableFeatures, replyPortDescription));
@@ -311,11 +313,11 @@ public class DeviceInitializationUtils {
                         final MultipartReplyPortDesc portDesc = ((MultipartReplyPortDescCase) body)
                                 .getMultipartReplyPortDesc();
                         for (final PortGrouping port : portDesc.getPorts()) {
-                            final short ofVersion = dContext.getDeviceState().getVersion();
+                            final short ofVersion = dContext.getDeviceInfo().getVersion();
                             final TranslatorKey translatorKey = new TranslatorKey(ofVersion, PortGrouping.class.getName());
                             final MessageTranslator<PortGrouping, FlowCapableNodeConnector> translator = dContext.oook()
                                     .lookupTranslator(translatorKey);
-                            final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, dContext.getDeviceState(), null);
+                            final FlowCapableNodeConnector fcNodeConnector = translator.translate(port, dContext.getDeviceInfo(), null);
 
                             final BigInteger dataPathId = dContext.getPrimaryConnectionContext().getFeatures()
                                     .getDatapathId();
@@ -340,18 +342,18 @@ public class DeviceInitializationUtils {
                 }
             }
         } catch (final Exception e) {
-            LOG.debug("Failed to write node {} to DS ", dContext.getDeviceState().getNodeId().toString(), e);
+            LOG.debug("Failed to write node {} to DS ", dContext.getDeviceInfo().getNodeId().toString(), e);
         }
     }
 
     private static void createEmptyFlowCapableNodeInDs(final DeviceContext deviceContext) {
         final FlowCapableNodeBuilder flowCapableNodeBuilder = new FlowCapableNodeBuilder();
-        final InstanceIdentifier<FlowCapableNode> fNodeII = deviceContext.getDeviceState().getNodeInstanceIdentifier()
+        final InstanceIdentifier<FlowCapableNode> fNodeII = deviceContext.getDeviceInfo().getNodeInstanceIdentifier()
                 .augmentation(FlowCapableNode.class);
         try {
             deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, fNodeII, flowCapableNodeBuilder.build());
         } catch (final Exception e) {
-            LOG.debug("Failed to write node {} to DS ", deviceContext.getDeviceState().getNodeId().toString(), e);
+            LOG.debug("Failed to write node {} to DS ", deviceContext.getDeviceInfo().getNodeId().toString(), e);
         }
     }
 
@@ -362,7 +364,7 @@ public class DeviceInitializationUtils {
 
         if (remoteAddress == null) {
             LOG.warn("IP address of the node {} cannot be obtained. No connection with switch.", deviceContext
-                    .getDeviceState().getNodeId());
+                    .getDeviceInfo().getNodeId());
             return null;
         }
         LOG.info("IP address of switch is: {}", remoteAddress);
@@ -384,7 +386,7 @@ public class DeviceInitializationUtils {
             try {
                 dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableII, tableBuilder.build());
             } catch (final Exception e) {
-                LOG.debug("Failed to write node {} to DS ", dContext.getDeviceState().getNodeId().toString(), e);
+                LOG.debug("Failed to write node {} to DS ", dContext.getDeviceInfo().getNodeId().toString(), e);
             }
 
         }
@@ -398,7 +400,7 @@ public class DeviceInitializationUtils {
             public void onSuccess(final RpcResult<List<MultipartReply>> rpcResult) {
                 final List<MultipartReply> result = rpcResult.getResult();
                 if (result != null) {
-                    LOG.info("Static node {} info: {} collected", deviceContext.getDeviceState().getNodeId(), type);
+                    LOG.info("Static node {} info: {} collected", deviceContext.getDeviceInfo().getNodeId(), type);
                     translateAndWriteReply(type, deviceContext, nodeII, result);
                 } else {
                     final Iterator<RpcError> rpcErrorIterator = rpcResult.getErrors().iterator();
@@ -486,8 +488,8 @@ public class DeviceInitializationUtils {
                 }
                 if (allSucceeded) {
                     createEmptyFlowCapableNodeInDs(deviceContext);
-                    makeEmptyTables(deviceContext, deviceContext.getDeviceState().getNodeInstanceIdentifier(),
-                            deviceContext.getDeviceState().getFeatures().getTables());
+                    makeEmptyTables(deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(),
+                            deviceContext.getPrimaryConnectionContext().getFeatures().getTables());
                 }
             }
 
index 66c3a4dbb2bd1502d91dbc997739e6858908bd8e..10f3eb9b47f21e621035ed2557fa4a99c910f16a 100644 (file)
@@ -45,7 +45,7 @@ public class LifecycleConductorImplTest {
     @Mock
     private ServiceChangeListener serviceChangeListener;
     @Mock
-    private ConcurrentHashMap<NodeId, ServiceChangeListener> serviceChangeListeners;
+    private ConcurrentHashMap<DeviceInfo, ServiceChangeListener> serviceChangeListeners;
     @Mock
     private DeviceContext deviceContext;
     @Mock
@@ -75,7 +75,7 @@ public class LifecycleConductorImplTest {
 
     @Before
     public void setUp() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(deviceContext);
         when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
 
         lifecycleConductor = new LifecycleConductorImpl(messageIntelligenceAgency);
@@ -90,7 +90,7 @@ public class LifecycleConductorImplTest {
 
     @Test
     public void addOneTimeListenerWhenServicesChangesDoneTest() {
-        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, nodeId);
+        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, deviceInfo);
         assertEquals(false,lifecycleConductor.isServiceChangeListenersEmpty());
     }
 
@@ -100,9 +100,9 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void notifyServiceChangeListenersTest1() {
-        lifecycleConductor.notifyServiceChangeListeners(nodeId,true);
+        lifecycleConductor.notifyServiceChangeListeners(deviceInfo,true);
         when(serviceChangeListeners.size()).thenReturn(0);
-        verify(serviceChangeListeners,times(0)).remove(nodeId);
+        verify(serviceChangeListeners,times(0)).remove(deviceInfo);
     }
 
     /**
@@ -110,9 +110,9 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void notifyServiceChangeListenersTest2() {
-        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, nodeId);
+        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, deviceInfo);
         assertEquals(false,lifecycleConductor.isServiceChangeListenersEmpty());
-        lifecycleConductor.notifyServiceChangeListeners(nodeId,true);
+        lifecycleConductor.notifyServiceChangeListeners(deviceInfo,true);
         assertEquals(true,lifecycleConductor.isServiceChangeListenersEmpty());
     }
 
@@ -122,8 +122,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void roleInitializationDoneTest1() {
-        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, nodeId);
-        lifecycleConductor.roleInitializationDone(nodeId,false);
+        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, deviceInfo);
+        lifecycleConductor.roleInitializationDone(deviceInfo,false);
         verify(deviceContext,times(1)).shutdownConnection();
     }
 
@@ -132,8 +132,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void roleInitializationDoneTest2() {
-        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, nodeId);
-        lifecycleConductor.roleInitializationDone(nodeId,true);
+        lifecycleConductor.addOneTimeListenerWhenServicesChangesDone(serviceChangeListener, deviceInfo);
+        lifecycleConductor.roleInitializationDone(deviceInfo,true);
         verify(deviceContext,times(0)).shutdownConnection();
     }
 
@@ -142,10 +142,10 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void roleChangeOnDeviceTest1() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(null);
-        lifecycleConductor.roleChangeOnDevice(nodeId,true,ofpRole,false);
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(null);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,true,ofpRole,false);
         verify(deviceContext,times(0)).shutdownConnection();
-        lifecycleConductor.roleChangeOnDevice(nodeId,false,ofpRole,false);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,false,ofpRole,false);
         verify(deviceContext,times(0)).shutdownConnection();
     }
 
@@ -154,8 +154,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void roleChangeOnDeviceTest2() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        lifecycleConductor.roleChangeOnDevice(nodeId,false,ofpRole,false);
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(deviceContext);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,false,ofpRole,false);
         verify(deviceContext,times(1)).shutdownConnection();
     }
 
@@ -165,8 +165,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void roleChangeOnDeviceTest3() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        lifecycleConductor.roleChangeOnDevice(nodeId,true,ofpRole,true);
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(deviceContext);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,true,ofpRole,true);
         verify(deviceContext,times(0)).shutdownConnection();
     }
 
@@ -176,9 +176,9 @@ public class LifecycleConductorImplTest {
     @Test
     public void roleChangeOnDeviceTest4() {
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(deviceContext);
         when(deviceContext.onClusterRoleChange(null, OfpRole.BECOMEMASTER)).thenReturn(listenableFuture);
-        lifecycleConductor.roleChangeOnDevice(nodeId,true,OfpRole.BECOMEMASTER,false);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,true,OfpRole.BECOMEMASTER,false);
         verify(statisticsManager).startScheduling(Mockito.<DeviceInfo>any());
     }
 
@@ -188,9 +188,9 @@ public class LifecycleConductorImplTest {
     @Test
     public void roleChangeOnDeviceTest5() {
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(deviceContext);
         when(deviceContext.onClusterRoleChange(null, OfpRole.BECOMESLAVE)).thenReturn(listenableFuture);
-        lifecycleConductor.roleChangeOnDevice(nodeId,true,OfpRole.BECOMESLAVE,false);
+        lifecycleConductor.roleChangeOnDevice(deviceInfo,true,OfpRole.BECOMESLAVE,false);
         verify(statisticsManager).stopScheduling(Mockito.<DeviceInfo>any());
     }
 
@@ -199,8 +199,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void gainVersionSafelyTest1() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(null);
-        assertNull(lifecycleConductor.gainVersionSafely(nodeId));
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(null);
+        assertNull(lifecycleConductor.gainVersionSafely(deviceInfo));
     }
 
     /**
@@ -208,8 +208,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void gainVersionSafelyTest2() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        lifecycleConductor.gainVersionSafely(nodeId);
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(deviceContext);
+        lifecycleConductor.gainVersionSafely(deviceInfo);
         verify(deviceContext,times(1)).getPrimaryConnectionContext();
     }
 
@@ -218,8 +218,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void gainConnectionStateSafelyTest1() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(null);
-        assertNull(lifecycleConductor.gainConnectionStateSafely(nodeId));
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(null);
+        assertNull(lifecycleConductor.gainConnectionStateSafely(deviceInfo));
     }
 
     /**
@@ -227,8 +227,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void gainConnectionStateSafelyTest2() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        lifecycleConductor.gainConnectionStateSafely(nodeId);
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(deviceContext);
+        lifecycleConductor.gainConnectionStateSafely(deviceInfo);
         verify(deviceContext,times(1)).getPrimaryConnectionContext();
     }
 
@@ -237,8 +237,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void reserveXidForDeviceMessageTest1() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(null);
-        assertNull(lifecycleConductor.reserveXidForDeviceMessage(nodeId));
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(null);
+        assertNull(lifecycleConductor.reserveXidForDeviceMessage(deviceInfo));
     }
 
     /**
@@ -246,8 +246,8 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void reserveXidForDeviceMessageTest2() {
-        when(deviceManager.getDeviceContextFromNodeId(nodeId)).thenReturn(deviceContext);
-        lifecycleConductor.reserveXidForDeviceMessage(nodeId);
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(deviceContext);
+        lifecycleConductor.reserveXidForDeviceMessage(deviceInfo);
         verify(deviceContext,times(1)).reserveXidForDeviceMessage();
     }
 
@@ -256,7 +256,7 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void deviceStartInitializationDoneTest() {
-        lifecycleConductor.deviceStartInitializationDone(nodeId, false);
+        lifecycleConductor.deviceStartInitializationDone(deviceInfo, false);
         verify(deviceContext,times(1)).shutdownConnection();
     }
 
@@ -265,7 +265,7 @@ public class LifecycleConductorImplTest {
      */
     @Test
     public void deviceInitializationDoneTest() {
-        lifecycleConductor.deviceInitializationDone(nodeId, false);
+        lifecycleConductor.deviceInitializationDone(deviceInfo, false);
         verify(deviceContext,times(1)).shutdownConnection();
     }
 }
index a787fe7a7536358930f7e90adc51b762371a8167..31e8ffe3b93e6a80ecc140989e24784e79162c1b 100644 (file)
@@ -103,6 +103,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -179,8 +180,9 @@ public class DeviceContextImplTest {
         Mockito.when(rTx.read(LogicalDatastoreType.OPERATIONAL, nodeKeyIdent)).thenReturn(noExistNodeFuture);
         Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(rTx);
         Mockito.when(dataBroker.createTransactionChain(Mockito.any(TransactionChainManager.class))).thenReturn(txChainFactory);
-        Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
-        Mockito.when(deviceState.getNodeId()).thenReturn(nodeId);
+        Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
+        Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
         final SettableFuture<RpcResult<GetAsyncReply>> settableFuture = SettableFuture.create();
         final SettableFuture<RpcResult<MultipartReply>> settableFutureMultiReply = SettableFuture.create();
         Mockito.when(requestContext.getFuture()).thenReturn(settableFuture);
@@ -203,12 +205,11 @@ public class DeviceContextImplTest {
         when(connectionContext.getFeatures()).thenReturn(mockedFeaturesReply);
         when(connectionContext.getFeatures().getCapabilities()).thenReturn(mock(Capabilities.class));
 
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         Mockito.when(featuresOutput.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
         Mockito.when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
-        Mockito.when(deviceState.getFeatures()).thenReturn(featuresOutput);
-        Mockito.when(messageTranslatorPacketReceived.translate(any(Object.class), any(DeviceState.class), any(Object.class))).thenReturn(mock(PacketReceived.class));
-        Mockito.when(messageTranslatorFlowCapableNodeConnector.translate(any(Object.class), any(DeviceState.class), any(Object.class))).thenReturn(mock(FlowCapableNodeConnector.class));
+        Mockito.when(messageTranslatorPacketReceived.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(mock(PacketReceived.class));
+        Mockito.when(messageTranslatorFlowCapableNodeConnector.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(mock(FlowCapableNodeConnector.class));
         Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3, PacketIn.class.getName())))).thenReturn(messageTranslatorPacketReceived);
         Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3, PortGrouping.class.getName())))).thenReturn(messageTranslatorFlowCapableNodeConnector);
         Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3,
@@ -414,7 +415,7 @@ public class DeviceContextImplTest {
         when(connectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
 
         final NodeId dummyNodeId = new NodeId("dummyNodeId");
-        when(deviceState.getNodeId()).thenReturn(dummyNodeId);
+        when(deviceInfo.getNodeId()).thenReturn(dummyNodeId);
 
         final ConnectionContext mockedAuxiliaryConnectionContext = prepareConnectionContext();
         deviceContext.addAuxiliaryConnectionContext(mockedAuxiliaryConnectionContext);
@@ -463,7 +464,7 @@ public class DeviceContextImplTest {
     }
 
     @Test
-    public void testPortStatusMessage() {
+    public void testPortStatusMessage() throws Exception{
         final PortStatusMessage mockedPortStatusMessage = mock(PortStatusMessage.class);
         final Class dummyClass = Class.class;
         when(mockedPortStatusMessage.getImplementedInterface()).thenReturn(dummyClass);
@@ -471,10 +472,10 @@ public class DeviceContextImplTest {
 
         final GetFeaturesOutput mockedFeature = mock(GetFeaturesOutput.class);
         when(mockedFeature.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
-        when(deviceState.getFeatures()).thenReturn(mockedFeature);
 
         when(mockedPortStatusMessage.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         when(mockedPortStatusMessage.getReason()).thenReturn(PortReason.OFPPRADD);
+        when(mockedPortStatusMessage.getPortNo()).thenReturn(42L);
 
         OpenflowPortsUtil.init();
         deviceContext.processPortStatusMessage(mockedPortStatusMessage);
@@ -491,7 +492,7 @@ public class DeviceContextImplTest {
                 .setMatch(new MatchBuilder().build());
         final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class);
 
-        Mockito.when(messageTranslatorFlowRemoved.translate(any(Object.class), any(DeviceState.class), any(Object.class)))
+        Mockito.when(messageTranslatorFlowRemoved.translate(any(Object.class), any(DeviceInfo.class), any(Object.class)))
                 .thenReturn(flowRemovedMdsalBld.build());
 
         // insert flow+flowId into local registry
index 403f6242ac3955d94e0f2c847cb0c492443a8c29..bbb8ae81be9a0574c3a1a56125917f4d6f91d0fa 100644 (file)
@@ -190,7 +190,6 @@ public class DeviceManagerImplTest {
         order.verify(mockConnectionContext).setOutboundQueueProvider(any(OutboundQueueProvider.class));
         order.verify(mockConnectionContext).setOutboundQueueHandleRegistration(
                 Mockito.<OutboundQueueHandlerRegistration<OutboundQueueProvider>>any());
-        order.verify(mockConnectionContext).getNodeId();
         verify(deviceInitPhaseHandler).onDeviceContextLevelUp(Matchers.<DeviceInfo>any());
     }
 
@@ -204,7 +203,7 @@ public class DeviceManagerImplTest {
                 .setPortNo(41L);
         when(mockFeatures.getPhyPort()).thenReturn(Collections.singletonList(phyPort.build()));
         final MessageTranslator<Object, Object> mockedTranslator = mock(MessageTranslator.class);
-        when(mockedTranslator.translate(Matchers.<Object>any(), Matchers.<DeviceState>any(), Matchers.any()))
+        when(mockedTranslator.translate(Matchers.<Object>any(), Matchers.<DeviceInfo>any(), Matchers.any()))
                 .thenReturn(null);
         when(translatorLibrary.lookupTranslator(Matchers.<TranslatorKey>any())).thenReturn(mockedTranslator);
 
@@ -215,7 +214,6 @@ public class DeviceManagerImplTest {
         order.verify(mockConnectionContext).setOutboundQueueProvider(any(OutboundQueueProvider.class));
         order.verify(mockConnectionContext).setOutboundQueueHandleRegistration(
                 Mockito.<OutboundQueueHandlerRegistration<OutboundQueueProvider>>any());
-        order.verify(mockConnectionContext).getNodeId();
         verify(deviceInitPhaseHandler).onDeviceContextLevelUp(Matchers.<DeviceInfo>any());
     }
 
index 012d744252a87cd24ea40bc9b76bd0dc2cc460a4..82230c9862722fef02bcc90ca597dccd5cc6e40d 100644 (file)
@@ -29,15 +29,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * org.opendaylight.openflowplugin.impl.device
  *
  * test of {@link DeviceStateImpl} - lightweight version, using basic ways (TDD)
- *
- * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
- *
- * Created: Mar 29, 2015
  */
 @RunWith(MockitoJUnitRunner.class)
 public class DeviceStateImplTest {
 
-    private NodeId nodeId;
     @Mock
     private FeaturesReply featuresReply;
     private DeviceStateImpl deviceState;
@@ -50,48 +45,9 @@ public class DeviceStateImplTest {
 
     @Before
     public void initialization() {
-        nodeId = new NodeId("test-node-id");
         Mockito.when(featuresReply.getVersion()).thenReturn(version);
         Mockito.when(featuresReply.getPhyPort()).thenReturn(pPort);
-        deviceState = new DeviceStateImpl(featuresReply, nodeId);
-    }
-
-    /**
-     * Test method for {@link DeviceStateImpl#DeviceStateImpl(FeaturesReply, NodeId)}.
-     */
-    @Test(expected=NullPointerException.class)
-    public void testDeviceStateImplNullNodeId(){
-        new DeviceStateImpl(featuresReply, null);
-    }
-
-    /**
-     * Test method for {@link DeviceStateImpl#DeviceStateImpl(FeaturesReply, NodeId)}.
-     */
-    @Test(expected=IllegalArgumentException.class)
-    public void testDeviceStateImplNullFeaturesReply(){
-        new DeviceStateImpl(null, nodeId);
-    }
-
-    /**
-     * Test method for {@link DeviceStateImpl#getNodeId()}.
-     */
-    @Test
-    public void testGetNodeId(){
-        final NodeId getNodeId = deviceState.getNodeId();
-        Assert.assertNotNull(getNodeId);
-        Assert.assertEquals(nodeId, getNodeId);
-    }
-
-    /**
-     * Test method for {@link DeviceStateImpl#getFeatures()}.
-     */
-    @Test
-    public void testGetFeatures(){
-        final GetFeaturesOutputBuilder expetedResult = new GetFeaturesOutputBuilder(featuresReply);
-        final GetFeaturesOutput getFeatures = deviceState.getFeatures();
-        Assert.assertNotNull(getFeatures);
-        Assert.assertEquals(expetedResult.getVersion(), getFeatures.getVersion());
-        Assert.assertEquals(expetedResult.getPhyPort(), getFeatures.getPhyPort());
+        deviceState = new DeviceStateImpl();
     }
 
     @Test
index 296ea4ef6b4d4bb89a7321d65e9276d28645b105..68c07e23539f6a3931ab5ac3f7780cc63ad1100b 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.impl.util.DeviceStateUtil;
@@ -66,6 +67,8 @@ public class TransactionChainManagerTest {
     @Mock
     DeviceState deviceState;
     @Mock
+    DeviceInfo deviceInfo;
+    @Mock
     LifecycleConductor conductor;
 
     @Mock
@@ -85,9 +88,9 @@ public class TransactionChainManagerTest {
                 .thenReturn(txChain);
         nodeId = new NodeId("h2g2:42");
         nodeKeyIdent = DeviceStateUtil.createNodeInstanceIdentifier(nodeId);
-        Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
-        Mockito.when(deviceState.getNodeId()).thenReturn(nodeId);
-        txChainManager = new TransactionChainManager(dataBroker, deviceState, conductor);
+        Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
+        txChainManager = new TransactionChainManager(dataBroker, deviceInfo, conductor);
         Mockito.when(txChain.newWriteOnlyTransaction()).thenReturn(writeTx);
 
         path = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
index 2df7f6edbe9b48ab7b59b8a563246f32904d13a0..cf60cb5e71ef7c91c7e99af799b73c1f531bd684 100644 (file)
@@ -24,6 +24,7 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
@@ -49,6 +50,8 @@ public class FlowRegistryKeyFactoryTest {
     private DeviceContext deviceContext;
     @Mock
     private DeviceState deviceState;
+    @Mock
+    private DeviceInfo deviceInfo;
 
 
     @Before
@@ -59,7 +62,7 @@ public class FlowRegistryKeyFactoryTest {
         }
         FLOWS_STATISTICS_UPDATE_BUILDER.setFlowAndStatisticsMapList(flowAndStatisticsMapListList);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
     }
 
     @Test
index 36385b3c145344d73f378479a988a423098736c5..8349f477a7053abf2224da79a308f856d9a09dbe 100644 (file)
@@ -113,7 +113,7 @@ public class RoleContextImplTest {
     @Test
     public void testCreateRequestContext() throws Exception {
         roleContext.createRequestContext();
-        Mockito.verify(conductor).reserveXidForDeviceMessage(nodeId);
+        Mockito.verify(conductor).reserveXidForDeviceMessage(deviceInfo);
     }
 
     @Test(expected = NullPointerException.class)
index aa9ef753bc67b06d281a1e8ab54c0f7f61fba8ff..fe20b2e68e6f6681e2ef8bc7a7ee3da6b079a82d 100644 (file)
@@ -115,23 +115,22 @@ public class RoleManagerImplTest {
     private final NodeId nodeId2 = NodeId.getDefaultInstance("openflow:2");
 
 
-    private final EntityOwnershipChange masterEntity = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), false, true, true);
-    private final EntityOwnershipChange masterTxEntity = new EntityOwnershipChange(RoleManagerImpl.makeTxEntity(nodeId), false, true, true);
-    private final EntityOwnershipChange slaveEntity = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), true, false, true);
-    private final EntityOwnershipChange slaveTxEntityLast = new EntityOwnershipChange(RoleManagerImpl.makeTxEntity(nodeId), true, false, false);
-    private final EntityOwnershipChange masterEntityNotOwner = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), true, false, true);
+    private final EntityOwnershipChange masterEntity = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), false, true, true, false);
+    private final EntityOwnershipChange masterTxEntity = new EntityOwnershipChange(RoleManagerImpl.makeTxEntity(nodeId), false, true, true, false);
+    private final EntityOwnershipChange slaveEntity = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), true, false, true, false);
+    private final EntityOwnershipChange slaveTxEntityLast = new EntityOwnershipChange(RoleManagerImpl.makeTxEntity(nodeId), true, false, false, false);
+    private final EntityOwnershipChange masterEntityNotOwner = new EntityOwnershipChange(RoleManagerImpl.makeEntity(nodeId), true, false, true, false);
 
     private InOrder inOrder;
 
     @Before
     public void setUp() throws Exception {
         CheckedFuture<Void, TransactionCommitFailedException> future = Futures.immediateCheckedFuture(null);
-        Mockito.when(deviceState.getFeatures()).thenReturn(featuresOutput);
         Mockito.when(entityOwnershipService.registerListener(Mockito.anyString(), Mockito.any(EntityOwnershipListener.class))).thenReturn(entityOwnershipListenerRegistration);
         Mockito.when(entityOwnershipService.registerCandidate(Mockito.any(Entity.class))).thenReturn(entityOwnershipCandidateRegistration);
         Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
+        Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
         Mockito.when(connectionContext.getFeatures()).thenReturn(featuresReply);
         Mockito.when(connectionContext.getNodeId()).thenReturn(nodeId);
         Mockito.when(connectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
@@ -141,13 +140,14 @@ public class RoleManagerImplTest {
         Mockito.doNothing().when(deviceTerminationPhaseHandler).onDeviceContextLevelDown(Mockito.<DeviceInfo>any());
         Mockito.when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
         Mockito.when(writeTransaction.submit()).thenReturn(future);
-        Mockito.when(deviceManager.getDeviceContextFromNodeId(Mockito.<NodeId>any())).thenReturn(deviceContext);
+        Mockito.when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(deviceContext);
         Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
         Mockito.when(deviceInfo2.getNodeId()).thenReturn(nodeId2);
+        Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
         roleManager = new RoleManagerImpl(entityOwnershipService, dataBroker, conductor);
         roleManager.setDeviceInitializationPhaseHandler(deviceInitializationPhaseHandler);
         roleManager.setDeviceTerminationPhaseHandler(deviceTerminationPhaseHandler);
-        Mockito.when(conductor.getDeviceContext(Mockito.<NodeId>any())).thenReturn(deviceContext);
+        Mockito.when(conductor.getDeviceContext(deviceInfo)).thenReturn(deviceContext);
         roleManagerSpy = Mockito.spy(roleManager);
         roleManagerSpy.onDeviceContextLevelUp(deviceInfo);
         roleContextSpy = Mockito.spy(roleManager.getRoleContext(nodeId));
@@ -248,7 +248,7 @@ public class RoleManagerImplTest {
         Mockito.when(roleContextSpy.isTxCandidateRegistered()).thenReturn(false);
         roleManagerSpy.changeOwnershipForTxEntity(slaveTxEntityLast, roleContextSpy);
         verify(roleContextSpy).close();
-        verify(conductor).closeConnection(nodeId);
+        verify(conductor).closeConnection(deviceInfo);
     }
 
     @Test
@@ -256,48 +256,48 @@ public class RoleManagerImplTest {
         Mockito.when(roleContextSpy.isTxCandidateRegistered()).thenReturn(true);
         roleManagerSpy.changeOwnershipForTxEntity(masterEntityNotOwner, roleContextSpy);
         verify(roleContextSpy).close();
-        verify(conductor).closeConnection(nodeId);
+        verify(conductor).closeConnection(deviceInfo);
     }
 
     @Test
     public void testAddListener() throws Exception {
         roleManager.addRoleChangeListener((new RoleChangeListener() {
             @Override
-            public void roleInitializationDone(final NodeId nodeId, final boolean success) {
-                Assert.assertTrue(nodeId.equals(nodeId));
+            public void roleInitializationDone(final DeviceInfo deviceInfo_, final boolean success) {
+                Assert.assertTrue(deviceInfo.equals(deviceInfo_));
                 Assert.assertTrue(success);
             }
 
             @Override
-            public void roleChangeOnDevice(final NodeId nodeId_, final boolean success, final OfpRole newRole, final boolean initializationPhase) {
-                Assert.assertTrue(nodeId.equals(nodeId_));
+            public void roleChangeOnDevice(final DeviceInfo deviceInfo_, final boolean success, final OfpRole newRole, final boolean initializationPhase) {
+                Assert.assertTrue(deviceInfo.equals(deviceInfo_));
                 Assert.assertTrue(success);
                 Assert.assertFalse(initializationPhase);
                 Assert.assertTrue(newRole.equals(OfpRole.BECOMEMASTER));
             }
         }));
-        roleManager.notifyListenersRoleInitializationDone(nodeId, true);
-        roleManager.notifyListenersRoleChangeOnDevice(nodeId, true, OfpRole.BECOMEMASTER, false);
+        roleManager.notifyListenersRoleInitializationDone(deviceInfo, true);
+        roleManager.notifyListenersRoleChangeOnDevice(deviceInfo, true, OfpRole.BECOMEMASTER, false);
     }
 
     @Test
     public void testMakeDeviceRoleChange() throws Exception{
         roleManagerSpy.makeDeviceRoleChange(OfpRole.BECOMEMASTER, roleContextSpy, true);
         verify(roleManagerSpy, atLeastOnce()).sendRoleChangeToDevice(Mockito.<OfpRole>any(), Mockito.<RoleContext>any());
-        verify(roleManagerSpy, atLeastOnce()).notifyListenersRoleChangeOnDevice(Mockito.<NodeId>any(), eq(true), Mockito.<OfpRole>any(), eq(true));
+        verify(roleManagerSpy, atLeastOnce()).notifyListenersRoleChangeOnDevice(Mockito.<DeviceInfo>any(), eq(true), Mockito.<OfpRole>any(), eq(true));
     }
 
     @Test
     public void testServicesChangeDone() throws Exception {
         roleManagerSpy.setRoleContext(nodeId2, roleContextSpy);
-        roleManagerSpy.servicesChangeDone(nodeId2, true);
+        roleManagerSpy.servicesChangeDone(deviceInfo2, true);
         verify(roleContextSpy).unregisterCandidate(Mockito.<Entity>any());
     }
 
     @Test
     public void testServicesChangeDoneContextIsNull() throws Exception {
         roleManagerSpy.setRoleContext(nodeId, roleContextSpy);
-        roleManagerSpy.servicesChangeDone(nodeId2, true);
+        roleManagerSpy.servicesChangeDone(deviceInfo2, true);
         verify(roleContextSpy, never()).unregisterCandidate(Mockito.<Entity>any());
     }
 }
\ No newline at end of file
index f523828cb17d9c76dac987c531dbc1855e352cac..08f97f5c619db89afb3ebca3ae17350dc5feddb5 100644 (file)
@@ -21,6 +21,7 @@ import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.XidSequencer;
@@ -47,6 +48,8 @@ public class RpcContextImplTest {
     @Mock
     private DeviceState deviceState;
     @Mock
+    private DeviceInfo deviceInfo;
+    @Mock
     private XidSequencer xidSequencer;
     @Mock
     private MessageSpy messageSpy;
@@ -67,7 +70,7 @@ public class RpcContextImplTest {
         nodeInstanceIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
 
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
+        when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
         when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
 
         rpcContext = new RpcContextImpl(rpcProviderRegistry,deviceContext, messageSpy, MAX_REQUESTS,nodeInstanceIdentifier);
index 60ca70f6195072d3f1dc4cd90419df2819dbefac..333ef0576eb673d02b6254d652bb3f7de65169dc 100644 (file)
@@ -103,28 +103,26 @@ public class RpcManagerImplTest {
         Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
         Mockito.when(deviceContext.getItemLifeCycleSourceRegistry()).thenReturn(itemLifeCycleRegistry);
-        Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodePath);
-        Mockito.when(deviceState.getFeatures()).thenReturn(featuresOutput);
+        Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
         rpcManager.setDeviceTerminationPhaseHandler(deviceTerminationPhaseHandler);
         Mockito.when(connectionContext.getFeatures()).thenReturn(features);
         Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
         Mockito.when(deviceContext.getItemLifeCycleSourceRegistry()).thenReturn(itemLifeCycleRegistry);
-        Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodePath);
+        Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
         Mockito.when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
         Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeKey.getId());
-        Mockito.when(deviceState.getNodeId()).thenReturn(nodeKey.getId());
         Mockito.when(rpcProviderRegistry.addRoutedRpcImplementation(
                 Matchers.<Class<RpcService>>any(), Matchers.any(RpcService.class)))
                 .thenReturn(routedRpcRegistration);
-        Mockito.when(conductor.getDeviceContext(Mockito.<NodeId>any())).thenReturn(deviceContext);
+        Mockito.when(conductor.getDeviceContext(deviceInfo)).thenReturn(deviceContext);
         Mockito.when(contexts.remove(deviceInfo)).thenReturn(removedContexts);
     }
 
     @Test
     public void onDeviceContextLevelUp() throws Exception {
         rpcManager.onDeviceContextLevelUp(deviceInfo);
-        verify(conductor).getDeviceContext(Mockito.<NodeId>any());
+        verify(conductor).getDeviceContext(deviceInfo);
     }
 
     @Test
index 5239335897abfc319efdd9000ddc8f41bf5b1a7a..8916519edd590054bc3119a31156895c452ddeb8 100644 (file)
@@ -51,6 +51,6 @@ public class FlowCapableTransactionServiceImplTest extends ServiceMocking {
 
     private SendBarrierInput buildSendBarrierInput() {
         return new SendBarrierInputBuilder()
-                .setNode(new NodeRef(mockedDeviceState.getNodeInstanceIdentifier())).build();
+                .setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier())).build();
     }
 }
\ No newline at end of file
index 756b1ee4371b6cb5a0a85521d5b9823f6100199a..3e4c4f0162caa738b967c46acea0d27829dcf537 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
@@ -88,6 +89,8 @@ public class MultipartRequestOnTheFlyCallbackTest {
     @Mock
     private DeviceState mockedDeviceState;
     @Mock
+    private DeviceInfo mockedDeviceInfo;
+    @Mock
     private GetFeaturesOutput mocketGetFeaturesOutput;
     @Mock
     private DeviceFlowRegistry mockedFlowRegistry;
@@ -113,15 +116,16 @@ public class MultipartRequestOnTheFlyCallbackTest {
         when(mocketGetFeaturesOutput.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
 
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimaryConnection);
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(NODE_PATH);
-        when(mockedDeviceState.getFeatures()).thenReturn(mocketGetFeaturesOutput);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_PATH);
         when(mockedDeviceState.deviceSynchronized()).thenReturn(true);
-        when(mockedDeviceState.getNodeId()).thenReturn(mockedNodeId);
+        when(mockedDeviceInfo.getNodeId()).thenReturn(mockedNodeId);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
 
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
         when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(mockedFlowRegistry);
 
-        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceState.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
         final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
         flowNodeBuilder.setTable(Collections.<Table> emptyList());
         final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
@@ -137,8 +141,8 @@ public class MultipartRequestOnTheFlyCallbackTest {
             }
         };
         multipartRequestOnTheFlyCallback = new MultipartRequestOnTheFlyCallback(dummyRequestContext, String.class,
-                mockedDeviceContext.getMessageSpy(),dummyEventIdentifier, mockedDeviceContext.getDeviceState(),
-                mockedDeviceContext.getDeviceFlowRegistry(), mockedDeviceContext);
+                mockedDeviceContext.getMessageSpy(),dummyEventIdentifier, mockedDeviceInfo,
+                mockedDeviceContext.getDeviceFlowRegistry(), mockedDeviceContext, mockedDeviceState);
     }
 
 
@@ -205,7 +209,7 @@ public class MultipartRequestOnTheFlyCallbackTest {
                 .setMultipartReplyBody(multipartReplyFlowCaseBuilder.build())
                 .setXid(21L);
 
-        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceState.getNodeInstanceIdentifier()
+        final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceInfo.getNodeInstanceIdentifier()
                 .augmentation(FlowCapableNode.class);
         final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
         final TableBuilder tableDataBld = new TableBuilder();
index cad3b6968dd0fb9c072b8b0012eddb4e081eea14..7647e5c3367aadadd079c52a0dbd7777d2a1211b 100644 (file)
@@ -79,7 +79,7 @@ public class PacketProcessingServiceImplTest extends ServiceMocking {
     private TransmitPacketInput buildTransmitPacketInput() {
         TransmitPacketInputBuilder transmitPacketInputBld = new TransmitPacketInputBuilder()
                 .setBufferId(OFConstants.OFP_NO_BUFFER)
-                .setNode(new NodeRef(mockedDeviceState.getNodeInstanceIdentifier()))
+                .setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier()))
                 .setPayload(ULTIMATE_PAYLOAD.getBytes())
                 .setEgress(new NodeConnectorRef(pathToNodeconnector));
         return transmitPacketInputBld.build();
index 62f00d19ad000a83b90640ffa12b8450dfb92934..80017d1948c82d3e385c3ae9b9cb5517b28561fa 100644 (file)
@@ -74,7 +74,7 @@ public class SalExperimenterMessageServiceImplTest extends ServiceMocking {
 
     private SendExperimenterInput buildSendExperimenterInput() {
         SendExperimenterInputBuilder sendExperimenterInputBld = new SendExperimenterInputBuilder()
-                .setNode(new NodeRef(mockedDeviceState.getNodeInstanceIdentifier()))
+                .setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier()))
                 .setExperimenterMessageOfChoice(new DummyExperimenter());
         return sendExperimenterInputBld.build();
     }
index 3cf72599f8d30a8a62c97fbb72f70289e10788f5..53e422c7c5a84fac01b65d0fea11cdf7b542f502 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -95,6 +96,8 @@ public class SalFlowServiceImplTest extends TestCase {
     @Mock
     private DeviceState mockedDeviceState;
     @Mock
+    private DeviceInfo mockedDeviceInfo;
+    @Mock
     private DeviceFlowRegistry deviceFlowRegistry;
     @Mock
     private GetFeaturesOutput mockedFeaturesOutput;
@@ -119,9 +122,11 @@ public class SalFlowServiceImplTest extends TestCase {
         when(requestContext.getXid()).thenReturn(new Xid(84L));
         when(requestContext.getFuture()).thenReturn(RpcResultBuilder.success().buildFuture());
 
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(NODE_II);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeaturesOutput);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_II);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
+        when(mockedDeviceInfo.getVersion()).thenReturn(DUMMY_VERSION);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
 
         salFlowService = new SalFlowServiceImpl(mockedRequestContextStack, mockedDeviceContext);
     }
index 35c702a5126ee290bd3d5c40c46c890fc29ed9a3..6781b157de0fc5f8d9ceb1204243c50e610de72c 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -76,6 +77,9 @@ public class SalRoleServiceImplTest {
     @Mock
     private DeviceState mockDeviceState;
 
+    @Mock
+    private DeviceInfo mockDeviceInfo;
+
     @Mock
     private GetFeaturesOutput mockFeaturesOutput;
 
@@ -93,10 +97,11 @@ public class SalRoleServiceImplTest {
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
-        Mockito.when(mockDeviceState.getNodeId()).thenReturn(testNodeId);
-        Mockito.when(mockDeviceState.getFeatures()).thenReturn(mockFeaturesOutput);
+        Mockito.when(mockDeviceInfo.getNodeId()).thenReturn(testNodeId);
+        Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
         Mockito.when(mockFeaturesOutput.getVersion()).thenReturn(testVersion);
         Mockito.when(mockDeviceContext.getDeviceState()).thenReturn(mockDeviceState);
+        Mockito.when(mockDeviceContext.getDeviceInfo()).thenReturn(mockDeviceInfo);
         Mockito.when(mockDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
         Mockito.when(mockConnectionContext.getFeatures()).thenReturn(mockFeaturesReply);
         Mockito.when(mockConnectionContext.getNodeId()).thenReturn(testNodeId);
index d826926f539fa1b4fce479a28c2b779bb7d20d34..4f699693afa9de139c4ba96483a4a30c960c058b 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -64,6 +65,8 @@ public abstract class ServiceMocking {
     @Mock
     protected DeviceState mockedDeviceState;
     @Mock
+    protected DeviceInfo mockedDeviceInfo;
+    @Mock
     protected DeviceInitializationPhaseHandler mockedDevicePhaseHandler;
     @Mock
     protected RequestContext mockedRequestContext;
@@ -88,13 +91,15 @@ public abstract class ServiceMocking {
         when(mockedPrimConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
         when(mockedPrimConnectionContext.getOutboundQueueProvider()).thenReturn(mockedOutboundQueue);
 
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(NODE_II);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeaturesOutput);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_II);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
+        when(mockedDeviceInfo.getVersion()).thenReturn(DUMMY_VERSION);
 
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext);
         when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy);
         when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl());
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
         when(mockedDeviceContext.getMultiMsgCollector(Matchers.<RequestContext<List<MultipartReply>>>any())).thenReturn(multiMessageCollector);
 
         setup();
index 022e2d68e80223257ad93436c5cf600ed2cddbf5..c47456cc897d1a7b2266ebeed4d2b11507025ecb 100644 (file)
@@ -15,7 +15,6 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.junit.Before;
-import org.mockito.Mockito;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -35,6 +34,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
+import java.math.BigInteger;
+
 
 class StatisticsContextImpMockInitiation {
     Boolean isTable = false;
@@ -80,10 +81,11 @@ class StatisticsContextImpMockInitiation {
         when(mockedDeviceState.isMetersAvailable()).thenReturn(isMeter);
         when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(isPort);
         when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(isQueue);
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(dummyNodeII);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeaturesOutput);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(dummyNodeII);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
 
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
         when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessageSpy);
 
@@ -92,9 +94,9 @@ class StatisticsContextImpMockInitiation {
         when(mockedConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
         when(mockedConnectionContext.getOutboundQueueProvider()).thenReturn(mockedOutboundQueue);
 
-        when(mockedDeviceManager.getDeviceContextFromNodeId(Mockito.<NodeId>any())).thenReturn(mockedDeviceContext);
+        when(mockedDeviceManager.getDeviceContextFromNodeId(mockedDeviceInfo)).thenReturn(mockedDeviceContext);
         mockConductor.setSafelyDeviceManager(mockedDeviceManager);
-        when(mockConductor.getDeviceContext(Mockito.<NodeId>any())).thenReturn(mockedDeviceContext);
+        when(mockConductor.getDeviceContext(mockedDeviceInfo)).thenReturn(mockedDeviceContext);
 
     }
 }
index 2006ca210f5920b19a1e61192a2dc7b33d5da920..2bebe44a60029e867586b09bd611b0bbfff25fe9 100644 (file)
@@ -32,7 +32,6 @@ import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
@@ -52,7 +51,7 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio
     @Before
     public void setUp() throws Exception {
         when(mockedDeviceContext.reserveXidForDeviceMessage()).thenReturn(TEST_XID);
-        when(mockConductor.getDeviceContext(Mockito.<NodeId>any())).thenReturn(mockedDeviceContext);
+        when(mockConductor.getDeviceContext(mockedDeviceInfo)).thenReturn(mockedDeviceContext);
         initStatisticsContext();
     }
 
@@ -100,14 +99,13 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio
     @Test
     public void testGatherDynamicData_all() throws Exception {
         Mockito.reset(mockedDeviceState);
-        when(mockedDeviceState.getFeatures()).thenReturn(mock(GetFeaturesOutput.class));
         when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isFlowStatisticsAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isGroupAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isMetersAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(Boolean.TRUE);
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(dummyNodeII);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(dummyNodeII);
         initStatisticsContext();
 
         when(mockedStatisticsGatheringService.getStatisticsOfType(Matchers.any(EventIdentifier.class), Matchers.any(MultipartType.class)))
index b1c389eca913baf3743cfd57f16c42968dfcbf64..2897c25cabfb712a7862ac04bf1c7e3e224b2ec0 100644 (file)
@@ -40,6 +40,7 @@ import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
@@ -159,6 +160,8 @@ public class StatisticsGatheringUtilsTest {
     private ConnectionContext connectionAdapter;
     @Mock
     private StatisticsGatherer statisticsService;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     public StatisticsGatheringUtilsTest() {
         OpenflowPortsUtil.init();
@@ -167,19 +170,21 @@ public class StatisticsGatheringUtilsTest {
     @Before
     public void setUp() throws Exception {
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
+        when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
         when(deviceContext.getDeviceFlowRegistry()).thenReturn(deviceFlowRegistry);
         when(deviceContext.getDeviceGroupRegistry()).thenReturn(deviceGroupRegistry);
         when(deviceContext.getDeviceMeterRegistry()).thenReturn(deviceMeterRegistry);
         when(deviceContext.getReadTransaction()).thenReturn(readTx);
         when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionAdapter);
         when(connectionAdapter.getNodeId()).thenReturn(DUMMY_NODE_ID);
-        when(deviceState.getFeatures()).thenReturn(features);
         when(connectionAdapter.getFeatures()).thenReturn(features);
-
-        when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         when(features.getDatapathId()).thenReturn(BigInteger.ONE);
+        when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+
+        when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        when(deviceInfo.getDatapathId()).thenReturn(BigInteger.ONE);
 
-        when(deviceState.getNodeInstanceIdentifier()).thenReturn(dummyNodePath);
+        when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(dummyNodePath);
     }
 
     @After
@@ -194,7 +199,7 @@ public class StatisticsGatheringUtilsTest {
         final ArgumentCaptor<Flow> flow = ArgumentCaptor.forClass(Flow.class);
 
         StatisticsGatheringUtils.writeFlowStatistics(prepareFlowStatisticsData(),
-                deviceContext.getDeviceState(), deviceContext.getDeviceFlowRegistry(), deviceContext);
+                deviceInfo, deviceContext.getDeviceFlowRegistry(), deviceContext);
 
         Mockito.verify(deviceContext).writeToTransaction(
                 dataStoreType.capture(), flowPath.capture(), flow.capture());
@@ -494,8 +499,8 @@ public class StatisticsGatheringUtilsTest {
     @Test
     public void testDeleteAllKnownFlowsNotSync() throws Exception {
         when(deviceState.deviceSynchronized()).thenReturn(false);
-        StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext.getDeviceState(),
-                deviceContext.getDeviceFlowRegistry(), deviceContext);
+        StatisticsGatheringUtils.deleteAllKnownFlows(deviceInfo,
+                deviceContext.getDeviceFlowRegistry(), deviceContext, deviceState);
         Mockito.verifyNoMoreInteractions(deviceFlowRegistry);
     }
 
@@ -503,7 +508,7 @@ public class StatisticsGatheringUtilsTest {
     public void testDeleteAllKnownFlows() throws Exception {
         final short tableId = 0;
         when(deviceState.deviceSynchronized()).thenReturn(true);
-        final InstanceIdentifier<FlowCapableNode> nodePath = deviceState.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+        final InstanceIdentifier<FlowCapableNode> nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
         final TableBuilder tableDataBld = new TableBuilder();
         tableDataBld.setId(tableId);
         final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
@@ -511,11 +516,11 @@ public class StatisticsGatheringUtilsTest {
         final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
         final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt);
         when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
-        final KeyedInstanceIdentifier<Table, TableKey> tablePath = deviceState.getNodeInstanceIdentifier()
+        final KeyedInstanceIdentifier<Table, TableKey> tablePath = deviceInfo.getNodeInstanceIdentifier()
                 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId));
 
-        StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext.getDeviceState(),
-                deviceContext.getDeviceFlowRegistry(), deviceContext);
+        StatisticsGatheringUtils.deleteAllKnownFlows(deviceInfo,
+                deviceContext.getDeviceFlowRegistry(), deviceContext, deviceState);
 
         verify(deviceContext).writeToTransaction(
                 LogicalDatastoreType.OPERATIONAL,
index 2d732f13a425c827406c75ccd37b96c795446de8..aab0e8e04a6f5a02ed91782e0a6b15390f57a288 100644 (file)
@@ -156,12 +156,11 @@ public class StatisticsManagerImplTest {
         when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(Boolean.TRUE);
         when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(Boolean.TRUE);
-        when(mockedDeviceState.getFeatures()).thenReturn(featuresOutput);
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(nodePath);
 
+        when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
         when(deviceInfo.getNodeId()).thenReturn(NODE_ID);
-        when(mockedDeviceState.getNodeId()).thenReturn(NODE_ID);
 
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(deviceInfo);
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext);
         when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy);
         when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl());
@@ -183,8 +182,8 @@ public class StatisticsManagerImplTest {
 
         statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, false, conductor);
         statisticsManager.setDeviceInitializationPhaseHandler(deviceInitializationPhaseHandler);
-        when(deviceManager.getDeviceContextFromNodeId(Mockito.<NodeId>any())).thenReturn(mockedDeviceContext);
-        when(conductor.getDeviceContext(Mockito.<NodeId>any())).thenReturn(mockedDeviceContext);
+        when(deviceManager.getDeviceContextFromNodeId(deviceInfo)).thenReturn(mockedDeviceContext);
+        when(conductor.getDeviceContext(deviceInfo)).thenReturn(mockedDeviceContext);
     }
 
     @Test
@@ -375,7 +374,7 @@ public class StatisticsManagerImplTest {
         final TimeCounter mockTimerCounter = Mockito.mock(TimeCounter.class);
 
         statisticsManager.pollStatistics(mockedDeviceContext, statisticsContext, mockTimerCounter);
-        verify(mockedDeviceContext).getDeviceState();
+        verify(mockedDeviceContext).getDeviceInfo();
 
         when(mockedDeviceContext.getDeviceState().isValid()).thenReturn(true);
         statisticsManager.pollStatistics(mockedDeviceContext, statisticsContext, mockTimerCounter);
index a3480ed9ad9775bdc4890d643e19b9a7b4c59bb3..bd25110f4a528f2efaa7e5cf161251c1b6130ab7 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
@@ -64,6 +65,8 @@ public abstract class AbstractStatsServiceTest {
     protected TranslatorLibrary translatorLibrary;
     @Mock
     protected DeviceState deviceState;
+    @Mock
+    protected DeviceInfo deviceInfo;
 
 
     public static final NodeId NODE_ID = new NodeId("unit-test-node:123");
@@ -91,9 +94,10 @@ public abstract class AbstractStatsServiceTest {
         Mockito.when(deviceContext.getMultiMsgCollector(Matchers.any(RequestContext.class))).thenReturn(multiMsgCollector);
         Mockito.when(deviceContext.oook()).thenReturn(translatorLibrary);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        Mockito.when(deviceState.getNodeId()).thenReturn(NODE_ID);
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
-        Mockito.when(deviceState.getFeatures()).thenReturn(getFeaturesOutput);
+        Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(NODE_ID);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
         Mockito.when(connectionContext.getFeatures()).thenReturn(features);
         Mockito.when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
         Mockito.when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
index 236e50577a1d81e77995b223aac88199de7c48bf..8c3d71dbb6debce9ebdcba942fc22549578c7f6b 100644 (file)
@@ -82,7 +82,7 @@ public class OpendaylightFlowStatisticsServiceImpl2Test extends AbstractStatsSer
                          }
         ).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
         Mockito.when(translator.translate(
-                        Matchers.any(MultipartReply.class), Matchers.same(deviceState), Matchers.isNull())
+                        Matchers.any(MultipartReply.class), Matchers.same(deviceInfo), Matchers.isNull())
         ).thenReturn(new AggregatedFlowStatisticsBuilder().build());
 
 
index d6dccf17037816a9bc6fbe6ac31442043455be0a..598ddbcad2d596f49e0df0d6b907daaa8eebd50a 100644 (file)
@@ -24,6 +24,7 @@ import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
@@ -64,6 +65,8 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest
     @Mock
     private DeviceState deviceState;
     @Mock
+    private DeviceInfo deviceInfo;
+    @Mock
     private MessageTranslator<Object, Object> translator;
     @Mock
     private GetFeaturesOutput featuresOutput;
@@ -95,9 +98,9 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest
         Mockito.when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        Mockito.when(deviceState.getNodeId()).thenReturn(NODE_ID);
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
-        Mockito.when(deviceState.getFeatures()).thenReturn(featuresOutput);
+        Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
+        Mockito.when(deviceInfo.getNodeId()).thenReturn(NODE_ID);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting();
         Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
 
@@ -140,7 +143,7 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest
                 .setFlowCount(new Counter32(12L))
                 .setPacketCount(new Counter64(BigInteger.valueOf(13L)))
                 .build();
-        Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceState), Matchers.any()))
+        Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any()))
                 .thenReturn(aggregatedStats);
 
 
index 835e489101cbd5b2987bd6448445c44a9194b59e..2e08295b19c60269c2ab3177295dead2c64ad1ec 100644 (file)
@@ -95,7 +95,7 @@ public class OpendaylightFlowStatisticsServiceDelegateImplTest extends AbstractS
                 .setNode(createNodeRef("unitProt:123"))
                 .setTableId(new TableId((short) 1));
 
-        Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceState), Matchers.any()))
+        Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any()))
                 .thenReturn(new AggregatedFlowStatisticsBuilder()
                         .setByteCount(new Counter64(BigInteger.valueOf(50L)))
                         .setPacketCount(new Counter64(BigInteger.valueOf(51L)))
index ab611e216afbb57f0e163a8732e748d2acccd267..8bb91a8249dbc16fb02c5a0301d5293b9e05468f 100644 (file)
@@ -31,7 +31,7 @@ public class StatisticsGatheringOnTheFlyServiceTest extends ServiceMocking {
     protected void setup() {
         statisticsGatheringService = new StatisticsGatheringOnTheFlyService(mockedRequestContextStack, mockedDeviceContext);
         Mockito.doReturn(NODE_ID).when(mockedPrimConnectionContext).getNodeId();
-        Mockito.when(mockedDeviceContext.getDeviceState().getNodeId()).thenReturn(NODE_ID);
+        Mockito.when(mockedDeviceInfo.getNodeId()).thenReturn(NODE_ID);
     }
 
     @Test
index 7263b980c7841715982f7bbe0b032355e22ec180..ac20355da025133340165830708bff5620a7dc60 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
@@ -67,7 +68,7 @@ public abstract class AbstractDirectStatisticsServiceTest {
     @Mock
     protected DeviceState deviceState;
     @Mock
-    protected GetFeaturesOutput getFeaturesOutput;
+    protected DeviceInfo deviceInfo;
 
     protected NodeConnectorId nodeConnectorId;
     protected KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier;
@@ -95,13 +96,11 @@ public abstract class AbstractDirectStatisticsServiceTest {
         when(deviceContext.getMultiMsgCollector(any())).thenReturn(multiMsgCollector);
         when(deviceContext.oook()).thenReturn(translatorLibrary);
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
-        when(deviceState.getNodeId()).thenReturn(new NodeId(NODE_ID));
-        when(deviceState.getVersion()).thenReturn(OF_VERSION);
-        when(deviceState.getFeatures()).thenReturn(getFeaturesOutput);
-        when(getFeaturesOutput.getVersion()).thenReturn(OF_VERSION);
-        when(getFeaturesOutput.getDatapathId()).thenReturn(DATAPATH_ID);
+        when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
+        when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
+        when(deviceInfo.getNodeId()).thenReturn(new NodeId(NODE_ID));
+        when(deviceInfo.getVersion()).thenReturn(OF_VERSION);
+        when(deviceInfo.getDatapathId()).thenReturn(DATAPATH_ID);
         when(connectionContext.getFeatures()).thenReturn(features);
         when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
         when(features.getVersion()).thenReturn(OF_VERSION);
index bac6d1ebc571885026961161e8d97802f4e9091e..83eae57e0f2e5d123ee228a34ad1da603bc2ab7c 100644 (file)
@@ -15,6 +15,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
@@ -30,6 +31,8 @@ public class AggregatedFlowStatisticsTranslatorTest {
     private AggregatedFlowStatisticsTranslator translator;
     @Mock
     private DeviceState deviceState;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     @Before
     public void setUp() throws Exception {
@@ -47,7 +50,7 @@ public class AggregatedFlowStatisticsTranslatorTest {
         MultipartReplyMessageBuilder mpInputBld = new MultipartReplyMessageBuilder()
                 .setMultipartReplyBody(inputBld.build());
 
-        final AggregatedFlowStatistics statistics = translator.translate(mpInputBld.build(), deviceState, null);
+        final AggregatedFlowStatistics statistics = translator.translate(mpInputBld.build(), deviceInfo, null);
 
         Assert.assertEquals(aggregateStatsValueBld.getByteCount(), statistics.getByteCount().getValue());
         Assert.assertEquals(aggregateStatsValueBld.getFlowCount(), statistics.getFlowCount().getValue());
index 823a5b14651c24b875f6315b5d7d5999706b741e..5fa15e094b6a8cd326f89cb5104c366614c6aa50 100644 (file)
@@ -20,6 +20,7 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
@@ -52,6 +53,9 @@ public class FlowRemovedTranslatorTest {
     @Mock
     private DeviceState deviceState;
 
+    @Mock
+    private DeviceInfo deviceInfo;
+
     @Mock
     private GetFeaturesOutput features;
 
@@ -69,15 +73,14 @@ public class FlowRemovedTranslatorTest {
         translatorV10 = new FlowRemovedV10Translator();
 
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeId);
-        when(deviceState.getFeatures()).thenReturn(features);
+        when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeId);
         when(features.getDatapathId()).thenReturn(BigInteger.TEN);
     }
 
     @Test
     public void testTranslate() throws Exception {
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved flowRemovedMessage = buildMessage(false);
-        final FlowRemoved flowRemoved = translator.translate(flowRemovedMessage, deviceState, null);
+        final FlowRemoved flowRemoved = translator.translate(flowRemovedMessage, deviceInfo, null);
 
         assertEquals(flowRemovedMessage.getCookie(), flowRemoved.getCookie().getValue());
         assertEquals(flowRemovedMessage.getPriority(), flowRemoved.getPriority());
@@ -87,7 +90,7 @@ public class FlowRemovedTranslatorTest {
     @Test
     public void testTranslateV10() throws Exception {
         org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved flowRemovedMessage = buildMessage(true);
-        final FlowRemoved flowRemoved = translatorV10.translate(flowRemovedMessage, deviceState, null);
+        final FlowRemoved flowRemoved = translatorV10.translate(flowRemovedMessage, deviceInfo, null);
 
         assertEquals(flowRemovedMessage.getCookie(), flowRemoved.getCookie().getValue());
         assertEquals(flowRemovedMessage.getPriority(), flowRemoved.getPriority());
index f6358fad05462f83e37d6ae8eaf8eebcd4c374cf..18e244e2f8b9d6924db2e4a81a09c0ed280dcde1 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -63,6 +64,8 @@ public class PacketReceivedTranslatorTest {
     @Mock
     DeviceContext deviceContext;
     @Mock
+    DeviceInfo deviceInfo;
+    @Mock
     List<PhyPort> phyPorts;
     @Mock
     PhyPort phyPort;
@@ -84,8 +87,8 @@ public class PacketReceivedTranslatorTest {
         Mockito.when(connectionContext.getFeatures()).thenReturn(featuresReply);
         Mockito.when(featuresReply.getDatapathId()).thenReturn(BigInteger.TEN);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
-        Mockito.when(deviceState.getFeatures()).thenReturn(getFeaturesOutput);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
         Mockito.when(getFeaturesOutput.getDatapathId()).thenReturn(BigInteger.TEN);
         Mockito.when(getFeaturesOutput.getPhyPort()).thenReturn(phyPorts);
         Mockito.when(phyPort.getPortNo()).thenReturn(PORT_NO_DS);
@@ -98,9 +101,9 @@ public class PacketReceivedTranslatorTest {
                 .child(Node.class, new NodeKey(new NodeId("openflow:10")));
         final PacketReceivedTranslator packetReceivedTranslator = new PacketReceivedTranslator();
         final PacketInMessage packetInMessage = createPacketInMessage(DATA.getBytes(), PORT_NO);
-        Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodePath);
+        Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
 
-        final PacketReceived packetReceived = packetReceivedTranslator.translate(packetInMessage, deviceState, null);
+        final PacketReceived packetReceived = packetReceivedTranslator.translate(packetInMessage, deviceInfo, null);
 
         Assert.assertArrayEquals(packetInMessage.getData(), packetReceived.getPayload());
         Assert.assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController",
index c4a1f2a285ff76ddac21c96ec5126f12e32a81b7..5500dea5ee8cca73858cc82da691fe1d6c59c57e 100644 (file)
@@ -17,6 +17,7 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
@@ -40,6 +41,8 @@ public class PortUpdateTranslatorTest {
     private DeviceContext deviceContext;
     @Mock
     private DeviceState deviceState;
+    @Mock
+    private DeviceInfo deviceInfo;
 
     private org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig portConfig;
     private StateBuilder portStateBld;
@@ -47,7 +50,7 @@ public class PortUpdateTranslatorTest {
 
     @Before
     public void setUp() throws Exception {
-        Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
+        Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
         portUpdateTranslator = new PortUpdateTranslator();
 
         portStateBld = new StateBuilder().setLive(true);
@@ -59,13 +62,13 @@ public class PortUpdateTranslatorTest {
 
     @Test
     public void testTranslate_13() throws Exception {
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures portFeatures =
                 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures
                         .getDefaultInstance("hundredGbFd");
 
 
-        final FlowCapableNodeConnector nodeConnector = portUpdateTranslator.translate(portBld.build(), deviceState, null);
+        final FlowCapableNodeConnector nodeConnector = portUpdateTranslator.translate(portBld.build(), deviceInfo, null);
 
         commonCheck(nodeConnector);
 
@@ -88,14 +91,14 @@ public class PortUpdateTranslatorTest {
 
     @Test
     public void testTranslate_10() throws Exception {
-        Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
+        Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures portFeatures =
                 new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures(
                         null, null, null, false, false, true, null, null,
                         null, false, false, null, null, null, null, null
                 );
 
-        final FlowCapableNodeConnector nodeConnector = portUpdateTranslator.translate(portBld.build(), deviceState, null);
+        final FlowCapableNodeConnector nodeConnector = portUpdateTranslator.translate(portBld.build(), deviceInfo, null);
 
         commonCheck(nodeConnector);
 
index e20beab46b23393a8b9df81efbe0586376b5b0a7..70bd8cd29fb538b6e8ebaa45446397c75a1a4962 100644 (file)
@@ -46,6 +46,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandle
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
@@ -130,6 +131,8 @@ public class DeviceInitializationUtilsTest {
     @Mock
     private DeviceContextImpl mockedDeviceContext;
     @Mock
+    private DeviceInfo mockedDeviceInfo;
+    @Mock
     private DeviceInitializationUtils deviceInitializationUtils;
 
     @Before
@@ -140,6 +143,7 @@ public class DeviceInitializationUtilsTest {
         when(mockConnectionContext.getFeatures()).thenReturn(mockFeatures);
         when(mockConnectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
 
         final Capabilities capabilitiesV13 = mock(Capabilities.class);
         final CapabilitiesV10 capabilitiesV10 = mock(CapabilitiesV10.class);
@@ -156,10 +160,9 @@ public class DeviceInitializationUtilsTest {
 
         GetFeaturesOutput mockedFeatures = mock(GetFeaturesOutput.class);
         when(mockedFeatures.getTables()).thenReturn((short) 2);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeatures);
-        when(mockedDeviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
+        when(mockedDeviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
 
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_II);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_II);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
         when(mockedDeviceContext.getMultiMsgCollector(Mockito.any(RequestContext.class))).thenReturn(msgCollector);
         when(mockedDeviceContext.oook()).thenReturn(tLibrary);
@@ -179,9 +182,9 @@ public class DeviceInitializationUtilsTest {
 
         final GetFeaturesOutput mockedFeatures = mock(GetFeaturesOutput.class);
         when(mockedFeatures.getTables()).thenReturn((short) 2);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeatures);
+        when(mockConnectionContext.getFeatures()).thenReturn(mockedFeatures);
 
-        when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_II);
+        when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_II);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
 
         final RpcResult<List<MultipartReply>> mockedRpcResult = mock(RpcResult.class);
@@ -280,7 +283,7 @@ public class DeviceInitializationUtilsTest {
         when(mockedPrimaryConnectionContext.getFeatures()).thenReturn(mockedFeatures);
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimaryConnectionContext);
         final DeviceState mockedDeviceState = mock(DeviceState.class);
-        when(mockedDeviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
+        when(mockedDeviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
         final MessageTranslator mockedTranslator = mock(MessageTranslator.class);
         when(translatorLibrary.lookupTranslator(any(TranslatorKey.class))).thenReturn(mockedTranslator);
index cf0149cd79ffea230d337755f76834bdb7e5be30..b6f36a1974d749129ddd0525d28cbab6f3e2131b 100644 (file)
@@ -22,6 +22,7 @@ import org.junit.Test;
 import org.mockito.Matchers;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
@@ -47,15 +48,18 @@ public class MdSalRegistrationUtilsTest {
         final DeviceState mockedDeviceState = mock(DeviceState.class);
         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
 
+        final DeviceInfo mockedDeviceInfo = mock(DeviceInfo.class);
+        when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
+
         final FeaturesReply mockedFeatures = mock(FeaturesReply.class);
         when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures);
 
         final GetFeaturesOutput mockedFeaturesOutput = mock(GetFeaturesOutput.class);
-        when(mockedDeviceState.getFeatures()).thenReturn(mockedFeaturesOutput);
 
         final BigInteger mockedDataPathId = mock(BigInteger.class);
         when(mockedFeatures.getDatapathId()).thenReturn(mockedDataPathId);
         when(mockedFeaturesOutput.getDatapathId()).thenReturn(mockedDataPathId);
+        when(mockedDeviceInfo.getDatapathId()).thenReturn(mockedDataPathId);
 
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
         MdSalRegistrationUtils.registerMasterServices(mockedRpcContext, mockedDeviceContext, OfpRole.BECOMEMASTER);