Search in sources :

Example 1 with Counters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project netvirt by opendaylight.

the class StatisticsImpl method initializeCountrsConfigDataSrore.

private void initializeCountrsConfigDataSrore() {
    ReadWriteTransaction transaction = db.newReadWriteTransaction();
    CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
    CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
    try {
        Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
        if (!iecrcOpt.isPresent()) {
            creatIngressEelementCountersContainerInConfig(transaction, CountersServiceUtils.IECRC_IDENTIFIER);
        }
        Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
        if (!eecrcOpt.isPresent()) {
            creatEgressEelementCountersContainerInConfig(transaction, CountersServiceUtils.EECRC_IDENTIFIER);
        }
        transaction.submit();
    } catch (InterruptedException | ExecutionException e) {
        StatisticsPluginImplCounters.failed_creating_counters_config.inc();
        LOG.warn("failed creating counters config data structure in DB");
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) Optional(com.google.common.base.Optional) IngressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.IngressElementCountersRequestConfig) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with Counters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project netvirt by opendaylight.

the class NaptManager method removeExternalIpCounter.

protected void removeExternalIpCounter(long routerId, String externalIp) {
    // Remove from external-counters model
    InstanceIdentifier<ExternalIpCounter> id = InstanceIdentifier.builder(ExternalIpsCounter.class).child(ExternalCounters.class, new ExternalCountersKey(routerId)).child(ExternalIpCounter.class, new ExternalIpCounterKey(externalIp)).build();
    LOG.debug("removeExternalIpCounter : Removing ExternalIpsCounter from datastore");
    MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
}
Also used : ExternalCountersKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.ips.counter.ExternalCountersKey) ExternalIpCounter(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.ips.counter.external.counters.ExternalIpCounter) ExternalIpCounterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.ips.counter.external.counters.ExternalIpCounterKey) ExternalIpsCounter(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalIpsCounter)

Example 3 with Counters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyFlatBatchImplTest method testExecuteSyncStrategy.

@Test
public void testExecuteSyncStrategy() throws Exception {
    final SynchronizationDiffInput diffInput = new SynchronizationDiffInput(NODE_IDENT, groupsToAddOrUpdate, metersToAddOrUpdate, flowsToAddOrUpdate, flowsToRemove, metersToRemove, groupsToRemove);
    Mockito.when(flatBatchService.processFlatBatch(Matchers.<ProcessFlatBatchInput>any())).thenReturn(RpcResultBuilder.success(new ProcessFlatBatchOutputBuilder().build()).buildFuture());
    final SyncCrudCounters counters = new SyncCrudCounters();
    final ListenableFuture<RpcResult<Void>> rpcResult = syncPlanPushStrategy.executeSyncStrategy(RpcResultBuilder.<Void>success().buildFuture(), diffInput, counters);
    Mockito.verify(flatBatchService).processFlatBatch(processFlatBatchInputCpt.capture());
    final ProcessFlatBatchInput processFlatBatchInput = processFlatBatchInputCpt.getValue();
    Assert.assertFalse(processFlatBatchInput.isExitOnFirstError());
    Assert.assertEquals(13, processFlatBatchInput.getBatch().size());
    Assert.assertTrue(rpcResult.isDone());
    Assert.assertTrue(rpcResult.get().isSuccessful());
    Assert.assertEquals(6, counters.getFlowCrudCounts().getAdded());
    Assert.assertEquals(3, counters.getFlowCrudCounts().getUpdated());
    Assert.assertEquals(6, counters.getFlowCrudCounts().getRemoved());
    Assert.assertEquals(6, counters.getGroupCrudCounts().getAdded());
    Assert.assertEquals(3, counters.getGroupCrudCounts().getUpdated());
    Assert.assertEquals(6, counters.getGroupCrudCounts().getRemoved());
    Assert.assertEquals(3, counters.getMeterCrudCounts().getAdded());
    Assert.assertEquals(3, counters.getMeterCrudCounts().getUpdated());
    Assert.assertEquals(3, counters.getMeterCrudCounts().getRemoved());
}
Also used : ProcessFlatBatchOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder) SyncCrudCounters(org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ProcessFlatBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInput) Test(org.junit.Test)

