Search in sources :

Example 6 with SyncCrudCounters

use of org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyFlatBatchImpl method executeSyncStrategy.

@Override
public ListenableFuture<RpcResult<Void>> executeSyncStrategy(ListenableFuture<RpcResult<Void>> resultVehicle, final SynchronizationDiffInput diffInput, final SyncCrudCounters counters) {
    // prepare default (full) counts
    counters.getGroupCrudCounts().setAdded(ReconcileUtil.countTotalPushed(diffInput.getGroupsToAddOrUpdate()));
    counters.getGroupCrudCounts().setUpdated(ReconcileUtil.countTotalUpdated(diffInput.getGroupsToAddOrUpdate()));
    counters.getGroupCrudCounts().setRemoved(ReconcileUtil.countTotalPushed(diffInput.getGroupsToRemove()));
    counters.getFlowCrudCounts().setAdded(ReconcileUtil.countTotalPushed(diffInput.getFlowsToAddOrUpdate().values()));
    counters.getFlowCrudCounts().setUpdated(ReconcileUtil.countTotalUpdated(diffInput.getFlowsToAddOrUpdate().values()));
    counters.getFlowCrudCounts().setRemoved(ReconcileUtil.countTotalPushed(diffInput.getFlowsToRemove().values()));
    counters.getMeterCrudCounts().setAdded(diffInput.getMetersToAddOrUpdate().getItemsToPush().size());
    counters.getMeterCrudCounts().setUpdated(diffInput.getMetersToAddOrUpdate().getItemsToUpdate().size());
    counters.getMeterCrudCounts().setRemoved(diffInput.getMetersToRemove().getItemsToPush().size());
    /* Tables - have to be pushed before groups */
    // TODO enable table-update when ready
    // resultVehicle = updateTableFeatures(nodeIdent, configTree);
    resultVehicle = Futures.transformAsync(resultVehicle, input -> {
        final List<Batch> batchBag = new ArrayList<>();
        int batchOrder = 0;
        batchOrder = assembleAddOrUpdateGroups(batchBag, batchOrder, diffInput.getGroupsToAddOrUpdate());
        batchOrder = assembleAddOrUpdateMeters(batchBag, batchOrder, diffInput.getMetersToAddOrUpdate());
        batchOrder = assembleAddOrUpdateFlows(batchBag, batchOrder, diffInput.getFlowsToAddOrUpdate());
        batchOrder = assembleRemoveFlows(batchBag, batchOrder, diffInput.getFlowsToRemove());
        batchOrder = assembleRemoveMeters(batchBag, batchOrder, diffInput.getMetersToRemove());
        batchOrder = assembleRemoveGroups(batchBag, batchOrder, diffInput.getGroupsToRemove());
        LOG.trace("Index of last batch step: {}", batchOrder);
        final ProcessFlatBatchInput flatBatchInput = new ProcessFlatBatchInputBuilder().setNode(new NodeRef(PathUtil.digNodePath(diffInput.getNodeIdent()))).setExitOnFirstError(false).setBatch(batchBag).build();
        final Future<RpcResult<ProcessFlatBatchOutput>> rpcResultFuture = flatBatchService.processFlatBatch(flatBatchInput);
        if (LOG.isDebugEnabled()) {
            Futures.addCallback(JdkFutureAdapters.listenInPoolThread(rpcResultFuture), createCounterCallback(batchBag, batchOrder, counters), MoreExecutors.directExecutor());
        }
        return Futures.transform(JdkFutureAdapters.listenInPoolThread(rpcResultFuture), ReconcileUtil.<ProcessFlatBatchOutput>createRpcResultToVoidFunction("flat-batch"), MoreExecutors.directExecutor());
    }, MoreExecutors.directExecutor());
    return resultVehicle;
}
Also used : FlatBatchAddFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddFlowCaseBuilder) FlatBatchRemoveFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlow) OriginalBatchedFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.input.update.grouping.OriginalBatchedFlowBuilder) ProcessFlatBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInput) LoggerFactory(org.slf4j.LoggerFactory) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) SalFlatBatchService(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService) OriginalBatchedMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.OriginalBatchedMeterBuilder) PeekingIterator(com.google.common.collect.PeekingIterator) FlatBatchUpdateMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateMeterCase) FlatBatchUpdateGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroup) FlatBatchRemoveFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveFlowCaseBuilder) FlatBatchUpdateFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateFlowCase) Future(java.util.concurrent.Future) Map(java.util.Map) FlatBatchAddFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddFlowCase) OriginalBatchedGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.input.update.grouping.OriginalBatchedGroupBuilder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) FlatBatchAddGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroupBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) FlatBatchAddMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddMeterCase) FlatBatchRemoveFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlowBuilder) FlatBatchAddFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow) Range(com.google.common.collect.Range) FlatBatchRemoveGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroupBuilder) FlatBatchUpdateGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCase) FlatBatchUpdateMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeter) FlatBatchUpdateMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeterBuilder) BatchFailure(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure) ProcessFlatBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput) List(java.util.List) UpdatedBatchedGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.input.update.grouping.UpdatedBatchedGroupBuilder) SyncCrudCounters(org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters) FlatBatchUpdateFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlowBuilder) FlatBatchRemoveGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveGroupCaseBuilder) FlatBatchRemoveMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveMeterCaseBuilder) FlatBatchUpdateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) FlatBatchRemoveMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeter) FlatBatchAddMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeter) JdkFutureAdapters(com.google.common.util.concurrent.JdkFutureAdapters) Iterators(com.google.common.collect.Iterators) ProcessFlatBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInputBuilder) ArrayList(java.util.ArrayList) FlatBatchAddMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddMeterCaseBuilder) LinkedHashMap(java.util.LinkedHashMap) FlatBatchRemoveFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveFlowCase) UpdatedBatchedMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.UpdatedBatchedMeterBuilder) SyncPlanPushStrategy(org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy) FlatBatchRemoveMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeterBuilder) PathUtil(org.opendaylight.openflowplugin.applications.frsync.util.PathUtil) FlatBatchUpdateGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroupBuilder) Nonnull(javax.annotation.Nonnull) FlatBatchAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCase) FlatBatchRemoveMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveMeterCase) BatchChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.BatchChoice) FlatBatchAddGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCaseBuilder) UpdatedBatchedFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.input.update.grouping.UpdatedBatchedFlowBuilder) FlatBatchAddFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder) Logger(org.slf4j.Logger) FlatBatchUpdateMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateMeterCaseBuilder) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) FlatBatchRemoveGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroup) FlatBatchAddGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroup) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) FutureCallback(com.google.common.util.concurrent.FutureCallback) FlatBatchRemoveGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveGroupCase) Futures(com.google.common.util.concurrent.Futures) Batch(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch) FlatBatchUpdateFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateFlowCaseBuilder) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ReconcileUtil(org.opendaylight.openflowplugin.applications.frsync.util.ReconcileUtil) BatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchBuilder) FlatBatchUpdateGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCaseBuilder) FlatBatchAddMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeterBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) ProcessFlatBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInputBuilder) ProcessFlatBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInput) Future(java.util.concurrent.Future) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) List(java.util.List) ArrayList(java.util.ArrayList) ProcessFlatBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput)

