use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method flushRemoveGroupPortionAndBarrier.
private ListenableFuture<RpcResult<Void>> flushRemoveGroupPortionAndBarrier(final InstanceIdentifier<FlowCapableNode> nodeIdent, final ItemSyncBox<Group> groupsPortion) {
List<ListenableFuture<RpcResult<RemoveGroupOutput>>> allResults = new ArrayList<>();
for (Group group : groupsPortion.getItemsToPush()) {
final KeyedInstanceIdentifier<Group, GroupKey> groupIdent = nodeIdent.child(Group.class, group.getKey());
allResults.add(JdkFutureAdapters.listenInPoolThread(groupForwarder.remove(groupIdent, group, nodeIdent)));
}
final ListenableFuture<RpcResult<Void>> singleVoidResult = Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<RemoveGroupOutput>createRpcResultCondenser("group remove"), MoreExecutors.directExecutor());
return Futures.transformAsync(singleVoidResult, ReconcileUtil.chainBarrierFlush(PathUtil.digNodePath(nodeIdent), transactionService), MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method addMissingFlows.
ListenableFuture<RpcResult<Void>> addMissingFlows(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final Map<TableKey, ItemSyncBox<Flow>> flowsInTablesSyncBox, final SyncCrudCounters counters) {
if (flowsInTablesSyncBox.isEmpty()) {
LOG.trace("no tables in config for node: {} -> SKIPPING", nodeId.getValue());
return RpcResultBuilder.<Void>success().buildFuture();
}
final List<ListenableFuture<RpcResult<AddFlowOutput>>> allResults = new ArrayList<>();
final List<ListenableFuture<RpcResult<UpdateFlowOutput>>> allUpdateResults = new ArrayList<>();
final CrudCounts flowCrudCounts = counters.getFlowCrudCounts();
for (Map.Entry<TableKey, ItemSyncBox<Flow>> flowsInTableBoxEntry : flowsInTablesSyncBox.entrySet()) {
final TableKey tableKey = flowsInTableBoxEntry.getKey();
final ItemSyncBox<Flow> flowSyncBox = flowsInTableBoxEntry.getValue();
final KeyedInstanceIdentifier<Table, TableKey> tableIdent = nodeIdent.child(Table.class, tableKey);
for (final Flow flow : flowSyncBox.getItemsToPush()) {
final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class, flow.getKey());
LOG.trace("adding flow {} in table {} - absent on device {} match{}", flow.getId(), tableKey, nodeId, flow.getMatch());
allResults.add(JdkFutureAdapters.listenInPoolThread(flowForwarder.add(flowIdent, flow, nodeIdent)));
flowCrudCounts.incAdded();
}
for (final ItemSyncBox.ItemUpdateTuple<Flow> flowUpdate : flowSyncBox.getItemsToUpdate()) {
final Flow existingFlow = flowUpdate.getOriginal();
final Flow updatedFlow = flowUpdate.getUpdated();
final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class, updatedFlow.getKey());
LOG.trace("flow {} in table {} - needs update on device {} match{}", updatedFlow.getId(), tableKey, nodeId, updatedFlow.getMatch());
allUpdateResults.add(JdkFutureAdapters.listenInPoolThread(flowForwarder.update(flowIdent, existingFlow, updatedFlow, nodeIdent)));
flowCrudCounts.incUpdated();
}
}
final ListenableFuture<RpcResult<Void>> singleVoidAddResult = Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<AddFlowOutput>createRpcResultCondenser("flow adding"), MoreExecutors.directExecutor());
final ListenableFuture<RpcResult<Void>> singleVoidUpdateResult = Futures.transform(Futures.allAsList(allUpdateResults), ReconcileUtil.<UpdateFlowOutput>createRpcResultCondenser("flow updating"), MoreExecutors.directExecutor());
return Futures.transform(Futures.allAsList(singleVoidAddResult, singleVoidUpdateResult), ReconcileUtil.<Void>createRpcResultCondenser("flow 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 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.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class TableForwarder method update.
@Override
public Future<RpcResult<UpdateTableOutput>> update(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures original, final TableFeatures update, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.debug("Forwarding Table Update request [Tbl id, node Id {} {}", identifier, nodeIdent);
final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
final InstanceIdentifier<Table> iiToTable = nodeIdent.child(Table.class, new TableKey(identifier.firstKeyOf(TableFeatures.class).getTableId()));
builder.setTableRef(new TableRef(iiToTable));
builder.setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(Collections.singletonList(update)).build());
builder.setOriginalTable(new OriginalTableBuilder().setTableFeatures(Collections.singletonList(original)).build());
LOG.debug("Invoking SalTableService {} ", nodeIdent);
return salTableService.updateTable(builder.build());
}
Aggregations