import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
-public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutput, RemoveFlowOutput, UpdateFlowOutput> {
+public class FlowForwarder implements ForwardingRulesCommitter<Flow, AddFlowOutput, RemoveFlowOutput,
+ UpdateFlowOutput> {
private static final Logger LOG = LoggerFactory.getLogger(FlowForwarder.class);
private static final String TABLE_ID_MISMATCH = "tableId mismatch";
private static final Logger LOG = LoggerFactory.getLogger(FlowForwarder.class);
private static final String TABLE_ID_MISMATCH = "tableId mismatch";
final Flow removeDataObj,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding Flow REMOVE request Tbl id, node Id {} {}",
identifier, nodeIdent);
final Flow removeDataObj,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding Flow REMOVE request Tbl id, node Id {} {}",
identifier, nodeIdent);
if (tableIdValidationPrecondition(tableKey, removeDataObj)) {
final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj);
builder.setFlowRef(new FlowRef(identifier));
if (tableIdValidationPrecondition(tableKey, removeDataObj)) {
final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj);
builder.setFlowRef(new FlowRef(identifier));
return salFlowService.removeFlow(builder.build());
} else {
return RpcResultBuilder.<RemoveFlowOutput>failed()
return salFlowService.removeFlow(builder.build());
} else {
return RpcResultBuilder.<RemoveFlowOutput>failed()
final Flow original, final Flow update,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding Flow UPDATE request [Tbl id, node Id {} {} {}",
identifier, nodeIdent, update);
final Flow original, final Flow update,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding Flow UPDATE request [Tbl id, node Id {} {} {}",
identifier, nodeIdent, update);
- final Future<RpcResult<UpdateFlowOutput>> output;
- final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
+ final ListenableFuture<RpcResult<UpdateFlowOutput>> output;
+ final TableKey tableKey = identifier.firstKeyOf(Table.class);
if (tableIdValidationPrecondition(tableKey, update)) {
final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
if (tableIdValidationPrecondition(tableKey, update)) {
final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
// always needs to set strict flag into update-flow input so that
// only a flow entry associated with a given flow object is updated.
// always needs to set strict flag into update-flow input so that
// only a flow entry associated with a given flow object is updated.
- builder.setUpdatedFlow((new UpdatedFlowBuilder(update)).setStrict(Boolean.TRUE).build());
- builder.setOriginalFlow((new OriginalFlowBuilder(original)).setStrict(Boolean.TRUE).build());
+ builder.setUpdatedFlow(new UpdatedFlowBuilder(update).setStrict(Boolean.TRUE).build());
+ builder.setOriginalFlow(new OriginalFlowBuilder(original).setStrict(Boolean.TRUE).build());
output = salFlowService.updateFlow(builder.build());
} else {
output = RpcResultBuilder.<UpdateFlowOutput>failed()
output = salFlowService.updateFlow(builder.build());
} else {
output = RpcResultBuilder.<UpdateFlowOutput>failed()
final Flow addDataObj,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding the Flow ADD request [Tbl id, node Id {} {} {}",
identifier, nodeIdent, addDataObj);
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);
+ final ListenableFuture<RpcResult<AddFlowOutput>> output;
+ final TableKey tableKey = identifier.firstKeyOf(Table.class);
if (tableIdValidationPrecondition(tableKey, addDataObj)) {
final AddFlowInputBuilder builder = new AddFlowInputBuilder(addDataObj);
if (tableIdValidationPrecondition(tableKey, addDataObj)) {
final AddFlowInputBuilder builder = new AddFlowInputBuilder(addDataObj);
builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
output = salFlowService.addFlow(builder.build());
} else {
builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
output = salFlowService.addFlow(builder.build());
} else {
- Preconditions.checkNotNull(tableKey, "TableKey can not be null or empty!");
- Preconditions.checkNotNull(flow, "Flow can not be null or empty!");
+ requireNonNull(tableKey, "TableKey can not be null or empty!");
+ requireNonNull(flow, "Flow can not be null or empty!");
if (!tableKey.getId().equals(flow.getTableId())) {
LOG.warn("TableID in URI tableId={} and in payload tableId={} is not same.",
flow.getTableId(), tableKey.getId());
if (!tableKey.getId().equals(flow.getTableId())) {
LOG.warn("TableID in URI tableId={} and in payload tableId={} is not same.",
flow.getTableId(), tableKey.getId());