use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder in project openflowplugin by opendaylight.
the class FlowForwarder method add.
@Override
public Future<RpcResult<AddFlowOutput>> add(final InstanceIdentifier<Flow> identifier, final Flow addDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
Future<RpcResult<AddFlowOutput>> future;
final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
if (tableIdValidationPrecondition(tableKey, addDataObj)) {
final AddFlowInputBuilder builder = new AddFlowInputBuilder(addDataObj);
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
builder.setFlowRef(new FlowRef(identifier));
builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
future = provider.getSalFlowService().addFlow(builder.build());
} else {
future = Futures.<RpcResult<AddFlowOutput>>immediateFuture(null);
}
return future;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder in project openflowplugin by opendaylight.
the class SalBulkFlowServiceImpl method addFlowsRpc.
@Override
public Future<RpcResult<Void>> addFlowsRpc(AddFlowsRpcInput input) {
List<ListenableFuture<RpcResult<AddFlowOutput>>> bulkResults = new ArrayList<>();
for (BulkFlowBaseContentGrouping bulkFlow : input.getBulkFlowItem()) {
AddFlowInputBuilder flowInputBuilder = new AddFlowInputBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow) bulkFlow);
final NodeRef nodeRef = bulkFlow.getNode();
flowInputBuilder.setNode(nodeRef);
flowInputBuilder.setTableId(bulkFlow.getTableId());
Future<RpcResult<AddFlowOutput>> rpcAddFlowResult = flowService.addFlow(flowInputBuilder.build());
bulkResults.add(JdkFutureAdapters.listenInPoolThread(rpcAddFlowResult));
}
return handleResultFuture(Futures.allAsList(bulkResults));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder in project openflowplugin by opendaylight.
the class LLDPPacketPuntEnforcer method onDataTreeChanged.
@Override
public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<FlowCapableNode>> modifications) {
for (DataTreeModification<FlowCapableNode> modification : modifications) {
if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
AddFlowInputBuilder addFlowInput = new AddFlowInputBuilder(createFlow());
addFlowInput.setNode(new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class)));
final Future<RpcResult<AddFlowOutput>> resultFuture = this.flowService.addFlow(addFlowInput.build());
JdkFutures.addErrorLogging(resultFuture, LOG, "addFlow");
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder in project openflowplugin by opendaylight.
the class FlowForwarder method add.
@Override
public Future<RpcResult<AddFlowOutput>> add(final InstanceIdentifier<Flow> identifier, final Flow addDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding the Flow ADD request [Tbl id, node Id {} {} {}", identifier, nodeIdent, addDataObj);
final Future<RpcResult<AddFlowOutput>> output;
final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
if (tableIdValidationPrecondition(tableKey, addDataObj)) {
final AddFlowInputBuilder builder = new AddFlowInputBuilder(addDataObj);
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
builder.setFlowRef(new FlowRef(identifier));
builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
output = salFlowService.addFlow(builder.build());
} else {
output = RpcResultBuilder.<AddFlowOutput>failed().withError(RpcError.ErrorType.APPLICATION, TABLE_ID_MISMATCH).buildFuture();
}
return output;
}
Aggregations