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;
}
}
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;
}
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);
}
}
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;
}
Aggregations