use of org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry in project openflowplugin by opendaylight.
the class SyncReactorFutureZipDecoratorTest method testSyncupWithOptimizedConfigDeltaCompression.
@Test
public void testSyncupWithOptimizedConfigDeltaCompression() throws Exception {
final FlowCapableNode dataBefore = Mockito.mock(FlowCapableNode.class);
final FlowCapableNode dataAfter = Mockito.mock(FlowCapableNode.class);
final FlowCapableNode dataAfter2 = Mockito.mock(FlowCapableNode.class);
final CountDownLatch latchForFirst = new CountDownLatch(1);
final CountDownLatch latchForNext = new CountDownLatch(1);
final SyncupEntry first = new SyncupEntry(dataBefore, configDS, null, operationalDS);
final SyncupEntry second = new SyncupEntry(dataAfter, configDS, dataBefore, configDS);
final SyncupEntry third = new SyncupEntry(null, configDS, dataAfter, configDS);
final SyncupEntry fourth = new SyncupEntry(dataAfter2, configDS, null, configDS);
final SyncupEntry zipped = new SyncupEntry(dataAfter2, configDS, dataBefore, configDS);
final List<ListenableFuture<Boolean>> allResults = new ArrayList<>();
Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first))).thenAnswer(invocationOnMock -> {
LOG.info("unlocking next configs");
latchForNext.countDown();
latchForFirst.await();
LOG.info("unlocking first delegate");
return Futures.immediateFuture(Boolean.TRUE);
});
allResults.add(reactor.syncup(fcNodePath, first));
latchForNext.await();
mockSyncupWithEntry(second);
allResults.add(reactor.syncup(fcNodePath, second));
mockSyncupWithEntry(third);
allResults.add(reactor.syncup(fcNodePath, third));
mockSyncupWithEntry(fourth);
allResults.add(reactor.syncup(fcNodePath, fourth));
latchForFirst.countDown();
Futures.allAsList(allResults).get(1, TimeUnit.SECONDS);
LOG.info("all configs done");
syncThreadPool.shutdown();
boolean terminated = syncThreadPool.awaitTermination(1, TimeUnit.SECONDS);
if (!terminated) {
LOG.info("thread pool not terminated.");
syncThreadPool.shutdownNow();
}
final InOrder inOrder = Mockito.inOrder(delegate);
inOrder.verify(delegate).syncup(fcNodePath, first);
inOrder.verify(delegate).syncup(fcNodePath, zipped);
inOrder.verifyNoMoreInteractions();
}
use of org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry in project openflowplugin by opendaylight.
the class SyncReactorFutureZipDecoratorTest method testSyncupConfigEmptyQueue.
@Test
public void testSyncupConfigEmptyQueue() throws Exception {
final FlowCapableNode dataBefore = Mockito.mock(FlowCapableNode.class);
final FlowCapableNode dataAfter = Mockito.mock(FlowCapableNode.class);
final CountDownLatch latchForNext = new CountDownLatch(1);
final SyncupEntry first = new SyncupEntry(dataBefore, configDS, null, configDS);
final SyncupEntry second = new SyncupEntry(dataAfter, configDS, dataBefore, configDS);
Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first))).thenAnswer(invocationOnMock -> {
LOG.info("unlocking next config");
latchForNext.countDown();
return Futures.immediateFuture(Boolean.TRUE);
});
reactor.syncup(fcNodePath, first);
latchForNext.await();
mockSyncupWithEntry(second);
reactor.syncup(fcNodePath, second);
boolean terminated = syncThreadPool.awaitTermination(1, TimeUnit.SECONDS);
if (!terminated) {
LOG.info("thread pool not terminated.");
syncThreadPool.shutdownNow();
}
final InOrder inOrder = Mockito.inOrder(delegate);
inOrder.verify(delegate).syncup(fcNodePath, first);
inOrder.verify(delegate).syncup(fcNodePath, second);
inOrder.verifyNoMoreInteractions();
}
use of org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry in project openflowplugin by opendaylight.
the class SimplifiedConfigListener method onNodeAdded.
/**
* If node was added to config DS and it is already present in operational DS (connected) diff between current
* new configuration and actual configuration (seen in operational) should be calculated and sent to device.
*/
private ListenableFuture<Boolean> onNodeAdded(final InstanceIdentifier<FlowCapableNode> nodePath, final FlowCapableNode dataAfter, final FlowCapableNode operationalNode) {
LOG.debug("Reconciliation {}: {}", dsType(), PathUtil.digNodeId(nodePath).getValue());
final SyncupEntry syncupEntry = new SyncupEntry(dataAfter, dsType(), operationalNode, LogicalDatastoreType.OPERATIONAL);
return reactor.syncup(nodePath, syncupEntry);
}
use of org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry in project openflowplugin by opendaylight.
the class SimplifiedOperationalListener method reconciliation.
/**
* If node is present in config DS diff between wanted configuration (in config DS) and actual device
* configuration (coming from operational) should be calculated and sent to device.
* @param modification from DS
* @return optional syncup future
*/
private Optional<ListenableFuture<Boolean>> reconciliation(final DataTreeModification<Node> modification) {
final NodeId nodeId = ModificationUtil.nodeId(modification);
final Optional<FlowCapableNode> nodeConfiguration = configDao.loadByNodeId(nodeId);
if (nodeConfiguration.isPresent()) {
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);
final FlowCapableNode fcOperationalNode = ModificationUtil.flowCapableNodeAfter(modification);
final SyncupEntry syncupEntry = new SyncupEntry(nodeConfiguration.get(), LogicalDatastoreType.CONFIGURATION, fcOperationalNode, dsType());
return Optional.of(reactor.syncup(nodePath, syncupEntry));
} else {
LOG.debug("Config not present for reconciliation: {}", nodeId.getValue());
reconciliationRegistry.unregisterIfRegistered(nodeId);
return skipModification(modification);
}
}
use of org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry in project openflowplugin by opendaylight.
the class SyncReactorFutureZipDecorator method updateOptimizedConfigDelta.
private void updateOptimizedConfigDelta(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath, final SyncupEntry actual, final SyncupEntry previous) {
final SyncupEntry updatedEntry = new SyncupEntry(actual.getAfter(), actual.getDsTypeAfter(), previous.getBefore(), previous.getDsTypeBefore());
compressionQueue.put(flowcapableNodePath, updatedEntry);
}
Aggregations