use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method addMissingGroups.
ListenableFuture<RpcResult<Void>> addMissingGroups(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final List<ItemSyncBox<Group>> groupsAddPlan, final SyncCrudCounters counters) {
if (groupsAddPlan.isEmpty()) {
LOG.trace("no groups configured for node: {} -> SKIPPING", nodeId.getValue());
return RpcResultBuilder.<Void>success().buildFuture();
}
ListenableFuture<RpcResult<Void>> chainedResult;
try {
if (!groupsAddPlan.isEmpty()) {
final CrudCounts groupCrudCounts = counters.getGroupCrudCounts();
groupCrudCounts.setAdded(ReconcileUtil.countTotalPushed(groupsAddPlan));
groupCrudCounts.setUpdated(ReconcileUtil.countTotalUpdated(groupsAddPlan));
if (LOG.isDebugEnabled()) {
LOG.debug("adding groups: planSteps={}, toAddTotal={}, toUpdateTotal={}", groupsAddPlan.size(), groupCrudCounts.getAdded(), groupCrudCounts.getUpdated());
}
chainedResult = flushAddGroupPortionAndBarrier(nodeIdent, groupsAddPlan.get(0));
for (final ItemSyncBox<Group> groupsPortion : Iterables.skip(groupsAddPlan, 1)) {
chainedResult = Futures.transformAsync(chainedResult, input -> {
final ListenableFuture<RpcResult<Void>> result;
if (input.isSuccessful()) {
result = flushAddGroupPortionAndBarrier(nodeIdent, groupsPortion);
} else {
// pass through original unsuccessful rpcResult
result = Futures.immediateFuture(input);
}
return result;
}, MoreExecutors.directExecutor());
}
} else {
chainedResult = RpcResultBuilder.<Void>success().buildFuture();
}
} catch (IllegalStateException e) {
chainedResult = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "failed to add missing groups", e).buildFuture();
}
return chainedResult;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method removeRedundantFlows.
ListenableFuture<RpcResult<Void>> removeRedundantFlows(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final Map<TableKey, ItemSyncBox<Flow>> removalPlan, final SyncCrudCounters counters) {
if (removalPlan.isEmpty()) {
LOG.trace("no tables in operational for node: {} -> SKIPPING", nodeId.getValue());
return RpcResultBuilder.<Void>success().buildFuture();
}
final List<ListenableFuture<RpcResult<RemoveFlowOutput>>> allResults = new ArrayList<>();
final CrudCounts flowCrudCounts = counters.getFlowCrudCounts();
for (final Map.Entry<TableKey, ItemSyncBox<Flow>> flowsPerTable : removalPlan.entrySet()) {
final KeyedInstanceIdentifier<Table, TableKey> tableIdent = nodeIdent.child(Table.class, flowsPerTable.getKey());
// loop flows on device and check if the are configured
for (final Flow flow : flowsPerTable.getValue().getItemsToPush()) {
final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class, flow.getKey());
allResults.add(JdkFutureAdapters.listenInPoolThread(flowForwarder.remove(flowIdent, flow, nodeIdent)));
flowCrudCounts.incRemoved();
}
}
final ListenableFuture<RpcResult<Void>> singleVoidResult = Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<RemoveFlowOutput>createRpcResultCondenser("flow remove"), MoreExecutors.directExecutor());
return Futures.transformAsync(singleVoidResult, ReconcileUtil.chainBarrierFlush(PathUtil.digNodePath(nodeIdent), transactionService), MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project openflowplugin by opendaylight.
the class SyncReactorImpl method syncup.
@Override
public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> nodeIdent, final SyncupEntry syncupEntry) {
final NodeId nodeId = PathUtil.digNodeId(nodeIdent);
FlowCapableNode configTree = syncupEntry.getAfter();
FlowCapableNode operationalTree = syncupEntry.getBefore();
final SyncCrudCounters counters = new SyncCrudCounters();
/**
* instructions:
* - extract diff changes and prepare change steps in safe order
* - optimization: decide if updates needed
* - execute chosen implementation (e.g. conventional API, bulk API, flat bulk API)
* - recommended order follows:
* reconciliation strategy - phase 1: - add/update missing objects in following order:
* - table features - groups (reordered) - meters - flows
* reconciliation strategy - phase 2: - remove redundant objects in following order:
* - flows - meters - groups (reordered)
*/
final List<ItemSyncBox<Group>> groupsToAddOrUpdate = extractGroupsToAddOrUpdate(nodeId, configTree, operationalTree);
final ItemSyncBox<Meter> metersToAddOrUpdate = extractMetersToAddOrUpdate(nodeId, configTree, operationalTree);
final Map<TableKey, ItemSyncBox<Flow>> flowsToAddOrUpdate = extractFlowsToAddOrUpdate(nodeId, configTree, operationalTree);
final Map<TableKey, ItemSyncBox<Flow>> flowsToRemove = extractFlowsToRemove(nodeId, configTree, operationalTree);
final ItemSyncBox<Meter> metersToRemove = extractMetersToRemove(nodeId, configTree, operationalTree);
final List<ItemSyncBox<Group>> groupsToRemove = extractGroupsToRemove(nodeId, configTree, operationalTree);
final SynchronizationDiffInput input = new SynchronizationDiffInput(nodeIdent, groupsToAddOrUpdate, metersToAddOrUpdate, flowsToAddOrUpdate, flowsToRemove, metersToRemove, groupsToRemove);
final ListenableFuture<RpcResult<Void>> bootstrapResultFuture = RpcResultBuilder.<Void>success().buildFuture();
final ListenableFuture<RpcResult<Void>> resultVehicle = syncPlanPushStrategy.executeSyncStrategy(bootstrapResultFuture, input, counters);
return Futures.transform(resultVehicle, input1 -> {
if (input1 == null) {
return false;
}
if (LOG.isDebugEnabled()) {
final CrudCounts flowCrudCounts = counters.getFlowCrudCounts();
final CrudCounts meterCrudCounts = counters.getMeterCrudCounts();
final CrudCounts groupCrudCounts = counters.getGroupCrudCounts();
LOG.debug("Syncup outcome[{}] (added/updated/removed): flow={}/{}/{}, group={}/{}/{}, " + "meter={}/{}/{}, errors={}", nodeId.getValue(), flowCrudCounts.getAdded(), flowCrudCounts.getUpdated(), flowCrudCounts.getRemoved(), groupCrudCounts.getAdded(), groupCrudCounts.getUpdated(), groupCrudCounts.getRemoved(), meterCrudCounts.getAdded(), meterCrudCounts.getUpdated(), meterCrudCounts.getRemoved(), Arrays.toString(input1.getErrors().toArray()));
}
return input1.isSuccessful();
}, MoreExecutors.directExecutor());
}
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 getNodeConnectorCounters.
@Override
@SuppressWarnings("checkstyle:illegalCatch")
public ListenableFuture<RpcResult<GetNodeConnectorCountersOutput>> getNodeConnectorCounters(GetNodeConnectorCountersInput input) {
String portId = input.getPortId();
LOG.trace("getting port counters of port {}", portId);
Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(db, portId);
if (interfaceState == null) {
LOG.warn("trying to get counters for non exist port {}", portId);
return RpcResultBuilder.<GetNodeConnectorCountersOutput>failed().buildFuture();
}
BigInteger dpId = InterfaceUtils.getDpIdFromInterface(interfaceState);
if (interfaceState.getLowerLayerIf() == null || interfaceState.getLowerLayerIf().isEmpty()) {
LOG.warn("Lower layer if wasn't found for port {}", portId);
return RpcResultBuilder.<GetNodeConnectorCountersOutput>failed().buildFuture();
}
String portNumber = interfaceState.getLowerLayerIf().get(0);
portNumber = portNumber.split(":")[2];
List<CounterResult> counterResults = new ArrayList<>();
try {
if (!getNodeConnectorResult(counterResults, dpId, portNumber)) {
statisticsCounters.failedGettingNodeConnectorCounters();
return RpcResultBuilder.<GetNodeConnectorCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get port counters").buildFuture();
}
} catch (RuntimeException e) {
LOG.warn("failed to get counter result for port {}", portId, e);
}
GetNodeConnectorCountersOutputBuilder gpcob = new GetNodeConnectorCountersOutputBuilder();
gpcob.setCounterResult(counterResults);
return RpcResultBuilder.success(gpcob.build()).buildFuture();
}
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 getNodeCounters.
@Override
@SuppressWarnings("checkstyle:illegalCatch")
public ListenableFuture<RpcResult<GetNodeCountersOutput>> getNodeCounters(GetNodeCountersInput input) {
BigInteger dpId = input.getNodeId();
LOG.trace("getting node counters for node {}", dpId);
GetNodeCountersOutputBuilder gncob = new GetNodeCountersOutputBuilder();
List<CounterResult> counterResults = new ArrayList<>();
try {
if (!getNodeResult(counterResults, dpId)) {
statisticsCounters.failedGettingNodeCounters();
return RpcResultBuilder.<GetNodeCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get node counters for node: " + dpId).buildFuture();
}
} catch (RuntimeException e) {
LOG.warn("failed to get counter result for node {}", dpId, e);
return RpcResultBuilder.<GetNodeCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get node counters for node: " + dpId).buildFuture();
}
gncob.setCounterResult(counterResults);
return RpcResultBuilder.success(gncob.build()).buildFuture();
}
Aggregations