X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Frole%2FRoleContextImpl.java;h=5ddf504fbb066de0a50927683df0f363e042e2c9;hb=d10c556113e37e0cb9fa08ed47932f72ba454ee3;hp=9950a304921d9d7b637a5642dc6d58394e6653b1;hpb=d8a96dca4974f44509df513fcc352a64b7977569;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java index 9950a30492..5ddf504fbb 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java @@ -16,6 +16,7 @@ import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlready import org.opendaylight.controller.md.sal.common.api.clustering.Entity; import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration; import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; +import org.opendaylight.openflowplugin.api.openflow.OFPContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor; @@ -47,6 +48,7 @@ class RoleContextImpl implements RoleContext { private final Semaphore roleChangeGuard = new Semaphore(1, true); private final LifecycleConductor conductor; + private volatile CONTEXT_STATE contextState; RoleContextImpl(final DeviceInfo deviceInfo, final EntityOwnershipService entityOwnershipService, final Entity entity, final Entity txEntity, final LifecycleConductor lifecycleConductor) { this.entityOwnershipService = entityOwnershipService; @@ -54,11 +56,13 @@ class RoleContextImpl implements RoleContext { this.txEntity = txEntity; this.deviceInfo = deviceInfo; this.conductor = lifecycleConductor; + contextState = CONTEXT_STATE.INITIALIZATION; } @Override public boolean initialization() { LOG.info("Initialization main candidate for node {}", deviceInfo.getNodeId()); + contextState = CONTEXT_STATE.WORKING; return registerCandidate(this.entity); } @@ -76,7 +80,7 @@ class RoleContextImpl implements RoleContext { @Nullable @Override public RequestContext createRequestContext() { - return new AbstractRequestContext(conductor.reserveXidForDeviceMessage(deviceInfo.getNodeId())) { + return new AbstractRequestContext(conductor.reserveXidForDeviceMessage(deviceInfo)) { @Override public void close() { } @@ -183,10 +187,16 @@ class RoleContextImpl implements RoleContext { @Override public void close() { + contextState = CONTEXT_STATE.TERMINATION; unregisterAllCandidates(); } public boolean isMaster(){ return (txEntityOwnershipCandidateRegistration != null && entityOwnershipCandidateRegistration != null); } + + @Override + public CONTEXT_STATE getState() { + return contextState; + } }