final FlowCapableNode operationalNode) throws InterruptedException {
NodeId nodeId = PathUtil.digNodeId(nodePath);
LOG.trace("onNodeAdded {}", nodeId.getValue());
+ LOG.debug("Reconciliation {}: {}", dsType(), nodeId.getValue());
final SyncupEntry syncupEntry = new SyncupEntry(dataAfter, dsType(), operationalNode, LogicalDatastoreType.OPERATIONAL);
return reactor.syncup(nodePath, syncupEntry);
}
final Optional<FlowCapableNode> nodeConfiguration = configDao.loadByNodeId(nodeId);
if (nodeConfiguration.isPresent()) {
- LOG.debug("Reconciliation: {}", nodeId.getValue());
+ LOG.debug("Reconciliation {}: {}", dsType(), nodeId.getValue());
final InstanceIdentifier<FlowCapableNode> nodePath = InstanceIdentifier.create(Nodes.class)
.child(Node.class, new NodeKey(ModificationUtil.nodeId(modification)))
.augmentation(FlowCapableNode.class);
return Optional.of(reactor.syncup(nodePath, syncupEntry));
} else {
LOG.debug("Config not present for reconciliation: {}", nodeId.getValue());
+ reconciliationRegistry.unregisterIfRegistered(nodeId);
return skipModification(modification);
}
}
}
@Test
- public void testOnDataTreeChangeAddSyncup() throws Exception {
- Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
+ public void testOnDataTreeChangedAddPhysical() {
operationalAdd();
- prepareFreshOperational(true);
- final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(configNode, configDS, fcOperationalNode, operationalDS);
-
nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
-
- Mockito.verify(deviceMastershipManager).onDeviceConnected(NODE_ID);
- Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
- Mockito.verify(roTx).close();
- }
-
- @Test
- public void testOnDataTreeChangedAddSkip() throws Exception {
- // Related to bug 5920 -> https://bugs.opendaylight.org/show_bug.cgi?id=5920
- Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
- operationalAdd();
- prepareFreshOperational(true);
-
- Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
- .thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
-
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
-
Mockito.verify(deviceMastershipManager).onDeviceConnected(NODE_ID);
Mockito.verifyZeroInteractions(reactor);
- Mockito.verify(roTx).close();
}
@Test
@Test
public void testOnDataTreeChangedReconcileNotRegistered() {
- operationalUpdate();
Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(false);
+ operationalUpdate();
nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
Mockito.verify(roTx).close();
}
+ @Test
+ public void testOnDataTreeChangedReconcileAndConfigNotPresent() throws Exception {
+ // Related to bug 5920 -> https://bugs.opendaylight.org/show_bug.cgi?id=5920
+ Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
+ operationalUpdate();
+ prepareFreshOperational(true);
+
+ Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
+ .thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
+
+ nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+
+ Mockito.verify(reconciliationRegistry).unregisterIfRegistered(NODE_ID);
+ Mockito.verifyZeroInteractions(reactor);
+ Mockito.verify(roTx).close();
+ }
+
private void prepareFreshOperational(final boolean afterRegistration) throws ParseException {
Mockito.when(operationalNode.getAugmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(statisticsGatheringStatus);
Mockito.when(statisticsGatheringStatus.getSnapshotGatheringStatusEnd()).thenReturn(snapshotGatheringStatusEnd);
import io.netty.util.Timeout;
import java.util.Optional;
import org.opendaylight.openflowplugin.api.openflow.OFPContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleService;
import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
*/
boolean isSchedulingEnabled();
- LifecycleService getLifecycleService();
+ /**
+ * Gain device state
+ * @return device state from device context from lifecycle service
+ */
+ DeviceState gainDeviceState();
+
+ /**
+ * Gain device context
+ * @return device context from lifecycle service
+ */
+ DeviceContext gainDeviceContext();
+
+ /**
+ * In case to change mastership to slave or connection interrupted stop the future and release thread
+ */
+ void stopGatheringData();
}
try {
ConnectionStatus connectionStatusResult = deviceConnectedHandler.deviceConnected(connectionContext);
if (!ConnectionStatus.MAY_CONTINUE.equals(connectionStatusResult)) {
- connectionContext.closeConnection(ConnectionStatus.ALREADY_CONNECTED.equals(connectionStatusResult));
+ connectionContext.closeConnection(true);
}
SessionStatistics.countEvent(connectionContext.getNodeId().toString(),
SessionStatistics.ConnectionStatus.CONNECTION_CREATED);
LOG.info("Starting device context cluster services for node {}", deviceInfo.getLOGValue());
- lazyTransactionManagerInitialiaztion();
+ lazyTransactionManagerInitialization();
this.transactionChainManager.activateTransactionManager();
}
@VisibleForTesting
- void lazyTransactionManagerInitialiaztion() {
+ void lazyTransactionManagerInitialization() {
if (!this.initialized) {
if (LOG.isDebugEnabled()) {
LOG.debug("Transaction chain manager for node {} created", deviceInfo.getLOGValue());
@Override
public void instantiateServiceInstance() {
- LOG.info("========== Starting clustering MASTER services for node {} ==========", this.deviceContext.getDeviceInfo().getLOGValue());
+ LOG.info("Starting clustering MASTER services for node {}", this.deviceContext.getDeviceInfo().getLOGValue());
- if (this.clusterInitializationPhaseHandler.onContextInstantiateService(null)) {
- LOG.info("========== Start-up clustering MASTER services for node {} was SUCCESSFUL ==========", this.deviceContext.getDeviceInfo().getLOGValue());
- } else {
- LOG.warn("========== Start-up clustering MASTER services for node {} was UN-SUCCESSFUL ==========", this.deviceContext.getDeviceInfo().getLOGValue());
+ if (!this.clusterInitializationPhaseHandler.onContextInstantiateService(null)) {
this.closeConnection();
}
@Override
public ListenableFuture<Void> closeServiceInstance() {
- if (LOG.isDebugEnabled()) {
- LOG.debug("========== Stopping clustering MASTER services for node {} ==========", this.deviceContext.getDeviceInfo().getLOGValue());
- }
+
+ LOG.info("Stopping clustering MASTER services for node {}", this.deviceContext.getDeviceInfo().getLOGValue());
final boolean connectionInterrupted =
this.deviceContext
.getConnectionState()
.equals(ConnectionContext.CONNECTION_STATE.RIP);
- LOG.info("Stopping role context cluster services for node {}", getIdentifier());
roleContext.stopClusterServices(connectionInterrupted);
-
- LOG.info("Stopping statistics context cluster services for node {}", getIdentifier());
statContext.stopClusterServices(connectionInterrupted);
-
- LOG.info("Stopping rpc context cluster services for node {}", getIdentifier());
rpcContext.stopClusterServices(connectionInterrupted);
-
- LOG.info("Stopping device context cluster services for node {}", getIdentifier());
return deviceContext.stopClusterServices(connectionInterrupted);
+
}
@Override
@Override
public void onFailure(Throwable t) {
if (deviceFlowRegistryFill.isCancelled()) {
- LOG.debug("Cancelled filling flow registry with flows for node: {}", deviceContext.getDeviceInfo().getLOGValue());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cancelled filling flow registry with flows for node: {}", deviceContext.getDeviceInfo().getLOGValue());
+ }
} else {
LOG.warn("Failed filling flow registry with flows for node: {} with exception: {}", deviceContext.getDeviceInfo().getLOGValue(), t);
}
return false;
}
- LOG.info("Caching flows IDs ...");
fillDeviceFlowRegistry();
return true;
}
class RoleContextImpl implements RoleContext {
private static final Logger LOG = LoggerFactory.getLogger(RoleContextImpl.class);
- // Maximum limit of timeout retries when cleaning DS, to prevent infinite recursive loops
- private static final int MAX_CLEAN_DS_RETRIES = 0;
private SalRoleService salRoleService = null;
private final HashedWheelTimer hashedWheelTimer;
final RoleManager myManager,
final LifecycleService lifecycleService) {
this.deviceInfo = deviceInfo;
- state = CONTEXT_STATE.WORKING;
+ this.state = CONTEXT_STATE.WORKING;
this.myManager = myManager;
this.hashedWheelTimer = hashedWheelTimer;
this.lifecycleService = lifecycleService;
}
public void startupClusterServices() throws ExecutionException, InterruptedException {
- Futures.addCallback(sendRoleChangeToDevice(OfpRole.BECOMEMASTER), new FutureCallback<RpcResult<SetRoleOutput>>() {
- @Override
- public void onSuccess(@Nullable RpcResult<SetRoleOutput> setRoleOutputRpcResult) {
- if (LOG.isDebugEnabled()) {
- 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.getLOGValue());
- lifecycleService.closeConnection();
- }
- });
+ Futures.addCallback(sendRoleChangeToDevice(OfpRole.BECOMEMASTER), new RpcResultFutureCallback());
}
@Override
return false;
}
- Futures.addCallback(sendRoleChangeToDevice(OfpRole.BECOMEMASTER), new FutureCallback<RpcResult<SetRoleOutput>>() {
- @Override
- public void onSuccess(@Nullable RpcResult<SetRoleOutput> setRoleOutputRpcResult) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Role MASTER was successfully set on device, node {}", deviceInfo.getLOGValue());
- }
- }
+ Futures.addCallback(sendRoleChangeToDevice(OfpRole.BECOMEMASTER), new RpcResultFutureCallback());
+ return this.clusterInitializationPhaseHandler.onContextInstantiateService(connectionContext);
+ }
- @Override
- public void onFailure(final Throwable throwable) {
- LOG.warn("Was not able to set MASTER role on device, node {}", deviceInfo.getLOGValue());
- lifecycleService.closeConnection();
+ private class RpcResultFutureCallback implements FutureCallback<RpcResult<SetRoleOutput>> {
+ @Override
+ public void onSuccess(@Nullable RpcResult<SetRoleOutput> setRoleOutputRpcResult) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Role MASTER was successfully set on device, node {}", deviceInfo.getLOGValue());
}
- });
+ }
- return this.clusterInitializationPhaseHandler.onContextInstantiateService(connectionContext);
+ @Override
+ public void onFailure(final Throwable throwable) {
+ LOG.warn("Was not able to set MASTER role on device, node {}", deviceInfo.getLOGValue());
+ lifecycleService.closeConnection();
+ }
}
}
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
private ClusterInitializationPhaseHandler clusterInitializationPhaseHandler;
private ClusterInitializationPhaseHandler initialSubmitHandler;
+ private ListenableFuture<Boolean> lastDataGathering;
+
StatisticsContextImpl(@Nonnull final DeviceInfo deviceInfo,
final boolean shuttingDownStatisticsPolling,
@Nonnull final LifecycleService lifecycleService,
- @Nonnull final ConvertorExecutor convertorExecutor,
+ @Nonnull final ConvertorExecutor convertorExecutor,
@Nonnull final StatisticsManager myManager) {
this.lifecycleService = lifecycleService;
this.deviceContext = lifecycleService.getDeviceContext();
setState(CONTEXT_STATE.INITIALIZATION);
this.deviceInfo = deviceInfo;
this.myManager = myManager;
+ this.lastDataGathering = null;
}
@Override
}
private ListenableFuture<Boolean> gatherDynamicData(final boolean initial) {
+ this.lastDataGathering = null;
if (shuttingDownStatisticsPolling) {
LOG.debug("Statistics for device {} is not enabled.", getDeviceInfo().getNodeId().getValue());
return Futures.immediateFuture(Boolean.TRUE);
}
}
});
+ this.lastDataGathering = settableStatResultFuture;
return settableStatResultFuture;
}
}
LOG.debug("Statistics context is already in state TERMINATION.");
}
} else {
+ stopGatheringData();
setState(CONTEXT_STATE.TERMINATION);
schedulingEnabled = false;
for (final Iterator<RequestContext<?>> iterator = Iterators.consumingIterator(requestContexts.iterator());
}
if ( ! iterator.hasNext()) {
resultFuture.set(Boolean.TRUE);
- LOG.debug("Stats collection successfully finished for node {}", getDeviceInfo().getNodeId());
+ LOG.debug("Stats collection successfully finished for node {}", getDeviceInfo().getLOGValue());
return;
}
final MultipartType nextType = iterator.next();
- LOG.debug("Stats iterating to next type for node {} of type {}", getDeviceInfo().getNodeId(), nextType);
+ LOG.debug("Stats iterating to next type for node {} of type {}", getDeviceInfo().getLOGValue(), nextType);
final ListenableFuture<Boolean> deviceStatisticsCollectionFuture = chooseStat(nextType, initial);
Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
@Override
public ListenableFuture<Void> stopClusterServices(boolean deviceDisconnected) {
+ stopGatheringData();
myManager.stopScheduling(deviceInfo);
return Futures.immediateFuture(null);
}
@Override
- public LifecycleService getLifecycleService() {
- return lifecycleService;
+ public DeviceState gainDeviceState() {
+ return gainDeviceContext().getDeviceState();
+ }
+
+ @Override
+ public DeviceContext gainDeviceContext() {
+ return this.lifecycleService.getDeviceContext();
+ }
+
+ @Override
+ public void stopGatheringData() {
+ if (Objects.nonNull(this.lastDataGathering)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Stop the running statistics gathering for node {}", this.deviceInfo.getLOGValue());
+ }
+ this.lastDataGathering.cancel(true);
+ }
}
@Override
private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerImpl.class);
private static final long DEFAULT_STATS_TIMEOUT_SEC = 50L;
- private final ConvertorExecutor convertorExecutor;
+ private final ConvertorExecutor converterExecutor;
private DeviceInitializationPhaseHandler deviceInitPhaseHandler;
private DeviceTerminationPhaseHandler deviceTerminPhaseHandler;
final HashedWheelTimer hashedWheelTimer,
final ConvertorExecutor convertorExecutor) {
Preconditions.checkArgument(rpcProviderRegistry != null);
- this.convertorExecutor = convertorExecutor;
- this.controlServiceRegistration = Preconditions.checkNotNull(rpcProviderRegistry.addRpcImplementation(
- StatisticsManagerControlService.class, this));
+ this.converterExecutor = convertorExecutor;
+ this.controlServiceRegistration = Preconditions.checkNotNull(
+ rpcProviderRegistry.addRpcImplementation(StatisticsManagerControlService.class, this)
+ );
this.isStatisticsPollingEnabled = isStatisticsPollingEnabled;
this.hashedWheelTimer = hashedWheelTimer;
}
@Override
- public void onDeviceContextLevelUp(final DeviceInfo deviceInfo, final LifecycleService lifecycleService) throws Exception {
-
- final StatisticsContext statisticsContext = new StatisticsContextImpl(deviceInfo, isStatisticsPollingEnabled, lifecycleService, convertorExecutor, this);
- Verify.verify(contexts.putIfAbsent(deviceInfo, statisticsContext) == null, "StatisticsCtx still not closed for Node {}", deviceInfo.getLOGValue());
+ public void onDeviceContextLevelUp(final DeviceInfo deviceInfo,
+ final LifecycleService lifecycleService) throws Exception {
+
+ final StatisticsContext statisticsContext =
+ new StatisticsContextImpl(
+ deviceInfo,
+ isStatisticsPollingEnabled,
+ lifecycleService,
+ converterExecutor,
+ this);
+ Verify.verify(
+ contexts.putIfAbsent(deviceInfo, statisticsContext) == null,
+ "StatisticsCtx still not closed for Node {}", deviceInfo.getLOGValue()
+ );
lifecycleService.setStatContext(statisticsContext);
deviceInitPhaseHandler.onDeviceContextLevelUp(deviceInfo, lifecycleService);
}
LOG.trace("Gathering for node {} failure: ", deviceInfo.getLOGValue(), throwable);
}
calculateTimerDelay(timeCounter);
- if (throwable instanceof CancellationException) {
- /* This often happens when something wrong with akka or DS, so closing connection will help to restart device **/
- contexts.get(deviceInfo).getLifecycleService().closeConnection();
+ if (throwable instanceof IllegalStateException) {
+ stopScheduling(deviceInfo);
} else {
- if (throwable instanceof IllegalStateException) {
- stopScheduling(deviceInfo);
- } else {
- scheduleNextPolling(deviceState, deviceInfo, statisticsContext, timeCounter);
- }
+ scheduleNextPolling(deviceState, deviceInfo, statisticsContext, timeCounter);
}
}
});
for (Map.Entry<DeviceInfo, StatisticsContext> entry : contexts.entrySet()) {
final DeviceInfo deviceInfo = entry.getKey();
final StatisticsContext statisticsContext = entry.getValue();
- final DeviceContext deviceContext = statisticsContext.getLifecycleService().getDeviceContext();
+ final DeviceContext deviceContext = statisticsContext.gainDeviceContext();
switch (targetWorkMode) {
case COLLECTALL:
- scheduleNextPolling(deviceContext.getDeviceState(), deviceInfo, statisticsContext, new TimeCounter());
+ scheduleNextPolling(statisticsContext.gainDeviceState(), deviceInfo, statisticsContext, new TimeCounter());
for (final ItemLifeCycleSource lifeCycleSource : deviceContext.getItemLifeCycleSourceRegistry().getLifeCycleSources()) {
lifeCycleSource.setItemLifecycleListener(null);
}
LOG.info("Scheduling statistics poll for device: {}", deviceInfo.getNodeId());
statisticsContext.setSchedulingEnabled(true);
- final DeviceState deviceState = contexts.get(deviceInfo).getLifecycleService().getDeviceContext().getDeviceState();
- scheduleNextPolling(deviceState, deviceInfo, statisticsContext, new TimeCounter());
+ scheduleNextPolling(
+ statisticsContext.gainDeviceState(),
+ deviceInfo,
+ statisticsContext,
+ new TimeCounter()
+ );
}
@Override
LOG.warn("Statistics context not found for device: {}", deviceInfo.getNodeId());
return;
}
-
statisticsContext.setSchedulingEnabled(false);
}
xid = new Xid(atomicLong.incrementAndGet());
xidMulti = new Xid(atomicLong.incrementAndGet());
- ((DeviceContextImpl) deviceContext).lazyTransactionManagerInitialiaztion();
+ ((DeviceContextImpl) deviceContext).lazyTransactionManagerInitialization();
Mockito.doNothing().when(deviceContextSpy).writeToTransaction(Mockito.<LogicalDatastoreType>any(), Mockito.<InstanceIdentifier>any(), any());
private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerImplTest.class);
- private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("444");
- private static final Short DUMMY_VERSION = OFConstants.OFP_VERSION_1_3;
public static final NodeId NODE_ID = new NodeId("ofp-unit-dummy-node-id");
@Mock
when(itemLifeCycleRegistry.getLifeCycleSources()).thenReturn(
Collections.<ItemLifeCycleSource>emptyList());
- when(statisticContext.getLifecycleService()).thenReturn(lifecycleService);
+ when(statisticContext.gainDeviceContext()).thenReturn(mockedDeviceContext);
+ when(statisticContext.gainDeviceState()).thenReturn(mockedDeviceState);
when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
- when(statisticContext.getLifecycleService()).thenReturn(lifecycleService);
+ when(statisticContext.gainDeviceContext()).thenReturn(mockedDeviceContext);
+ when(statisticContext.gainDeviceState()).thenReturn(mockedDeviceState);
when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
- when(statisticContext.getLifecycleService()).thenReturn(lifecycleService);
+ when(statisticContext.gainDeviceContext()).thenReturn(mockedDeviceContext);
+ when(statisticContext.gainDeviceState()).thenReturn(mockedDeviceState);
when(lifecycleService.getDeviceContext()).thenReturn(mockedDeviceContext);
final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld =
if (System.getProperty(INSPECT_OSGI) != null) {
option
.add(CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address="+DEBUG_PORT))
- .add(CoreOptions.mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject()));
+ .add(CoreOptions.mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject());
}
return option;
import com.google.common.util.concurrent.Futures;
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Deque;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
import javax.inject.Inject;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
}
}
- final class TriggerTestListener implements DataChangeListener {
+ final class TriggerTestListener implements DataTreeChangeListener<FlowCapableNode> {
public TriggerTestListener() {
// NOOP
}
@Override
- public void onDataChanged(
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> arg0) {
- Set<InstanceIdentifier<?>> keySet = arg0.getCreatedData().keySet();
- if (keySet.size() == 1) {
- for (InstanceIdentifier<?> key : keySet) {
- InstanceIdentifier<FlowCapableNode> neededKey =
- key.firstIdentifierOf(FlowCapableNode.class);
- if (neededKey != null) {
- LOG.info("Node was added (brm) {}", neededKey);
- writeFlow(createTestFlow(), neededKey);
+ public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<FlowCapableNode>> modifications) {
+
+ for (DataTreeModification modification : modifications) {
+ if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
+ InstanceIdentifier<FlowCapableNode> ii = modification.getRootPath().getRootIdentifier();
+ if (ii != null) {
+ LOG.info("Node was added (brm) {}", ii);
+ writeFlow(createTestFlow(), ii);
break;
}
}
LOG.debug("testFlowMod integration test");
TriggerTestListener brmListener = new TriggerTestListener();
- dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
- getWildcardPath(), brmListener, DataChangeScope.BASE);
+ final DataTreeIdentifier<FlowCapableNode> dataTreeIdentifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, getWildcardPath());
+ dataBroker.registerDataTreeChangeListener(dataTreeIdentifier, brmListener);
switchSim = createSimpleClient();
switchSim.setSecuredClient(false);
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
import java.util.ArrayDeque;
import java.util.Deque;
-
import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;
import org.opendaylight.openflowjava.protocol.impl.clients.SendEvent;
import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent;
/**
* Attempt to simulate the MLX running 1.0 talking to ODL
*
- * @param auxId
- * @param pluginVersionBitmap
* @return handshake scenario without switch version bitmap
*/
public static Deque<ClientEvent> createHandshakeScenarioNoVBM_OF10_TwoHello() {
/**
* Attempt to simulate the MLX running 1.0 talking to ODL
*
- * @param auxId
- * @param pluginVersionBitmap
* @return handshake scenario without switch version bitmap
*/
public static Deque<ClientEvent> createHandshakeScenarioNOVBM_OF10_OneHello() {
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-
import org.junit.Assert;
import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
public abstract class SimulatorAssistant {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SimulatorAssistant.class);
+
+ private static final Logger LOG = LoggerFactory.getLogger(SimulatorAssistant.class);
/**
- * @param switchSim
+ * @param switchSim
* @throws InterruptedException
*/
public static void waitForSwitchSimulatorOn(SimpleClient switchSim) {