Bug 4105: Remove candidates on PeerDown
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / entityownership / DistributedEntityOwnershipCandidateRegistration.java
index 1089ec28039f8ff0be20fb558999115e86b358a0..b92a124b2831adb2a224122db29cdfac6d4d353c 100644 (file)
@@ -17,13 +17,24 @@ import org.opendaylight.controller.md.sal.common.impl.clustering.AbstractEntityO
  * @author Thomas Pantelis
  */
 class DistributedEntityOwnershipCandidateRegistration extends AbstractEntityOwnershipCandidateRegistration {
+    private final DistributedEntityOwnershipService service;
 
-    DistributedEntityOwnershipCandidateRegistration(EntityOwnershipCandidate candidate, Entity entity) {
+    DistributedEntityOwnershipCandidateRegistration(EntityOwnershipCandidate candidate, Entity entity,
+            DistributedEntityOwnershipService service) {
         super(candidate, entity);
+        this.service = service;
     }
 
     @Override
-    public void close() {
-        // TODO - need to send unregister message.
+    protected void removeRegistration() {
+        service.unregisterCandidate(getEntity(), getInstance());
     }
+
+    @Override
+    public String toString() {
+        return "DistributedEntityOwnershipCandidateRegistration [entity=" + getEntity() + ", candidate="
+                + getInstance() + "]";
+    }
+
+
 }