use of org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method removeRedundantMeters.
ListenableFuture<RpcResult<Void>> removeRedundantMeters(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final ItemSyncBox<Meter> meterRemovalPlan, final SyncCrudCounters counters) {
if (meterRemovalPlan.isEmpty()) {
LOG.trace("no meters on device for node: {} -> SKIPPING", nodeId.getValue());
return RpcResultBuilder.<Void>success().buildFuture();
}
final CrudCounts meterCrudCounts = counters.getMeterCrudCounts();
final List<ListenableFuture<RpcResult<RemoveMeterOutput>>> allResults = new ArrayList<>();
for (Meter meter : meterRemovalPlan.getItemsToPush()) {
LOG.trace("removing meter {} - absent in config {}", meter.getMeterId(), nodeId);
final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent = nodeIdent.child(Meter.class, meter.getKey());
allResults.add(JdkFutureAdapters.listenInPoolThread(meterForwarder.remove(meterIdent, meter, nodeIdent)));
meterCrudCounts.incRemoved();
}
return Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<RemoveMeterOutput>createRpcResultCondenser("meter remove"), MoreExecutors.directExecutor());
}
use of org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts 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;
}
Aggregations