Search in sources :

Example 71 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class SimplifiedConfigListenerTest method setUp.

@Before
public void setUp() throws Exception {
    final DataBroker db = Mockito.mock(DataBroker.class);
    final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
    final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
    final FlowCapableNodeDao operationalDao = new FlowCapableNodeCachedDao(operationalSnapshot, new FlowCapableNodeOdlDao(db, LogicalDatastoreType.OPERATIONAL));
    nodeListenerConfig = new SimplifiedConfigListener(reactor, configSnapshot, operationalDao);
    fcNodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID)).augmentation(FlowCapableNode.class);
    final DataTreeIdentifier<FlowCapableNode> dataTreeIdentifier = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, fcNodePath);
    Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
    Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier);
    Mockito.when(dataTreeModification.getRootNode()).thenReturn(configModification);
}
Also used : FlowCapableNodeSnapshotDao(org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeSnapshotDao) FlowCapableNodeOdlDao(org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeOdlDao) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) FlowCapableNodeDao(org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeDao) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) FlowCapableNodeCachedDao(org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeCachedDao) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Before(org.junit.Before)

Example 72 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class SimplifiedConfigListenerTest method loadOperationalDSAndPrepareSyncupEntry.

private SyncupEntry loadOperationalDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter, final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
    Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath)).thenReturn(Futures.immediateCheckedFuture(Optional.of(dataBefore)));
    final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
    Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(syncupEntry))).thenReturn(Futures.immediateFuture(Boolean.TRUE));
    return syncupEntry;
}
Also used : FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry)

Example 73 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class SimplifiedOperationalListenerTest method loadConfigDSAndPrepareSyncupEntry.

private SyncupEntry loadConfigDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter, final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
    Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath)).thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode)));
    final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
    Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(syncupEntry))).thenReturn(Futures.immediateFuture(Boolean.TRUE));
    return syncupEntry;
}
Also used : FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry)

Example 74 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class SyncReactorImplTest method testSyncup.

@Test
public void testSyncup() throws Exception {
    final FlowCapableNode configFcn = new FlowCapableNodeBuilder().setGroup(Collections.singletonList(DSInputFactory.createGroup(1L))).setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(DSInputFactory.createFlow("f1", 1))).build())).setMeter(Collections.singletonList(DSInputFactory.createMeter(1L))).build();
    final FlowCapableNode operationalFcn = new FlowCapableNodeBuilder().setGroup(Collections.singletonList(DSInputFactory.createGroup(2L))).setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(DSInputFactory.createFlow("f2", 2))).build())).setMeter(Collections.singletonList(DSInputFactory.createMeter(2L))).build();
    final SyncupEntry syncupEntry = new SyncupEntry(configFcn, LogicalDatastoreType.CONFIGURATION, operationalFcn, LogicalDatastoreType.OPERATIONAL);
    Mockito.when(syncPlanPushStrategy.executeSyncStrategy(Matchers.<ListenableFuture<RpcResult<Void>>>any(), Matchers.<SynchronizationDiffInput>any(), Matchers.<SyncCrudCounters>any())).thenReturn(RpcResultBuilder.<Void>success().buildFuture());
    final ListenableFuture<Boolean> syncupResult = reactor.syncup(NODE_IDENT, syncupEntry);
    Assert.assertTrue(syncupResult.isDone());
    final Boolean voidRpcResult = syncupResult.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(voidRpcResult);
    Mockito.verify(syncPlanPushStrategy).executeSyncStrategy(Matchers.<ListenableFuture<RpcResult<Void>>>any(), syncDiffInputCaptor.capture(), Matchers.<SyncCrudCounters>any());
    final SynchronizationDiffInput diffInput = syncDiffInputCaptor.getValue();
    Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getFlowsToAddOrUpdate().values()));
    Assert.assertEquals(0, ReconcileUtil.countTotalUpdated(diffInput.getFlowsToAddOrUpdate().values()));
    Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getFlowsToRemove().values()));
    Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getGroupsToAddOrUpdate()));
    Assert.assertEquals(0, ReconcileUtil.countTotalUpdated(diffInput.getGroupsToAddOrUpdate()));
    Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getGroupsToRemove()));
    Assert.assertEquals(1, diffInput.getMetersToAddOrUpdate().getItemsToPush().size());
    Assert.assertEquals(0, diffInput.getMetersToAddOrUpdate().getItemsToUpdate().size());
    Assert.assertEquals(1, diffInput.getMetersToRemove().getItemsToPush().size());
}
Also used : FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry) SynchronizationDiffInput(org.opendaylight.openflowplugin.applications.frsync.impl.strategy.SynchronizationDiffInput) Test(org.junit.Test)

Example 75 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class NodeNotificationSupplierImpl method createNotification.

@Override
public NodeUpdated createNotification(final FlowCapableNode flowCapableNode, final InstanceIdentifier<FlowCapableNode> ii) {
    Preconditions.checkArgument(flowCapableNode != null);
    Preconditions.checkArgument(ii != null);
    final FlowCapableNodeUpdatedBuilder flowNodeNotifBuilder = new FlowCapableNodeUpdatedBuilder(flowCapableNode);
    final NodeUpdatedBuilder notifBuilder = new NodeUpdatedBuilder();
    notifBuilder.setId(ii.firstKeyOf(Node.class, NodeKey.class).getId());
    notifBuilder.setNodeRef(new NodeRef(getNodeII(ii)));
    notifBuilder.addAugmentation(FlowCapableNodeUpdated.class, flowNodeNotifBuilder.build());
    return notifBuilder.build();
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder) FlowCapableNodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder) FlowCapableNodeUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder)

Aggregations

FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)48 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)29 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)26 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)22 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)20 ArrayList (java.util.ArrayList)17 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)15 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)15 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)15 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)15 Test (org.junit.Test)14 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)14 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)10 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)9 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)9 CrudCounts (org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts)8 FlowCapableNodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder)8