import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.buildGroupInstanceIdentifier;
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getFlowId;
-import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdFromNodeIdentifier;
+import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdValueFromNodeIdentifier;
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getTableId;
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isFlowDependentOnGroup;
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isGroupExistsOnDevice;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
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.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput;
final Flow flow,
final InstanceIdentifier<FlowCapableNode> nodeIdent,
final BundleId bundleId) {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
- nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+ nodeConfigurator.enqueueJob(nodeId, () -> {
final List<Message> messages = new ArrayList<>(1);
String node = nodeIdent.firstKeyOf(Node.class).getId().getValue();
BundleInnerMessage bundleInnerMessage = new BundleRemoveFlowCaseBuilder()
final Flow flow,
final InstanceIdentifier<FlowCapableNode> nodeIdent,
final BundleId bundleId) {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
- return nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+ return nodeConfigurator.enqueueJob(nodeId, () -> {
BundleInnerMessage bundleInnerMessage = new BundleAddFlowCaseBuilder()
.setAddFlowCaseData(new AddFlowCaseDataBuilder(flow)
.build())
ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture;
if (groupId != null) {
LOG.trace("The flow {} is dependent on group {}. Checking if the group is already present",
- getFlowId(new FlowRef(identifier)), groupId);
+ getFlowId(identifier), groupId);
if (isGroupExistsOnDevice(nodeIdent, groupId, forwardingRulesManager)) {
LOG.trace("The dependent group {} is already programmed. Updating the flow {}", groupId,
- getFlowId(new FlowRef(identifier)));
+ getFlowId(identifier));
resultFuture = Futures.immediateFuture(RpcResultBuilder.<AddBundleMessagesOutput>success().build());
} else {
LOG.trace("The dependent group {} isn't programmed yet. Pushing the group", groupId);
.setMessage(messages).build())
.build();
LOG.trace("Pushing flow update message {} to bundle {} for device {}", addBundleMessagesInput,
- bundleId.getValue(), getNodeIdFromNodeIdentifier(nodeIdent));
+ bundleId.getValue(), getNodeIdValueFromNodeIdentifier(nodeIdent));
resultFuture = forwardingRulesManager
.getSalBundleService()
.addBundleMessages(addBundleMessagesInput);
Futures.transformAsync(resultFuture, rpcResult -> {
if (rpcResult.isSuccessful()) {
forwardingRulesManager.getDevicesGroupRegistry()
- .storeGroup(getNodeIdFromNodeIdentifier(nodeIdent), groupId);
+ .storeGroup(getNodeIdValueFromNodeIdentifier(nodeIdent), groupId);
LOG.trace("Group {} stored in cache", groupId);
}
return Futures.immediateFuture(null);
private final InstanceIdentifier<FlowCapableNode> nodeIdent;
private final BundleId bundleId;
private final Message messages;
- private final NodeId nodeId;
+ private final String nodeId;
private final String flowId;
private final Uint8 tableId;
private final SettableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture;
this.bundleId = bundleId;
this.messages = messages;
this.resultFuture = resultFuture;
- this.flowId = getFlowId(new FlowRef(identifier));
- this.tableId = getTableId(new FlowTableRef(identifier));
- this.nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
+ this.flowId = getFlowId(identifier);
+ this.tableId = getTableId(identifier);
+ nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
}
@Override
.build();
LOG.trace("Pushing flow add message {} to bundle {} for device {}", addBundleMessagesInput,
- bundleId.getValue(), nodeId.getValue());
+ bundleId.getValue(), nodeId);
final ListenableFuture<RpcResult<AddBundleMessagesOutput>> addFuture =
forwardingRulesManager.getSalBundleService().addBundleMessages(addBundleMessagesInput);
resultFuture.set(result);
if (!result.getErrors().isEmpty()) {
LOG.error("Flow add with flowId {} and tableId {} failed for node {} with error: {}",
- flowId, tableId, nodeId.getValue(), result.getErrors().toString());
+ flowId, tableId, nodeId, result.getErrors().toString());
}
}
}, MoreExecutors.directExecutor());
} else {
LOG.error("Error {} while pushing flow add bundle {} for device {}", rpcResult.getErrors(), messages,
- nodeId.getValue());
+ nodeId);
resultFuture.set(rpcResult);
}
}
@Override
public void onFailure(Throwable throwable) {
- LOG.error("Error while pushing flow add bundle {} for device {}", messages, nodeId.getValue());
+ LOG.error("Error while pushing flow add bundle {} for device {}", messages, nodeId);
resultFuture.setException(throwable);
}
}
package org.opendaylight.openflowplugin.applications.frm.impl;
-import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdFromNodeIdentifier;
+import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdValueFromNodeIdentifier;
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isGroupExistsOnDevice;
import com.google.common.base.Preconditions;
import org.opendaylight.openflowplugin.applications.frm.NodeConfigurator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+
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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput;
@Override
public void remove(final InstanceIdentifier<Group> identifier, final Group group,
final InstanceIdentifier<FlowCapableNode> nodeIdent, final BundleId bundleId) {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
- nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+ nodeConfigurator.enqueueJob(nodeId, () -> {
final List<Message> messages = new ArrayList<>(1);
BundleInnerMessage bundleInnerMessage = new BundleRemoveGroupCaseBuilder()
.setRemoveGroupCaseData(new RemoveGroupCaseDataBuilder(group).build())
.setMessages(new MessagesBuilder().setMessage(messages).build())
.build();
LOG.trace("Pushing group remove message {} to bundle {} for device {}", addBundleMessagesInput,
- bundleId.getValue(), nodeId.getValue());
+ bundleId.getValue(), nodeId);
final ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager
.getSalBundleService().addBundleMessages(addBundleMessagesInput);
Futures.addCallback(resultFuture,
final Group updatedGroup,
final InstanceIdentifier<FlowCapableNode> nodeIdent,
final BundleId bundleId) {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
- nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+ nodeConfigurator.enqueueJob(nodeId, () -> {
final List<Message> messages = new ArrayList<>(1);
BundleInnerMessage bundleInnerMessage = new BundleUpdateGroupCaseBuilder()
.setUpdateGroupCaseData(new UpdateGroupCaseDataBuilder(updatedGroup).build())
.setMessages(new MessagesBuilder().setMessage(messages).build())
.build();
LOG.trace("Pushing group update message {} to bundle {} for device {}", addBundleMessagesInput,
- bundleId.getValue(), nodeId.getValue());
+ bundleId.getValue(), nodeId);
final ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager
.getSalBundleService()
.addBundleMessages(addBundleMessagesInput);
final Group group,
final InstanceIdentifier<FlowCapableNode> nodeIdent,
final BundleId bundleId) {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
final Uint32 groupId = group.getGroupId().getValue();
- return nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ return nodeConfigurator.enqueueJob(nodeId, () -> {
if (isGroupExistsOnDevice(nodeIdent, groupId, forwardingRulesManager)) {
LOG.debug("Group {} already exists in the device. Ignoring the add DTCN", groupId);
return Futures.immediateFuture(RpcResultBuilder.<AddBundleMessagesOutput>success().build());
.setMessage(messages).build())
.build();
LOG.trace("Pushing group add message {} to bundle {} for device {}", addBundleMessagesInput,
- bundleId.getValue(), nodeId.getValue());
+ bundleId.getValue(), nodeId);
ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager
.getSalBundleService()
.addBundleMessages(addBundleMessagesInput);
private final class BundleAddGroupCallBack implements FutureCallback<RpcResult<AddBundleMessagesOutput>> {
private final Uint32 groupId;
- private final NodeId nodeId;
+ private final String nodeId;
- private BundleAddGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+ private BundleAddGroupCallBack(final Uint32 groupId, final String nodeId) {
this.groupId = groupId;
this.nodeId = nodeId;
}
private final class BundleUpdateGroupCallBack implements FutureCallback<RpcResult<AddBundleMessagesOutput>> {
private final Uint32 groupId;
- private final NodeId nodeId;
+ private final String nodeId;
- private BundleUpdateGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+ private BundleUpdateGroupCallBack(final Uint32 groupId, final String nodeId) {
this.groupId = groupId;
this.nodeId = nodeId;
}
private final class BundleRemoveGroupCallBack implements FutureCallback<RpcResult<AddBundleMessagesOutput>> {
private final Uint32 groupId;
- private final NodeId nodeId;
+ private final String nodeId;
- private BundleRemoveGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+ private BundleRemoveGroupCallBack(final Uint32 groupId, final String nodeId) {
this.groupId = groupId;
this.nodeId = nodeId;
}
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yangtools.yang.common.Uint32;
public class DevicesGroupRegistry {
- private final Map<NodeId, List<Uint32>> deviceGroupMapping = new ConcurrentHashMap<>();
+ private final Map<String, List<Uint32>> deviceGroupMapping = new ConcurrentHashMap<>();
- public boolean isGroupPresent(NodeId nodeId, Uint32 groupId) {
+ public boolean isGroupPresent(String nodeId, Uint32 groupId) {
return deviceGroupMapping.get(nodeId) != null ? deviceGroupMapping.get(nodeId).contains(groupId) : false;
}
- public void storeGroup(NodeId nodeId, Uint32 groupId) {
+ public void storeGroup(String nodeId, Uint32 groupId) {
deviceGroupMapping.computeIfAbsent(nodeId, groupIdList -> new ArrayList<>()).add(groupId);
}
- public void removeGroup(NodeId nodeId, Uint32 groupId) {
+ public void removeGroup(String nodeId, Uint32 groupId) {
deviceGroupMapping.computeIfPresent(nodeId, (node, groupIds) -> groupIds).remove(groupId);
}
- public void clearNodeGroups(NodeId nodeId) {
+ public void clearNodeGroups(String nodeId) {
deviceGroupMapping.remove(nodeId);
}
-
-}
+}
\ No newline at end of file
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.buildGroupInstanceIdentifier;
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getActiveBundle;
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getFlowId;
-import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdFromNodeIdentifier;
+import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdValueFromNodeIdentifier;
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isFlowDependentOnGroup;
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isGroupExistsOnDevice;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
if (bundleId != null) {
provider.getBundleFlowListener().remove(identifier, removeDataObj, nodeIdent, bundleId);
} else {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
- nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+ nodeConfigurator.enqueueJob(nodeId, () -> {
final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj);
builder.setFlowRef(new FlowRef(identifier));
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
if (bundleId != null) {
provider.getBundleFlowListener().update(identifier, original, update, nodeIdent, bundleId);
} else {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
- nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+ nodeConfigurator.enqueueJob(nodeId, () -> {
final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
builder.setFlowRef(new FlowRef(identifier));
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);
+ getFlowId(identifier), groupId);
if (isGroupExistsOnDevice(nodeIdent, groupId, provider)) {
LOG.trace("The dependent group {} is already programmed. Updating the flow {}", groupId,
- getFlowId(new FlowRef(identifier)));
+ getFlowId(identifier));
return provider.getSalFlowService().updateFlow(builder.build());
} else {
LOG.trace("The dependent group {} isn't programmed yet. Pushing the group", groupId);
}
LOG.trace("The flow {} is not dependent on any group. Updating the flow",
- getFlowId(new FlowRef(identifier)));
+ getFlowId(identifier));
return provider.getSalFlowService().updateFlow(builder.build());
});
}
if (bundleId != null) {
return provider.getBundleFlowListener().add(identifier, addDataObj, nodeIdent, bundleId);
} else {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
- nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+ nodeConfigurator.enqueueJob(nodeId, () -> {
final AddFlowInputBuilder builder = new AddFlowInputBuilder(addDataObj);
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
private final class AddFlowCallBack implements FutureCallback<RpcResult<AddGroupOutput>> {
private final AddFlowInput addFlowInput;
- private final NodeId nodeId;
+ private final String nodeId;
private final Uint32 groupId;
private final SettableFuture<RpcResult<AddFlowOutput>> resultFuture;
- private AddFlowCallBack(final AddFlowInput addFlowInput, final NodeId nodeId, Uint32 groupId,
+ private AddFlowCallBack(final AddFlowInput addFlowInput, final String nodeId, Uint32 groupId,
SettableFuture<RpcResult<AddFlowOutput>> resultFuture) {
this.addFlowInput = addFlowInput;
this.nodeId = nodeId;
}, MoreExecutors.directExecutor());
LOG.debug("Flow add with id {} finished without error for node {}",
- getFlowId(addFlowInput.getFlowRef()), nodeId.getValue());
+ getFlowId(addFlowInput.getFlowRef()), nodeId);
} else {
LOG.error("Flow add with id {} failed for node {} with error {}", getFlowId(addFlowInput.getFlowRef()),
- nodeId.getValue(), rpcResult.getErrors());
+ 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 String nodeId;
private final Uint32 groupId;
private final SettableFuture<RpcResult<UpdateFlowOutput>> resultFuture;
- private UpdateFlowCallBack(final UpdateFlowInput updateFlowInput, final NodeId nodeId,
+ private UpdateFlowCallBack(final UpdateFlowInput updateFlowInput, final String nodeId,
SettableFuture<RpcResult<UpdateFlowOutput>> resultFuture, Uint32 groupId) {
this.updateFlowInput = updateFlowInput;
this.nodeId = nodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
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.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
public ListenableFuture<Boolean> reconcileConfiguration(InstanceIdentifier<FlowCapableNode> connectedNode) {
LOG.info("Triggering reconciliation for device {}", connectedNode.firstKeyOf(Node.class));
// Clearing the group registry cache for the connected node if exists
- NodeId nodeId = FrmUtil.getNodeIdFromNodeIdentifier(connectedNode);
+ String nodeId = FrmUtil.getNodeIdValueFromNodeIdentifier(connectedNode);
provider.getDevicesGroupRegistry().clearNodeGroups(nodeId);
if (provider.isStaleMarkingEnabled()) {
LOG.info("Stale-Marking is ENABLED and proceeding with deletion of " + "stale-marked entities on switch {}",
public ListenableFuture<Boolean> startReconciliation(DeviceInfo node) {
InstanceIdentifier<FlowCapableNode> connectedNode = node.getNodeInstanceIdentifier()
.augmentation(FlowCapableNode.class);
+ // Clearing the group registry cache for the connected node if exists
+ provider.getDevicesGroupRegistry().clearNodeGroups(node.toString());
return futureMap.computeIfAbsent(node, future -> reconcileConfiguration(connectedNode));
}
package org.opendaylight.openflowplugin.applications.frm.impl;
import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getActiveBundle;
-import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdFromNodeIdentifier;
+import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdValueFromNodeIdentifier;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
@Override
protected InstanceIdentifier<Group> getWildCardPath() {
- return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)
+ return InstanceIdentifier.create(Nodes.class)
+ .child(Node.class)
+ .augmentation(FlowCapableNode.class)
.child(Group.class);
}
if (bundleId != null) {
provider.getBundleGroupListener().remove(identifier, removeDataObj, nodeIdent, bundleId);
} else {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
- nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+ nodeConfigurator.enqueueJob(nodeId, () -> {
final Group group = removeDataObj;
- final RemoveGroupInputBuilder builder = new RemoveGroupInputBuilder(group);
- builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
- builder.setGroupRef(new GroupRef(identifier));
- builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
+ final RemoveGroupInput removeGroup = new RemoveGroupInputBuilder(group)
+ .setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)))
+ .setGroupRef(new GroupRef(identifier))
+ .setTransactionUri(new Uri(provider.getNewTransactionId()))
+ .build();
final ListenableFuture<RpcResult<RemoveGroupOutput>> resultFuture =
- this.provider.getSalGroupService().removeGroup(builder.build());
+ this.provider.getSalGroupService()
+ .removeGroup(removeGroup);
Futures.addCallback(resultFuture,
new RemoveGroupCallBack(removeDataObj.getGroupId().getValue(), nodeId),
MoreExecutors.directExecutor());
if (bundleId != null) {
provider.getBundleGroupListener().update(identifier, original, update, nodeIdent, bundleId);
} else {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
- nodeConfigurator.enqueueJob(nodeId.getValue(), () -> {
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
+ nodeConfigurator.enqueueJob(nodeId, () -> {
final Group originalGroup = original;
final Group updatedGroup = update;
final UpdateGroupInputBuilder builder = new UpdateGroupInputBuilder();
builder.setUpdatedGroup(new UpdatedGroupBuilder(updatedGroup).build());
builder.setOriginalGroup(new OriginalGroupBuilder(originalGroup).build());
UpdateGroupInput updateGroupInput = builder.build();
- final ListenableFuture<RpcResult<UpdateGroupOutput>> resultFuture;
- resultFuture = this.provider.getSalGroupService().updateGroup(updateGroupInput);
+ final ListenableFuture<RpcResult<UpdateGroupOutput>> resultFuture = this.provider.getSalGroupService()
+ .updateGroup(updateGroupInput);
LoggingFutures.addErrorLogging(resultFuture, LOG, "updateGroup");
Futures.addCallback(resultFuture,
new UpdateGroupCallBack(updateGroupInput.getOriginalGroup().getGroupId().getValue(), nodeId),
if (bundleId != null) {
return provider.getBundleGroupListener().add(identifier, addDataObj, nodeIdent, bundleId);
} else {
- final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
+ final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
return nodeConfigurator
- .enqueueJob(nodeId.getValue(), () -> {
+ .enqueueJob(nodeId, () -> {
final Group group = addDataObj;
final AddGroupInputBuilder builder = new AddGroupInputBuilder(group);
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
private final class AddGroupCallBack implements FutureCallback<RpcResult<AddGroupOutput>> {
private final Uint32 groupId;
- private final NodeId nodeId;
+ private final String nodeId;
- private AddGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+ private AddGroupCallBack(final Uint32 groupId, final String nodeId) {
this.groupId = groupId;
this.nodeId = nodeId;
}
private final class UpdateGroupCallBack implements FutureCallback<RpcResult<UpdateGroupOutput>> {
private final Uint32 groupId;
- private final NodeId nodeId;
+ private final String nodeId;
- private UpdateGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+ private UpdateGroupCallBack(final Uint32 groupId, final String nodeId) {
this.groupId = groupId;
this.nodeId = nodeId;
}
private final class RemoveGroupCallBack implements FutureCallback<RpcResult<RemoveGroupOutput>> {
private final Uint32 groupId;
- private final NodeId nodeId;
+ private final String nodeId;
- private RemoveGroupCallBack(final Uint32 groupId, final NodeId nodeId) {
+ private RemoveGroupCallBack(final Uint32 groupId, final String nodeId) {
this.groupId = groupId;
this.nodeId = nodeId;
}
return nodeIdent.firstKeyOf(Node.class).getId();
}
+ public static String getNodeIdValueFromNodeIdentifier(final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+ return getNodeIdFromNodeIdentifier(nodeIdent).getValue();
+ }
+
public static String getFlowId(final FlowRef flowRef) {
return flowRef.getValue().firstKeyOf(Flow.class).getId().getValue();
}
+ public static String getFlowId(final InstanceIdentifier<Flow> identifier) {
+ return getFlowId(new FlowRef(identifier));
+ }
+
public static Uint8 getTableId(final FlowTableRef flowTableRef) {
return flowTableRef.getValue().firstKeyOf(Table.class).getId();
}
+ public static Uint8 getTableId(final InstanceIdentifier<Flow> identifier) {
+ return getTableId(new FlowTableRef(identifier));
+ }
+
public static BigInteger getDpnIdFromNodeName(final InstanceIdentifier<FlowCapableNode> nodeIdent) {
String nodeId = nodeIdent.firstKeyOf(Node.class).getId().getValue();
String dpId = nodeId.substring(nodeId.lastIndexOf(SEPARATOR) + 1);
final InstanceIdentifier<FlowCapableNode> nodeIdent, final Uint32 groupId) {
NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
InstanceIdentifier<Group> groupInstanceId = InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class)
- .child(Group.class, new GroupKey(new GroupId(groupId))).build();
+ .child(Node.class, new NodeKey(nodeId))
+ .augmentation(FlowCapableNode.class)
+ .child(Group.class, new GroupKey(new GroupId(groupId)))
+ .build();
return groupInstanceId;
}
public static BundleId getActiveBundle(final InstanceIdentifier<FlowCapableNode> nodeIdent,
- final ForwardingRulesManager provider) {
+ final ForwardingRulesManager provider) {
BigInteger dpId = getDpnIdFromNodeName(nodeIdent);
final NodeRef nodeRef = new NodeRef(nodeIdent.firstIdentifierOf(Node.class));
GetActiveBundleInputBuilder input = new GetActiveBundleInputBuilder().setNodeId(dpId).setNode(nodeRef);
}
public static boolean isGroupExistsOnDevice(final InstanceIdentifier<FlowCapableNode> nodeIdent,
- final Uint32 groupId, final ForwardingRulesManager provider) {
- NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent);
+ final Uint32 groupId,
+ final ForwardingRulesManager provider) {
+ String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
return provider.getDevicesGroupRegistry().isGroupPresent(nodeId, groupId);
}
}