From: Jozef Bacigal Date: Thu, 11 Aug 2016 10:54:43 +0000 (+0200) Subject: Bug 5596 - restart devices management improvement X-Git-Tag: release/boron~12 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=2578bbbc093ee26fa014ed2c115f6be76af096e2;p=openflowplugin.git Bug 5596 - restart devices management improvement Change-Id: I61b384062e780eec342d7b7eb0ffa05bc0f6c7de Signed-off-by: Jozef Bacigal --- diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPContext.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPContext.java index 0840568efb..c16d5fafb6 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPContext.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OFPContext.java @@ -48,8 +48,9 @@ public interface OFPContext { /** * About to stop services in cluster not master anymore or going down * @return Future most of services need time to be closed + * @param deviceDisconnected */ - default ListenableFuture stopClusterServices(){ + default ListenableFuture stopClusterServices(final boolean deviceDisconnected){ return Futures.immediateFailedFuture(new RejectedExecutionException("Cannot stop abstract services, check implementation of cluster services")); } diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/connection/ConnectionContext.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/connection/ConnectionContext.java index 88e1c9174f..4e91673d08 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/connection/ConnectionContext.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/connection/ConnectionContext.java @@ -106,6 +106,8 @@ public interface ConnectionContext { */ void setDeviceDisconnectedHandler(DeviceDisconnectedHandler deviceDisconnectedHandler); + String getSafeNodeIdForLOG(); + void setOutboundQueueHandleRegistration(OutboundQueueHandlerRegistration outboundQueueHandlerRegistration); /** @@ -139,7 +141,7 @@ public interface ConnectionContext { /** * Create and return basic device info - * @return + * @return created device info */ DeviceInfo getDeviceInfo(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java index 30eccf1db3..986bbb178e 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ConnectionContextImpl.java @@ -162,12 +162,14 @@ public class ConnectionContextImpl implements ConnectionContext { @Override public void onConnectionClosed() { + + connectionState = ConnectionContext.CONNECTION_STATE.RIP; + if (null == nodeId){ SessionStatistics.countEvent(connectionAdapter.getRemoteAddress().toString(), SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_DEVICE); } else { SessionStatistics.countEvent(nodeId.toString(), SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_DEVICE); } - connectionState = ConnectionContext.CONNECTION_STATE.RIP; final InetSocketAddress remoteAddress = connectionAdapter.getRemoteAddress(); final Short auxiliaryId; @@ -200,7 +202,8 @@ public class ConnectionContextImpl implements ConnectionContext { * This method returns safe nodeId for logging * @return string value od nodeId or string "null" */ - private String getSafeNodeIdForLOG() { + @Override + public String getSafeNodeIdForLOG() { return null == nodeId ? "null" : nodeId.getValue(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java index 1bf37f1782..1d5263a8a7 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java @@ -51,7 +51,7 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe @Override public void onDisconnectEvent(final DisconnectEvent notification) { LOG.info("ConnectionEvent: Connection closed by device, Device:{}, NodeId:{}", - connectionContext.getConnectionAdapter().getRemoteAddress(), connectionContext.getNodeId()); + connectionContext.getConnectionAdapter().getRemoteAddress(), connectionContext.getSafeNodeIdForLOG()); connectionContext.onConnectionClosed(); } @@ -98,7 +98,7 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe if (shouldBeDisconnected) { if (LOG.isInfoEnabled()) { LOG.info("ConnectionEvent:Closing connection as device is idle. Echo sent at {}. Device:{}, NodeId:{}", - new Date(System.currentTimeMillis() - echoReplyTimeout), remoteAddress, connectionContext.getNodeId()); + new Date(System.currentTimeMillis() - echoReplyTimeout), remoteAddress, connectionContext.getSafeNodeIdForLOG()); } connectionContext.closeConnection(true); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java index 558f44cfb5..96acf077a9 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java @@ -545,7 +545,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi } @Override - public ListenableFuture stopClusterServices() { + public ListenableFuture stopClusterServices(boolean deviceDisconnected) { return this.transactionChainManager.deactivateTransactionManager(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java index 35c372b332..a3ed4479c6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java @@ -260,11 +260,6 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi @Override public void onDeviceContextLevelDown(final DeviceInfo deviceInfo) { - deviceContexts.remove(deviceInfo); - if (LOG.isDebugEnabled()) { - LOG.debug("Device context removed for node {}", deviceInfo.getLOGValue()); - } - LifecycleService lifecycleService = lifecycleServices.remove(deviceInfo); if (LOG.isDebugEnabled()) { LOG.debug("Lifecycle service removed for node {}", deviceInfo.getLOGValue()); @@ -279,6 +274,12 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi LOG.warn("Closing lifecycle service for node {} was unsuccessful ", deviceInfo.getLOGValue(), e); } } + + deviceContexts.remove(deviceInfo); + if (LOG.isDebugEnabled()) { + LOG.debug("Device context removed for node {}", deviceInfo.getLOGValue()); + } + } @Override diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManager.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManager.java index 7ccdc42824..dcb7f70bbb 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManager.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManager.java @@ -276,7 +276,7 @@ class TransactionChainManager implements TransactionChainListener, AutoCloseable } ListenableFuture shuttingDown() { - LOG.debug("TxManager is going SHUTTING_DOWN for node {}", nodeII); + LOG.debug("TxManager is going SHUTTING_DOWN for node {}", nodeII.getKey().getId().getValue()); ListenableFuture future; synchronized (txLock) { this.transactionChainManagerStatus = TransactionChainManagerStatus.SHUTTING_DOWN; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/LifecycleServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/LifecycleServiceImpl.java index d5e024a905..729a3d8718 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/LifecycleServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/LifecycleServiceImpl.java @@ -45,8 +45,7 @@ public class LifecycleServiceImpl implements LifecycleService { try { if (LOG.isDebugEnabled()) { - LOG.debug("Starting clustering MASTER services for node {}", this.deviceContext.getDeviceInfo().getLOGValue()); - LOG.debug("==============================================="); + LOG.debug("========== Starting clustering MASTER services for node {} ==========", this.deviceContext.getDeviceInfo().getLOGValue()); } if (connectionInterrupted()) { @@ -108,21 +107,26 @@ public class LifecycleServiceImpl implements LifecycleService { @Override public ListenableFuture closeServiceInstance() { if (LOG.isDebugEnabled()) { - LOG.debug("Stopping clustering MASTER services for node {}", this.deviceContext.getDeviceInfo().getLOGValue()); - LOG.debug("==============================================="); + LOG.debug("========== Stopping clustering MASTER services for node {} ==========", this.deviceContext.getDeviceInfo().getLOGValue()); } + final boolean connectionInterrupted = + this.deviceContext + .getPrimaryConnectionContext() + .getConnectionState() + .equals(ConnectionContext.CONNECTION_STATE.RIP); + LOG.info("Stopping role context cluster services for node {}", getIdentifier()); - roleContext.stopClusterServices(); + roleContext.stopClusterServices(connectionInterrupted); LOG.info("Stopping statistics context cluster services for node {}", getIdentifier()); - statContext.stopClusterServices(); + statContext.stopClusterServices(connectionInterrupted); LOG.info("Stopping rpc context cluster services for node {}", getIdentifier()); - rpcContext.stopClusterServices(); + rpcContext.stopClusterServices(connectionInterrupted); LOG.info("Stopping device context cluster services for node {}", getIdentifier()); - return deviceContext.stopClusterServices(); + return deviceContext.stopClusterServices(connectionInterrupted); } @Override diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java index baefc62aca..c44f1e3e9c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java @@ -84,7 +84,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry { @Override public ListenableFuture>> fill() { - LOG.debug("Filling flow registry with flows for node: {}", instanceIdentifier); + LOG.debug("Filling flow registry with flows for node: {}", instanceIdentifier.getKey().getId().getValue()); // Prepare path for read transaction // TODO: Read only Tables, and not entire FlowCapableNode (fix Yang model) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java index 483b8c7faf..888a4e9590 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java @@ -24,7 +24,6 @@ import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; -import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleService; import org.opendaylight.openflowplugin.api.openflow.role.RoleContext; import org.opendaylight.openflowplugin.api.openflow.role.RoleManager; import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext; @@ -54,14 +53,11 @@ class RoleContextImpl implements RoleContext { private final DeviceInfo deviceInfo; private CONTEXT_STATE state; private final RoleManager myManager; - private final LifecycleService lifecycleService; RoleContextImpl(final DeviceInfo deviceInfo, final HashedWheelTimer hashedWheelTimer, - final RoleManager myManager, - final LifecycleService lifecycleService) { + final RoleManager myManager) { this.deviceInfo = deviceInfo; - this.lifecycleService = lifecycleService; state = CONTEXT_STATE.WORKING; this.myManager = myManager; this.hashedWheelTimer = hashedWheelTimer; @@ -113,46 +109,49 @@ class RoleContextImpl implements RoleContext { @Override public void onSuccess(@Nullable RpcResult setRoleOutputRpcResult) { if (LOG.isDebugEnabled()) { - LOG.debug("Role MASTER was successfully set on device, node {}", deviceInfo.getNodeId().getValue()); + LOG.debug("Role MASTER was successfully set on device, node {}", deviceInfo.getLOGValue()); } } @Override public void onFailure(final Throwable throwable) { - LOG.warn("Was not able to set MASTER role on device, node {}", deviceInfo.getNodeId().getValue()); - lifecycleService.closeConnection(); + LOG.warn("Was not able to set MASTER role on device, node {}", deviceInfo.getLOGValue()); } }); } @Override - public ListenableFuture stopClusterServices() { - ListenableFuture future = Futures.transform(makeDeviceSlave(), new Function, Void>() { - @Nullable - @Override - public Void apply(@Nullable RpcResult setRoleOutputRpcResult) { - return null; - } - }); - - Futures.addCallback(future, new FutureCallback() { - @Override - public void onSuccess(@Nullable Void aVoid) { - if (LOG.isDebugEnabled()) { - LOG.debug("Role SLAVE was successfully propagated on device, node {}", deviceInfo.getNodeId().getValue()); - } - myManager.removeDeviceFromOperationalDS(deviceInfo, MAX_CLEAN_DS_RETRIES); + public ListenableFuture stopClusterServices(final boolean deviceDisconnected) { + + if (!deviceDisconnected) { + ListenableFuture future = Futures.transform(makeDeviceSlave(), new Function, Void>() { + @Nullable + @Override + public Void apply(@Nullable RpcResult setRoleOutputRpcResult) { + return null; + } + }); + + Futures.addCallback(future, new FutureCallback() { + @Override + public void onSuccess(@Nullable Void aVoid) { + if (LOG.isDebugEnabled()) { + LOG.debug("Role SLAVE was successfully propagated on device, node {}", deviceInfo.getLOGValue()); } + } - @Override - public void onFailure(final Throwable throwable) { - LOG.warn("Was not able to set role SLAVE to device on node {} ", deviceInfo.getNodeId().getValue()); - LOG.trace("Error occurred on device role setting, probably connection loss: ", throwable); - myManager.removeDeviceFromOperationalDS(deviceInfo, MAX_CLEAN_DS_RETRIES); + @Override + public void onFailure(final Throwable throwable) { + LOG.warn("Was not able to set role SLAVE to device on node {} ", deviceInfo.getLOGValue()); + LOG.trace("Error occurred on device role setting, probably connection loss: ", throwable); + myManager.removeDeviceFromOperationalDS(deviceInfo, MAX_CLEAN_DS_RETRIES); - } - }); - return future; + } + }); + return future; + } else { + return myManager.removeDeviceFromOperationalDS(deviceInfo, MAX_CLEAN_DS_RETRIES); + } } @Override @@ -177,7 +176,7 @@ class RoleContextImpl implements RoleContext { setRoleOutputFuture = getSalRoleService().setRole(setRoleInput); final TimerTask timerTask = timeout -> { if (!setRoleOutputFuture.isDone()) { - LOG.warn("New role {} was not propagated to device {} during 10 sec", newRole, deviceInfo.getNodeId()); + LOG.warn("New role {} was not propagated to device {} during 10 sec", newRole, deviceInfo.getLOGValue()); setRoleOutputFuture.cancel(true); } }; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleManagerImpl.java index 4514193049..e6decb4a7c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleManagerImpl.java @@ -71,7 +71,7 @@ public class RoleManagerImpl implements RoleManager { @Override public void onDeviceContextLevelUp(@CheckForNull final DeviceInfo deviceInfo, final LifecycleService lifecycleService) throws Exception { final DeviceContext deviceContext = Preconditions.checkNotNull(lifecycleService.getDeviceContext()); - final RoleContext roleContext = new RoleContextImpl(deviceInfo, hashedWheelTimer, this, lifecycleService); + final RoleContext roleContext = new RoleContextImpl(deviceInfo, hashedWheelTimer, this); roleContext.setSalRoleService(new SalRoleServiceImpl(roleContext, deviceContext)); Verify.verify(contexts.putIfAbsent(deviceInfo, roleContext) == null, "Role context for master Node %s is still not closed.", deviceInfo.getLOGValue()); Futures.addCallback(roleContext.makeDeviceSlave(), new FutureCallback>() { @@ -85,7 +85,6 @@ public class RoleManagerImpl implements RoleManager { @Override public void onFailure(Throwable throwable) { LOG.warn("Was not able to set role SLAVE to device on node {} ",deviceInfo.getLOGValue()); - lifecycleService.closeConnection(); } }); lifecycleService.setRoleContext(roleContext); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java index b5563d6e86..6d1954d30d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java @@ -25,7 +25,6 @@ import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; -import org.opendaylight.openflowplugin.api.openflow.device.XidSequencer; import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy; import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider; @@ -90,7 +89,7 @@ class RpcContextImpl implements RpcContext { final RoutedRpcRegistration routedRpcReg = rpcProviderRegistry.addRoutedRpcImplementation(serviceClass, serviceInstance); routedRpcReg.registerPath(NodeContext.class, nodeInstanceIdentifier); rpcRegistrations.put(serviceClass, routedRpcReg); - LOG.debug("Registration of service {} for device {}.", serviceClass, nodeInstanceIdentifier); + LOG.debug("Registration of service {} for device {}.", serviceClass.getSimpleName(), nodeInstanceIdentifier.getKey().getId().getValue()); } } @@ -120,8 +119,8 @@ class RpcContextImpl implements RpcContext { rpcRegistration.unregisterPath(NodeContext.class, nodeInstanceIdentifier); rpcRegistration.close(); if (LOG.isDebugEnabled()) { - LOG.debug("Closing RPC Registration of service {} for device {}.", rpcRegistration.getServiceType(), - nodeInstanceIdentifier); + LOG.debug("Closing RPC Registration of service {} for device {}.", rpcRegistration.getServiceType().getSimpleName(), + nodeInstanceIdentifier.getKey().getId().getValue()); } } } @@ -133,12 +132,12 @@ class RpcContextImpl implements RpcContext { LOG.trace("Device queue {} at capacity", this); return null; } else { - LOG.trace("Acquired semaphore for {}, available permits:{} ", nodeInstanceIdentifier.getKey().getId(), tracker.availablePermits()); + LOG.trace("Acquired semaphore for {}, available permits:{} ", nodeInstanceIdentifier.getKey().getId().getValue(), tracker.availablePermits()); } final Long xid = deviceInfo.reserveXidForDeviceMessage(); if (xid == null) { - LOG.warn("Xid cannot be reserved for new RequestContext, node:{}", nodeInstanceIdentifier.getKey().getId()); + LOG.warn("Xid cannot be reserved for new RequestContext, node:{}", nodeInstanceIdentifier.getKey().getId().getValue()); tracker.release(); return null; } @@ -161,7 +160,7 @@ class RpcContextImpl implements RpcContext { if (rpcRegistration != null) { rpcRegistration.unregisterPath(NodeContext.class, nodeInstanceIdentifier); rpcRegistration.close(); - LOG.debug("Unregistration serviceClass {} for Node {}", serviceClass, nodeInstanceIdentifier.getKey().getId()); + LOG.debug("Un-registration serviceClass {} for Node {}", serviceClass.getSimpleName(), nodeInstanceIdentifier.getKey().getId().getValue()); } } @@ -214,7 +213,7 @@ class RpcContextImpl implements RpcContext { } @Override - public ListenableFuture stopClusterServices() { + public ListenableFuture stopClusterServices(boolean deviceDisconnected) { MdSalRegistrationUtils.unregisterServices(this); return Futures.immediateFuture(null); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalRoleServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalRoleServiceImpl.java index c90cff8c6d..9906515af6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalRoleServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalRoleServiceImpl.java @@ -69,7 +69,7 @@ public final class SalRoleServiceImpl extends AbstractSimpleService failed().buildFuture(); } // compare with last known role and set if different. If they are same, then return. diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java index 144d664c2b..9c8755e83d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java @@ -426,7 +426,7 @@ class StatisticsContextImpl implements StatisticsContext { } @Override - public ListenableFuture stopClusterServices() { + public ListenableFuture stopClusterServices(boolean deviceDisconnected) { myManager.stopScheduling(deviceInfo); return Futures.immediateFuture(null); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java index 176a776689..19bb57d8f0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImplTest.java @@ -104,7 +104,7 @@ public class SystemNotificationsListenerImplTest { verifyCommonInvocationsSubSet(); Mockito.verify(connectionContext).onConnectionClosed(); Mockito.verify(connectionContext).getConnectionAdapter(); - Mockito.verify(connectionContext).getNodeId(); + Mockito.verify(connectionContext, Mockito.atLeastOnce()).getSafeNodeIdForLOG(); } /** @@ -123,7 +123,7 @@ public class SystemNotificationsListenerImplTest { verifyCommonInvocationsSubSet(); Mockito.verify(connectionContext).onConnectionClosed(); Mockito.verify(connectionContext).getConnectionAdapter(); - Mockito.verify(connectionContext).getNodeId(); + Mockito.verify(connectionContext, Mockito.atLeastOnce()).getSafeNodeIdForLOG(); } /** @@ -144,7 +144,7 @@ public class SystemNotificationsListenerImplTest { verifyCommonInvocationsSubSet(); Mockito.verify(connectionContext).onConnectionClosed(); Mockito.verify(connectionContext).getConnectionAdapter(); - Mockito.verify(connectionContext).getNodeId(); + Mockito.verify(connectionContext, Mockito.atLeastOnce()).getSafeNodeIdForLOG(); } /** @@ -163,7 +163,7 @@ public class SystemNotificationsListenerImplTest { verifyCommonInvocationsSubSet(); Mockito.verify(connectionContext).onConnectionClosed(); Mockito.verify(connectionContext).getConnectionAdapter(); - Mockito.verify(connectionContext).getNodeId(); + Mockito.verify(connectionContext, Mockito.atLeastOnce()).getSafeNodeIdForLOG(); } /** @@ -212,7 +212,7 @@ public class SystemNotificationsListenerImplTest { Mockito.verify(connectionAdapter).disconnect(); Mockito.verify(connectionContext).changeStateToTimeouting(); Mockito.verify(connectionContext).closeConnection(true); - Mockito.verify(connectionContext).getNodeId(); + Mockito.verify(connectionContext, Mockito.atLeastOnce()).getSafeNodeIdForLOG(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleContextImplTest.java index 3e8b905f10..dc3b6dccc4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleContextImplTest.java @@ -44,7 +44,7 @@ public class RoleContextImplTest { @Before public void setup() throws CandidateAlreadyRegisteredException { - roleContext = new RoleContextImpl(deviceInfo, hashedWheelTimer, roleManager, lifecycleService); + roleContext = new RoleContextImpl(deviceInfo, hashedWheelTimer, roleManager); Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java index 4344cc01e6..d38ff06800 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java @@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.impl.rpc; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -58,6 +59,8 @@ public class RpcContextImplTest { private DeviceContext deviceContext; @Mock private BindingAwareBroker.RoutedRpcRegistration routedRpcReg; + + private Class serviceClass; @Mock private NotificationPublishService notificationPublishService; @Mock @@ -166,6 +169,8 @@ public class RpcContextImplTest { @Test public void testClose() { + serviceClass = TestRpcService.class; + when(routedRpcReg.getServiceType()).thenReturn(serviceClass); rpcContext.registerRpcServiceImplementation(TestRpcService.class, serviceInstance); rpcContext.close(); assertEquals(rpcContext.isEmptyRpcRegistrations(), true);