Example 7 with SyncCrudCounters

use of org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImpl method removeRedundantGroups.

ListenableFuture<RpcResult<Void>> removeRedundantGroups(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final List<ItemSyncBox<Group>> groupsRemovalPlan, final SyncCrudCounters counters) {
    if (groupsRemovalPlan.isEmpty()) {
        LOG.trace("no groups on device for node: {} -> SKIPPING", nodeId.getValue());
        return RpcResultBuilder.<Void>success().buildFuture();
    }
    final CrudCounts groupCrudCounts = counters.getGroupCrudCounts();
    ListenableFuture<RpcResult<Void>> chainedResult = RpcResultBuilder.<Void>success().buildFuture();
    try {
        groupCrudCounts.setRemoved(ReconcileUtil.countTotalPushed(groupsRemovalPlan));
        if (LOG.isDebugEnabled()) {
            LOG.debug("removing groups: planSteps={}, toRemoveTotal={}", groupsRemovalPlan.size(), groupCrudCounts.getRemoved());
        }
        Collections.reverse(groupsRemovalPlan);
        for (final ItemSyncBox<Group> groupsPortion : groupsRemovalPlan) {
            chainedResult = Futures.transformAsync(chainedResult, input -> {
                final ListenableFuture<RpcResult<Void>> result;
                if (input.isSuccessful()) {
                    result = flushRemoveGroupPortionAndBarrier(nodeIdent, groupsPortion);
                } else {
                    // pass through original unsuccessful rpcResult
                    result = Futures.immediateFuture(input);
                }
                return result;
            }, MoreExecutors.directExecutor());
        }
    } catch (IllegalStateException e) {
        chainedResult = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "failed to add missing groups", e).buildFuture();
    }
    return chainedResult;
}
Also used : CrudCounts(org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts) AddFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput) Iterables(com.google.common.collect.Iterables) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) CrudCounts(org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts) LoggerFactory(org.slf4j.LoggerFactory) FlowCapableTransactionService(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) JdkFutureAdapters(com.google.common.util.concurrent.JdkFutureAdapters) RemoveGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput) UpdateGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput) ArrayList(java.util.ArrayList) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) UpdateMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Map(java.util.Map) RemoveMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput) SyncPlanPushStrategy(org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy) PathUtil(org.opendaylight.openflowplugin.applications.frsync.util.PathUtil) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) UpdateTableOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput) Logger(org.slf4j.Logger) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) FxChainUtil(org.opendaylight.openflowplugin.applications.frsync.util.FxChainUtil) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) RemoveFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput) AddGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) SyncCrudCounters(org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) AddMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput) ReconcileUtil(org.opendaylight.openflowplugin.applications.frsync.util.ReconcileUtil) Collections(java.util.Collections) UpdateFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) RpcError(org.opendaylight.yangtools.yang.common.RpcError) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 8 with SyncCrudCounters

