Merge "Correction classes names in loggers."
authormichal rehak <mirehak@cisco.com>
Fri, 11 Mar 2016 14:42:51 +0000 (14:42 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 11 Mar 2016 14:42:51 +0000 (14:42 +0000)
30 files changed:
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProvider.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/HandshakeListener.java
openflowplugin-controller-config/src/main/resources/initial/42-openflowplugin-new.xml
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.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/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/RpcContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java [moved from openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistratorUtils.java with 98% similarity]
openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/config/openflow/plugin/impl/rev150327/OpenFlowProviderModule.java
openflowplugin-impl/src/main/yang/openflow-plugin-impl.yang
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/HandshakeListenerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.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/util/MdSalRegistrationUtilsTest.java [moved from openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistratorUtilsTest.java with 85% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/ConnectionConductorImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/HandshakeManagerImpl.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/HandshakeManagerImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/translator/PacketInV10TranslatorTest.java

index 82a69c5847a1a45a147a78ef86b93834f10ec928..6173fb536f8e5285c827099106cb3d5dc1b9e4a9 100644 (file)
@@ -67,4 +67,10 @@ public interface OpenFlowPluginProvider extends AutoCloseable, BindingService {
      * @param isStatisticsRpcEnabled
      */
     void setIsStatisticsRpcEnabled(boolean isStatisticsRpcEnabled);
+
+    void setBarrierCountLimit(int barrierCountLimit);
+
+    void setBarrierInterval(long barrierTimeoutLimit);
+
+    void setEchoReplyTimeout(long echoReplyTimeout);
 }
index 0e96d1aeb85a11e83bf3c6673385303dabc6e95e..85cb3636c514ed6ecb3e650f61bac1ec5bdef653 100644 (file)
@@ -66,14 +66,14 @@ public interface DeviceContext extends AutoCloseable,
      *
      * @param connectionContext
      */
-    void addAuxiliaryConenctionContext(ConnectionContext connectionContext);
+    void addAuxiliaryConnectionContext(ConnectionContext connectionContext);
 
     /**
      * Method removes auxiliary connection context from this context representing single device connection.
      *
      * @param connectionContext
      */
-    void removeAuxiliaryConenctionContext(ConnectionContext connectionContext);
+    void removeAuxiliaryConnectionContext(ConnectionContext connectionContext);
 
 
     /**
index deb2efc34170a443963aa93c63311d21fd1bf1ed..5140977e4feadaa388c7f32bd68c134f9a5b5f8d 100644 (file)
@@ -20,7 +20,7 @@ public interface HandshakeListener {
      * @param featureOutput obtained
      * @param version negotiated
      */
-    void onHandshakeSuccessfull(GetFeaturesOutput featureOutput, Short version);
+    void onHandshakeSuccessful(GetFeaturesOutput featureOutput, Short version);
 
     /**
      * This method is called when handshake fails for some reason. It allows
index d81a392ded5a8d5161340acb63b3b4ec6636092c..7a282c09dc0b9c53b21cdc95064bb181b91f8f20 100644 (file)
@@ -90,6 +90,9 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
                     <switch-features-mandatory>false</switch-features-mandatory>
                     <global-notification-quota>64000</global-notification-quota>
                     <is-statistics-polling-off>false</is-statistics-polling-off>
+                    <barrier-interval-timeout-limit>500</barrier-interval-timeout-limit>
+                    <barrier-count-limit>25600</barrier-count-limit>
+                    <echo-reply-timeout>2000</echo-reply-timeout>
                 </module>
             </modules>
 
index a7c74d618c5981d8fffe2e977cc9e8d2c675b81c..463998a6a8e80e7306b891680ff4bdbda2570c09 100644 (file)
@@ -63,6 +63,9 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
 
     private final int rpcRequestsQuota;
     private final long globalNotificationQuota;
+    private long barrierInterval;
+    private int barrierCountLimit;
+    private long echoReplyTimeout;
     private DeviceManager deviceManager;
     private RoleManager roleManager;
     private RpcManager rpcManager;
@@ -130,6 +133,22 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
         this.entityOwnershipService = entityOwnershipService;
     }
 
+    @Override
+    public void setBarrierCountLimit(int barrierCountLimit) {
+        this.barrierCountLimit = barrierCountLimit;
+    }
+
+    @Override
+    public void setBarrierInterval(long barrierTimeoutLimit) {
+        this.barrierInterval = barrierTimeoutLimit;
+    }
+
+    @Override
+    public void setEchoReplyTimeout(long echoReplyTimeout) {
+        this.echoReplyTimeout = echoReplyTimeout;
+    }
+
+
     @Override
     public void setSwitchFeaturesMandatory(final boolean switchFeaturesMandatory) {
         this.switchFeaturesMandatory = switchFeaturesMandatory;
@@ -166,13 +185,14 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
         // TODO: rewrite later!
         OFSessionUtil.getSessionManager().setExtensionConverterProvider(extensionConverterManager);
 
-        connectionManager = new ConnectionManagerImpl();
+        connectionManager = new ConnectionManagerImpl(echoReplyTimeout);
 
         registerMXBean(messageIntelligenceAgency);
 
-        deviceManager = new DeviceManagerImpl(dataBroker, messageIntelligenceAgency, globalNotificationQuota, switchFeaturesMandatory);
+        deviceManager = new DeviceManagerImpl(dataBroker, messageIntelligenceAgency, globalNotificationQuota,
+                switchFeaturesMandatory, barrierInterval, barrierCountLimit);
         ((ExtensionConverterProviderKeeper) deviceManager).setExtensionConverterProvider(extensionConverterManager);
-        roleManager = new RoleManagerImpl(entityOwnershipService, dataBroker, switchFeaturesMandatory);
+        roleManager = new RoleManagerImpl(entityOwnershipService, dataBroker);
         statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, isStatisticsPollingOff);
         rpcManager = new RpcManagerImpl(rpcProviderRegistry, rpcRequestsQuota);
 
index 9901b7162cbcb2fa6eabad5f6d44dbcc3873fc87..544e7124ba44bb6627efc050820b2803a5715545 100644 (file)
@@ -41,6 +41,12 @@ public class ConnectionManagerImpl implements ConnectionManager {
     private static final int HELLO_LIMIT = 20;
     private final boolean bitmapNegotiationEnabled = true;
     private DeviceConnectedHandler deviceConnectedHandler;
+    private final long echoReplyTimeout;
+
+    public ConnectionManagerImpl(long echoReplyTimeout) {
+        this.echoReplyTimeout = echoReplyTimeout;
+    }
+
 
     @Override
     public void onSwitchConnected(final ConnectionAdapter connectionAdapter) {
@@ -71,7 +77,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
                 new OpenflowProtocolListenerInitialImpl(connectionContext, handshakeContext);
         connectionAdapter.setMessageListener(ofMessageListener);
 
-        final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl(connectionContext);
+        final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl(connectionContext, echoReplyTimeout);
         connectionAdapter.setSystemListener(systemListener);
 
         LOG.trace("connection ballet finished");
index 61480de5f0f91aabee7f0171a976a626d8860933..f1c7a9a2e41ed3930e118d7ef2df2357a66eb7da 100644 (file)
@@ -48,7 +48,7 @@ public class HandshakeListenerImpl implements HandshakeListener {
     }
 
     @Override
-    public void onHandshakeSuccessfull(final GetFeaturesOutput featureOutput, final Short version) {
+    public void onHandshakeSuccessful(final GetFeaturesOutput featureOutput, final Short version) {
         LOG.debug("handshake succeeded: {}", connectionContext.getConnectionAdapter().getRemoteAddress());
         closeHandshakeContext();
         connectionContext.changeStateToWorking();
@@ -102,7 +102,7 @@ public class HandshakeListenerImpl implements HandshakeListener {
             handshakeContext.close();
         } catch (final Exception e) {
             LOG.warn("Closing handshake context failed: {}", e.getMessage());
-            LOG.debug("Detail in hanshake context close:", e);
+            LOG.debug("Detail in handshake context close:", e);
         }
     }
 
index de1619895ef44294731546f57ef42ce6d2aca66b..ebb03b889fbad2b1879a7d527d5117adbfcedfcc 100644 (file)
@@ -35,9 +35,11 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe
     private static final Logger LOG = LoggerFactory.getLogger(SystemNotificationsListenerImpl.class);
     @VisibleForTesting
     static final long MAX_ECHO_REPLY_TIMEOUT = 2000;
+    private final long echoReplyTimeout;
 
-    public SystemNotificationsListenerImpl(@Nonnull final ConnectionContext connectionContext) {
+    public SystemNotificationsListenerImpl(@Nonnull final ConnectionContext connectionContext, long echoReplyTimeout) {
         this.connectionContext = Preconditions.checkNotNull(connectionContext);
+        this.echoReplyTimeout = echoReplyTimeout;
     }
 
     @Override
@@ -56,36 +58,42 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe
 
                 if (ConnectionContext.CONNECTION_STATE.WORKING.equals(connectionContext.getConnectionState())) {
                     FeaturesReply features = connectionContext.getFeatures();
-                    LOG.debug(
-                            "first idle state occured, node={}|auxId={}",
-                            remoteAddress, features.getAuxiliaryId());
+                    LOG.debug("Switch Idle state occured, node={}|auxId={}", remoteAddress, features.getAuxiliaryId());
                     connectionContext.changeStateToTimeouting();
                     EchoInputBuilder builder = new EchoInputBuilder();
                     builder.setVersion(features.getVersion());
                     Xid xid = new Xid(0L);
                     builder.setXid(xid.getValue());
 
-                    Future<RpcResult<EchoOutput>> echoReplyFuture = connectionContext.getConnectionAdapter()
-                            .echo(builder.build());
+                    Future<RpcResult<EchoOutput>> echoReplyFuture = connectionContext.getConnectionAdapter().echo(builder.build());
 
                     try {
-                        RpcResult<EchoOutput> echoReplyValue = echoReplyFuture.get(MAX_ECHO_REPLY_TIMEOUT, TimeUnit.MILLISECONDS);
+                        RpcResult<EchoOutput> echoReplyValue = echoReplyFuture.get(echoReplyTimeout, TimeUnit.MILLISECONDS);
                         if (echoReplyValue.isSuccessful()) {
                             connectionContext.changeStateToWorking();
                             shouldBeDisconnected = false;
                         } else {
-                            for (RpcError replyError : echoReplyValue
-                                    .getErrors()) {
+                            for (RpcError replyError : echoReplyValue.getErrors()) {
                                 Throwable cause = replyError.getCause();
-                                LOG.warn("while receiving echoReply [{}] in TIMEOUTING state {} ",
-                                        remoteAddress,
-                                        cause.getMessage());
-                                LOG.trace("while receiving echoReply [{}] in TIMEOUTING state ..", remoteAddress, cause);
+                                if (LOG.isWarnEnabled()) {
+                                    LOG.warn("Received EchoReply from [{}] in TIMEOUTING state, Error:{}", remoteAddress, cause.getMessage());
+                                }
+
+                                if (LOG.isTraceEnabled()) {
+                                    LOG.trace("Received EchoReply from [{}] in TIMEOUTING state, Error:{}", remoteAddress, cause);
+                                }
+
                             }
                         }
                     } catch (Exception e) {
-                        LOG.warn("while waiting for echoReply in TIMEOUTING state: {}", e.getMessage());
-                        LOG.trace("while waiting for echoReply in TIMEOUTING state ..", remoteAddress, e);
+                        if (LOG.isWarnEnabled()) {
+                            LOG.warn("Exception while  waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e.getMessage());
+                        }
+
+                        if (LOG.isTraceEnabled()) {
+                            LOG.trace("Exception while  waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e);
+                        }
+
                     }
                 }
                 if (shouldBeDisconnected) {
index e5c62d7e657a82bcfac6debb342a7f2d548fbc10..43cb394dbf55d7507739f6a9f6b3ae2f47dc1654 100644 (file)
@@ -77,7 +77,7 @@ import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory
 import org.opendaylight.openflowplugin.impl.registry.group.DeviceGroupRegistryImpl;
 import org.opendaylight.openflowplugin.impl.registry.meter.DeviceMeterRegistryImpl;
 import org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtils;
-import org.opendaylight.openflowplugin.impl.util.MdSalRegistratorUtils;
+import org.opendaylight.openflowplugin.impl.util.MdSalRegistrationUtils;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchConnectionCookieOFImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.ExperimenterMessageFromDevBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
@@ -155,7 +155,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     private ExtensionConverterProvider extensionConverterProvider;
 
     private final boolean switchFeaturesMandatory;
-    private StatisticsContext statCtx;
+    private StatisticsContext statisticsContext;
 
 
     @VisibleForTesting
@@ -214,7 +214,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     }
 
     @Override
-    public void addAuxiliaryConenctionContext(final ConnectionContext connectionContext) {
+    public void addAuxiliaryConnectionContext(final ConnectionContext connectionContext) {
         final SwitchConnectionDistinguisher connectionDistinguisher = createConnectionDistinguisher(connectionContext);
         auxiliaryConnectionContexts.put(connectionDistinguisher, connectionContext);
     }
@@ -224,8 +224,11 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     }
 
     @Override
-    public void removeAuxiliaryConenctionContext(final ConnectionContext connectionContext) {
-        // TODO Auto-generated method stub
+    public void removeAuxiliaryConnectionContext(final ConnectionContext connectionContext) {
+        final SwitchConnectionDistinguisher connectionDistinguisher = createConnectionDistinguisher(connectionContext);
+        if (null != connectionDistinguisher) {
+            auxiliaryConnectionContexts.remove(connectionDistinguisher);
+        }
     }
 
     @Override
@@ -247,7 +250,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
             return Futures.immediateFuture(null);
         }
         if (OfpRole.BECOMEMASTER.equals(role)) {
-            MdSalRegistratorUtils.registerMasterServices(getRpcContext(), DeviceContextImpl.this, role);
+            MdSalRegistrationUtils.registerMasterServices(getRpcContext(), DeviceContextImpl.this, role);
             getRpcContext().registerStatCompatibilityServices();
             if (!deviceState.deviceSynchronized()) {
                 //TODO: no necessary code for yet - it needs for initialization phase only
@@ -267,7 +270,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
                 @Override
                 public void onFailure(Throwable throwable) {
                     LOG.debug("Device {} init unexpected fail. Unregister RPCs", getDeviceState().getNodeId());
-                    MdSalRegistratorUtils.unregisterServices(getRpcContext());
+                    MdSalRegistrationUtils.unregisterServices(getRpcContext());
                 }
 
             });
@@ -276,13 +279,13 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
 
         } else if (OfpRole.BECOMESLAVE.equals(role)) {
             if (null != rpcContext) {
-                MdSalRegistratorUtils.registerSlaveServices(rpcContext, role);
+                MdSalRegistrationUtils.registerSlaveServices(rpcContext, role);
             }
             return transactionChainManager.deactivateTransactionManager();
         } else {
             LOG.warn("Unknown OFCluster Role {} for Node {}", role, deviceState.getNodeId());
             if (null != rpcContext) {
-                MdSalRegistratorUtils.unregisterServices(rpcContext);
+                MdSalRegistrationUtils.unregisterServices(rpcContext);
             }
             return transactionChainManager.deactivateTransactionManager();
         }
@@ -294,7 +297,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
      * all possible MultipartTypes for polling in StatTypeList
      */
     private ListenableFuture<Void> asyncClusterRoleChange() {
-        if (statCtx == null) {
+        if (statisticsContext == null) {
             final String errMsg = String.format("DeviceCtx %s is up but we are missing StatisticsContext", deviceState.getNodeId());
             LOG.warn(errMsg);
             return Futures.immediateFailedFuture(new IllegalStateException(errMsg));
@@ -590,7 +593,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
 
                 @Override
                 public void onSuccess(final Void result) {
-                    LOG.info("TxChain {} was shutdown successfull.", getDeviceState().getNodeId());
+                    LOG.info("TxChain {} was shutdown successful.", getDeviceState().getNodeId());
                     tearDownClean();
                 }
 
@@ -643,8 +646,8 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     }
 
     @Override
-    public void setNotificationService(final NotificationService notificationServiceParam) {
-        notificationService = notificationServiceParam;
+    public void setNotificationService(final NotificationService notificationService) {
+        this.notificationService = notificationService;
     }
 
     @Override
@@ -719,11 +722,11 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
 
     @Override
     public void setStatisticsContext(final StatisticsContext statisticsContext) {
-        this.statCtx = statisticsContext;
+        this.statisticsContext = statisticsContext;
     }
 
     @Override
     public StatisticsContext getStatisticsContext() {
-        return statCtx;
+        return statisticsContext;
     }
 }
index 903137d55d2c3af7385609426f605163a15f050c..5742453758ac93079dda72473db0d0f62dc10323 100644 (file)
@@ -58,6 +58,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     private static final long TICK_DURATION = 10; // 0.5 sec.
     private final long globalNotificationQuota;
     private final boolean switchFeaturesMandatory;
+
     private ScheduledThreadPoolExecutor spyPool;
     private final int spyRate = 10;
 
@@ -71,13 +72,14 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     private final ConcurrentMap<NodeId, DeviceContext> deviceContexts = new ConcurrentHashMap<>();
     private final MessageIntelligenceAgency messageIntelligenceAgency;
 
-    private final long barrierNanos = TimeUnit.MILLISECONDS.toNanos(500);
-    private final int maxQueueDepth = 25600;
+    private final long barrierIntervalNanos;
+    private final int barrierCountLimit;
     private ExtensionConverterProvider extensionConverterProvider;
 
     public DeviceManagerImpl(@Nonnull final DataBroker dataBroker,
                              @Nonnull final MessageIntelligenceAgency messageIntelligenceAgency,
-                             final long globalNotificationQuota, final boolean switchFeaturesMandatory) {
+                             final long globalNotificationQuota, final boolean switchFeaturesMandatory,
+                             final long barrierInterval, final int barrierCountLimit) {
         this.switchFeaturesMandatory = switchFeaturesMandatory;
         this.globalNotificationQuota = globalNotificationQuota;
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
@@ -96,6 +98,8 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         }
 
         this.messageIntelligenceAgency = messageIntelligenceAgency;
+        this.barrierIntervalNanos = TimeUnit.MILLISECONDS.toNanos(barrierInterval);
+        this.barrierCountLimit = barrierCountLimit;
     }
 
 
@@ -133,7 +137,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
 
         connectionContext.setOutboundQueueProvider(outboundQueueProvider);
         final OutboundQueueHandlerRegistration<OutboundQueueProvider> outboundQueueHandlerRegistration =
-                connectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, maxQueueDepth, barrierNanos);
+                connectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, barrierCountLimit, barrierIntervalNanos);
         connectionContext.setOutboundQueueHandleRegistration(outboundQueueHandlerRegistration);
 
         final DeviceState deviceState = createDeviceState(connectionContext);
index d49021ed1e067e1e508b2617f9f148b6dfb2332c..efbeefdbc7ea41eca83ca37ad0ca8b4f34fff330 100644 (file)
@@ -58,6 +58,7 @@ class DeviceStateImpl implements DeviceState {
         version = featuresReply.getVersion();
         statPollEnabled = false;
         deviceSynchronized = false;
+        role = OfpRole.BECOMESLAVE;
     }
 
     @Override
index d2e8fb80e056b8d9e125369bb66496e264729ebe..7fc9739892fcfb7aba176f25679aaf8d0f9164ad 100644 (file)
@@ -55,23 +55,24 @@ public class RoleContextImpl implements RoleContext {
 
     private final EntityOwnershipService entityOwnershipService;
     private EntityOwnershipCandidateRegistration entityOwnershipCandidateRegistration;
+    private EntityOwnershipCandidateRegistration txEntityOwnershipCandidateRegistration;
+
     private final DeviceContext deviceContext;
-    private final Entity entity;
-    private SalRoleService salRoleService;
 
-    private EntityOwnershipCandidateRegistration txEntityOwnershipCandidateRegistration;
+    private final Entity entity;
     private final Entity txEntity;
 
+    private SalRoleService salRoleService;
+
     private final Semaphore mainCandidateGuard = new Semaphore(1, true);
     private final Semaphore txCandidateGuard = new Semaphore(1, true);
 
     public RoleContextImpl(final DeviceContext deviceContext, final EntityOwnershipService entityOwnershipService,
-                           final Entity entity, final Entity txEnitity) {
+                           final Entity entity, final Entity txEntity) {
         this.entityOwnershipService = Preconditions.checkNotNull(entityOwnershipService);
         this.deviceContext = Preconditions.checkNotNull(deviceContext);
         this.entity = Preconditions.checkNotNull(entity);
-        this.txEntity = Preconditions.checkNotNull(txEnitity);
-
+        this.txEntity = Preconditions.checkNotNull(txEntity);
         salRoleService = new SalRoleServiceImpl(this, deviceContext);
     }
 
@@ -110,7 +111,7 @@ public class RoleContextImpl implements RoleContext {
         LOG.trace("onRoleChanged method call for Entity {}", entity);
 
         if (!isDeviceConnected()) {
-            // this can happen as after the disconnect, we still get a last messsage from EntityOwnershipService.
+            // this can happen as after the disconnect, we still get a last message from EntityOwnershipService.
             LOG.info("Device {} is disconnected from this node. Hence not attempting a role change.",
                     deviceContext.getPrimaryConnectionContext().getNodeId());
             LOG.debug("SetRole cancelled for entity [{}], reason = device disconnected.", entity);
@@ -210,7 +211,7 @@ public class RoleContextImpl implements RoleContext {
     }
 
     private ListenableFuture<Void> sendRoleChangeToDevice(final OfpRole newRole, final AsyncFunction<RpcResult<SetRoleOutput>, Void> function) {
-        LOG.debug("Send new Role {} to Device {}", newRole, deviceContext.getDeviceState().getNodeId());
+        LOG.debug("Send new role {} to device {}", newRole, deviceContext.getDeviceState().getNodeId());
         final Future<RpcResult<SetRoleOutput>> setRoleOutputFuture;
         if (deviceContext.getDeviceState().getFeatures().getVersion() < OFConstants.OFP_VERSION_1_3) {
             LOG.debug("Device OF version {} not support ROLE", deviceContext.getDeviceState().getFeatures().getVersion());
@@ -224,7 +225,7 @@ public class RoleContextImpl implements RoleContext {
                 @Override
                 public void run(final Timeout timeout) throws Exception {
                     if (!setRoleOutputFuture.isDone()) {
-                        LOG.info("New Role {} was not propagated to device {} during 10 sec. Close connection immediately.",
+                        LOG.info("New role {} was not propagated to device {} during 10 sec. Close connection immediately.",
                                 newRole, deviceContext.getDeviceState().getNodeId());
                         deviceContext.close();
                     }
index b365c797b7eadb1b298bd5e951bd82c02c04e9f9..fc159499cff4c61bb2cfe325d43b82da7a297d94 100644 (file)
@@ -63,15 +63,13 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener {
     private final ConcurrentMap<Entity, RoleContext> txContexts = new ConcurrentHashMap<>();
     private final EntityOwnershipListenerRegistration entityOwnershipListenerRegistration;
     private final EntityOwnershipListenerRegistration txEntityOwnershipListenerRegistration;
-    private final boolean switchFeaturesMandatory;
 
-    public RoleManagerImpl(final EntityOwnershipService entityOwnershipService, final DataBroker dataBroker, final boolean switchFeaturesMandatory) {
+    public RoleManagerImpl(final EntityOwnershipService entityOwnershipService, final DataBroker dataBroker) {
         this.entityOwnershipService = Preconditions.checkNotNull(entityOwnershipService);
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
-        this.switchFeaturesMandatory = switchFeaturesMandatory;
         this.entityOwnershipListenerRegistration = Preconditions.checkNotNull(entityOwnershipService.registerListener(RoleManager.ENTITY_TYPE, this));
         this.txEntityOwnershipListenerRegistration = Preconditions.checkNotNull(entityOwnershipService.registerListener(TX_ENTITY_TYPE, this));
-        LOG.debug("Registering OpenflowOwnershipListener listening to all entity ownership changes");
+        LOG.debug("Register OpenflowOwnershipListener to all entity ownership changes");
     }
 
     @Override
@@ -81,14 +79,14 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener {
 
     @Override
     public void onDeviceContextLevelUp(@CheckForNull final DeviceContext deviceContext) throws Exception {
-        LOG.debug("RoleManager called for device:{}", deviceContext.getPrimaryConnectionContext().getNodeId());
+        LOG.trace("Role manager called for device:{}", deviceContext.getPrimaryConnectionContext().getNodeId());
         final RoleContext roleContext = new RoleContextImpl(deviceContext, entityOwnershipService,
                 makeEntity(deviceContext.getDeviceState().getNodeId()),
                 makeTxEntity(deviceContext.getDeviceState().getNodeId()));
 
-        Verify.verify(contexts.putIfAbsent(roleContext.getEntity(), roleContext) == null, "RoleCtx for master Node {} is still not closed.", deviceContext.getDeviceState().getNodeId());
+        Verify.verify(contexts.putIfAbsent(roleContext.getEntity(), roleContext) == null, "Role context for master Node {} is still not closed.", deviceContext.getDeviceState().getNodeId());
         Verify.verify(!txContexts.containsKey(roleContext.getTxEntity()),
-                "RoleCtx for master Node {} is still not closed. TxEntity was not unregistered yet.", deviceContext.getDeviceState().getNodeId());
+                "Role context for master Node {} is still not closed. TxEntity was not unregistered yet.", deviceContext.getDeviceState().getNodeId());
 
         // if the device context gets closed (mostly on connection close), we would need to cleanup
         deviceContext.addDeviceContextClosedHandler(this);
@@ -124,7 +122,7 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener {
     @Override
     public void onDeviceContextClosed(final DeviceContext deviceContext) {
         final NodeId nodeId = deviceContext.getDeviceState().getNodeId();
-        LOG.debug("onDeviceContextClosed for node {}", nodeId);
+        LOG.trace("onDeviceContextClosed for node {}", nodeId);
         final Entity entity = makeEntity(nodeId);
         final RoleContext roleContext = contexts.get(entity);
         if (roleContext != null) {
@@ -148,7 +146,7 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener {
                     // TODO : is there a chance to have TxEntity ?
                 }
             } else {
-                LOG.warn("EntityOwnershipService doesn't return state for entity: {} in close proces", entity);
+                LOG.warn("EntityOwnershipService doesn't return state for entity: {} in close process", entity);
             }
             roleContext.close();
         }
@@ -380,14 +378,14 @@ public class RoleManagerImpl implements RoleManager, EntityOwnershipListener {
         Futures.addCallback(removeDeviceFromOperDS(roleContext), new FutureCallback<Void>() {
             @Override
             public void onSuccess(@Nullable final Void aVoid) {
-                LOG.debug("Freeing roleContext slot for device: {}", roleContext.getDeviceState().getNodeId());
+                LOG.debug("Removing context for device: {}", roleContext.getDeviceState().getNodeId());
                 contexts.remove(ownershipChange.getEntity(), roleContext);
                 roleContext.suspendTxCandidate();
             }
 
             @Override
             public void onFailure(final Throwable throwable) {
-                LOG.warn("NOT freeing roleContext slot for device: {}, {}", roleContext.getDeviceState()
+                LOG.warn("Removing role context for device: {}, but {}", roleContext.getDeviceState()
                         .getNodeId(), throwable.getMessage());
                 contexts.remove(ownershipChange.getEntity(), roleContext);
                 roleContext.suspendTxCandidate();
index ba7d36f4abf255960d5624be8a22117429a1126a..3179038cc87fed1876c270860bf1e67522525079 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
-import org.opendaylight.openflowplugin.impl.util.MdSalRegistratorUtils;
+import org.opendaylight.openflowplugin.impl.util.MdSalRegistrationUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.slf4j.Logger;
@@ -72,7 +72,7 @@ public class RpcContextImpl implements RpcContext {
     @Override
     public void registerStatCompatibilityServices() {
         if (isStatisticsRpcEnabled) {
-            MdSalRegistratorUtils.registerStatCompatibilityServices(RpcContextImpl.this, deviceContext,
+            MdSalRegistrationUtils.registerStatCompatibilityServices(RpcContextImpl.this, deviceContext,
                     notificationPublishService, new AtomicLong());
         }
     }
@@ -105,7 +105,7 @@ public class RpcContextImpl implements RpcContext {
             LOG.trace("Device queue {} at capacity", this);
             return null;
         } else {
-            LOG.info("Acquired semaphore for {}, available permits:{} ", deviceContext.getDeviceState().getNodeId(), tracker.availablePermits());
+            LOG.trace("Acquired semaphore for {}, available permits:{} ", deviceContext.getDeviceState().getNodeId(), tracker.availablePermits());
         }
 
         final Long xid = deviceContext.reservedXidForDeviceMessage();
index 523ccc5aeed58c17d063bbe9034b358b7faf086f..4681d12381d620c65f2612ef87d323523b72cb44 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcManager;
-import org.opendaylight.openflowplugin.impl.util.MdSalRegistratorUtils;
+import org.opendaylight.openflowplugin.impl.util.MdSalRegistrationUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.slf4j.Logger;
@@ -55,21 +55,21 @@ public class RpcManagerImpl implements RpcManager {
         final RpcContext rpcContext = new RpcContextImpl(deviceContext.getMessageSpy(), rpcProviderRegistry,
                 deviceContext, maxRequestsQuota, isStatisticsRpcEnabled, notificationPublishService);
 
-        Verify.verify(contexts.putIfAbsent(deviceContext, rpcContext) == null, "RpcCtx still not closed for node {}", nodeId);
+        Verify.verify(contexts.putIfAbsent(deviceContext, rpcContext) == null, "RPC context still not closed for node {}", nodeId);
         deviceContext.addDeviceContextClosedHandler(this);
 
         if (OfpRole.BECOMEMASTER.equals(ofpRole)) {
-            LOG.info("Registering Openflow RPCs for node:{}, role:{}", nodeId, ofpRole);
-            MdSalRegistratorUtils.registerMasterServices(rpcContext, deviceContext, ofpRole);
+            LOG.info("Registering Openflow RPCs services for node:{}, role:{}", nodeId, ofpRole);
+            MdSalRegistrationUtils.registerMasterServices(rpcContext, deviceContext, ofpRole);
 
         } else if(OfpRole.BECOMESLAVE.equals(ofpRole)) {
             // if slave, we need to de-register rpcs if any have been registered, in case of master to slave
-            LOG.info("Unregistering RPC registration (if any) for slave role for node:{}", deviceContext.getDeviceState().getNodeId());
-            MdSalRegistratorUtils.registerSlaveServices(rpcContext, ofpRole);
+            LOG.info("Unregister RPC services (if any) for slave role for node:{}", deviceContext.getDeviceState().getNodeId());
+            MdSalRegistrationUtils.registerSlaveServices(rpcContext, ofpRole);
         } else {
             // if we don't know role, we need to unregister rpcs if any have been registered
-            LOG.info("Unregistering RPC registration (if any) for slave role for node:{}", deviceContext.getDeviceState().getNodeId());
-            MdSalRegistratorUtils.unregisterServices(rpcContext);
+            LOG.info("Unregister RPC services (if any) for slave role for node:{}", deviceContext.getDeviceState().getNodeId());
+            MdSalRegistrationUtils.unregisterServices(rpcContext);
         }
 
         // finish device initialization cycle back to DeviceManager
@@ -89,7 +89,7 @@ public class RpcManagerImpl implements RpcManager {
     public void onDeviceContextClosed(final DeviceContext deviceContext) {
         final RpcContext removedContext = contexts.remove(deviceContext);
         if (removedContext != null) {
-            LOG.info("Unregistering rpcs for device context closure");
+            LOG.info("Unregister RPCs services for device context closure");
             removedContext.close();
         }
     }
index 3cb77d0bddad4fb3a6ac6fda6c59d5511791d142..992275175eb9cdbb86a5d6dc1e55f46c4925029e 100644 (file)
@@ -126,7 +126,6 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
             public void onSuccess(final Boolean statisticsGathered) {
                 if (statisticsGathered) {
                     //there are some statistics on device worth gathering
-                    contexts.put(deviceContext, statisticsContext);
                     final TimeCounter timeCounter = new TimeCounter();
                     deviceContext.getDeviceState().setStatisticsPollingEnabledProp(true);
                     scheduleNextPolling(deviceContext, statisticsContext, timeCounter);
@@ -140,8 +139,8 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
                     }
                     deviceContext.getDeviceState().setDeviceSynchronized(true);
                 } else {
-                    final String deviceAdress = deviceContext.getPrimaryConnectionContext().getConnectionAdapter().getRemoteAddress().toString();
-                    LOG.info("Statistics for device {} could not be gathered. Closing its device context.", deviceAdress);
+                    final String deviceAddress = deviceContext.getPrimaryConnectionContext().getConnectionAdapter().getRemoteAddress().toString();
+                    LOG.info("Statistics for device {} could not be gathered. Closing its device context.", deviceAddress);
                     deviceContext.close();
                 }
             }
similarity index 98%
rename from openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistratorUtils.java
rename to openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java
index 15310237119be2b8c7bdb461f7893113e8fb13f8..70390535baa8042c31b53b368870badeea7e3172 100644 (file)
@@ -51,7 +51,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
 
-public class MdSalRegistratorUtils {
+public class MdSalRegistrationUtils {
 
     //TODO: Make one register and one unregister method for all services
 
@@ -60,7 +60,7 @@ public class MdSalRegistratorUtils {
                 //NOBODY
             };
 
-    private MdSalRegistratorUtils() {
+    private MdSalRegistrationUtils() {
         throw new IllegalStateException();
     }
 
@@ -94,7 +94,7 @@ public class MdSalRegistratorUtils {
     }
 
     /**
-     * Method unregisters all services in first step. So we don't need to call {@link MdSalRegistratorUtils#unregisterServices(RpcContext)}
+     * Method unregisters all services in first step. So we don't need to call {@link MdSalRegistrationUtils#unregisterServices(RpcContext)}
      * directly before by change role from {@link OfpRole#BECOMEMASTER} to {@link OfpRole#BECOMESLAVE}.
      * Method registers {@link SalEchoService} in next step only because we would like to have SalEchoService as local service for all apps
      * to be able actively check connection status for slave connection too.
index cc7d179466349a2f704a077555ae9808166d61e1..4717561f7de4d8af3d5837bc0e87466bde33ff7c 100644 (file)
@@ -10,11 +10,11 @@ public class OpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.ope
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenFlowProviderModule.class);
 
-    public OpenFlowProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    public OpenFlowProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
-    public OpenFlowProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327.OpenFlowProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public OpenFlowProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327.OpenFlowProviderModule oldModule, final java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
@@ -27,7 +27,7 @@ public class OpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.ope
     public java.lang.AutoCloseable createInstance() {
         LOG.info("Initializing new OFP southbound.");
         OpenflowPortsUtil.init();
-        OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(getRpcRequestsQuota(), getGlobalNotificationQuota());
+        final OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(getRpcRequestsQuota(), getGlobalNotificationQuota());
 
         openflowPluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
         openflowPluginProvider.setDataBroker(getDataBrokerDependency());
@@ -38,9 +38,17 @@ public class OpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.ope
         openflowPluginProvider.setIsStatisticsPollingOff(getIsStatisticsPollingOff());
         openflowPluginProvider.setEntityOwnershipService(getEntityOwnershipServiceDependency());
         openflowPluginProvider.setIsStatisticsRpcEnabled(getIsStatisticsRpcEnabled());
+        openflowPluginProvider.setBarrierCountLimit(getBarrierCountLimit().getValue());
+        openflowPluginProvider.setBarrierInterval(getBarrierIntervalTimeoutLimit().getValue());
+        openflowPluginProvider.setEchoReplyTimeout(getEchoReplyTimeout().getValue());
 
         openflowPluginProvider.initialize();
 
+        LOG.info("Configured values, StatisticsPollingOff:{}, SwitchFeaturesMandatory:{}, BarrierCountLimit:{}, BarrierTimeoutLimit:{}, EchoReplyTimeout:{}",
+                getIsStatisticsPollingOff(), getSwitchFeaturesMandatory(), getBarrierCountLimit().getValue(),
+                getBarrierIntervalTimeoutLimit().getValue(), getEchoReplyTimeout().getValue());
+
+
         return openflowPluginProvider;
     }
 
index aee2d6ccd1d1c776f6a84cf3737094bc152f511e..e86ae12ba251fefd5f093801c7401ea573bb3bc1 100644 (file)
@@ -20,6 +20,18 @@ module openflow-plugin-provider-impl {
             "Second openflow plugin implementation.";
     }
 
+    typedef non-zero-uint32-type {
+        type uint32 {
+            range "1..max";
+        }
+    }
+
+    typedef non-zero-uint16-type {
+        type uint16 {
+            range "1..max";
+        }
+     }
+
     identity openflow-plugin-provider-impl {
         base config:module-type;
         config:provided-service openflow-provider:openflow-provider;
@@ -101,6 +113,18 @@ module openflow-plugin-provider-impl {
                 type boolean;
                 default "false";
             }
+            leaf barrier-interval-timeout-limit {
+                type non-zero-uint32-type;
+                default 500;
+            }
+            leaf barrier-count-limit {
+                type non-zero-uint16-type;
+                default 25600;
+            }
+            leaf echo-reply-timeout {
+                type non-zero-uint32-type;
+                default 2000;
+            }
         }
 
     }
index 3c3f5c1bde3fbda6015ac6cd43c7a392dca9d701..813c1bd372a04084d63bc47ff05d8e098847a437 100644 (file)
@@ -55,12 +55,14 @@ public class ConnectionManagerImplTest {
     @Captor
     private ArgumentCaptor<OpenflowProtocolListener> ofpListenerAC;
 
+    private final static int ECHO_REPLY_TIMEOUT = 500;
+
     /**
      * before each test method
      */
     @Before
     public void setUp() {
-        connectionManagerImpl = new ConnectionManagerImpl();
+        connectionManagerImpl = new ConnectionManagerImpl(ECHO_REPLY_TIMEOUT);
         connectionManagerImpl.setDeviceConnectedHandler(deviceConnectedHandler);
         final InetSocketAddress deviceAddress = InetSocketAddress.createUnresolved("yahoo", 42);
         Mockito.when(connection.getRemoteAddress()).thenReturn(deviceAddress);
index 73d2a36709af1ed7e86a333695a473bf180c9917..90d908b6b460ccf609c6ed3ec34107f0b13c3b66 100644 (file)
@@ -74,7 +74,7 @@ public class HandshakeListenerImplTest {
 
     @Test
     public void testOnHandshakeSuccessfull() throws Exception {
-        handshakeListener.onHandshakeSuccessfull(features, version);
+        handshakeListener.onHandshakeSuccessful(features, version);
         Mockito.verify(connectionContextSpy).changeStateToWorking();
         Mockito.verify(connectionContextSpy).setFeatures(Matchers.any(FeaturesReply.class));
         Mockito.verify(connectionContextSpy).setNodeId(nodeIdCaptor.capture());
index e2cb7224d3ce0fdffd39fefdddb013de88166399..84fbd22b60b9848ffccafa64f7b985805311a36d 100644 (file)
@@ -40,6 +40,7 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 public class SystemNotificationsListenerImplTest {
 
     public static final int SAFE_TIMEOUT = 1000;
+    private final static int ECHO_REPLY_TIMEOUT = 2000;
     @Mock
     private org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter connectionAdapter;
     @Mock
@@ -64,7 +65,7 @@ public class SystemNotificationsListenerImplTest {
         Mockito.when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter);
         Mockito.when(connectionContext.getFeatures()).thenReturn(features);
 
-        systemNotificationsListener = new SystemNotificationsListenerImpl(connectionContext);
+        systemNotificationsListener = new SystemNotificationsListenerImpl(connectionContext, ECHO_REPLY_TIMEOUT);
     }
 
     @After
index 63cdfceb0542d89883356daa198c9265b2911b92..0a4bb06eb13f28659143a8c0ebc2b7d8a24fa994 100644 (file)
@@ -268,7 +268,7 @@ public class DeviceContextImplTest {
 
     private ConnectionContext addDummyAuxiliaryConnectionContext() {
         ConnectionContext mockedConnectionContext = prepareConnectionContext();
-        deviceContext.addAuxiliaryConenctionContext(mockedConnectionContext);
+        deviceContext.addAuxiliaryConnectionContext(mockedConnectionContext);
         return mockedConnectionContext;
     }
 
@@ -392,7 +392,7 @@ public class DeviceContextImplTest {
         when(deviceState.getNodeId()).thenReturn(dummyNodeId);
 
         ConnectionContext mockedAuxiliaryConnectionContext = prepareConnectionContext();
-        deviceContext.addAuxiliaryConenctionContext(mockedAuxiliaryConnectionContext);
+        deviceContext.addAuxiliaryConnectionContext(mockedAuxiliaryConnectionContext);
         DeviceContextClosedHandler mockedDeviceContextClosedHandler = mock(DeviceContextClosedHandler.class);
         deviceContext.addDeviceContextClosedHandler(mockedDeviceContextClosedHandler);
         when(deviceState.isValid()).thenReturn(true);
index 8ec6befe162ce80efb255d3213d30781dc66b50d..fbde5c46bc91411f6a4d61b1b0324b84a837d6ac 100644 (file)
@@ -79,6 +79,8 @@ public class DeviceManagerImplTest {
     private static final Long DUMMY_MAX_METER = 544L;
     private static final String DUMMY_DATAPATH_ID = "44";
     private static final Long DUMMY_PORT_NUMBER = 21L;
+    private static final int barrierCountLimit = 25600;
+    private static final int barrierIntervalNanos = 500;
 
     @Mock
     CheckedFuture<Void, TransactionCommitFailedException> mockedFuture;
@@ -144,7 +146,8 @@ public class DeviceManagerImplTest {
 
         final MessageIntelligenceAgency mockedMessageIntelligenceAgency = mock(MessageIntelligenceAgency.class);
         final DeviceManagerImpl deviceManager = new DeviceManagerImpl(mockedDataBroker, mockedMessageIntelligenceAgency,
-                TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA, false);
+                TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA, false, barrierIntervalNanos, barrierCountLimit);
+
         deviceManager.setDeviceInitializationPhaseHandler(deviceInitPhaseHandler);
 
         return deviceManager;
index 1a854dfc00507660a4a796a151afde437f7d8ee1..8affe98015a81387ca3d0f0879da0f8e0b1ec42e 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 /**
  * openflowplugin-impl
@@ -94,4 +95,39 @@ public class DeviceStateImplTest {
         Assert.assertEquals(expetedResult.getPhyPort(), getFeatures.getPhyPort());
     }
 
+    @Test
+    public void testIsValid_initialValue(){
+        Assert.assertFalse(deviceState.isValid());
+    }
+
+    @Test
+    public void testDeviceSynchronized_initialValue(){
+        Assert.assertFalse(deviceState.deviceSynchronized());
+    }
+
+    @Test
+    public void testStatPollEnabled_initialValue(){
+        Assert.assertFalse(deviceState.isStatisticsPollingEnabled());
+    }
+
+    @Test
+    public void testRole_initialValue(){
+        Assert.assertFalse(deviceState.getRole().equals(OfpRole.BECOMEMASTER));
+        Assert.assertFalse(deviceState.getRole().equals(OfpRole.NOCHANGE));
+    }
+
+    @Test
+    public void testStatistics_initialValue(){
+        Assert.assertFalse(deviceState.isFlowStatisticsAvailable());
+        Assert.assertFalse(deviceState.isPortStatisticsAvailable());
+        Assert.assertFalse(deviceState.isQueueStatisticsAvailable());
+        Assert.assertFalse(deviceState.isTableStatisticsAvailable());
+    }
+
+    @Test
+    public void testMeterAndGroupAvailable_initialValue(){
+        Assert.assertFalse(deviceState.isGroupAvailable());
+        Assert.assertFalse(deviceState.isMetersAvailable());
+    }
+
 }
similarity index 85%
rename from openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistratorUtilsTest.java
rename to openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java
index f8f08b6ad38d483cc6956d76d2eee2b4f331ff21..1147120edc8a23ffe5a727abe4f6163b6197dea3 100644 (file)
@@ -27,10 +27,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
-public class MdSalRegistratorUtilsTest {
+public class MdSalRegistrationUtilsTest {
 
     /**
-     * Number of currently registrated services (can be changed) in {@link MdSalRegistratorUtils#registerMasterServices
+     * Number of currently registrated services (can be changed) in {@link MdSalRegistrationUtils#registerServices
      * (RpcContext, DeviceContext)}
      */
     private static final int NUMBER_OF_RPC_SERVICE_REGISTRATION = 11;
@@ -49,9 +49,9 @@ public class MdSalRegistratorUtilsTest {
         when(mockedFeatures.getDatapathId()).thenReturn(mockedDataPathId);
 
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
-        MdSalRegistratorUtils.registerMasterServices(mockedRpcContext,mockedDeviceContext, OfpRole.BECOMEMASTER);
-        verify(mockedRpcContext, times(NUMBER_OF_RPC_SERVICE_REGISTRATION)).registerRpcServiceImplementation(any
-                        (RpcService.class.getClass()), any(RpcService.class));
+        MdSalRegistrationUtils.registerMasterServices(mockedRpcContext,mockedDeviceContext, OfpRole.BECOMEMASTER);
+        verify(mockedRpcContext, times(NUMBER_OF_RPC_SERVICE_REGISTRATION)).registerRpcServiceImplementation(
+                any(RpcService.class.getClass()), any(RpcService.class));
     }
 
 }
index e9ad1e3d1ba04e4fb14cdaac51ce850ded1fe204..8c3f2901f01d8ec488eb5b68654d2380155953df 100644 (file)
@@ -456,8 +456,8 @@ public class ConnectionConductorImpl implements OpenflowProtocolListener,
     }
 
     @Override
-    public void onHandshakeSuccessfull(GetFeaturesOutput featureOutput,
-                                       Short negotiatedVersion) {
+    public void onHandshakeSuccessful(GetFeaturesOutput featureOutput,
+                                      Short negotiatedVersion) {
         postHandshakeBasic(featureOutput, negotiatedVersion);
     }
 
index 0a4e98c47d8204b266a72d09db9b5fb6a0ae3cd3..78997ef27cc79f90db13a7a2f1ab0fea9dc7bcf1 100644 (file)
@@ -389,7 +389,7 @@ public class HandshakeManagerImpl implements HandshakeManager {
                                     featureOutput.getAuxiliaryId());
                             LOG.trace("handshake SETTLED: version={}, datapathId={}, auxiliaryId={}",
                                     version, featureOutput.getDatapathId(), featureOutput.getAuxiliaryId());
-                            handshakeListener.onHandshakeSuccessfull(featureOutput, proposedVersion);
+                            handshakeListener.onHandshakeSuccessful(featureOutput, proposedVersion);
                         } else {
                             // handshake failed
                             LOG.warn("issuing disconnect during handshake [{}]", connectionAdapter.getRemoteAddress());
index deaa7aa002365073d7494091db7a97fab8fcb082..2b1210bdfce2eefd5a01ffbd3edc818e6e3e6ed4 100644 (file)
@@ -163,7 +163,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(version, helloXid).build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(resultFeatures.getResult(), version);
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(resultFeatures.getResult(), version);
     }
 
     /**
@@ -181,7 +181,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(version, helloXid).build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(resultFeatures.getResult(), version);
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(resultFeatures.getResult(), version);
     }
 
     /**
@@ -197,7 +197,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(version, helloXid).build());
 
-        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessful(
                 Matchers.any(GetFeaturesOutput.class), Matchers.anyShort());
     }
 
@@ -216,7 +216,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(version, helloXid).build());
 
-        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessful(
                 Matchers.any(GetFeaturesOutput.class), Matchers.anyShort());
     }
 
@@ -238,7 +238,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(expVersion, helloXid).build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(
                 resultFeatures.getResult(), expVersion);
     }
 
@@ -262,7 +262,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(expVersion, helloXid).build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(
                 resultFeatures.getResult(), expVersion);
     }
 
@@ -281,7 +281,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(version, helloXid).build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(
                 resultFeatures.getResult(), version);
     }
 
@@ -302,7 +302,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(version, helloXid).build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(
                 resultFeatures.getResult(), version);
     }
 
@@ -324,7 +324,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(expVersion, helloXid).build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(
                 resultFeatures.getResult(), expVersion);
     }
 
@@ -346,7 +346,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(expVersion, helloXid).build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(
                 resultFeatures.getResult(), expVersion);
     }
 
@@ -365,7 +365,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(version, helloXid).build());
 
-        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessful(
                 Matchers.any(GetFeaturesOutput.class), Matchers.anyShort());
     }
 
@@ -386,7 +386,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(createHelloMessage(version, helloXid).build());
 
-        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessful(
                 Matchers.any(GetFeaturesOutput.class), Matchers.anyShort());
     }
 
@@ -409,7 +409,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(helloMessage.build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(
                 resultFeatures.getResult(), version);
     }
 
@@ -434,7 +434,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(helloMessage.build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(
                 resultFeatures.getResult(), version);
     }
 
@@ -457,7 +457,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(helloMessage.build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(
                 resultFeatures.getResult(), version);
     }
 
@@ -482,7 +482,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(helloMessage.build());
 
-        Mockito.verify(handshakeListener).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener).onHandshakeSuccessful(
                 resultFeatures.getResult(), version);
     }
 
@@ -503,7 +503,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(helloMessage.build());
 
-        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessful(
                 Matchers.any(GetFeaturesOutput.class), Matchers.anyShort());
     }
 
@@ -526,7 +526,7 @@ public class HandshakeManagerImplTest {
 
         handshakeManager.shake(helloMessage.build());
 
-        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessfull(
+        Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessful(
                 Matchers.any(GetFeaturesOutput.class), Matchers.anyShort());
     }
 
index 043811a68cf16800f6dabe72f2c2e264b9687fec..a31d89fd89b51cd0027b82705381602ab08e265f 100644 (file)
@@ -273,6 +273,6 @@ public class PacketInV10TranslatorTest {
         connectionConductor.setQueueProcessor(queueProcessor);\r
         connectionConductor.init();\r
         connectionConductor\r
-                .onHandshakeSuccessfull(featuresOutput, (short) 0x01);\r
+                .onHandshakeSuccessful(featuresOutput, (short) 0x01);\r
     }\r
 }\r