use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project openflowplugin by opendaylight.
the class ReconcileUtil method resolveAndDivideGroupDiffs.
/**
* Returns a list of safe synchronization steps.
*
* @param nodeId target node
* @param installedGroupsArg groups resent on device
* @param pendingGroups groups configured for device
* @param gatherUpdates check content of pending item if present on device (and create update task eventually)
* @return list of safe synchronization steps
*/
public static List<ItemSyncBox<Group>> resolveAndDivideGroupDiffs(final NodeId nodeId, final Map<Long, Group> installedGroupsArg, final Collection<Group> pendingGroups, final boolean gatherUpdates) {
final Map<Long, Group> installedGroups = new HashMap<>(installedGroupsArg);
final List<ItemSyncBox<Group>> plan = new ArrayList<>();
while (!Iterables.isEmpty(pendingGroups)) {
final ItemSyncBox<Group> stepPlan = new ItemSyncBox<>();
final Iterator<Group> iterator = pendingGroups.iterator();
final Map<Long, Group> installIncrement = new HashMap<>();
while (iterator.hasNext()) {
final Group group = iterator.next();
final Group existingGroup = installedGroups.get(group.getGroupId().getValue());
if (existingGroup != null) {
if (!gatherUpdates) {
iterator.remove();
} else {
// check buckets and eventually update
if (group.equals(existingGroup)) {
iterator.remove();
} else {
if (checkGroupPrecondition(installedGroups.keySet(), group)) {
iterator.remove();
LOG.trace("Group {} on device {} differs - planned for update", group.getGroupId(), nodeId);
stepPlan.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(existingGroup, group));
}
}
}
} else if (checkGroupPrecondition(installedGroups.keySet(), group)) {
iterator.remove();
installIncrement.put(group.getGroupId().getValue(), group);
stepPlan.getItemsToPush().add(group);
}
}
if (!stepPlan.isEmpty()) {
// atomic update of installed flows in order to keep plan portions clean of local group dependencies
installedGroups.putAll(installIncrement);
plan.add(stepPlan);
} else if (!pendingGroups.isEmpty()) {
LOG.warn("Failed to resolve and divide groups into preconditions-match based ordered plan: {}, " + "resolving stuck at level {}", nodeId.getValue(), plan.size());
throw new IllegalStateException("Failed to resolve and divide groups when matching preconditions");
}
}
return plan;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update 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.bmp.message.rev200120.route.monitoring.message.Update in project openflowplugin by opendaylight.
the class ReconcileUtil method resolveMeterDiffs.
/**
* Resolves meter differences.
*
* @param nodeId target node
* @param meterOperationalMap meters present on device
* @param metersConfigured meters configured for device
* @param gatherUpdates check content of pending item if present on device (and create update task eventually)
* @return synchronization box
*/
public static ItemSyncBox<Meter> resolveMeterDiffs(final NodeId nodeId, final Map<MeterId, Meter> meterOperationalMap, final List<Meter> metersConfigured, final boolean gatherUpdates) {
LOG.trace("resolving meters for {}", nodeId.getValue());
final ItemSyncBox<Meter> syncBox = new ItemSyncBox<>();
for (Meter meter : metersConfigured) {
final Meter existingMeter = meterOperationalMap.get(meter.getMeterId());
if (existingMeter == null) {
syncBox.getItemsToPush().add(meter);
} else {
// compare content and eventually update
if (gatherUpdates && !meter.equals(existingMeter)) {
syncBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(existingMeter, meter));
}
}
}
return syncBox;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project openflowplugin by opendaylight.
the class FlatBatchFlowAdapters method adaptFlatBatchUpdateFlow.
/**
* Adapt flat batch update flow.
* @param planStep batch step containing changes of the same type
* @param node pointer for RPC routing
* @return input suitable for {@link org.opendaylight.yang.gen.v1.urn
* .opendaylight.flows.service.rev160314.SalFlowsBatchService#updateFlowsBatch(UpdateFlowsBatchInput)}
*/
public static UpdateFlowsBatchInput adaptFlatBatchUpdateFlow(final BatchPlanStep planStep, final NodeRef node) {
final List<BatchUpdateFlows> batchFlows = new ArrayList<>();
for (FlatBatchUpdateFlow batchUpdateFlow : planStep.<FlatBatchUpdateFlow>getTaskBag()) {
final BatchUpdateFlows updateFlows = new BatchUpdateFlowsBuilder(batchUpdateFlow).build();
batchFlows.add(updateFlows);
}
return new UpdateFlowsBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchUpdateFlows(batchFlows).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project openflowplugin by opendaylight.
the class FlatBatchMeterAdapters method adaptFlatBatchUpdateMeter.
/**
* Adapt flat batch update meter.
* @param planStep batch step containing changes of the same type
* @param node pointer for RPC routing
* @return input suitable for {@link org.opendaylight.yang.gen.v1.urn
* .opendaylight.meters.service.rev160316.SalMetersBatchService#updateMetersBatch(UpdateMetersBatchInput)}
*/
public static UpdateMetersBatchInput adaptFlatBatchUpdateMeter(final BatchPlanStep planStep, final NodeRef node) {
final List<BatchUpdateMeters> batchMeters = new ArrayList<>();
for (FlatBatchUpdateMeter batchUpdateMeter : planStep.<FlatBatchUpdateMeter>getTaskBag()) {
final BatchUpdateMeters updateMeters = new BatchUpdateMetersBuilder(batchUpdateMeter).build();
batchMeters.add(updateMeters);
}
return new UpdateMetersBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchUpdateMeters(batchMeters).build();
}
Aggregations