import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.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;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
private final boolean switchFeaturesMandatory;
private StatisticsContext statisticsContext;
- private final NodeId nodeId;
+ private final DeviceInfo deviceInfo;
private volatile DEVICE_CONTEXT_STATE deviceCtxState;
private boolean isStatisticsRpcEnabled;
flowLifeCycleKeeper = new ItemLifeCycleSourceImpl();
itemLifeCycleSourceRegistry.registerLifeCycleSource(flowLifeCycleKeeper);
deviceCtxState = DEVICE_CONTEXT_STATE.INITIALIZATION;
-
- nodeId = primaryConnectionContext.getNodeId();
+ deviceInfo = primaryConnectionContext.getDeviceInfo();
}
/**
public void removeAuxiliaryConnectionContext(final ConnectionContext connectionContext) {
final SwitchConnectionDistinguisher connectionDistinguisher = createConnectionDistinguisher(connectionContext);
LOG.debug("auxiliary connection dropped: {}, nodeId:{}", connectionContext.getConnectionAdapter()
- .getRemoteAddress(), nodeId);
+ .getRemoteAddress(), deviceInfo.getNodeId());
auxiliaryConnectionContexts.remove(connectionDistinguisher);
}
@Override
public ListenableFuture<Void> onClusterRoleChange(final OfpRole oldRole, @CheckForNull final OfpRole role) {
- LOG.trace("onClusterRoleChange {} for node:", role, nodeId);
+ LOG.trace("onClusterRoleChange {} for node:", role, deviceInfo.getNodeId());
Preconditions.checkArgument(role != null);
if (role.equals(oldRole)) {
- LOG.debug("Demanded role change for device {} is not changed. OldRole: {}, NewRole {}", nodeId, oldRole, role);
+ LOG.debug("Demanded role change for device {} is not changed. OldRole: {}, NewRole {}", deviceInfo.getNodeId(), oldRole, role);
return Futures.immediateFuture(null);
}
if (OfpRole.BECOMEMASTER.equals(role)) {
} else if (OfpRole.BECOMESLAVE.equals(role)) {
return onDeviceLostClusterLeadership();
} else {
- LOG.warn("Unknown OFCluster Role {} for Node {}", role, nodeId);
+ LOG.warn("Unknown OFCluster Role {} for Node {}", role, deviceInfo.getNodeId());
if (null != rpcContext) {
MdSalRegistrationUtils.unregisterServices(rpcContext);
}
@Override
public ListenableFuture<Void> onDeviceLostClusterLeadership() {
- LOG.trace("onDeviceLostClusterLeadership for node: {}", nodeId);
+ LOG.trace("onDeviceLostClusterLeadership for node: {}", deviceInfo.getNodeId());
if (null != rpcContext) {
MdSalRegistrationUtils.registerSlaveServices(rpcContext, OfpRole.BECOMESLAVE);
}
@Override
public ListenableFuture<Void> onDeviceTakeClusterLeadership() {
- LOG.trace("onDeviceTakeClusterLeadership for node: {}", nodeId);
+ LOG.trace("onDeviceTakeClusterLeadership for node: {}", deviceInfo.getNodeId());
/* validation */
if (statisticsContext == null) {
- final String errMsg = String.format("DeviceCtx %s is up but we are missing StatisticsContext", nodeId);
+ final String errMsg = String.format("DeviceCtx %s is up but we are missing StatisticsContext", deviceInfo.getDatapathId());
LOG.warn(errMsg);
return Futures.immediateFailedFuture(new IllegalStateException(errMsg));
}
if (rpcContext == null) {
- final String errMsg = String.format("DeviceCtx %s is up but we are missing RpcContext", nodeId);
+ final String errMsg = String.format("DeviceCtx %s is up but we are missing RpcContext", deviceInfo.getDatapathId());
LOG.warn(errMsg);
return Futures.immediateFailedFuture(new IllegalStateException(errMsg));
}
LOG.warn(errMsg);
throw new IllegalStateException(errMsg);
}
- LOG.debug("Get Initial Device {} information is successful", nodeId);
+ LOG.debug("Get Initial Device {} information is successful", deviceInfo.getNodeId());
getDeviceState().setDeviceSynchronized(true);
initialSubmitTransaction();
getDeviceState().setStatisticsPollingEnabledProp(true);
@Override
public synchronized void shutdownConnection() {
- LOG.debug("Shutdown method for node {}", nodeId);
+ LOG.debug("Shutdown method for node {}", deviceInfo.getNodeId());
deviceState.setValid(false);
if (DEVICE_CONTEXT_STATE.TERMINATION.equals(deviceCtxState)) {
- LOG.debug("DeviceCtx for Node {} is in termination process.", nodeId);
+ LOG.debug("DeviceCtx for Node {} is in termination process.", deviceInfo.getNodeId());
return;
}
deviceCtxState = DEVICE_CONTEXT_STATE.TERMINATION;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.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;
private MessageTranslator<Object, Object> messageTranslatorFlowRemoved;
@Mock
private LifecycleConductor lifecycleConductor;
+ @Mock
+ private DeviceInfo deviceInfo;
private InOrder inOrderDevState;
Mockito.when(dataBroker.createTransactionChain(Mockito.any(TransactionChainManager.class))).thenReturn(txChainFactory);
Mockito.when(deviceState.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
Mockito.when(deviceState.getNodeId()).thenReturn(nodeId);
-// txChainManager = new TransactionChainManager(dataBroker, deviceState);
final SettableFuture<RpcResult<GetAsyncReply>> settableFuture = SettableFuture.create();
final SettableFuture<RpcResult<MultipartReply>> settableFutureMultiReply = SettableFuture.create();
Mockito.when(requestContext.getFuture()).thenReturn(settableFuture);
- Mockito.doAnswer(new Answer<Object>() {
- @SuppressWarnings("unchecked")
- @Override
- public Object answer(final InvocationOnMock invocation) {
- settableFuture.set((RpcResult<GetAsyncReply>) invocation.getArguments()[0]);
- return null;
- }
+ Mockito.doAnswer(invocation -> {
+ settableFuture.set((RpcResult<GetAsyncReply>) invocation.getArguments()[0]);
+ return null;
}).when(requestContext).setResult(any(RpcResult.class));
Mockito.when(requestContextMultiReply.getFuture()).thenReturn(settableFutureMultiReply);
- Mockito.doAnswer(new Answer<Object>() {
- @SuppressWarnings("unchecked")
- @Override
- public Object answer(final InvocationOnMock invocation) {
- settableFutureMultiReply.set((RpcResult<MultipartReply>) invocation.getArguments()[0]);
- return null;
- }
+ Mockito.doAnswer(invocation -> {
+ settableFutureMultiReply.set((RpcResult<MultipartReply>) invocation.getArguments()[0]);
+ return null;
}).when(requestContextMultiReply).setResult(any(RpcResult.class));
Mockito.when(txChainFactory.newWriteOnlyTransaction()).thenReturn(wTx);
Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(rTx);
Mockito.when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
Mockito.when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter);
+ Mockito.when(connectionContext.getDeviceInfo()).thenReturn(deviceInfo);
final FeaturesReply mockedFeaturesReply = mock(FeaturesReply.class);
when(connectionContext.getFeatures()).thenReturn(mockedFeaturesReply);
when(connectionContext.getFeatures().getCapabilities()).thenReturn(mock(Capabilities.class));