use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class MeterForwarder method add.
@Override
public Future<RpcResult<AddMeterOutput>> add(final InstanceIdentifier<Meter> identifier, final Meter addDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Received the Meter ADD request [Tbl id, node Id {} {} {}", identifier, nodeIdent, addDataObj);
final AddMeterInputBuilder builder = new AddMeterInputBuilder(addDataObj);
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
builder.setMeterRef(new MeterRef(identifier));
return salMeterService.addMeter(builder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method executeSyncStrategy.
@Override
public ListenableFuture<RpcResult<Void>> executeSyncStrategy(ListenableFuture<RpcResult<Void>> resultVehicle, final SynchronizationDiffInput diffInput, final SyncCrudCounters counters) {
final InstanceIdentifier<FlowCapableNode> nodeIdent = diffInput.getNodeIdent();
final NodeId nodeId = PathUtil.digNodeId(nodeIdent);
/* Tables - have to be pushed before groups */
// TODO enable table-update when ready
// resultVehicle = updateTableFeatures(nodeIdent, configTree);
resultVehicle = Futures.transformAsync(resultVehicle, input -> {
if (!input.isSuccessful()) {
// TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
// final ListenableFuture<RpcResult<Void>> singleVoidUpdateResult = Futures.transform(
// Futures.asList Arrays.asList(input, output),
// ReconcileUtil.<UpdateFlowOutput>createRpcResultCondenser("TODO"));
}
return addMissingGroups(nodeId, nodeIdent, diffInput.getGroupsToAddOrUpdate(), counters);
}, MoreExecutors.directExecutor());
Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "addMissingGroups"), MoreExecutors.directExecutor());
resultVehicle = Futures.transformAsync(resultVehicle, input -> {
if (!input.isSuccessful()) {
// TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
}
return addMissingMeters(nodeId, nodeIdent, diffInput.getMetersToAddOrUpdate(), counters);
}, MoreExecutors.directExecutor());
Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "addMissingMeters"), MoreExecutors.directExecutor());
resultVehicle = Futures.transformAsync(resultVehicle, input -> {
if (!input.isSuccessful()) {
// TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
}
return addMissingFlows(nodeId, nodeIdent, diffInput.getFlowsToAddOrUpdate(), counters);
}, MoreExecutors.directExecutor());
Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "addMissingFlows"), MoreExecutors.directExecutor());
resultVehicle = Futures.transformAsync(resultVehicle, input -> {
if (!input.isSuccessful()) {
// TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
}
return removeRedundantFlows(nodeId, nodeIdent, diffInput.getFlowsToRemove(), counters);
}, MoreExecutors.directExecutor());
Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "removeRedundantFlows"), MoreExecutors.directExecutor());
resultVehicle = Futures.transformAsync(resultVehicle, input -> {
if (!input.isSuccessful()) {
// TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
}
return removeRedundantMeters(nodeId, nodeIdent, diffInput.getMetersToRemove(), counters);
}, MoreExecutors.directExecutor());
Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "removeRedundantMeters"), MoreExecutors.directExecutor());
resultVehicle = Futures.transformAsync(resultVehicle, input -> {
if (!input.isSuccessful()) {
// TODO chain errors but not skip processing on first error return Futures.immediateFuture(input);
}
return removeRedundantGroups(nodeId, nodeIdent, diffInput.getGroupsToRemove(), counters);
}, MoreExecutors.directExecutor());
Futures.addCallback(resultVehicle, FxChainUtil.logResultCallback(nodeId, "removeRedundantGroups"), MoreExecutors.directExecutor());
return resultVehicle;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method addMissingMeters.
ListenableFuture<RpcResult<Void>> addMissingMeters(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final ItemSyncBox<Meter> syncBox, final SyncCrudCounters counters) {
if (syncBox.isEmpty()) {
LOG.trace("no meters configured for node: {} -> SKIPPING", nodeId.getValue());
return RpcResultBuilder.<Void>success().buildFuture();
}
final CrudCounts meterCrudCounts = counters.getMeterCrudCounts();
final List<ListenableFuture<RpcResult<AddMeterOutput>>> allResults = new ArrayList<>();
final List<ListenableFuture<RpcResult<UpdateMeterOutput>>> allUpdateResults = new ArrayList<>();
for (Meter meter : syncBox.getItemsToPush()) {
final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent = nodeIdent.child(Meter.class, meter.getKey());
LOG.debug("adding meter {} - absent on device {}", meter.getMeterId(), nodeId);
allResults.add(JdkFutureAdapters.listenInPoolThread(meterForwarder.add(meterIdent, meter, nodeIdent)));
meterCrudCounts.incAdded();
}
for (ItemSyncBox.ItemUpdateTuple<Meter> meterTuple : syncBox.getItemsToUpdate()) {
final Meter existingMeter = meterTuple.getOriginal();
final Meter updated = meterTuple.getUpdated();
final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent = nodeIdent.child(Meter.class, updated.getKey());
LOG.trace("meter {} - needs update on device {}", updated.getMeterId(), nodeId);
allUpdateResults.add(JdkFutureAdapters.listenInPoolThread(meterForwarder.update(meterIdent, existingMeter, updated, nodeIdent)));
meterCrudCounts.incUpdated();
}
final ListenableFuture<RpcResult<Void>> singleVoidAddResult = Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<AddMeterOutput>createRpcResultCondenser("meter add"), MoreExecutors.directExecutor());
final ListenableFuture<RpcResult<Void>> singleVoidUpdateResult = Futures.transform(Futures.allAsList(allUpdateResults), ReconcileUtil.<UpdateMeterOutput>createRpcResultCondenser("meter update"), MoreExecutors.directExecutor());
return Futures.transform(Futures.allAsList(singleVoidUpdateResult, singleVoidAddResult), ReconcileUtil.<Void>createRpcResultCondenser("meter add/update"), MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode 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.flow.inventory.rev130819.FlowCapableNode 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());
}
Aggregations