use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables 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.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables 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.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project openflowplugin by opendaylight.
the class FlowCapableNodeLookups method wrapTablesToMap.
@Nonnull
public static Map<Short, Table> wrapTablesToMap(@Nullable final List<Table> tables) {
final Map<Short, Table> tableMap;
if (tables == null) {
tableMap = Collections.emptyMap();
} else {
LOG.trace("tables found: {}", tables.size());
tableMap = new HashMap<>();
for (Table table : tables) {
tableMap.put(table.getId(), table);
}
}
return tableMap;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project openflowplugin by opendaylight.
the class ReconcileUtil method resolveFlowDiffsInAllTables.
/**
* Resolves flow differences in all tables.
*
* @param nodeId target node
* @param tableOperationalMap flow-tables resent on device
* @param tablesConfigured flow-tables configured for device
* @param gatherUpdates check content of pending item if present on device (and create update task eventually)
* @return map : key={@link TableKey}, value={@link ItemSyncBox} of safe synchronization steps
*/
public static Map<TableKey, ItemSyncBox<Flow>> resolveFlowDiffsInAllTables(final NodeId nodeId, final Map<Short, Table> tableOperationalMap, final List<Table> tablesConfigured, final boolean gatherUpdates) {
LOG.trace("resolving flows in tables for {}", nodeId.getValue());
final Map<TableKey, ItemSyncBox<Flow>> tableFlowSyncBoxes = new HashMap<>();
for (final Table tableConfigured : tablesConfigured) {
final List<Flow> flowsConfigured = tableConfigured.getFlow();
if (flowsConfigured == null || flowsConfigured.isEmpty()) {
continue;
}
// lookup table (on device)
final Table tableOperational = tableOperationalMap.get(tableConfigured.getId());
// wrap existing (on device) flows in current table into map
final Map<FlowDescriptor, Flow> flowOperationalMap = FlowCapableNodeLookups.wrapFlowsToMap(tableOperational != null ? tableOperational.getFlow() : null);
final ItemSyncBox<Flow> flowsSyncBox = resolveFlowDiffsInTable(flowsConfigured, flowOperationalMap, gatherUpdates);
if (!flowsSyncBox.isEmpty()) {
tableFlowSyncBoxes.put(tableConfigured.getKey(), flowsSyncBox);
}
}
return tableFlowSyncBoxes;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project openflowplugin by opendaylight.
the class FeaturesReplyMessageFactoryTest method test.
/**
* Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00" + " 00 00 00 00 01 02 03");
GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
Assert.assertEquals("Wrong buffers", 0x00010203L, builtByFactory.getBuffers().longValue());
Assert.assertEquals("Wrong number of tables", 0x01, builtByFactory.getTables().shortValue());
Assert.assertEquals("Wrong auxiliaryId", 0x01, builtByFactory.getAuxiliaryId().shortValue());
Assert.assertEquals("Wrong capabilities", new Capabilities(false, false, false, false, false, false, false), builtByFactory.getCapabilities());
Assert.assertEquals("Wrong reserved", 0x00010203L, builtByFactory.getReserved().longValue());
}
Aggregations