import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final String GROUP_EXISTS_IN_DEVICE_ERROR = "GROUPEXISTS";
private ListenerRegistration<FlowForwarder> listenerRegistration;
- private final BundleFlowForwarder bundleFlowForwarder;
public FlowForwarder(final ForwardingRulesManager manager, final DataBroker db) {
super(manager, db);
- bundleFlowForwarder = new BundleFlowForwarder(manager);
}
@Override
if (tableIdValidationPrecondition(tableKey, removeDataObj)) {
BundleId bundleId = getActiveBundle(nodeIdent, provider);
if (bundleId != null) {
- bundleFlowForwarder.remove(identifier, removeDataObj, nodeIdent, bundleId);
+ provider.getBundleFlowListener().remove(identifier, removeDataObj, nodeIdent, bundleId);
} else {
- final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj);
- builder.setFlowRef(new FlowRef(identifier));
- builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
- builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
-
- // This method is called only when a given flow object has been
- // removed from datastore. So FRM always needs to set strict flag
- // into remove-flow input so that only a flow entry associated with
- // a given flow object is removed.
- builder.setTransactionUri(new Uri(provider.getNewTransactionId())).setStrict(Boolean.TRUE);
- LoggingFutures.addErrorLogging(provider.getSalFlowService().removeFlow(builder.build()), LOG,
- "removeFlow");
+ final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
+ nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj);
+ builder.setFlowRef(new FlowRef(identifier));
+ builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
+ builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
+
+ // This method is called only when a given flow object has been
+ // removed from datastore. So FRM always needs to set strict flag
+ // into remove-flow input so that only a flow entry associated with
+ // a given flow object is removed.
+ builder.setTransactionUri(new Uri(provider.getNewTransactionId())).setStrict(Boolean.TRUE);
+ final ListenableFuture<RpcResult<RemoveFlowOutput>> resultFuture =
+ provider.getSalFlowService().removeFlow(builder.build());
+ LoggingFutures.addErrorLogging(resultFuture, LOG, "removeFlow");
+ return resultFuture;
+ });
}
}
}
if (tableIdValidationPrecondition(tableKey, update)) {
BundleId bundleId = getActiveBundle(nodeIdent, provider);
if (bundleId != null) {
- bundleFlowForwarder.update(identifier, original, update, nodeIdent, bundleId);
+ provider.getBundleFlowListener().update(identifier, original, update, nodeIdent, bundleId);
} else {
final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
builder.setUpdatedFlow(new UpdatedFlowBuilder(update).setStrict(Boolean.TRUE).build());
builder.setOriginalFlow(new OriginalFlowBuilder(original).setStrict(Boolean.TRUE).build());
- Long groupId = isFlowDependentOnGroup(update);
+ Uint32 groupId = isFlowDependentOnGroup(update);
if (groupId != null) {
LOG.trace("The flow {} is dependent on group {}. Checking if the group is already present",
getFlowId(new FlowRef(identifier)), groupId);
if (tableIdValidationPrecondition(tableKey, addDataObj)) {
BundleId bundleId = getActiveBundle(nodeIdent, provider);
if (bundleId != null) {
- return bundleFlowForwarder.add(identifier, addDataObj, nodeIdent, bundleId);
+ return provider.getBundleFlowListener().add(identifier, addDataObj, nodeIdent, bundleId);
} else {
final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
builder.setFlowRef(new FlowRef(identifier));
builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
- Long groupId = isFlowDependentOnGroup(addDataObj);
+ Uint32 groupId = isFlowDependentOnGroup(addDataObj);
if (groupId != null) {
LOG.trace("The flow {} is dependent on group {}. Checking if the group is already present",
getFlowId(new FlowRef(identifier)), groupId);
@Override
public void createStaleMarkEntity(InstanceIdentifier<Flow> identifier, Flow del,
InstanceIdentifier<FlowCapableNode> nodeIdent) {
- LOG.debug("Creating Stale-Mark entry for the switch {} for flow {} ", nodeIdent.toString(), del.toString());
+ LOG.debug("Creating Stale-Mark entry for the switch {} for flow {} ", nodeIdent, del);
StaleFlow staleFlow = makeStaleFlow(identifier, del, nodeIdent);
persistStaleFlow(staleFlow, nodeIdent);
}
}
private ListenableFuture<RpcResult<AddGroupOutput>> pushDependentGroup(
- final InstanceIdentifier<FlowCapableNode> nodeIdent, final Long groupId) {
+ final InstanceIdentifier<FlowCapableNode> nodeIdent, final Uint32 groupId) {
//TODO This read to the DS might have a performance impact.
//if the dependent group is not installed than we should just cache the parent group,
private final class AddFlowCallBack implements FutureCallback<RpcResult<AddGroupOutput>> {
private final AddFlowInput addFlowInput;
private final NodeId nodeId;
- private final Long groupId;
+ private final Uint32 groupId;
private final SettableFuture<RpcResult<AddFlowOutput>> resultFuture;
- private AddFlowCallBack(final AddFlowInput addFlowInput, final NodeId nodeId, Long groupId,
+ private AddFlowCallBack(final AddFlowInput addFlowInput, final NodeId nodeId, Uint32 groupId,
SettableFuture<RpcResult<AddFlowOutput>> resultFuture) {
this.addFlowInput = addFlowInput;
this.nodeId = nodeId;
getFlowId(addFlowInput.getFlowRef()), nodeId);
} else {
LOG.error("Flow add with id {} failed for node {} with error {}", getFlowId(addFlowInput.getFlowRef()),
- nodeId, rpcResult.getErrors().toString());
+ nodeId, rpcResult.getErrors());
resultFuture.set(RpcResultBuilder.<AddFlowOutput>failed()
.withRpcErrors(rpcResult.getErrors()).build());
}
private final class UpdateFlowCallBack implements FutureCallback<RpcResult<AddGroupOutput>> {
private final UpdateFlowInput updateFlowInput;
private final NodeId nodeId;
- private final Long groupId;
+ private final Uint32 groupId;
private final SettableFuture<RpcResult<UpdateFlowOutput>> resultFuture;
private UpdateFlowCallBack(final UpdateFlowInput updateFlowInput, final NodeId nodeId,
- SettableFuture<RpcResult<UpdateFlowOutput>> resultFuture, Long groupId) {
+ SettableFuture<RpcResult<UpdateFlowOutput>> resultFuture, Uint32 groupId) {
this.updateFlowInput = updateFlowInput;
this.nodeId = nodeId;
this.groupId = groupId;
getFlowId(updateFlowInput.getFlowRef()), nodeId);
} else {
LOG.error("Flow update with id {} failed for node {} with error {}",
- getFlowId(updateFlowInput.getFlowRef()), nodeId, rpcResult.getErrors().toString());
+ getFlowId(updateFlowInput.getFlowRef()), nodeId, rpcResult.getErrors());
resultFuture.set(RpcResultBuilder.<UpdateFlowOutput>failed()
.withRpcErrors(rpcResult.getErrors()).build());
}