Search in sources :

Example 6 with BatchFailure

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure in project openflowplugin by opendaylight.

the class FlatBatchUtilTest method testMergeJobsResultsFutures.

@Test
public void testMergeJobsResultsFutures() throws Exception {
    final BatchFailure batchFailure = new BatchFailureBuilder().setBatchOrder(9).setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder().setFlowId(new FlowId("11")).build()).build();
    final ProcessFlatBatchOutput output = new ProcessFlatBatchOutputBuilder().setBatchFailure(Lists.newArrayList(batchFailure)).build();
    final RpcResult<ProcessFlatBatchOutput> rpcResultFailed = RpcResultBuilder.<ProcessFlatBatchOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-rpcError").withResult(output).build();
    final RpcResult<ProcessFlatBatchOutput> rpcResultSuccess = RpcResultBuilder.<ProcessFlatBatchOutput>success().withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>())).build();
    final RpcResult<ProcessFlatBatchOutput> rpcResult1 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultSuccess));
    Assert.assertEquals(1, rpcResult1.getErrors().size());
    Assert.assertFalse(rpcResult1.isSuccessful());
    final RpcResult<ProcessFlatBatchOutput> rpcResult2 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultFailed));
    Assert.assertEquals(2, rpcResult2.getErrors().size());
    Assert.assertFalse(rpcResult2.isSuccessful());
    final RpcResult<ProcessFlatBatchOutput> rpcResult3 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultSuccess, rpcResultSuccess));
    Assert.assertEquals(0, rpcResult3.getErrors().size());
    Assert.assertTrue(rpcResult3.isSuccessful());
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) BatchFailure(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure) ProcessFlatBatchOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder) BatchFailureBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder) FlatBatchFailureFlowIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureFlowIdCaseBuilder) ProcessFlatBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput) Test(org.junit.Test)

Example 7 with BatchFailure

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure in project openflowplugin by opendaylight.

the class FlatBatchFlowAdapters method wrapBatchFlowFailuresForFlat.

private static <T extends BatchFlowOutputListGrouping> List<BatchFailure> wrapBatchFlowFailuresForFlat(final RpcResult<T> input, final int stepOffset) {
    final List<BatchFailure> batchFailures = new ArrayList<>();
    if (input.getResult().getBatchFailedFlowsOutput() != null) {
        for (BatchFailedFlowsOutput stepOutput : input.getResult().getBatchFailedFlowsOutput()) {
            final BatchFailure batchFailure = new BatchFailureBuilder().setBatchOrder(stepOffset + stepOutput.getBatchOrder()).setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder().setFlowId(stepOutput.getFlowId()).build()).build();
            batchFailures.add(batchFailure);
        }
    }
    return batchFailures;
}
Also used : BatchFailure(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure) BatchFailureBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder) BatchFailedFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput) ArrayList(java.util.ArrayList) FlatBatchFailureFlowIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureFlowIdCaseBuilder)

Example 8 with BatchFailure

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure in project openflowplugin by opendaylight.

the class FlatBatchMeterAdapters method convertBatchMeterResult.

/**
 * Convert meter batch result.
 * @param stepOffset offset of current batch plan step
 * @return converted {@link ProcessFlatBatchOutput} RPC result
 */
@VisibleForTesting
static <T extends BatchMeterOutputListGrouping> Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>> convertBatchMeterResult(final int stepOffset) {
    return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {

        @Nullable
        @Override
        public RpcResult<ProcessFlatBatchOutput> apply(@Nonnull final RpcResult<T> input) {
            List<BatchFailure> batchFailures = wrapBatchMeterFailuresForFlat(input, stepOffset);
            ProcessFlatBatchOutputBuilder outputBuilder = new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
            return RpcResultBuilder.<ProcessFlatBatchOutput>status(input.isSuccessful()).withRpcErrors(input.getErrors()).withResult(outputBuilder.build()).build();
        }
    };
}
Also used : Function(com.google.common.base.Function) BatchFailure(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure) ProcessFlatBatchOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder) Nonnull(javax.annotation.Nonnull) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ProcessFlatBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

BatchFailure (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure)8 ProcessFlatBatchOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput)4 ProcessFlatBatchOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder)4 BatchFailureBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 Function (com.google.common.base.Function)3 ArrayList (java.util.ArrayList)3 Nonnull (javax.annotation.Nonnull)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 FlatBatchFailureFlowIdCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureFlowIdCaseBuilder)2 Range (com.google.common.collect.Range)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 Batch (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch)1 BatchChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.BatchChoice)1 FlatBatchFailureGroupIdCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureGroupIdCaseBuilder)1 FlatBatchFailureMeterIdCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureMeterIdCaseBuilder)1 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)1 BatchFailedFlowsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput)1