use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class MultiLayerFlowService method processFlowModInputBuilders.
public ListenableFuture<RpcResult<O>> processFlowModInputBuilders(final List<FlowModInputBuilder> ofFlowModInputs) {
final List<ListenableFuture<RpcResult<O>>> partialFutures = new ArrayList<>(ofFlowModInputs.size());
for (final FlowModInputBuilder flowModInputBuilder : ofFlowModInputs) {
partialFutures.add(handleServiceCall(flowModInputBuilder));
}
final ListenableFuture<List<RpcResult<O>>> allFutures = Futures.successfulAsList(partialFutures);
final SettableFuture<RpcResult<O>> finalFuture = SettableFuture.create();
Futures.addCallback(allFutures, new FutureCallback<List<RpcResult<O>>>() {
@Override
public void onSuccess(@Nonnull final List<RpcResult<O>> results) {
final ArrayList<RpcError> errors = new ArrayList();
for (RpcResult<O> flowModResult : results) {
if (flowModResult == null) {
errors.add(RpcResultBuilder.newError(RpcError.ErrorType.PROTOCOL, OFConstants.APPLICATION_TAG, "unexpected flowMod result (null) occurred"));
} else if (!flowModResult.isSuccessful()) {
errors.addAll(flowModResult.getErrors());
}
}
final RpcResultBuilder<O> rpcResultBuilder;
if (errors.isEmpty()) {
rpcResultBuilder = RpcResultBuilder.success();
} else {
rpcResultBuilder = RpcResultBuilder.<O>failed().withRpcErrors(errors);
}
finalFuture.set(rpcResultBuilder.build());
}
@Override
public void onFailure(final Throwable throwable) {
RpcResultBuilder<O> rpcResultBuilder = RpcResultBuilder.failed();
finalFuture.set(rpcResultBuilder.build());
}
}, MoreExecutors.directExecutor());
return finalFuture;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class PacketProcessingServiceImpl method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final TransmitPacketInput input) throws ServiceException {
final PacketOutConvertorData data = new PacketOutConvertorData(getVersion());
data.setDatapathId(getDatapathId());
data.setXid(xid.getValue());
final Optional<PacketOutInput> result = convertorExecutor.convert(input, data);
return result.orElse(PacketOutConvertor.defaultResult(getVersion()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class AllMeterConfigStatsService method transformToNotification.
@Override
public MeterConfigStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
MeterConfigStatsUpdatedBuilder message = new MeterConfigStatsUpdatedBuilder();
message.setId(getDeviceInfo().getNodeId());
message.setMoreReplies(Boolean.FALSE);
message.setTransactionId(emulatedTxId);
message.setMeterConfigStats(new ArrayList<>());
for (MultipartReply mpReply : result) {
MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase) mpReply.getMultipartReplyBody();
MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
final Optional<List<MeterConfigStats>> meterConfigStatsList = convertorExecutor.convert(replyBody.getMeterConfig(), data);
meterConfigStatsList.ifPresent(meterConfigStats -> message.getMeterConfigStats().addAll(meterConfigStats));
}
return message.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class FlatBatchGroupAdapters method convertBatchGroupResult.
/**
* Convert batch group result.
* @param stepOffset offset of current batch plan step
* @return converted {@link ProcessFlatBatchOutput} RPC result
*/
@VisibleForTesting
static <T extends BatchGroupOutputListGrouping> Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>> convertBatchGroupResult(final int stepOffset) {
return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {
@Nullable
@Override
public RpcResult<ProcessFlatBatchOutput> apply(@Nonnull final RpcResult<T> input) {
List<BatchFailure> batchFailures = wrapBatchGroupFailuresForFlat(input, stepOffset);
ProcessFlatBatchOutputBuilder outputBuilder = new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
return RpcResultBuilder.<ProcessFlatBatchOutput>status(input.isSuccessful()).withRpcErrors(input.getErrors()).withResult(outputBuilder.build()).build();
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class SalFlowServiceImpl method updateFlow.
@Override
public Future<RpcResult<UpdateFlowOutput>> updateFlow(final UpdateFlowInput input) {
final UpdatedFlow updated = input.getUpdatedFlow();
final OriginalFlow original = input.getOriginalFlow();
final List<FlowModInputBuilder> allFlowMods = new ArrayList<>();
final List<FlowModInputBuilder> ofFlowModInputs;
ListenableFuture<RpcResult<UpdateFlowOutput>> future;
if (flowUpdateMessage.canUseSingleLayerSerialization()) {
if (!FlowCreatorUtil.canModifyFlow(original, updated, flowUpdateMessage.getVersion())) {
final SettableFuture<RpcResult<UpdateFlowOutput>> objectSettableFuture = SettableFuture.create();
final ListenableFuture<List<RpcResult<UpdateFlowOutput>>> listListenableFuture = Futures.successfulAsList(flowUpdateMessage.handleServiceCall(input.getOriginalFlow()), flowUpdateMessage.handleServiceCall(input.getUpdatedFlow()));
Futures.addCallback(listListenableFuture, new FutureCallback<List<RpcResult<UpdateFlowOutput>>>() {
@Override
public void onSuccess(@Nonnull final List<RpcResult<UpdateFlowOutput>> results) {
final ArrayList<RpcError> errors = new ArrayList();
for (RpcResult<UpdateFlowOutput> flowModResult : results) {
if (flowModResult == null) {
errors.add(RpcResultBuilder.newError(RpcError.ErrorType.PROTOCOL, OFConstants.APPLICATION_TAG, "unexpected flowMod result (null) occurred"));
} else if (!flowModResult.isSuccessful()) {
errors.addAll(flowModResult.getErrors());
}
}
final RpcResultBuilder<UpdateFlowOutput> rpcResultBuilder;
if (errors.isEmpty()) {
rpcResultBuilder = RpcResultBuilder.success();
} else {
rpcResultBuilder = RpcResultBuilder.<UpdateFlowOutput>failed().withRpcErrors(errors);
}
objectSettableFuture.set(rpcResultBuilder.build());
}
@Override
public void onFailure(final Throwable throwable) {
RpcResultBuilder<UpdateFlowOutput> rpcResultBuilder = RpcResultBuilder.failed();
objectSettableFuture.set(rpcResultBuilder.build());
}
}, MoreExecutors.directExecutor());
future = objectSettableFuture;
} else {
future = flowUpdateMessage.handleServiceCall(input.getUpdatedFlow());
}
} else {
if (!FlowCreatorUtil.canModifyFlow(original, updated, flowUpdate.getVersion())) {
// We would need to remove original and add updated.
// remove flow
final RemoveFlowInputBuilder removeflow = new RemoveFlowInputBuilder(original);
final List<FlowModInputBuilder> ofFlowRemoveInput = flowUpdate.toFlowModInputs(removeflow.build());
// remove flow should be the first
allFlowMods.addAll(ofFlowRemoveInput);
final AddFlowInputBuilder addFlowInputBuilder = new AddFlowInputBuilder(updated);
ofFlowModInputs = flowUpdate.toFlowModInputs(addFlowInputBuilder.build());
} else {
ofFlowModInputs = flowUpdate.toFlowModInputs(updated);
}
allFlowMods.addAll(ofFlowModInputs);
future = flowUpdate.processFlowModInputBuilders(allFlowMods);
}
Futures.addCallback(future, new UpdateFlowCallback(input), MoreExecutors.directExecutor());
return future;
}
Aggregations