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%2FDeviceMastership.java;h=cb88353e61d12ff2798ae32708c76b2ff6698929;hb=ff4d6a596324ccf31b4b567499f65607b7f1fe37;hp=10772da958ee34f3489686a6afa218a4055e3895;hpb=6a24c5ddc4aa7d2c1aacd4237844e38e9ce595f3;p=openflowplugin.git diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastership.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastership.java index 10772da958..cb88353e61 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastership.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastership.java @@ -8,9 +8,12 @@ package org.opendaylight.openflowplugin.applications.frm.impl; +import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.atomic.AtomicBoolean; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; @@ -18,7 +21,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,12 +38,16 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable private final AtomicBoolean deviceMastered = new AtomicBoolean(false); private final AtomicBoolean isDeviceInOperDS = new AtomicBoolean(false); private final InstanceIdentifier fcnIID; + private final KeyedInstanceIdentifier path; + + private ObjectRegistration<@NonNull FrmReconciliationService> reg; public DeviceMastership(final NodeId nodeId) { this.nodeId = nodeId; this.identifier = ServiceGroupIdentifier.create(nodeId.getValue()); fcnIID = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId)) .augmentation(FlowCapableNode.class); + path = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId)); } @Override @@ -66,11 +76,32 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable return deviceMastered.get(); } - public void setDeviceOperationalStatus(boolean inOperDS) { + public void setDeviceOperationalStatus(final boolean inOperDS) { isDeviceInOperDS.set(inOperDS); } public void reconcile() { deviceMastered.set(true); } + + public void registerReconciliationRpc(final RpcProviderService rpcProviderService, + final FrmReconciliationService reconcliationService) { + if (reg == null) { + LOG.debug("The path is registered : {}", path); + reg = rpcProviderService.registerRpcImplementation(FrmReconciliationService.class, reconcliationService, + ImmutableSet.of(path)); + } else { + LOG.debug("The path is already registered : {}", path); + } + } + + public void deregisterReconciliationRpc() { + if (reg != null) { + reg.close(); + reg = null; + LOG.debug("The path is unregistered : {}", path); + } else { + LOG.debug("The path is already unregistered : {}", path); + } + } }