use of org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyFlatBatchImplTest method testDecrementCounters.

@Test
public void testDecrementCounters() throws Exception {
    final SyncCrudCounters counters = new SyncCrudCounters();
    counters.getFlowCrudCounts().setAdded(100);
    counters.getFlowCrudCounts().setUpdated(100);
    counters.getFlowCrudCounts().setRemoved(100);
    counters.getGroupCrudCounts().setAdded(100);
    counters.getGroupCrudCounts().setUpdated(100);
    counters.getGroupCrudCounts().setRemoved(100);
    counters.getMeterCrudCounts().setAdded(100);
    counters.getMeterCrudCounts().setUpdated(100);
    counters.getMeterCrudCounts().setRemoved(100);
    SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchAddFlowCaseBuilder().build(), counters);
    SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchUpdateFlowCaseBuilder().build(), counters);
    SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchRemoveFlowCaseBuilder().build(), counters);
    SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchAddGroupCaseBuilder().build(), counters);
    SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchUpdateGroupCaseBuilder().build(), counters);
    SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchRemoveGroupCaseBuilder().build(), counters);
    SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchAddMeterCaseBuilder().build(), counters);
    SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchUpdateMeterCaseBuilder().build(), counters);
    SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchRemoveMeterCaseBuilder().build(), counters);
    Assert.assertEquals(99, counters.getFlowCrudCounts().getAdded());
    Assert.assertEquals(99, counters.getFlowCrudCounts().getUpdated());
    Assert.assertEquals(99, counters.getFlowCrudCounts().getRemoved());
    Assert.assertEquals(99, counters.getGroupCrudCounts().getAdded());
    Assert.assertEquals(99, counters.getGroupCrudCounts().getUpdated());
    Assert.assertEquals(99, counters.getGroupCrudCounts().getRemoved());
    Assert.assertEquals(99, counters.getMeterCrudCounts().getAdded());
    Assert.assertEquals(99, counters.getMeterCrudCounts().getUpdated());
    Assert.assertEquals(99, counters.getMeterCrudCounts().getRemoved());
}
Also used : FlatBatchUpdateGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCaseBuilder) FlatBatchRemoveMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveMeterCaseBuilder) FlatBatchAddGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCaseBuilder) FlatBatchRemoveGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveGroupCaseBuilder) SyncCrudCounters(org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters) FlatBatchUpdateFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateFlowCaseBuilder) FlatBatchAddFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddFlowCaseBuilder) FlatBatchRemoveFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveFlowCaseBuilder) FlatBatchAddMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddMeterCaseBuilder) FlatBatchUpdateMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateMeterCaseBuilder) Test(org.junit.Test)

Example 9 with SyncCrudCounters

use of org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters 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)

Aggregations

SyncCrudCounters (org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters)9 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)7 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)7 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)6 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)6 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)6 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)5 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)5 Futures (com.google.common.util.concurrent.Futures)4 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Map (java.util.Map)4 SyncPlanPushStrategy (org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy)4 PathUtil (org.opendaylight.openflowplugin.applications.frsync.util.PathUtil)4 ReconcileUtil (org.opendaylight.openflowplugin.applications.frsync.util.ReconcileUtil)4 Iterables (com.google.common.collect.Iterables)3 Collections (java.util.Collections)3