Search in sources :

Example 1 with FlatBatchUpdateFlow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow 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();
}
Also used : UpdateFlowsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInputBuilder) BatchUpdateFlowsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlowsBuilder) ArrayList(java.util.ArrayList) FlatBatchUpdateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow) BatchUpdateFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlows)

Example 2 with FlatBatchUpdateFlow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyFlatBatchImpl method assembleAddOrUpdateFlows.

@VisibleForTesting
static int assembleAddOrUpdateFlows(final List<Batch> batchBag, int batchOrder, final Map<TableKey, ItemSyncBox<Flow>> flowItemSyncTableMap) {
    // process flow add+update
    int order = batchOrder;
    if (flowItemSyncTableMap != null) {
        for (Map.Entry<TableKey, ItemSyncBox<Flow>> syncBoxEntry : flowItemSyncTableMap.entrySet()) {
            final ItemSyncBox<Flow> flowItemSyncBox = syncBoxEntry.getValue();
            if (!flowItemSyncBox.getItemsToPush().isEmpty()) {
                final List<FlatBatchAddFlow> flatBatchAddFlowBag = new ArrayList<>(flowItemSyncBox.getItemsToUpdate().size());
                int itemOrder = 0;
                for (Flow flow : flowItemSyncBox.getItemsToPush()) {
                    flatBatchAddFlowBag.add(new FlatBatchAddFlowBuilder(flow).setBatchOrder(itemOrder++).setFlowId(flow.getId()).build());
                }
                final Batch batch = new BatchBuilder().setBatchChoice(new FlatBatchAddFlowCaseBuilder().setFlatBatchAddFlow(flatBatchAddFlowBag).build()).setBatchOrder(order).build();
                order += itemOrder;
                batchBag.add(batch);
            }
            if (!flowItemSyncBox.getItemsToUpdate().isEmpty()) {
                final List<FlatBatchUpdateFlow> flatBatchUpdateFlowBag = new ArrayList<>(flowItemSyncBox.getItemsToUpdate().size());
                int itemOrder = 0;
                for (ItemSyncBox.ItemUpdateTuple<Flow> flowUpdate : flowItemSyncBox.getItemsToUpdate()) {
                    flatBatchUpdateFlowBag.add(new FlatBatchUpdateFlowBuilder().setBatchOrder(itemOrder++).setFlowId(flowUpdate.getUpdated().getId()).setOriginalBatchedFlow(new OriginalBatchedFlowBuilder(flowUpdate.getOriginal()).build()).setUpdatedBatchedFlow(new UpdatedBatchedFlowBuilder(flowUpdate.getUpdated()).build()).build());
                }
                final Batch batch = new BatchBuilder().setBatchChoice(new FlatBatchUpdateFlowCaseBuilder().setFlatBatchUpdateFlow(flatBatchUpdateFlowBag).build()).setBatchOrder(order).build();
                order += itemOrder;
                batchBag.add(batch);
            }
        }
    }
    return order;
}
Also used : UpdatedBatchedFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.input.update.grouping.UpdatedBatchedFlowBuilder) OriginalBatchedFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.input.update.grouping.OriginalBatchedFlowBuilder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) ArrayList(java.util.ArrayList) BatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchBuilder) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) FlatBatchAddFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow) FlatBatchUpdateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow) FlatBatchUpdateFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlowBuilder) FlatBatchRemoveFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlow) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlatBatchAddFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow) FlatBatchUpdateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow) FlatBatchAddFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder) Batch(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch) FlatBatchUpdateFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateFlowCaseBuilder) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) FlatBatchAddFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddFlowCaseBuilder) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ArrayList (java.util.ArrayList)2 FlatBatchUpdateFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)1 Batch (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch)1 BatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchBuilder)1 FlatBatchAddFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddFlowCaseBuilder)1 FlatBatchUpdateFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateFlowCaseBuilder)1 FlatBatchAddFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow)1 FlatBatchAddFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder)1 FlatBatchRemoveFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlow)1 FlatBatchUpdateFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlowBuilder)1 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)1 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)1 UpdateFlowsBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInputBuilder)1 OriginalBatchedFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.input.update.grouping.OriginalBatchedFlowBuilder)1 UpdatedBatchedFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.input.update.grouping.UpdatedBatchedFlowBuilder)1 BatchUpdateFlows (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlows)1