Search in sources :

Example 51 with Meter

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

the class SyncPlanPushStrategyIncrementalImplTest method testExecuteSyncStrategy.

@Test
public void testExecuteSyncStrategy() throws Exception {
    final SynchronizationDiffInput diffInput = new SynchronizationDiffInput(NODE_IDENT, groupsToAddOrUpdate, metersToAddOrUpdate, flowsToAddOrUpdate, flowsToRemove, metersToRemove, groupsToRemove);
    final SyncCrudCounters syncCounters = new SyncCrudCounters();
    final ListenableFuture<RpcResult<Void>> rpcResult = syncPlanPushStrategy.executeSyncStrategy(RpcResultBuilder.<Void>success().buildFuture(), diffInput, syncCounters);
    Mockito.verify(groupCommitter, Mockito.times(6)).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.verify(groupCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.verify(groupCommitter, Mockito.times(6)).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.verify(flowCommitter, Mockito.times(6)).add(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.verify(flowCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.verify(flowCommitter, Mockito.times(6)).remove(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.verify(meterCommitter, Mockito.times(3)).add(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.verify(meterCommitter, Mockito.times(3)).update(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.verify(meterCommitter, Mockito.times(3)).remove(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Assert.assertTrue(rpcResult.isDone());
    Assert.assertTrue(rpcResult.get().isSuccessful());
    Assert.assertEquals(6, syncCounters.getFlowCrudCounts().getAdded());
    Assert.assertEquals(3, syncCounters.getFlowCrudCounts().getUpdated());
    Assert.assertEquals(6, syncCounters.getFlowCrudCounts().getRemoved());
    Assert.assertEquals(6, syncCounters.getGroupCrudCounts().getAdded());
    Assert.assertEquals(3, syncCounters.getGroupCrudCounts().getUpdated());
    Assert.assertEquals(6, syncCounters.getGroupCrudCounts().getRemoved());
    Assert.assertEquals(3, syncCounters.getMeterCrudCounts().getAdded());
    Assert.assertEquals(3, syncCounters.getMeterCrudCounts().getUpdated());
    Assert.assertEquals(3, syncCounters.getMeterCrudCounts().getRemoved());
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) SyncCrudCounters(org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) Test(org.junit.Test)

Example 52 with Meter

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

the class SyncPlanPushStrategyIncrementalImplTest method testAddMissingMeters_withUpdate.

@Test
public void testAddMissingMeters_withUpdate() throws Exception {
    Mockito.when(meterCommitter.add(Matchers.<InstanceIdentifier<Meter>>any(), meterCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new AddMeterOutputBuilder().build()).buildFuture());
    Mockito.when(meterCommitter.update(Matchers.<InstanceIdentifier<Meter>>any(), meterUpdateCaptor.capture(), meterUpdateCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateMeterOutputBuilder().build()).buildFuture());
    final ItemSyncBox<Meter> meterSyncBox = new ItemSyncBox<>();
    meterSyncBox.getItemsToPush().add(DSInputFactory.createMeter(2L));
    meterSyncBox.getItemsToPush().add(DSInputFactory.createMeter(4L));
    meterSyncBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(DSInputFactory.createMeter(1L), DSInputFactory.createMeterWithBody(1L)));
    final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.addMissingMeters(NODE_ID, NODE_IDENT, meterSyncBox, counters);
    Assert.assertTrue(result.isDone());
    Assert.assertTrue(result.get().isSuccessful());
    final List<Meter> meterCaptorAllValues = meterCaptor.getAllValues();
    Assert.assertEquals(2, meterCaptorAllValues.size());
    Assert.assertEquals(2L, meterCaptorAllValues.get(0).getMeterId().getValue().longValue());
    Assert.assertEquals(4L, meterCaptorAllValues.get(1).getMeterId().getValue().longValue());
    final List<Meter> meterUpdateCaptorAllValues = meterUpdateCaptor.getAllValues();
    Assert.assertEquals(2, meterUpdateCaptorAllValues.size());
    Assert.assertEquals(1L, meterUpdateCaptorAllValues.get(0).getMeterId().getValue().longValue());
    Assert.assertEquals(1L, meterUpdateCaptorAllValues.get(1).getMeterId().getValue().longValue());
    final InOrder inOrderMeters = Mockito.inOrder(flowCapableTxService, meterCommitter);
    inOrderMeters.verify(meterCommitter, Mockito.times(2)).add(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.eq(NODE_IDENT));
    inOrderMeters.verify(meterCommitter).update(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<Meter>any(), Matchers.eq(NODE_IDENT));
    // TODO: uncomment when enabled in impl
    // inOrderMeters.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
    inOrderMeters.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder) AddMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutputBuilder) Test(org.junit.Test)

Example 53 with Meter

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

the class MeterNotificationSupplierImpl method deleteNotification.

@Override
public MeterRemoved deleteNotification(final InstanceIdentifier<Meter> path) {
    Preconditions.checkArgument(path != null);
    final MeterRemovedBuilder builder = new MeterRemovedBuilder();
    builder.setMeterId(path.firstKeyOf(Meter.class, MeterKey.class).getMeterId());
    builder.setMeterRef(new MeterRef(path));
    builder.setNode(createNodeRef(path));
    return builder.build();
}
Also used : MeterRemovedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemovedBuilder) MeterRef(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef)

Example 54 with Meter

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

the class MeterNotificationSupplierImpl method createNotification.

@Override
public MeterAdded createNotification(final Meter dataTreeItemObject, final InstanceIdentifier<Meter> path) {
    Preconditions.checkArgument(dataTreeItemObject != null);
    Preconditions.checkArgument(path != null);
    final MeterAddedBuilder builder = new MeterAddedBuilder(dataTreeItemObject);
    builder.setMeterRef(new MeterRef(path));
    builder.setNode(createNodeRef(path));
    return builder.build();
}
Also used : MeterAddedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAddedBuilder) MeterRef(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef)

Example 55 with Meter

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

the class MeterNotificationSupplierImplTest method testCreateChangeEvent.

@Test
public void testCreateChangeEvent() {
    final TestData testData = new TestData(createTestMeterPath(), null, createTestMeter(), DataObjectModification.ModificationType.WRITE);
    Collection<DataTreeModification<Meter>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(MeterAdded.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) ArrayList(java.util.ArrayList) MeterAdded(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAdded) Test(org.junit.Test)

Aggregations

Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)24 Test (org.junit.Test)21 ArrayList (java.util.ArrayList)19 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)15 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)14 MeterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey)14 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)13 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder)11 MeterRef (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef)10 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)9 ByteBuf (io.netty.buffer.ByteBuf)6 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)6 StaleMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter)6 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)6 AddMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput)6 StaleMeterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey)5 MeterBandHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)4 StaleMeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterBuilder)4