X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=applications%2Fforwardingrules-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fapplications%2Ffrm%2Fimpl%2FGroupForwarder.java;h=cbb28503d73d05ab35aa7b02ff5a7a17307242ec;hb=05f8db12159673d0e0a95642fe86e62c14b7dc7b;hp=3dd51cad18e23b6624ddec20807cedac6cd18a91;hpb=13e1d5e6c0237b9378d60526dd8c1d79db6d2b49;p=openflowplugin.git diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java index 3dd51cad18..cbb28503d7 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java @@ -8,7 +8,7 @@ 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; @@ -27,6 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.Fl 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; @@ -40,7 +41,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group 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; @@ -98,7 +98,9 @@ public class GroupForwarder extends AbstractListeningCommiter { @Override protected InstanceIdentifier 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); } @@ -109,20 +111,24 @@ public class GroupForwarder extends AbstractListeningCommiter { if (bundleId != null) { provider.getBundleGroupListener().remove(identifier, removeDataObj, nodeIdent, bundleId); } else { - final Group group = removeDataObj; - final RemoveGroupInputBuilder builder = new RemoveGroupInputBuilder(group); - final NodeId nodeId = getNodeIdFromNodeIdentifier(nodeIdent); - - builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))); - builder.setGroupRef(new GroupRef(identifier)); - builder.setTransactionUri(new Uri(provider.getNewTransactionId())); - - final ListenableFuture> resultFuture = - this.provider.getSalGroupService().removeGroup(builder.build()); - Futures.addCallback(resultFuture, + final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent); + nodeConfigurator.enqueueJob(nodeId, () -> { + final Group group = removeDataObj; + 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> resultFuture = + this.provider.getSalGroupService() + .removeGroup(removeGroup); + Futures.addCallback(resultFuture, new RemoveGroupCallBack(removeDataObj.getGroupId().getValue(), nodeId), MoreExecutors.directExecutor()); - LoggingFutures.addErrorLogging(resultFuture, LOG, "removeGroup"); + LoggingFutures.addErrorLogging(resultFuture, LOG, "removeGroup"); + return resultFuture; + }); } } @@ -147,8 +153,8 @@ public class GroupForwarder extends AbstractListeningCommiter { 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(); @@ -158,8 +164,8 @@ public class GroupForwarder extends AbstractListeningCommiter { builder.setUpdatedGroup(new UpdatedGroupBuilder(updatedGroup).build()); builder.setOriginalGroup(new OriginalGroupBuilder(originalGroup).build()); UpdateGroupInput updateGroupInput = builder.build(); - final ListenableFuture> resultFuture; - resultFuture = this.provider.getSalGroupService().updateGroup(updateGroupInput); + final ListenableFuture> resultFuture = this.provider.getSalGroupService() + .updateGroup(updateGroupInput); LoggingFutures.addErrorLogging(resultFuture, LOG, "updateGroup"); Futures.addCallback(resultFuture, new UpdateGroupCallBack(updateGroupInput.getOriginalGroup().getGroupId().getValue(), nodeId), @@ -176,9 +182,9 @@ public class GroupForwarder extends AbstractListeningCommiter { 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))); @@ -198,7 +204,7 @@ public class GroupForwarder extends AbstractListeningCommiter { @Override public void createStaleMarkEntity(InstanceIdentifier identifier, Group del, InstanceIdentifier nodeIdent) { - LOG.debug("Creating Stale-Mark entry for the switch {} for Group {} ", nodeIdent.toString(), del.toString()); + LOG.debug("Creating Stale-Mark entry for the switch {} for Group {} ", nodeIdent, del); StaleGroup staleGroup = makeStaleGroup(identifier, del, nodeIdent); persistStaleGroup(staleGroup, nodeIdent); @@ -213,7 +219,7 @@ public class GroupForwarder extends AbstractListeningCommiter { private void persistStaleGroup(StaleGroup staleGroup, InstanceIdentifier nodeIdent) { WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleGroupInstanceIdentifier(staleGroup, nodeIdent), - staleGroup, false); + staleGroup); FluentFuture submitFuture = writeTransaction.commit(); handleStaleGroupResultFuture(submitFuture); @@ -242,9 +248,9 @@ public class GroupForwarder extends AbstractListeningCommiter { private final class AddGroupCallBack implements FutureCallback> { 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; } @@ -268,9 +274,9 @@ public class GroupForwarder extends AbstractListeningCommiter { private final class UpdateGroupCallBack implements FutureCallback> { 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; } @@ -295,9 +301,9 @@ public class GroupForwarder extends AbstractListeningCommiter { private final class RemoveGroupCallBack implements FutureCallback> { 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; }