Search in sources :

Example 1 with BatchStepType

use of org.opendaylight.openflowplugin.impl.services.batch.BatchStepType in project openflowplugin by opendaylight.

the class FlatBatchUtil method markBarriersWhereNeeded.

public static void markBarriersWhereNeeded(final List<BatchPlanStep> batchPlan) {
    final EnumSet<BatchStepType> previousTypes = EnumSet.noneOf(BatchStepType.class);
    BatchPlanStep previousPlanStep = null;
    for (BatchPlanStep planStep : batchPlan) {
        final BatchStepType type = planStep.getStepType();
        if (!previousTypes.isEmpty() && decideBarrier(previousTypes, type)) {
            previousPlanStep.setBarrierAfter(true);
            previousTypes.clear();
        }
        previousTypes.add(type);
        previousPlanStep = planStep;
    }
}
Also used : BatchPlanStep(org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep) BatchStepType(org.opendaylight.openflowplugin.impl.services.batch.BatchStepType)

Example 2 with BatchStepType

use of org.opendaylight.openflowplugin.impl.services.batch.BatchStepType in project openflowplugin by opendaylight.

the class FlatBatchUtil method detectBatchStepType.

@VisibleForTesting
static <T extends BatchChoice> BatchStepType detectBatchStepType(final T batchCase) {
    final BatchStepType type;
    final Class<? extends DataContainer> implementedInterface = batchCase.getImplementedInterface();
    if (FlatBatchAddFlowCase.class.equals(implementedInterface)) {
        type = BatchStepType.FLOW_ADD;
    } else if (FlatBatchRemoveFlowCase.class.equals(implementedInterface)) {
        type = BatchStepType.FLOW_REMOVE;
    } else if (FlatBatchUpdateFlowCase.class.equals(implementedInterface)) {
        type = BatchStepType.FLOW_UPDATE;
    } else if (FlatBatchAddGroupCase.class.equals(implementedInterface)) {
        type = BatchStepType.GROUP_ADD;
    } else if (FlatBatchRemoveGroupCase.class.equals(implementedInterface)) {
        type = BatchStepType.GROUP_REMOVE;
    } else if (FlatBatchUpdateGroupCase.class.equals(implementedInterface)) {
        type = BatchStepType.GROUP_UPDATE;
    } else if (FlatBatchAddMeterCase.class.equals(implementedInterface)) {
        type = BatchStepType.METER_ADD;
    } else if (FlatBatchRemoveMeterCase.class.equals(implementedInterface)) {
        type = BatchStepType.METER_REMOVE;
    } else if (FlatBatchUpdateMeterCase.class.equals(implementedInterface)) {
        type = BatchStepType.METER_UPDATE;
    } else {
        throw new IllegalArgumentException("Unsupported batch obtained: " + implementedInterface);
    }
    return type;
}
Also used : FlatBatchRemoveMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveMeterCase) FlatBatchRemoveFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveFlowCase) FlatBatchAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCase) BatchStepType(org.opendaylight.openflowplugin.impl.services.batch.BatchStepType) FlatBatchUpdateGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCase) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with BatchStepType

use of org.opendaylight.openflowplugin.impl.services.batch.BatchStepType in project openflowplugin by opendaylight.

the class FlatBatchUtilTest method testDetectBatchStepType.

@Test
public void testDetectBatchStepType() throws Exception {
    for (BatchStepType stepType : BatchStepType.values()) {
        LOG.debug("checking detection of: {}", stepType);
        final Batch batch = createBatch(stepType);
        final BatchStepType actualType = FlatBatchUtil.detectBatchStepType(batch.getBatchChoice());
        Assert.assertEquals(stepType, actualType);
    }
}
Also used : Batch(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch) BatchStepType(org.opendaylight.openflowplugin.impl.services.batch.BatchStepType) Test(org.junit.Test)

Example 4 with BatchStepType

use of org.opendaylight.openflowplugin.impl.services.batch.BatchStepType in project openflowplugin by opendaylight.

the class FlatBatchUtil method assembleBatchPlan.

public static List<BatchPlanStep> assembleBatchPlan(List<Batch> batches) {
    final List<BatchPlanStep> plan = new ArrayList<>();
    BatchPlanStep planStep;
    for (Batch batch : batches) {
        final BatchStepType nextStepType = detectBatchStepType(batch.getBatchChoice());
        planStep = new BatchPlanStep(nextStepType);
        planStep.getTaskBag().addAll(extractBatchData(planStep.getStepType(), batch.getBatchChoice()));
        if (!planStep.isEmpty()) {
            plan.add(planStep);
        }
    }
    return plan;
}
Also used : Batch(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch) ArrayList(java.util.ArrayList) BatchPlanStep(org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep) BatchStepType(org.opendaylight.openflowplugin.impl.services.batch.BatchStepType)

Aggregations

BatchStepType (org.opendaylight.openflowplugin.impl.services.batch.BatchStepType)4 BatchPlanStep (org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep)2 Batch (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 FlatBatchAddGroupCase (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCase)1 FlatBatchRemoveFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveFlowCase)1 FlatBatchRemoveMeterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveMeterCase)1 FlatBatchUpdateGroupCase (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCase)1