import org.opendaylight.openflowplugin.impl.util.PathUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchOutput;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
BatchStepJob batchJob;
final List<ListenableFuture<RpcResult<ProcessFlatBatchOutput>>> firedJobs = new ArrayList<>();
ListenableFuture<RpcResult<ProcessFlatBatchOutput>> chainSummaryResult =
- RpcResultBuilder.<ProcessFlatBatchOutput>success()
- .withRpcErrors(new ArrayList<>())
- .withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>()).build())
- .buildFuture();
+ FlatBatchUtil.createEmptyRpcBatchResultFuture(true);
for (int i = 0; i < batchJobsChain.size(); i++) {
batchJob = batchJobsChain.get(i);
chainJobs.add(new BatchStepJob(planStep, chainInput -> {
if (exitOnFirstError && !chainInput.isSuccessful()) {
LOG.debug("error on flat batch chain occurred -> skipping step {}", planStep.getStepType());
- return RpcResultBuilder.<ProcessFlatBatchOutput>status(false)
- .withRpcErrors(new ArrayList<>())
- .withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>()).build())
- .buildFuture();
+ return FlatBatchUtil.createEmptyRpcBatchResultFuture(false);
}
LOG.trace("batch progressing on step type {}", planStep.getStepType());
break;
default:
LOG.warn("Unsupported plan-step type occurred: {} -> OMITTING", planStep.getStepType());
- chainOutput = RpcResultBuilder.<ProcessFlatBatchOutput>status(true)
- .withRpcErrors(new ArrayList<>())
- .withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>()).build())
- .buildFuture();
+ chainOutput = FlatBatchUtil.createEmptyRpcBatchResultFuture(true);
}
return chainOutput;
}));
return Futures.transform(Futures.successfulAsList(firedJobs), mergeRpcResults());
}
+ /**
+ *
+ * @param status RPC result status
+ * @return ListenableFuture of RPC result with empty list of errors and batch failures
+ */
+ public static ListenableFuture<RpcResult<ProcessFlatBatchOutput>> createEmptyRpcBatchResultFuture(final boolean status) {
+ return RpcResultBuilder.<ProcessFlatBatchOutput>status(status)
+ .withRpcErrors(new ArrayList<>())
+ .withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>()).build())
+ .buildFuture();
+ }
}
import org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep;
import org.opendaylight.openflowplugin.impl.services.batch.BatchStepJob;
import org.opendaylight.openflowplugin.impl.services.batch.BatchStepType;
+import org.opendaylight.openflowplugin.impl.util.FlatBatchUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
Mockito.when(batchStepJob1.getPlanStep()).thenReturn(batchPlanStep1);
Mockito.when(batchStepJob2.getPlanStep()).thenReturn(batchPlanStep2);
- final ListenableFuture<RpcResult<ProcessFlatBatchOutput>> succeededChainOutput =
- RpcResultBuilder.<ProcessFlatBatchOutput>success().withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>()).build()).buildFuture();
+ final ListenableFuture<RpcResult<ProcessFlatBatchOutput>> succeededChainOutput = FlatBatchUtil.createEmptyRpcBatchResultFuture(true);
final ListenableFuture<RpcResult<ProcessFlatBatchOutput>> failedChainOutput =
RpcResultBuilder.<ProcessFlatBatchOutput>failed()
.withError(RpcError.ErrorType.APPLICATION, "ut-chainError")