Example 4 with Counters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImplTest method testRemoveRedundantMeters.

@Test
public void testRemoveRedundantMeters() throws Exception {
    Mockito.when(meterCommitter.remove(Matchers.<InstanceIdentifier<Meter>>any(), meterCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new RemoveMeterOutputBuilder().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.removeRedundantMeters(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 InOrder inOrderMeter = Mockito.inOrder(flowCapableTxService, meterCommitter);
    inOrderMeter.verify(meterCommitter, Mockito.times(2)).remove(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.eq(NODE_IDENT));
    // TODO: uncomment when enabled in impl
    // inOrderMeter.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
    inOrderMeter.verifyNoMoreInteractions();
}
Also used : RemoveMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutputBuilder) 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) Test(org.junit.Test)

Example 5 with Counters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImplTest method testAddMissingFlows_withUpdate.

@Test
public void testAddMissingFlows_withUpdate() throws Exception {
    Mockito.when(flowCommitter.add(Matchers.<InstanceIdentifier<Flow>>any(), flowCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
    Mockito.when(flowCommitter.update(Matchers.<InstanceIdentifier<Flow>>any(), flowUpdateCaptor.capture(), flowUpdateCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateFlowOutputBuilder().build()).buildFuture());
    final ItemSyncBox<Flow> flowBox = new ItemSyncBox<>();
    flowBox.getItemsToPush().add(DSInputFactory.createFlow("f3", 3));
    flowBox.getItemsToPush().add(DSInputFactory.createFlow("f4", 4));
    flowBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(DSInputFactory.createFlow("f1", 1), DSInputFactory.createFlowWithInstruction("f1", 1)));
    final Map<TableKey, ItemSyncBox<Flow>> flowBoxMap = new LinkedHashMap<>();
    flowBoxMap.put(new TableKey((short) 0), flowBox);
    // TODO: replace null
    final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.addMissingFlows(NODE_ID, NODE_IDENT, flowBoxMap, counters);
    Assert.assertTrue(result.isDone());
    Assert.assertTrue(result.get().isSuccessful());
    final List<Flow> flowCaptorAllValues = flowCaptor.getAllValues();
    Assert.assertEquals(2, flowCaptorAllValues.size());
    Assert.assertEquals("f3", flowCaptorAllValues.get(0).getId().getValue());
    Assert.assertEquals("f4", flowCaptorAllValues.get(1).getId().getValue());
    final List<Flow> flowUpdateCaptorAllValues = flowUpdateCaptor.getAllValues();
    Assert.assertEquals(2, flowUpdateCaptorAllValues.size());
    Assert.assertEquals("f1", flowUpdateCaptorAllValues.get(0).getId().getValue());
    Assert.assertEquals("f1", flowUpdateCaptorAllValues.get(1).getId().getValue());
    final InOrder inOrderFlow = Mockito.inOrder(flowCapableTxService, flowCommitter);
    // add f3, f4
    inOrderFlow.verify(flowCommitter, Mockito.times(2)).add(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.eq(NODE_IDENT));
    // update f1
    inOrderFlow.verify(flowCommitter).update(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<Flow>any(), Matchers.eq(NODE_IDENT));
    // TODO: uncomment when enabled in impl
    // inOrderFlow.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
    inOrderFlow.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) AddFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) LinkedHashMap(java.util.LinkedHashMap) UpdateFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder) Test(org.junit.Test)

Aggregations

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)23 ArrayList (java.util.ArrayList)17 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)17 ExecutionException (java.util.concurrent.ExecutionException)13 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 Test (org.junit.Test)11 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)11 Map (java.util.Map)10 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)10 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)10 InOrder (org.mockito.InOrder)9 BigInteger (java.math.BigInteger)8 List (java.util.List)8 CrudCounts (org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts)8 SyncCrudCounters (org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters)8 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)8 Futures (com.google.common.util.concurrent.Futures)7 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)7 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)6