Convert distributed EOS impl to use new DOM EOS interfaces 75/35475/14
authorTom Pantelis <tpanteli@brocade.com>
Fri, 26 Feb 2016 11:01:10 +0000 (06:01 -0500)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 19 Jul 2016 16:48:55 +0000 (16:48 +0000)
Change-Id: I5b2a6098a0c15f74ec2f16cb5451f3831ed913bf
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
26 files changed:
opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/06-clustered-entity-ownership.xml.conf
opendaylight/md-sal/sal-distributed-datastore/pom.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipCandidateRegistration.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipListenerRegistration.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnersModel.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupport.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/messages/RegisterCandidateLocal.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/messages/RegisterListenerLocal.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/messages/UnregisterCandidateLocal.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/messages/UnregisterListenerLocal.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModule.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModuleFactory.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-entity-ownership-service.yang [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/AbstractEntityOwnershipTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipServiceTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListenerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerActorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupportTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java
opendaylight/md-sal/sal-dom-broker/src/main/resources/org/opendaylight/blueprint/legacy-eos.xml

index 06a1fcb..e7428c8 100644 (file)
         <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
             <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
                 <module>
-                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:distributed-entity-ownership-service">prefix:distributed-entity-ownership-service-provider</type>
-                    <name>distributed-entity-ownership-service-provider</name>
-
-                    <data-store>
-                        <type xmlns:operational-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store">operational-dom-store-spi:operational-dom-datastore</type>
-                        <name>distributed-operational-store-service</name>
-                    </data-store>
+                    <type xmlns:legacy-eos="urn:opendaylight:params:xml:ns:yang:controller:config:legacy-entity-ownership-service-provider">legacy-eos:legacy-entity-ownership-service-provider</type>
+                    <name>legacy-entity-ownership-service-provider</name>
                 </module>
             </modules>
 
             <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
                 <service>
-                    <type xmlns:entity-ownership="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">entity-ownership:entity-ownership-service</type>
+                    <type xmlns:legacy-eos="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">legacy-eos:entity-ownership-service</type>
                     <instance>
                         <name>entity-ownership-service</name>
-                        <provider>/modules/module[type='distributed-entity-ownership-service-provider'][name='distributed-entity-ownership-service-provider']</provider>
+                        <provider>/modules/module[type='legacy-entity-ownership-service-provider'][name='legacy-entity-ownership-service-provider']</provider>
                     </instance>
                 </service>
             </services>
         </data>
     </configuration>
     <required-capabilities>
-        <capability>urn:opendaylight:params:xml:ns:yang:controller:config:distributed-entity-ownership-service?module=distributed-entity-ownership-service&amp;revision=2015-08-10</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:config:legacy-entity-ownership-service-provider?module=opendaylight-legacy-entity-ownership-service-provider&amp;revision=2016-02-26</capability>
     </required-capabilities>
 </snapshot>
index 1e58976..5844b3a 100644 (file)
       <groupId>org.opendaylight.mdsal</groupId>
       <artifactId>mdsal-dom-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.mdsal</groupId>
+      <artifactId>mdsal-eos-dom-api</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-core-spi</artifactId>
index 0492cbc..398671e 100644 (file)
@@ -7,18 +7,20 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.impl.clustering.AbstractEntityOwnershipCandidateRegistration;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 
 /**
  * Implementation of EntityOwnershipCandidateRegistration.
  *
  * @author Thomas Pantelis
  */
-class DistributedEntityOwnershipCandidateRegistration extends AbstractEntityOwnershipCandidateRegistration {
+class DistributedEntityOwnershipCandidateRegistration extends AbstractObjectRegistration<DOMEntity>
+        implements DOMEntityOwnershipCandidateRegistration {
     private final DistributedEntityOwnershipService service;
 
-    DistributedEntityOwnershipCandidateRegistration(Entity entity, DistributedEntityOwnershipService service) {
+    DistributedEntityOwnershipCandidateRegistration(DOMEntity entity, DistributedEntityOwnershipService service) {
         super(entity);
         this.service = service;
     }
index 9498e8f..2e0f4b4 100644 (file)
@@ -7,22 +7,26 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
-import org.opendaylight.controller.md.sal.common.impl.clustering.AbstractEntityOwnershipListenerRegistration;
+import com.google.common.base.Preconditions;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 
 /**
  * Implementation of EntityOwnershipListenerRegistration.
  *
  * @author Thomas Pantelis
  */
-class DistributedEntityOwnershipListenerRegistration extends AbstractEntityOwnershipListenerRegistration {
-
+class DistributedEntityOwnershipListenerRegistration extends AbstractObjectRegistration<DOMEntityOwnershipListener>
+        implements DOMEntityOwnershipListenerRegistration {
     private final DistributedEntityOwnershipService service;
+    private final String entityType;
 
-    DistributedEntityOwnershipListenerRegistration(EntityOwnershipListener listener, String entityType,
+    DistributedEntityOwnershipListenerRegistration(DOMEntityOwnershipListener listener, String entityType,
             DistributedEntityOwnershipService service) {
-        super(listener, entityType);
-        this.service = service;
+        super(listener);
+        this.entityType = Preconditions.checkNotNull(entityType, "entityType cannot be null");
+        this.service = Preconditions.checkNotNull(service, "DOMEntityOwnershipListener cannot be null");
     }
 
     @Override
@@ -30,6 +34,11 @@ class DistributedEntityOwnershipListenerRegistration extends AbstractEntityOwner
         service.unregisterListener(getEntityType(), getInstance());
     }
 
+    @Override
+    public String getEntityType() {
+        return entityType;
+    }
+
     @Override
     public String toString() {
         return "DistributedEntityOwnershipListenerRegistration [entityType=" + getEntityType()
index 8055be8..48c68e7 100644 (file)
@@ -35,13 +35,13 @@ import org.opendaylight.controller.cluster.datastore.messages.CreateShard;
 import org.opendaylight.controller.cluster.datastore.messages.GetShardDataTree;
 import org.opendaylight.controller.cluster.datastore.shardstrategy.ModuleShardStrategy;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
-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.EntityOwnershipListener;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
+import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.EntityOwners;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
@@ -60,14 +60,14 @@ import scala.concurrent.duration.Duration;
  *
  * @author Thomas Pantelis
  */
-public class DistributedEntityOwnershipService implements EntityOwnershipService, AutoCloseable {
+public class DistributedEntityOwnershipService implements DOMEntityOwnershipService, AutoCloseable {
     @VisibleForTesting
     static final String ENTITY_OWNERSHIP_SHARD_NAME = "entity-ownership";
 
     private static final Logger LOG = LoggerFactory.getLogger(DistributedEntityOwnershipService.class);
     private static final Timeout MESSAGE_TIMEOUT = new Timeout(1, TimeUnit.MINUTES);
 
-    private final ConcurrentMap<Entity, Entity> registeredEntities = new ConcurrentHashMap<>();
+    private final ConcurrentMap<DOMEntity, DOMEntity> registeredEntities = new ConcurrentHashMap<>();
     private final ActorContext context;
 
     private volatile ActorRef localEntityOwnershipShard;
@@ -140,7 +140,7 @@ public class DistributedEntityOwnershipService implements EntityOwnershipService
     }
 
     @Override
-    public EntityOwnershipCandidateRegistration registerCandidate(final Entity entity)
+    public DOMEntityOwnershipCandidateRegistration registerCandidate(final DOMEntity entity)
             throws CandidateAlreadyRegisteredException {
         Preconditions.checkNotNull(entity, "entity cannot be null");
 
@@ -156,7 +156,7 @@ public class DistributedEntityOwnershipService implements EntityOwnershipService
         return new DistributedEntityOwnershipCandidateRegistration(entity, this);
     }
 
-    void unregisterCandidate(final Entity entity) {
+    void unregisterCandidate(final DOMEntity entity) {
         LOG.debug("Unregistering candidate for {}", entity);
 
         executeLocalEntityOwnershipShardOperation(new UnregisterCandidateLocal(entity));
@@ -164,7 +164,8 @@ public class DistributedEntityOwnershipService implements EntityOwnershipService
     }
 
     @Override
-    public EntityOwnershipListenerRegistration registerListener(final String entityType, final EntityOwnershipListener listener) {
+    public DOMEntityOwnershipListenerRegistration registerListener(final String entityType,
+            final DOMEntityOwnershipListener listener) {
         Preconditions.checkNotNull(entityType, "entityType cannot be null");
         Preconditions.checkNotNull(listener, "listener cannot be null");
 
@@ -177,7 +178,7 @@ public class DistributedEntityOwnershipService implements EntityOwnershipService
     }
 
     @Override
-    public Optional<EntityOwnershipState> getOwnershipState(final Entity forEntity) {
+    public Optional<EntityOwnershipState> getOwnershipState(final DOMEntity forEntity) {
         Preconditions.checkNotNull(forEntity, "forEntity cannot be null");
 
         DataTree dataTree = getLocalEntityOwnershipShardDataTree();
@@ -186,7 +187,7 @@ public class DistributedEntityOwnershipService implements EntityOwnershipService
         }
 
         Optional<NormalizedNode<?, ?>> entityNode = dataTree.takeSnapshot().readNode(
-                entityPath(forEntity.getType(), forEntity.getId()));
+                entityPath(forEntity.getType(), forEntity.getIdentifier()));
         if (!entityNode.isPresent()) {
             return Optional.absent();
         }
@@ -205,11 +206,11 @@ public class DistributedEntityOwnershipService implements EntityOwnershipService
         boolean hasOwner = !Strings.isNullOrEmpty(owner);
         boolean isOwner = hasOwner && localMemberName.getName().equals(owner);
 
-        return Optional.of(new EntityOwnershipState(isOwner, hasOwner));
+        return Optional.of(EntityOwnershipState.from(isOwner, hasOwner));
     }
 
     @Override
-    public boolean isCandidateRegistered(@Nonnull final Entity entity) {
+    public boolean isCandidateRegistered(@Nonnull final DOMEntity entity) {
         return registeredEntities.get(entity) != null;
     }
 
@@ -232,7 +233,7 @@ public class DistributedEntityOwnershipService implements EntityOwnershipService
         return localEntityOwnershipShardDataTree;
     }
 
-    void unregisterListener(final String entityType, final EntityOwnershipListener listener) {
+    void unregisterListener(final String entityType, final DOMEntityOwnershipListener listener) {
         LOG.debug("Unregistering listener {} for entity type {}", listener, entityType);
 
         executeLocalEntityOwnershipShardOperation(new UnregisterListenerLocal(listener, entityType));
index 81a2751..050ee5d 100644 (file)
@@ -15,7 +15,7 @@ import com.google.common.base.Verify;
 import java.util.Collection;
 import java.util.Objects;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
@@ -62,7 +62,7 @@ class EntityOwnerChangeListener extends AbstractEntityOwnerChangeListener {
                 boolean wasOwner = localMemberName.equals(origOwner);
                 boolean hasOwner = !Strings.isNullOrEmpty(newOwner);
 
-                Entity entity = createEntity(change.getRootPath());
+                DOMEntity entity = createEntity(change.getRootPath());
 
                 LOG.debug("{}: Calling notifyEntityOwnershipListeners: entity: {}, wasOwner: {}, isOwner: {}, hasOwner: {}",
                         logId(), entity, wasOwner, isOwner, hasOwner);
index 205763a..57433ba 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
 import java.util.Map.Entry;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.EntityOwners;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.EntityType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.entity.type.entity.Candidate;
@@ -123,7 +123,7 @@ public final class EntityOwnersModel {
         return null;
     }
 
-    static Entity createEntity(YangInstanceIdentifier entityPath) {
+    static DOMEntity createEntity(YangInstanceIdentifier entityPath) {
         String entityType = null;
         YangInstanceIdentifier entityId = null;
         for(PathArgument pathArg: entityPath.getPathArguments()) {
@@ -138,6 +138,6 @@ public final class EntityOwnersModel {
             }
         }
 
-        return new Entity(entityType, entityId);
+        return new DOMEntity(entityType, entityId);
     }
 }
index 32250a7..df0b1ae 100644 (file)
@@ -11,8 +11,8 @@ import akka.actor.Props;
 import akka.japi.Creator;
 import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -24,22 +24,22 @@ import org.slf4j.LoggerFactory;
 class EntityOwnershipListenerActor extends AbstractUntypedActor {
     private static final Logger LOG = LoggerFactory.getLogger(EntityOwnershipListenerActor.class);
 
-    private final EntityOwnershipListener listener;
+    private final DOMEntityOwnershipListener listener;
 
-    private EntityOwnershipListenerActor(EntityOwnershipListener listener) {
+    private EntityOwnershipListenerActor(DOMEntityOwnershipListener listener) {
         this.listener = listener;
     }
 
     @Override
     protected void handleReceive(Object message) {
-        if (message instanceof EntityOwnershipChange) {
-            onEntityOwnershipChanged((EntityOwnershipChange)message);
+        if (message instanceof DOMEntityOwnershipChange) {
+            onEntityOwnershipChanged((DOMEntityOwnershipChange)message);
         } else {
             unknownMessage(message);
         }
     }
 
-    private void onEntityOwnershipChanged(EntityOwnershipChange change) {
+    private void onEntityOwnershipChanged(DOMEntityOwnershipChange change) {
         LOG.debug("Notifying EntityOwnershipListener {}: {}", listener, change);
 
         try {
@@ -49,16 +49,16 @@ class EntityOwnershipListenerActor extends AbstractUntypedActor {
         }
     }
 
-    static Props props(EntityOwnershipListener listener) {
+    static Props props(DOMEntityOwnershipListener listener) {
         return Props.create(new EntityOwnershipListenerCreator(listener));
     }
 
     private static final class EntityOwnershipListenerCreator implements Creator<EntityOwnershipListenerActor> {
         private static final long serialVersionUID = 1L;
 
-        private final EntityOwnershipListener listener;
+        private final DOMEntityOwnershipListener listener;
 
-        EntityOwnershipListenerCreator(EntityOwnershipListener listener) {
+        EntityOwnershipListenerCreator(DOMEntityOwnershipListener listener) {
             this.listener = Preconditions.checkNotNull(listener);
         }
 
index c0fe55f..26e6ab7 100644 (file)
@@ -18,9 +18,10 @@ import java.util.HashSet;
 import java.util.IdentityHashMap;
 import java.util.Map;
 import java.util.Set;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,9 +35,9 @@ class EntityOwnershipListenerSupport {
 
     private final String logId;
     private final ActorContext actorContext;
-    private final Map<EntityOwnershipListener, ListenerActorRefEntry> listenerActorMap = new IdentityHashMap<>();
-    private final Set<Entity> entitiesWithCandidateSet = new HashSet<>();
-    private final Multimap<String, EntityOwnershipListener> entityTypeListenerMap = HashMultimap.create();
+    private final Map<DOMEntityOwnershipListener, ListenerActorRefEntry> listenerActorMap = new IdentityHashMap<>();
+    private final Set<DOMEntity> entitiesWithCandidateSet = new HashSet<>();
+    private final Multimap<String, DOMEntityOwnershipListener> entityTypeListenerMap = HashMultimap.create();
     private volatile boolean inJeopardy = false;
 
     EntityOwnershipListenerSupport(ActorContext actorContext, String logId) {
@@ -60,50 +61,51 @@ class EntityOwnershipListenerSupport {
         return wasInJeopardy;
     }
 
-    boolean hasCandidateForEntity(Entity entity) {
+    boolean hasCandidateForEntity(DOMEntity entity) {
         return entitiesWithCandidateSet.contains(entity);
     }
 
-    void setHasCandidateForEntity(Entity entity) {
+    void setHasCandidateForEntity(DOMEntity entity) {
         entitiesWithCandidateSet.add(entity);
     }
 
-    void unsetHasCandidateForEntity(Entity entity) {
+    void unsetHasCandidateForEntity(DOMEntity entity) {
         entitiesWithCandidateSet.remove(entity);
     }
 
-    void addEntityOwnershipListener(String entityType, EntityOwnershipListener listener) {
+    void addEntityOwnershipListener(String entityType, DOMEntityOwnershipListener listener) {
         LOG.debug("{}: Adding EntityOwnershipListener {} for entity type {}", logId, listener, entityType);
 
         addListener(listener, entityType);
     }
 
-    void removeEntityOwnershipListener(String entityType, EntityOwnershipListener listener) {
+    void removeEntityOwnershipListener(String entityType, DOMEntityOwnershipListener listener) {
         LOG.debug("{}: Removing EntityOwnershipListener {} for entity type {}", logId, listener, entityType);
 
         removeListener(listener, entityType);
     }
 
-    void notifyEntityOwnershipListeners(Entity entity, boolean wasOwner, boolean isOwner, boolean hasOwner) {
+    void notifyEntityOwnershipListeners(DOMEntity entity, boolean wasOwner, boolean isOwner, boolean hasOwner) {
         notifyListeners(entity, entity.getType(), wasOwner, isOwner, hasOwner);
     }
 
-    void notifyEntityOwnershipListener(Entity entity, boolean wasOwner, boolean isOwner, boolean hasOwner,
-            EntityOwnershipListener listener) {
+    void notifyEntityOwnershipListener(DOMEntity entity, boolean wasOwner, boolean isOwner, boolean hasOwner,
+            DOMEntityOwnershipListener listener) {
         notifyListeners(entity, wasOwner, isOwner, hasOwner, Collections.singleton(listener));
     }
 
-    private void notifyListeners(Entity entity, String mapKey, boolean wasOwner, boolean isOwner, boolean hasOwner) {
-        Collection<EntityOwnershipListener> listeners = entityTypeListenerMap.get(mapKey);
+    private void notifyListeners(DOMEntity entity, String mapKey, boolean wasOwner, boolean isOwner, boolean hasOwner) {
+        Collection<DOMEntityOwnershipListener> listeners = entityTypeListenerMap.get(mapKey);
         if(!listeners.isEmpty()) {
             notifyListeners(entity, wasOwner, isOwner, hasOwner, listeners);
         }
     }
 
-    private void notifyListeners(Entity entity, boolean wasOwner, boolean isOwner, boolean hasOwner,
-            Collection<EntityOwnershipListener> listeners) {
-        EntityOwnershipChange changed = new EntityOwnershipChange(entity, wasOwner, isOwner, hasOwner, inJeopardy);
-        for(EntityOwnershipListener listener: listeners) {
+    private void notifyListeners(DOMEntity entity, boolean wasOwner, boolean isOwner, boolean hasOwner,
+            Collection<DOMEntityOwnershipListener> listeners) {
+        DOMEntityOwnershipChange changed = new DOMEntityOwnershipChange(entity,
+                EntityOwnershipChangeState.from(wasOwner, isOwner, hasOwner), inJeopardy);
+        for(DOMEntityOwnershipListener listener: listeners) {
             ActorRef listenerActor = listenerActorFor(listener);
 
             LOG.debug("{}: Notifying EntityOwnershipListenerActor {} with {}", logId, listenerActor, changed);
@@ -112,7 +114,7 @@ class EntityOwnershipListenerSupport {
         }
     }
 
-    private void addListener(EntityOwnershipListener listener, String mapKey) {
+    private void addListener(DOMEntityOwnershipListener listener, String mapKey) {
         if (entityTypeListenerMap.put(mapKey, listener)) {
             ListenerActorRefEntry listenerEntry = listenerActorMap.get(listener);
             if(listenerEntry == null) {
@@ -123,7 +125,7 @@ class EntityOwnershipListenerSupport {
         }
     }
 
-    private void removeListener(EntityOwnershipListener listener, String mapKey) {
+    private void removeListener(DOMEntityOwnershipListener listener, String mapKey) {
         if (entityTypeListenerMap.remove(mapKey, listener)) {
             ListenerActorRefEntry listenerEntry = listenerActorMap.get(listener);
 
@@ -141,7 +143,7 @@ class EntityOwnershipListenerSupport {
         }
     }
 
-    private ActorRef listenerActorFor(EntityOwnershipListener listener) {
+    private ActorRef listenerActorFor(DOMEntityOwnershipListener listener) {
         return listenerActorMap.get(listener).actorFor(listener);
     }
 
@@ -149,7 +151,7 @@ class EntityOwnershipListenerSupport {
         ActorRef actorRef;
         int referenceCount = 1;
 
-        ActorRef actorFor(EntityOwnershipListener listener) {
+        ActorRef actorFor(DOMEntityOwnershipListener listener) {
             if(actorRef == null) {
                 actorRef = actorContext.actorOf(EntityOwnershipListenerActor.props(listener));
 
index 8726dc5..6c151f8 100644 (file)
@@ -57,7 +57,7 @@ import org.opendaylight.controller.cluster.datastore.modification.DeleteModifica
 import org.opendaylight.controller.cluster.datastore.modification.MergeModification;
 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
 import org.opendaylight.controller.cluster.raft.RaftState;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
@@ -165,7 +165,7 @@ class EntityOwnershipShard extends Shard {
         listenerSupport.setHasCandidateForEntity(registerCandidate.getEntity());
 
         NormalizedNode<?, ?> entityOwners = entityOwnersWithCandidate(registerCandidate.getEntity().getType(),
-                registerCandidate.getEntity().getId(), localMemberName.getName());
+                registerCandidate.getEntity().getIdentifier(), localMemberName.getName());
         commitCoordinator.commitModification(new MergeModification(ENTITY_OWNERS_PATH, entityOwners), this);
 
         getSender().tell(SuccessReply.INSTANCE, getSelf());
@@ -174,10 +174,10 @@ class EntityOwnershipShard extends Shard {
     private void onUnregisterCandidateLocal(UnregisterCandidateLocal unregisterCandidate) {
         LOG.debug("{}: onUnregisterCandidateLocal: {}", persistenceId(), unregisterCandidate);
 
-        Entity entity = unregisterCandidate.getEntity();
+        DOMEntity entity = unregisterCandidate.getEntity();
         listenerSupport.unsetHasCandidateForEntity(entity);
 
-        YangInstanceIdentifier candidatePath = candidatePath(entity.getType(), entity.getId(), localMemberName.getName());
+        YangInstanceIdentifier candidatePath = candidatePath(entity.getType(), entity.getIdentifier(), localMemberName.getName());
         commitCoordinator.commitModification(new DeleteModification(candidatePath), this);
 
         getSender().tell(SuccessReply.INSTANCE, getSelf());
@@ -206,7 +206,7 @@ class EntityOwnershipShard extends Shard {
                     hasOwner = false;
                 }
 
-                Entity entity = new Entity(entityType,
+                DOMEntity entity = new DOMEntity(entityType,
                     (YangInstanceIdentifier) entityNode.getChild(ENTITY_ID_NODE_ID).get().getValue());
 
                 listenerSupport.notifyEntityOwnershipListener(entity, false, isOwner, hasOwner,
@@ -283,7 +283,7 @@ class EntityOwnershipShard extends Shard {
                     hasOwner = false;
                 }
 
-                Entity entity = new Entity(possibleType.get().getValue().toString(),
+                DOMEntity entity = new DOMEntity(possibleType.get().getValue().toString(),
                     (YangInstanceIdentifier) entityNode.getChild(ENTITY_ID_NODE_ID).get().getValue());
 
                 listenerSupport.notifyEntityOwnershipListeners(entity, isOwner, isOwner, hasOwner);
index 8b15aa2..3450033 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership.messages;
 
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 
 /**
  * Message sent to the local EntityOwnershipShard to register a candidate.
@@ -15,13 +15,13 @@ import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
  * @author Thomas Pantelis
  */
 public class RegisterCandidateLocal {
-    private final Entity entity;
+    private final DOMEntity entity;
 
-    public RegisterCandidateLocal(Entity entity) {
+    public RegisterCandidateLocal(DOMEntity entity) {
         this.entity = entity;
     }
 
-    public Entity getEntity() {
+    public DOMEntity getEntity() {
         return entity;
     }
 
index 6c64fb5..dd52cda 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership.messages;
 
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 
 /**
  * Message sent to the local EntityOwnershipShard to register an EntityOwnershipListener.
@@ -15,15 +15,15 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipL
  * @author Thomas Pantelis
  */
 public class RegisterListenerLocal {
-    private final EntityOwnershipListener listener;
+    private final DOMEntityOwnershipListener listener;
     private final String entityType;
 
-    public RegisterListenerLocal(EntityOwnershipListener listener, String entityType) {
+    public RegisterListenerLocal(DOMEntityOwnershipListener listener, String entityType) {
         this.listener = listener;
         this.entityType = entityType;
     }
 
-    public EntityOwnershipListener getListener() {
+    public DOMEntityOwnershipListener getListener() {
         return listener;
     }
 
index 3373564..8a94fab 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership.messages;
 
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 
 /**
  * Message sent to the local EntityOwnershipShard to unregister a candidate.
@@ -15,13 +15,13 @@ import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
  * @author Thomas Pantelis
  */
 public class UnregisterCandidateLocal {
-    private final Entity entity;
+    private final DOMEntity entity;
 
-    public UnregisterCandidateLocal(Entity entity) {
+    public UnregisterCandidateLocal(DOMEntity entity) {
         this.entity = entity;
     }
 
-    public Entity getEntity() {
+    public DOMEntity getEntity() {
         return entity;
     }
 
index 2bfa81a..03db369 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership.messages;
 
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 
 /**
  * Message sent to the local EntityOwnershipShard to unregister an EntityOwnershipListener.
@@ -15,15 +15,15 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipL
  * @author Thomas Pantelis
  */
 public class UnregisterListenerLocal {
-    private final EntityOwnershipListener listener;
+    private final DOMEntityOwnershipListener listener;
     private final String entityType;
 
-    public UnregisterListenerLocal(EntityOwnershipListener listener, String entityType) {
+    public UnregisterListenerLocal(DOMEntityOwnershipListener listener, String entityType) {
         this.listener = listener;
         this.entityType = entityType;
     }
 
-    public EntityOwnershipListener getListener() {
+    public DOMEntityOwnershipListener getListener() {
         return listener;
     }
 
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModule.java
deleted file mode 100644 (file)
index a7ea21f..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.config.yang.config.distributed_entity_ownership_service;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ForwardingObject;
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
-import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
-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.EntityOwnershipListener;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
-import org.osgi.framework.BundleContext;
-
-public class DistributedEntityOwnershipServiceProviderModule extends AbstractDistributedEntityOwnershipServiceProviderModule {
-    private BundleContext bundleContext;
-
-    public DistributedEntityOwnershipServiceProviderModule(final ModuleIdentifier identifier,
-            final DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public DistributedEntityOwnershipServiceProviderModule(final ModuleIdentifier identifier,
-            final DependencyResolver dependencyResolver,
-            final DistributedEntityOwnershipServiceProviderModule oldModule, final AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-    }
-
-    @Override
-    public boolean canReuseInstance(final AbstractDistributedEntityOwnershipServiceProviderModule oldModule) {
-        return true;
-    }
-
-    @Override
-    public AutoCloseable createInstance() {
-        // The DistributedEntityOwnershipService is provided via blueprint so wait for and return it here for
-        // backwards compatibility.
-        WaitingServiceTracker<EntityOwnershipService> tracker = WaitingServiceTracker.create(
-                EntityOwnershipService.class, bundleContext);
-        EntityOwnershipService delegate = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
-        return new ForwardingEntityOwnershipService(delegate, tracker);
-    }
-
-    public void setBundleContext(final BundleContext bundleContext) {
-        this.bundleContext = bundleContext;
-    }
-
-    private static class ForwardingEntityOwnershipService extends ForwardingObject
-            implements EntityOwnershipService, AutoCloseable {
-        private final EntityOwnershipService delegate;
-        private final AutoCloseable closeable;
-
-        public ForwardingEntityOwnershipService(EntityOwnershipService delegate, AutoCloseable closeable) {
-            this.delegate = delegate;
-            this.closeable = closeable;
-        }
-
-        @Override
-        public EntityOwnershipCandidateRegistration registerCandidate(Entity entity)
-                throws CandidateAlreadyRegisteredException {
-            return delegate().registerCandidate(entity);
-        }
-
-        @Override
-        public EntityOwnershipListenerRegistration registerListener(String entityType,
-                EntityOwnershipListener listener) {
-            return delegate().registerListener(entityType, listener);
-        }
-
-        @Override
-        public Optional<EntityOwnershipState> getOwnershipState(Entity forEntity) {
-            return delegate().getOwnershipState(forEntity);
-        }
-
-        @Override
-        public boolean isCandidateRegistered(Entity entity) {
-            return delegate().isCandidateRegistered(entity);
-        }
-
-        @Override
-        protected EntityOwnershipService delegate() {
-            return delegate;
-        }
-
-        @Override
-        public void close() throws Exception {
-            // We don't close the delegate as the life-cycle is controlled via blueprint.
-            closeable.close();
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModuleFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModuleFactory.java
deleted file mode 100644 (file)
index 927398a..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: distributed-entity-ownership-service yang module local name: distributed-entity-ownership-service-provider
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Aug 06 18:06:54 EDT 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.config.distributed_entity_ownership_service;
-
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
-import org.opendaylight.controller.config.spi.Module;
-import org.osgi.framework.BundleContext;
-
-public class DistributedEntityOwnershipServiceProviderModuleFactory extends org.opendaylight.controller.config.yang.config.distributed_entity_ownership_service.AbstractDistributedEntityOwnershipServiceProviderModuleFactory {
-
-    @Override
-    public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
-        DistributedEntityOwnershipServiceProviderModule module = (DistributedEntityOwnershipServiceProviderModule) super.createModule(instanceName, dependencyResolver, bundleContext);
-        module.setBundleContext(bundleContext);
-        return module;
-    }
-
-    @Override
-    public Module createModule(String instanceName, DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
-        DistributedEntityOwnershipServiceProviderModule module = (DistributedEntityOwnershipServiceProviderModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
-        module.setBundleContext(bundleContext);
-        return module;
-    }
-}
index 92f6c7a..d0c8b78 100644 (file)
     <argument ref="selectionStrategyConfig"/>
   </bean>
 
-  <service ref="distributedEntityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"
+  <service ref="distributedEntityOwnershipService" interface="org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService"
         odl:type="default"/>
 </blueprint>
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-entity-ownership-service.yang b/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-entity-ownership-service.yang
deleted file mode 100644 (file)
index 72c4d4f..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-module distributed-entity-ownership-service {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:controller:config:distributed-entity-ownership-service";
-    prefix "distributed-entity-ownership-service";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-operational-dom-datastore {prefix operational-dom-store-spi;}
-    import opendaylight-entity-ownership-service { prefix entity-ownership-service-spi; }
-
-    description
-        "This module contains the base YANG definitions for the DistributedEntityOwnershipService implementation";
-
-    revision "2015-08-10" {
-        description "Initial revision.";
-    }
-
-    // This is the definition of the service implementation as a module identity.
-    identity distributed-entity-ownership-service-provider {
-        base config:module-type;
-        config:provided-service entity-ownership-service-spi:entity-ownership-service;
-        config:java-name-prefix DistributedEntityOwnershipServiceProvider;
-    }
-
-    //  Augments the 'configuration' choice node under modules/module.
-    augment "/config:modules/config:module/config:configuration" {
-        case distributed-entity-ownership-service-provider {
-            when "/config:modules/config:module/config:type = 'distributed-entity-ownership-service-provider'";
-                container data-store {
-                    uses config:service-ref {
-                        refine type {
-                            mandatory false;
-                            config:required-identity operational-dom-store-spi:operational-dom-datastore;
-                        }
-                    }
-                }
-        }
-    }
-}
\ No newline at end of file
index 9315cc2..f93ac28 100644 (file)
@@ -29,8 +29,9 @@ import org.mockito.ArgumentMatcher;
 import org.mockito.Matchers;
 import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
 import org.opendaylight.controller.cluster.datastore.ShardDataTree;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.EntityOwners;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.EntityType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.entity.type.entity.Candidate;
@@ -172,34 +173,36 @@ public class AbstractEntityOwnershipTest extends AbstractActorTest {
         shardDataTree.notifyListeners(shardDataTree.commit(modification));
     }
 
-    static EntityOwnershipChange ownershipChange(final Entity expEntity, final boolean expWasOwner,
+    static DOMEntityOwnershipChange ownershipChange(final DOMEntity expEntity, final boolean expWasOwner,
             final boolean expIsOwner, final boolean expHasOwner) {
-        return Matchers.argThat(new ArgumentMatcher<EntityOwnershipChange>() {
+        return Matchers.argThat(new ArgumentMatcher<DOMEntityOwnershipChange>() {
             @Override
             public boolean matches(Object argument) {
-                EntityOwnershipChange change = (EntityOwnershipChange) argument;
-                return expEntity.equals(change.getEntity()) && expWasOwner == change.wasOwner() &&
-                        expIsOwner == change.isOwner() && expHasOwner == change.hasOwner();
+                DOMEntityOwnershipChange change = (DOMEntityOwnershipChange) argument;
+                return expEntity.equals(change.getEntity()) && expWasOwner == change.getState().wasOwner() &&
+                        expIsOwner == change.getState().isOwner() && expHasOwner == change.getState().hasOwner();
             }
 
             @Override
             public void describeTo(Description description) {
-                description.appendValue(new EntityOwnershipChange(expEntity, expWasOwner, expIsOwner, expHasOwner));
+                description.appendValue(new DOMEntityOwnershipChange(expEntity, EntityOwnershipChangeState.from(
+                        expWasOwner, expIsOwner, expHasOwner)));
             }
         });
     }
 
-    static EntityOwnershipChange ownershipChange(final Entity expEntity) {
-        return Matchers.argThat(new ArgumentMatcher<EntityOwnershipChange>() {
+    static DOMEntityOwnershipChange ownershipChange(final DOMEntity expEntity) {
+        return Matchers.argThat(new ArgumentMatcher<DOMEntityOwnershipChange>() {
             @Override
             public boolean matches(Object argument) {
-                EntityOwnershipChange change = (EntityOwnershipChange) argument;
+                DOMEntityOwnershipChange change = (DOMEntityOwnershipChange) argument;
                 return expEntity.equals(change.getEntity());
             }
 
             @Override
             public void describeTo(Description description) {
-                description.appendValue(new EntityOwnershipChange(expEntity, false, false, false));
+                description.appendValue(new DOMEntityOwnershipChange(expEntity, EntityOwnershipChangeState.from(
+                        false, false, false)));
             }
         });
     }
index c03f869..893ac52 100644 (file)
@@ -55,13 +55,13 @@ import org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolic
 import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
 import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
-import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
-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.EntityOwnershipChange;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
+import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.entity.type.entity.Candidate;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
@@ -79,11 +79,11 @@ public class DistributedEntityOwnershipIntegrationTest {
     private static final String MODULE_SHARDS_MEMBER_1_CONFIG = "module-shards-default-member-1.conf";
     private static final String ENTITY_TYPE1 = "entityType1";
     private static final String ENTITY_TYPE2 = "entityType2";
-    private static final Entity ENTITY1 = new Entity(ENTITY_TYPE1, "entity1");
-    private static final Entity ENTITY1_2 = new Entity(ENTITY_TYPE2, "entity1");
-    private static final Entity ENTITY2 = new Entity(ENTITY_TYPE1, "entity2");
-    private static final Entity ENTITY3 = new Entity(ENTITY_TYPE1, "entity3");
-    private static final Entity ENTITY4 = new Entity(ENTITY_TYPE1, "entity4");
+    private static final DOMEntity ENTITY1 = new DOMEntity(ENTITY_TYPE1, "entity1");
+    private static final DOMEntity ENTITY1_2 = new DOMEntity(ENTITY_TYPE2, "entity1");
+    private static final DOMEntity ENTITY2 = new DOMEntity(ENTITY_TYPE1, "entity2");
+    private static final DOMEntity ENTITY3 = new DOMEntity(ENTITY_TYPE1, "entity3");
+    private static final DOMEntity ENTITY4 = new DOMEntity(ENTITY_TYPE1, "entity4");
     private static final SchemaContext SCHEMA_CONTEXT = SchemaContextHelper.entityOwners();
 
     private final DatastoreContext.Builder leaderDatastoreContextBuilder =
@@ -96,16 +96,16 @@ public class DistributedEntityOwnershipIntegrationTest {
     private final List<MemberNode> memberNodes = new ArrayList<>();
 
     @Mock
-    private EntityOwnershipListener leaderMockListener;
+    private DOMEntityOwnershipListener leaderMockListener;
 
     @Mock
-    private EntityOwnershipListener leaderMockListener2;
+    private DOMEntityOwnershipListener leaderMockListener2;
 
     @Mock
-    private EntityOwnershipListener follower1MockListener;
+    private DOMEntityOwnershipListener follower1MockListener;
 
     @Mock
-    private EntityOwnershipListener follower2MockListener;
+    private DOMEntityOwnershipListener follower2MockListener;
 
     @Before
     public void setUp() {
@@ -148,9 +148,9 @@ public class DistributedEntityOwnershipIntegrationTest {
         follower1Node.configDataStore().waitTillReady();
         follower2Node.configDataStore().waitTillReady();
 
-        EntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
-        EntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
-        EntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
+        DOMEntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
+        DOMEntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
+        DOMEntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
 
         leaderNode.kit().waitUntilLeader(leaderNode.configDataStore().getActorContext(), ENTITY_OWNERSHIP_SHARD_NAME);
 
@@ -165,8 +165,8 @@ public class DistributedEntityOwnershipIntegrationTest {
         verify(follower1MockListener, timeout(5000)).ownershipChanged(ownershipChange(ENTITY1, false, false, true));
         reset(leaderMockListener, follower1MockListener);
 
-        verifyGetOwnershipState(leaderEntityOwnershipService, ENTITY1, true, true);
-        verifyGetOwnershipState(follower1EntityOwnershipService, ENTITY1, false, true);
+        verifyGetOwnershipState(leaderEntityOwnershipService, ENTITY1, EntityOwnershipState.IS_OWNER);
+        verifyGetOwnershipState(follower1EntityOwnershipService, ENTITY1, EntityOwnershipState.OWNED_BY_OTHER);
 
         // Register leader candidate for entity1_2 (same id, different type) and verify it becomes owner
 
@@ -187,7 +187,7 @@ public class DistributedEntityOwnershipIntegrationTest {
 
         // Register follower1 candidate for entity2 and verify it becomes owner
 
-        EntityOwnershipCandidateRegistration follower1Entity2Reg = follower1EntityOwnershipService.registerCandidate(ENTITY2);
+        DOMEntityOwnershipCandidateRegistration follower1Entity2Reg = follower1EntityOwnershipService.registerCandidate(ENTITY2);
         verify(follower1MockListener, timeout(5000)).ownershipChanged(ownershipChange(ENTITY2, false, true, true));
         verify(leaderMockListener, timeout(5000)).ownershipChanged(ownershipChange(ENTITY2, false, false, true));
         reset(leaderMockListener, follower1MockListener);
@@ -252,7 +252,7 @@ public class DistributedEntityOwnershipIntegrationTest {
 
         // Register leader candidate for entity2 and verify it becomes owner
 
-        EntityOwnershipCandidateRegistration leaderEntity2Reg = leaderEntityOwnershipService.registerCandidate(ENTITY2);
+        DOMEntityOwnershipCandidateRegistration leaderEntity2Reg = leaderEntityOwnershipService.registerCandidate(ENTITY2);
         verify(leaderMockListener, timeout(5000)).ownershipChanged(ownershipChange(ENTITY2, false, true, true));
         verifyOwner(leaderDistributedDataStore, ENTITY2, "member-1");
 
@@ -288,9 +288,9 @@ public class DistributedEntityOwnershipIntegrationTest {
         follower1Node.configDataStore().waitTillReady();
         follower2Node.configDataStore().waitTillReady();
 
-        EntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
-        EntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
-        EntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
+        DOMEntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
+        DOMEntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
+        DOMEntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
 
         leaderNode.kit().waitUntilLeader(leaderNode.configDataStore().getActorContext(), ENTITY_OWNERSHIP_SHARD_NAME);
 
@@ -371,11 +371,11 @@ public class DistributedEntityOwnershipIntegrationTest {
         follower1Node.configDataStore().waitTillReady();
         follower2Node.configDataStore().waitTillReady();
 
-        EntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
-        EntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
-        EntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
-        EntityOwnershipService follower3EntityOwnershipService = newOwnershipService(follower3Node.configDataStore());
-        EntityOwnershipService follower4EntityOwnershipService = newOwnershipService(follower4Node.configDataStore());
+        DOMEntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
+        DOMEntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
+        DOMEntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
+        DOMEntityOwnershipService follower3EntityOwnershipService = newOwnershipService(follower3Node.configDataStore());
+        DOMEntityOwnershipService follower4EntityOwnershipService = newOwnershipService(follower4Node.configDataStore());
 
         leaderNode.kit().waitUntilLeader(leaderNode.configDataStore().getActorContext(), ENTITY_OWNERSHIP_SHARD_NAME);
 
@@ -460,9 +460,9 @@ public class DistributedEntityOwnershipIntegrationTest {
         follower1Node.configDataStore().waitTillReady();
         follower2Node.configDataStore().waitTillReady();
 
-        EntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
-        EntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
-        EntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
+        DOMEntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
+        DOMEntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
+        DOMEntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
 
         leaderNode.kit().waitUntilLeader(leaderNode.configDataStore().getActorContext(), ENTITY_OWNERSHIP_SHARD_NAME);
 
@@ -470,17 +470,17 @@ public class DistributedEntityOwnershipIntegrationTest {
         follower1EntityOwnershipService.registerListener(ENTITY_TYPE1, follower1MockListener);
         follower2EntityOwnershipService.registerListener(ENTITY_TYPE1, follower2MockListener);
 
-        final EntityOwnershipCandidateRegistration candidate1 = leaderEntityOwnershipService.registerCandidate(ENTITY1);
+        final DOMEntityOwnershipCandidateRegistration candidate1 = leaderEntityOwnershipService.registerCandidate(ENTITY1);
         verify(leaderMockListener, timeout(5000)).ownershipChanged(ownershipChange(ENTITY1, false, true, true));
 
-        final EntityOwnershipCandidateRegistration candidate2 = follower1EntityOwnershipService.registerCandidate(ENTITY1);
-        final EntityOwnershipCandidateRegistration candidate3 = follower2EntityOwnershipService.registerCandidate(ENTITY1);
+        final DOMEntityOwnershipCandidateRegistration candidate2 = follower1EntityOwnershipService.registerCandidate(ENTITY1);
+        final DOMEntityOwnershipCandidateRegistration candidate3 = follower2EntityOwnershipService.registerCandidate(ENTITY1);
 
         Mockito.reset(leaderMockListener);
 
-        ArgumentCaptor<EntityOwnershipChange> leaderChangeCaptor = ArgumentCaptor.forClass(EntityOwnershipChange.class);
-        ArgumentCaptor<EntityOwnershipChange> follower1ChangeCaptor = ArgumentCaptor.forClass(EntityOwnershipChange.class);
-        ArgumentCaptor<EntityOwnershipChange> follower2ChangeCaptor = ArgumentCaptor.forClass(EntityOwnershipChange.class);
+        ArgumentCaptor<DOMEntityOwnershipChange> leaderChangeCaptor = ArgumentCaptor.forClass(DOMEntityOwnershipChange.class);
+        ArgumentCaptor<DOMEntityOwnershipChange> follower1ChangeCaptor = ArgumentCaptor.forClass(DOMEntityOwnershipChange.class);
+        ArgumentCaptor<DOMEntityOwnershipChange> follower2ChangeCaptor = ArgumentCaptor.forClass(DOMEntityOwnershipChange.class);
         doNothing().when(leaderMockListener).ownershipChanged(leaderChangeCaptor.capture());
         doNothing().when(follower1MockListener).ownershipChanged(follower1ChangeCaptor.capture());
         doNothing().when(follower2MockListener).ownershipChanged(follower2ChangeCaptor.capture());
@@ -493,14 +493,14 @@ public class DistributedEntityOwnershipIntegrationTest {
         for(int i=0;i<100;i++) {
             Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
             if(!leaderEntityOwnershipService.getOwnershipState(ENTITY1).isPresent() ||
-                    !leaderEntityOwnershipService.getOwnershipState(ENTITY1).get().hasOwner() &&
+                    leaderEntityOwnershipService.getOwnershipState(ENTITY1).get() == EntityOwnershipState.NO_OWNER &&
                     follower1EntityOwnershipService.getOwnershipState(ENTITY1).isPresent() &&
-                    !follower1EntityOwnershipService.getOwnershipState(ENTITY1).get().hasOwner() &&
+                    follower1EntityOwnershipService.getOwnershipState(ENTITY1).get() == EntityOwnershipState.NO_OWNER &&
                     follower2EntityOwnershipService.getOwnershipState(ENTITY1).isPresent() &&
-                    !follower2EntityOwnershipService.getOwnershipState(ENTITY1).get().hasOwner() &&
-                    leaderChangeCaptor.getAllValues().size() > 0 && !leaderChangeCaptor.getValue().hasOwner() &&
-                    leaderChangeCaptor.getAllValues().size() > 0 && !follower1ChangeCaptor.getValue().hasOwner() &&
-                    leaderChangeCaptor.getAllValues().size() > 0 && !follower2ChangeCaptor.getValue().hasOwner()) {
+                    follower2EntityOwnershipService.getOwnershipState(ENTITY1).get() == EntityOwnershipState.NO_OWNER &&
+                    leaderChangeCaptor.getAllValues().size() > 0 && !leaderChangeCaptor.getValue().getState().hasOwner() &&
+                    leaderChangeCaptor.getAllValues().size() > 0 && !follower1ChangeCaptor.getValue().getState().hasOwner() &&
+                    leaderChangeCaptor.getAllValues().size() > 0 && !follower2ChangeCaptor.getValue().getState().hasOwner()) {
                 passed = true;
                 break;
             }
@@ -523,7 +523,7 @@ public class DistributedEntityOwnershipIntegrationTest {
                 datastoreContextBuilder(leaderDatastoreContextBuilder).build();
 
         DistributedDataStore leaderDistributedDataStore = leaderNode.configDataStore();
-        EntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
+        DOMEntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
 
         leaderNode.kit().waitUntilLeader(leaderNode.configDataStore().getActorContext(), ENTITY_OWNERSHIP_SHARD_NAME);
 
@@ -537,12 +537,12 @@ public class DistributedEntityOwnershipIntegrationTest {
         leaderNode.waitForMembersUp("member-2");
         follower1Node.waitForMembersUp("member-1");
 
-        EntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1DistributedDataStore);
+        DOMEntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1DistributedDataStore);
 
         leaderEntityOwnershipService.registerListener(ENTITY_TYPE1, leaderMockListener);
 
         // Register a candidate for follower1 - should get queued since follower1 has no leader
-        EntityOwnershipCandidateRegistration candidateReg = follower1EntityOwnershipService.registerCandidate(ENTITY1);
+        DOMEntityOwnershipCandidateRegistration candidateReg = follower1EntityOwnershipService.registerCandidate(ENTITY1);
         Uninterruptibles.sleepUninterruptibly(300, TimeUnit.MILLISECONDS);
         verify(leaderMockListener, never()).ownershipChanged(ownershipChange(ENTITY1));
 
@@ -603,15 +603,15 @@ public class DistributedEntityOwnershipIntegrationTest {
         follower1Node.configDataStore().waitTillReady();
         follower2Node.configDataStore().waitTillReady();
 
-        EntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
-        EntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
-        EntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
+        DOMEntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
+        DOMEntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
+        DOMEntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
 
         leaderNode.kit().waitUntilLeader(leaderNode.configDataStore().getActorContext(), ENTITY_OWNERSHIP_SHARD_NAME);
 
         // Register leader candidate for entity1 and verify it becomes owner
 
-        EntityOwnershipCandidateRegistration leaderEntity1Reg = leaderEntityOwnershipService.registerCandidate(ENTITY1);
+        DOMEntityOwnershipCandidateRegistration leaderEntity1Reg = leaderEntityOwnershipService.registerCandidate(ENTITY1);
 
         verifyCandidates(leaderDistributedDataStore, ENTITY1, "member-1");
         verifyOwner(leaderDistributedDataStore, ENTITY1, "member-1");
@@ -644,15 +644,15 @@ public class DistributedEntityOwnershipIntegrationTest {
         follower1Node.configDataStore().waitTillReady();
         follower2Node.configDataStore().waitTillReady();
 
-        EntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
-        EntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
-        EntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
+        DOMEntityOwnershipService leaderEntityOwnershipService = newOwnershipService(leaderDistributedDataStore);
+        DOMEntityOwnershipService follower1EntityOwnershipService = newOwnershipService(follower1Node.configDataStore());
+        DOMEntityOwnershipService follower2EntityOwnershipService = newOwnershipService(follower2Node.configDataStore());
 
         leaderNode.kit().waitUntilLeader(leaderNode.configDataStore().getActorContext(), ENTITY_OWNERSHIP_SHARD_NAME);
 
         // Register leader candidate for entity1 and verify it becomes owner
 
-        EntityOwnershipCandidateRegistration leaderEntity1Reg = leaderEntityOwnershipService.registerCandidate(ENTITY1);
+        DOMEntityOwnershipCandidateRegistration leaderEntity1Reg = leaderEntityOwnershipService.registerCandidate(ENTITY1);
 
         verifyCandidates(leaderDistributedDataStore, ENTITY1, "member-1");
         verifyOwner(leaderDistributedDataStore, ENTITY1, "member-1");
@@ -664,20 +664,19 @@ public class DistributedEntityOwnershipIntegrationTest {
         verifyOwner(leaderDistributedDataStore, ENTITY1, "member-2");
     }
 
-    private static void verifyGetOwnershipState(EntityOwnershipService service, Entity entity,
-            boolean isOwner, boolean hasOwner) {
+    private static void verifyGetOwnershipState(final DOMEntityOwnershipService service, final DOMEntity entity,
+            final EntityOwnershipState expState) {
         Optional<EntityOwnershipState> state = service.getOwnershipState(entity);
         assertEquals("getOwnershipState present", true, state.isPresent());
-        assertEquals("isOwner", isOwner, state.get().isOwner());
-        assertEquals("hasOwner", hasOwner, state.get().hasOwner());
+        assertEquals("EntityOwnershipState", expState, state.get());
     }
 
-    private static void verifyCandidates(final DistributedDataStore dataStore, final Entity entity, final String... expCandidates) throws Exception {
+    private static void verifyCandidates(final DistributedDataStore dataStore, final DOMEntity entity, final String... expCandidates) throws Exception {
         AssertionError lastError = null;
         Stopwatch sw = Stopwatch.createStarted();
         while(sw.elapsed(TimeUnit.MILLISECONDS) <= 10000) {
             Optional<NormalizedNode<?, ?>> possible = dataStore.newReadOnlyTransaction().read(
-                    entityPath(entity.getType(), entity.getId()).node(Candidate.QNAME)).get(5, TimeUnit.SECONDS);
+                    entityPath(entity.getType(), entity.getIdentifier()).node(Candidate.QNAME)).get(5, TimeUnit.SECONDS);
             try {
                 assertEquals("Candidates not found for " + entity, true, possible.isPresent());
                 Collection<String> actual = new ArrayList<>();
@@ -696,8 +695,8 @@ public class DistributedEntityOwnershipIntegrationTest {
         throw lastError;
     }
 
-    private static void verifyOwner(final DistributedDataStore dataStore, final Entity entity, final String expOwner) {
-        AbstractEntityOwnershipTest.verifyOwner(expOwner, entity.getType(), entity.getId(),
+    private static void verifyOwner(final DistributedDataStore dataStore, final DOMEntity entity, final String expOwner) {
+        AbstractEntityOwnershipTest.verifyOwner(expOwner, entity.getType(), entity.getIdentifier(),
                 path -> {
                     try {
                         return dataStore.newReadOnlyTransaction().read(path).get(5, TimeUnit.SECONDS).get();
index 9343f38..6d092cf 100644 (file)
@@ -52,12 +52,12 @@ import org.opendaylight.controller.cluster.datastore.entityownership.messages.Un
 import org.opendaylight.controller.cluster.datastore.entityownership.selectionstrategy.EntityOwnerSelectionStrategyConfig;
 import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
-import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
-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.EntityOwnershipListener;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
+import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
@@ -131,9 +131,9 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh
             dataStore.getActorContext(), EntityOwnerSelectionStrategyConfig.newBuilder().build()));
 
         YangInstanceIdentifier entityId = YangInstanceIdentifier.of(QNAME);
-        Entity entity = new Entity(ENTITY_TYPE, entityId);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
 
-        EntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
+        DOMEntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
         verifyRegisterCandidateLocal(service, entity);
         verifyEntityOwnershipCandidateRegistration(entity, reg);
         verifyEntityCandidate(service.getLocalEntityOwnershipShard(), ENTITY_TYPE, entityId,
@@ -152,9 +152,9 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh
         // Register a different entity - should succeed
         reset(service);
 
-        Entity entity2 = new Entity(ENTITY_TYPE2, entityId);
-        EntityOwnershipCandidateRegistration reg2 = service.registerCandidate(entity2);
-        verifyRegisterCandidateLocal(service, entity2);
+        DOMEntity entity2 = new DOMEntity(ENTITY_TYPE2, entityId);
+        DOMEntityOwnershipCandidateRegistration reg2 = service.registerCandidate(entity2);
+
         verifyEntityOwnershipCandidateRegistration(entity2, reg2);
         verifyEntityCandidate(service.getLocalEntityOwnershipShard(), ENTITY_TYPE2, entityId,
                 dataStore.getActorContext().getCurrentMemberName().getName());
@@ -167,8 +167,9 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh
         DistributedEntityOwnershipService service = spy(DistributedEntityOwnershipService.start(
             dataStore.getActorContext(), EntityOwnerSelectionStrategyConfig.newBuilder().build()));
 
-        Entity entity = new Entity(ENTITY_TYPE, YangInstanceIdentifier.of(QNAME));
-        EntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, YangInstanceIdentifier.of(QNAME));
+
+        DOMEntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
 
         verifyEntityOwnershipCandidateRegistration(entity, reg);
         verifyRegisterCandidateLocal(service, entity);
@@ -192,10 +193,10 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh
             dataStore.getActorContext(), EntityOwnerSelectionStrategyConfig.newBuilder().build()));
 
         YangInstanceIdentifier entityId = YangInstanceIdentifier.of(QNAME);
-        Entity entity = new Entity(ENTITY_TYPE, entityId);
-        EntityOwnershipListener listener = mock(EntityOwnershipListener.class);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
+        DOMEntityOwnershipListener listener = mock(DOMEntityOwnershipListener.class);
 
-        EntityOwnershipListenerRegistration reg = service.registerListener(entity.getType(), listener);
+        DOMEntityOwnershipListenerRegistration reg = service.registerListener(entity.getType(), listener);
 
         assertNotNull("EntityOwnershipListenerRegistration null", reg);
         assertEquals("getEntityType", entity.getType(), reg.getEntityType());
@@ -223,31 +224,33 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh
 
         when(service.getLocalEntityOwnershipShardDataTree()).thenReturn(shardDataTree.getDataTree());
 
-        Entity entity1 = new Entity(ENTITY_TYPE, "one");
-        writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, entity1.getId(), "member-1"), shardDataTree);
+        DOMEntity entity1 = new DOMEntity(ENTITY_TYPE, "one");
+        writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, entity1.getIdentifier(), "member-1"), shardDataTree);
         writeNode(ENTITY_OWNERS_PATH, entityOwnersWithEntityTypeEntry(entityTypeEntryWithEntityEntry(entity1.getType(),
-                entityEntryWithOwner(entity1.getId(), "member-1"))), shardDataTree);
-        verifyGetOwnershipState(service, entity1, true, true);
+                entityEntryWithOwner(entity1.getIdentifier(), "member-1"))), shardDataTree);
+        verifyGetOwnershipState(service, entity1, EntityOwnershipState.IS_OWNER);
 
-        writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, entity1.getId(), "member-2"), shardDataTree);
-        writeNode(entityPath(entity1.getType(), entity1.getId()), entityEntryWithOwner(entity1.getId(), "member-2"),
-                shardDataTree);
-        verifyGetOwnershipState(service, entity1, false, true);
+        writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE,
+                entity1.getIdentifier(), "member-2"), shardDataTree);
+        writeNode(entityPath(entity1.getType(), entity1.getIdentifier()),
+                entityEntryWithOwner(entity1.getIdentifier(), "member-2"), shardDataTree);
+        verifyGetOwnershipState(service, entity1, EntityOwnershipState.OWNED_BY_OTHER);
 
-        writeNode(entityPath(entity1.getType(), entity1.getId()), entityEntryWithOwner(entity1.getId(), ""),
+        writeNode(entityPath(entity1.getType(), entity1.getIdentifier()), entityEntryWithOwner(entity1.getIdentifier(), ""),
                 shardDataTree);
-        verifyGetOwnershipState(service, entity1, false, false);
+        verifyGetOwnershipState(service, entity1, EntityOwnershipState.NO_OWNER);
 
-        Entity entity2 = new Entity(ENTITY_TYPE, "two");
+        DOMEntity entity2 = new DOMEntity(ENTITY_TYPE, "two");
         Optional<EntityOwnershipState> state = service.getOwnershipState(entity2);
         assertEquals("getOwnershipState present", false, state.isPresent());
 
-        writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, entity2.getId(), "member-1"), shardDataTree);
-        writeNode(entityPath(entity2.getType(), entity2.getId()), ImmutableNodes.mapEntry(ENTITY_QNAME,
-                ENTITY_ID_QNAME, entity2.getId()), shardDataTree);
-        verifyGetOwnershipState(service, entity2, false, false);
+        writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, entity2.getIdentifier(), "member-1"),
+                shardDataTree);
+        writeNode(entityPath(entity2.getType(), entity2.getIdentifier()), ImmutableNodes.mapEntry(ENTITY_QNAME,
+                ENTITY_ID_QNAME, entity2.getIdentifier()), shardDataTree);
+        verifyGetOwnershipState(service, entity2, EntityOwnershipState.NO_OWNER);
 
-        deleteNode(candidatePath(entityPath(entity2.getType(), entity2.getId()), "member-1"), shardDataTree);
+        deleteNode(candidatePath(entityPath(entity2.getType(), entity2.getIdentifier()), "member-1"), shardDataTree);
         Optional<EntityOwnershipState> state2 = service.getOwnershipState(entity2);
         assertEquals("getOwnershipState present", false, state2.isPresent());
         service.close();
@@ -258,7 +261,7 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh
         DistributedEntityOwnershipService service = DistributedEntityOwnershipService.start(dataStore.getActorContext(),
                 EntityOwnerSelectionStrategyConfig.newBuilder().build());
 
-        final Entity test = new Entity("test-type", "test");
+        final DOMEntity test = new DOMEntity("test-type", "test");
 
         assertFalse(service.isCandidateRegistered(test));
 
@@ -269,12 +272,11 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh
         service.close();
     }
 
-    private static void verifyGetOwnershipState(final DistributedEntityOwnershipService service, final Entity entity,
-            final boolean isOwner, final boolean hasOwner) {
+    private static void verifyGetOwnershipState(final DistributedEntityOwnershipService service, final DOMEntity entity,
+            final EntityOwnershipState expState) {
         Optional<EntityOwnershipState> state = service.getOwnershipState(entity);
         assertEquals("getOwnershipState present", true, state.isPresent());
-        assertEquals("isOwner", isOwner, state.get().isOwner());
-        assertEquals("hasOwner", hasOwner, state.get().hasOwner());
+        assertEquals("EntityOwnershipState", expState, state.get());
     }
 
     private void verifyEntityCandidate(final ActorRef entityOwnershipShard, final String entityType,
@@ -289,12 +291,13 @@ public class DistributedEntityOwnershipServiceTest extends AbstractEntityOwnersh
                 });
     }
 
-    private static void verifyRegisterCandidateLocal(final DistributedEntityOwnershipService service, final Entity entity) {
+    private static void verifyRegisterCandidateLocal(final DistributedEntityOwnershipService service, final DOMEntity entity) {
         RegisterCandidateLocal regCandidate = verifyMessage(service, RegisterCandidateLocal.class);
         assertEquals("getEntity", entity, regCandidate.getEntity());
     }
 
-    private static void verifyEntityOwnershipCandidateRegistration(final Entity entity, final EntityOwnershipCandidateRegistration reg) {
+    private static void verifyEntityOwnershipCandidateRegistration(final DOMEntity entity,
+            final DOMEntityOwnershipCandidateRegistration reg) {
         assertNotNull("EntityOwnershipCandidateRegistration null", reg);
         assertEquals("getInstance", entity, reg.getInstance());
     }
index 0385496..3c4fea0 100644 (file)
@@ -22,7 +22,7 @@ import org.junit.Test;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.datastore.ShardDataTree;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -44,8 +44,8 @@ public class EntityOwnerChangeListenerTest {
             YangInstanceIdentifier.of(QName.create("test", "2015-08-14", "entity1"));
     private static final YangInstanceIdentifier ENTITY_ID2 =
             YangInstanceIdentifier.of(QName.create("test", "2015-08-14", "entity2"));
-    private static final Entity ENTITY1 = new Entity(ENTITY_TYPE, ENTITY_ID1);
-    private static final Entity ENTITY2 = new Entity(ENTITY_TYPE, ENTITY_ID2);
+    private static final DOMEntity ENTITY1 = new DOMEntity(ENTITY_TYPE, ENTITY_ID1);
+    private static final DOMEntity ENTITY2 = new DOMEntity(ENTITY_TYPE, ENTITY_ID2);
 
     private final ShardDataTree shardDataTree = new ShardDataTree(SchemaContextHelper.entityOwners(),
         TreeType.OPERATIONAL);
@@ -62,7 +62,7 @@ public class EntityOwnerChangeListenerTest {
     public void testOnDataTreeChanged() throws Exception {
         writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID1, LOCAL_MEMBER_NAME));
         writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID2, LOCAL_MEMBER_NAME));
-        verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(Entity.class), anyBoolean(),
+        verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(DOMEntity.class), anyBoolean(),
                 anyBoolean(), anyBoolean());
 
         // Write local member as owner for entity 1
@@ -74,7 +74,7 @@ public class EntityOwnerChangeListenerTest {
 
         reset(mockListenerSupport);
         writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID1, REMOTE_MEMBER_NAME1));
-        verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(Entity.class), anyBoolean(),
+        verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(DOMEntity.class), anyBoolean(),
                 anyBoolean(), anyBoolean());
 
         // Change owner to remote member 1 for entity 1
@@ -116,7 +116,7 @@ public class EntityOwnerChangeListenerTest {
 
         reset(mockListenerSupport);
         writeNode(entityPath(ENTITY_TYPE, ENTITY_ID2), entityEntryWithOwner(ENTITY_ID2, LOCAL_MEMBER_NAME));
-        verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(Entity.class), anyBoolean(),
+        verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(DOMEntity.class), anyBoolean(),
                 anyBoolean(), anyBoolean());
 
         // Clear the owner for entity 2
@@ -129,7 +129,7 @@ public class EntityOwnerChangeListenerTest {
 
         reset(mockListenerSupport);
         writeNode(entityPath(ENTITY_TYPE, ENTITY_ID2), entityEntryWithOwner(ENTITY_ID2, null));
-        verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(Entity.class), anyBoolean(),
+        verify(mockListenerSupport, never()).notifyEntityOwnershipListeners(any(DOMEntity.class), anyBoolean(),
                 anyBoolean(), anyBoolean());
     }
 
index ef8e951..fe12a86 100644 (file)
@@ -17,9 +17,10 @@ import akka.testkit.TestActorRef;
 import org.junit.After;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.TestActorFactory;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
@@ -38,34 +39,37 @@ public class EntityOwnershipListenerActorTest extends AbstractEntityOwnershipTes
 
     @Test
     public void testOnEntityOwnershipChanged() {
-        EntityOwnershipListener mockListener = mock(EntityOwnershipListener.class);
+        DOMEntityOwnershipListener mockListener = mock(DOMEntityOwnershipListener.class);
 
         TestActorRef<EntityOwnershipListenerActor> listenerActor = actorFactory.createTestActor(
                 EntityOwnershipListenerActor.props(mockListener), actorFactory.generateActorId("listener"));
 
-        Entity entity = new Entity("test", YangInstanceIdentifier.of(QName.create("test", "id1")));
+        DOMEntity entity = new DOMEntity("test", YangInstanceIdentifier.of(QName.create("test", "id1")));
         boolean wasOwner = false;
         boolean isOwner = true;
         boolean hasOwner = true;
-        listenerActor.tell(new EntityOwnershipChange(entity, wasOwner, isOwner, hasOwner), ActorRef.noSender());
+        listenerActor.tell(new DOMEntityOwnershipChange(entity, EntityOwnershipChangeState.from(
+                wasOwner, isOwner, hasOwner)), ActorRef.noSender());
 
         verify(mockListener, timeout(5000)).ownershipChanged(ownershipChange(entity, wasOwner, isOwner, hasOwner));
     }
 
     @Test
     public void testOnEntityOwnershipChangedWithListenerEx() {
-        EntityOwnershipListener mockListener = mock(EntityOwnershipListener.class);
+        DOMEntityOwnershipListener mockListener = mock(DOMEntityOwnershipListener.class);
 
-        Entity entity1 = new Entity("test", YangInstanceIdentifier.of(QName.create("test", "id1")));
+        DOMEntity entity1 = new DOMEntity("test", YangInstanceIdentifier.of(QName.create("test", "id1")));
         doThrow(new RuntimeException("mock")).when(mockListener).ownershipChanged(ownershipChange(entity1, false, true, true));
-        Entity entity2 = new Entity("test", YangInstanceIdentifier.of(QName.create("test", "id2")));
+        DOMEntity entity2 = new DOMEntity("test", YangInstanceIdentifier.of(QName.create("test", "id2")));
         doNothing().when(mockListener).ownershipChanged(ownershipChange(entity2, true, false, false));
 
         TestActorRef<EntityOwnershipListenerActor> listenerActor = actorFactory.createTestActor(
                 EntityOwnershipListenerActor.props(mockListener), actorFactory.generateActorId("listener"));
 
-        listenerActor.tell(new EntityOwnershipChange(entity1, false, true, true), ActorRef.noSender());
-        listenerActor.tell(new EntityOwnershipChange(entity2, true, false, false), ActorRef.noSender());
+        listenerActor.tell(new DOMEntityOwnershipChange(entity1, EntityOwnershipChangeState.from(
+                false, true, true)), ActorRef.noSender());
+        listenerActor.tell(new DOMEntityOwnershipChange(entity2, EntityOwnershipChangeState.from(
+                true, false, false)), ActorRef.noSender());
 
         verify(mockListener, timeout(5000)).ownershipChanged(ownershipChange(entity2, true, false, false));
     }
index 27fe827..c4e789e 100644 (file)
@@ -28,9 +28,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.TestActorFactory;
 import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import scala.collection.Iterator;
@@ -62,14 +62,14 @@ public class EntityOwnershipListenerSupportTest extends AbstractEntityOwnershipT
     public void testNotifyEntityOwnershipListeners() {
         EntityOwnershipListenerSupport support = new EntityOwnershipListenerSupport(actorContext, "test");
 
-        EntityOwnershipListener mockListener1 = mock(EntityOwnershipListener.class, "EntityOwnershipListener1");
-        EntityOwnershipListener mockListener2 = mock(EntityOwnershipListener.class, "EntityOwnershipListener2");
-        EntityOwnershipListener mockListener1_2 = mock(EntityOwnershipListener.class, "EntityOwnershipListener1_2");
+        DOMEntityOwnershipListener mockListener1 = mock(DOMEntityOwnershipListener.class, "EntityOwnershipListener1");
+        DOMEntityOwnershipListener mockListener2 = mock(DOMEntityOwnershipListener.class, "EntityOwnershipListener2");
+        DOMEntityOwnershipListener mockListener1_2 = mock(DOMEntityOwnershipListener.class, "EntityOwnershipListener1_2");
         String entityType1 = "type1";
         String entityType2 = "type2";
-        Entity entity1 = new Entity(entityType1, YangInstanceIdentifier.of(QName.create("test", "id1")));
-        Entity entity2 = new Entity(entityType2, YangInstanceIdentifier.of(QName.create("test", "id2")));
-        Entity entity3 = new Entity("noListener", YangInstanceIdentifier.of(QName.create("test", "id5")));
+        DOMEntity entity1 = new DOMEntity(entityType1, YangInstanceIdentifier.of(QName.create("test", "id1")));
+        DOMEntity entity2 = new DOMEntity(entityType2, YangInstanceIdentifier.of(QName.create("test", "id2")));
+        DOMEntity entity3 = new DOMEntity("noListener", YangInstanceIdentifier.of(QName.create("test", "id5")));
 
         // Add EntityOwnershipListener registrations.
 
@@ -85,7 +85,7 @@ public class EntityOwnershipListenerSupportTest extends AbstractEntityOwnershipT
         verify(mockListener1, timeout(5000)).ownershipChanged(ownershipChange(entity1, false, true, true));
         verify(mockListener1_2, timeout(5000)).ownershipChanged(ownershipChange(entity1, false, true, true));
         Uninterruptibles.sleepUninterruptibly(300, TimeUnit.MILLISECONDS);
-        verify(mockListener2, never()).ownershipChanged(any(EntityOwnershipChange.class));
+        verify(mockListener2, never()).ownershipChanged(any(DOMEntityOwnershipChange.class));
         assertEquals("# of listener actors", 2, actorContext.children().size());
         reset(mockListener1, mockListener2, mockListener1_2);
 
@@ -95,8 +95,8 @@ public class EntityOwnershipListenerSupportTest extends AbstractEntityOwnershipT
 
         verify(mockListener2, timeout(5000)).ownershipChanged(ownershipChange(entity2, false, true, true));
         Uninterruptibles.sleepUninterruptibly(300, TimeUnit.MILLISECONDS);
-        verify(mockListener1, never()).ownershipChanged(any(EntityOwnershipChange.class));
-        verify(mockListener1_2, never()).ownershipChanged(any(EntityOwnershipChange.class));
+        verify(mockListener1, never()).ownershipChanged(any(DOMEntityOwnershipChange.class));
+        verify(mockListener1_2, never()).ownershipChanged(any(DOMEntityOwnershipChange.class));
         assertEquals("# of listener actors", 3, actorContext.children().size());
         reset(mockListener1, mockListener2, mockListener1_2);
 
@@ -105,9 +105,9 @@ public class EntityOwnershipListenerSupportTest extends AbstractEntityOwnershipT
         support.notifyEntityOwnershipListeners(entity3, true, false, true);
 
         Uninterruptibles.sleepUninterruptibly(300, TimeUnit.MILLISECONDS);
-        verify(mockListener1, never()).ownershipChanged(any(EntityOwnershipChange.class));
-        verify(mockListener2, never()).ownershipChanged(any(EntityOwnershipChange.class));
-        verify(mockListener1_2, never()).ownershipChanged(any(EntityOwnershipChange.class));
+        verify(mockListener1, never()).ownershipChanged(any(DOMEntityOwnershipChange.class));
+        verify(mockListener2, never()).ownershipChanged(any(DOMEntityOwnershipChange.class));
+        verify(mockListener1_2, never()).ownershipChanged(any(DOMEntityOwnershipChange.class));
         reset(mockListener1, mockListener2, mockListener1_2);
 
         Iterable<ActorRef> listenerActors = actorContext.children();
@@ -120,7 +120,7 @@ public class EntityOwnershipListenerSupportTest extends AbstractEntityOwnershipT
 
         verify(mockListener1_2, timeout(5000)).ownershipChanged(ownershipChange(entity1, true, false, true));
         Uninterruptibles.sleepUninterruptibly(300, TimeUnit.MILLISECONDS);
-        verify(mockListener1, never()).ownershipChanged(any(EntityOwnershipChange.class));
+        verify(mockListener1, never()).ownershipChanged(any(DOMEntityOwnershipChange.class));
         reset(mockListener1, mockListener2, mockListener1_2);
 
         // Unregister all listeners and verify their listener actors are destroyed.
@@ -151,8 +151,8 @@ public class EntityOwnershipListenerSupportTest extends AbstractEntityOwnershipT
         support.notifyEntityOwnershipListeners(entity1, false, false, true);
 
         verify(mockListener1, timeout(5000)).ownershipChanged(ownershipChange(entity1, false, false, true));
-        verify(mockListener1_2, never()).ownershipChanged(any(EntityOwnershipChange.class));
-        verify(mockListener2, never()).ownershipChanged(any(EntityOwnershipChange.class));
+        verify(mockListener1_2, never()).ownershipChanged(any(DOMEntityOwnershipChange.class));
+        verify(mockListener2, never()).ownershipChanged(any(DOMEntityOwnershipChange.class));
 
         // Quickly register and unregister mockListener2 - expecting no exceptions.
 
@@ -163,7 +163,7 @@ public class EntityOwnershipListenerSupportTest extends AbstractEntityOwnershipT
     @Test
     public void testHasCandidateForEntity() {
         EntityOwnershipListenerSupport support = new EntityOwnershipListenerSupport(actorContext, "test");
-        Entity entity = new Entity("type", YangInstanceIdentifier.of(QName.create("test", "id")));
+        DOMEntity entity = new DOMEntity("type", YangInstanceIdentifier.of(QName.create("test", "id")));
 
         assertEquals("hasCandidateForEntity", false, support.hasCandidateForEntity(entity));
 
index 3162981..4810413 100644 (file)
@@ -69,9 +69,9 @@ import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply;
 import org.opendaylight.controller.cluster.raft.messages.RequestVote;
 import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -115,7 +115,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         ShardTestKit.waitUntilLeader(shard);
 
         YangInstanceIdentifier entityId = ENTITY_ID1;
-        Entity entity = new Entity(ENTITY_TYPE, entityId);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
 
         shard.tell(new RegisterCandidateLocal(entity), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
@@ -139,7 +139,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
                 withDispatcher(Dispatchers.DefaultDispatcherId()));
 
         YangInstanceIdentifier entityId = ENTITY_ID1;
-        Entity entity = new Entity(ENTITY_TYPE, entityId);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
 
         shard.tell(new RegisterCandidateLocal(entity), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
@@ -174,7 +174,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         ShardTestKit.waitUntilLeader(shard);
 
         YangInstanceIdentifier entityId = ENTITY_ID1;
-        Entity entity = new Entity(ENTITY_TYPE, entityId);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
 
         shard.tell(new RegisterCandidateLocal(entity), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
@@ -214,7 +214,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
 
         YangInstanceIdentifier entityId = ENTITY_ID1;
-        Entity entity = new Entity(ENTITY_TYPE, entityId);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
 
         shard.tell(new RegisterCandidateLocal(entity), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
@@ -244,7 +244,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         shard.tell(new AppendEntries(1L, peerId, -1L, -1L, Collections.<ReplicatedLogEntry>emptyList(), -1L, -1L,
                 DataStoreVersions.CURRENT_VERSION), peer);
 
-        shard.tell(new RegisterCandidateLocal(new Entity(ENTITY_TYPE, ENTITY_ID1)), kit.getRef());
+        shard.tell(new RegisterCandidateLocal(new DOMEntity(ENTITY_TYPE, ENTITY_ID1)), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
 
         MockLeader leader = peer.underlyingActor();
@@ -260,7 +260,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
 
         shard.tell(dataStoreContextBuilder.shardTransactionCommitTimeoutInSeconds(1).build(), ActorRef.noSender());
 
-        shard.tell(new RegisterCandidateLocal(new Entity(ENTITY_TYPE, ENTITY_ID2)), kit.getRef());
+        shard.tell(new RegisterCandidateLocal(new DOMEntity(ENTITY_TYPE, ENTITY_ID2)), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
 
         assertEquals("Leader received BatchedModifications", true, Uninterruptibles.awaitUninterruptibly(
@@ -277,7 +277,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         for(int i = 1; i <= max; i++) {
             YangInstanceIdentifier id = YangInstanceIdentifier.of(QName.create("test", "2015-08-14", "test" + i));
             entityIds.add(id);
-            shard.tell(new RegisterCandidateLocal(new Entity(ENTITY_TYPE, id)), kit.getRef());
+            shard.tell(new RegisterCandidateLocal(new DOMEntity(ENTITY_TYPE, id)), kit.getRef());
         }
 
         assertEquals("Leader received BatchedModifications", true, Uninterruptibles.awaitUninterruptibly(
@@ -301,7 +301,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         TestActorRef<EntityOwnershipShard> shard = actorFactory.createTestActor(newShardProps());
         ShardTestKit.waitUntilLeader(shard);
 
-        Entity entity = new Entity(ENTITY_TYPE, ENTITY_ID1);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, ENTITY_ID1);
 
         // Register
 
@@ -333,7 +333,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         TestActorRef<EntityOwnershipShard> shard = actorFactory.createTestActor(newShardProps());
         ShardTestKit.waitUntilLeader(shard);
 
-        Entity entity = new Entity(ENTITY_TYPE, ENTITY_ID1);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, ENTITY_ID1);
         ShardDataTree shardDataTree = shard.underlyingActor().getDataStore();
 
         // Add a remote candidate
@@ -429,7 +429,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
 
         // Add candidates for entity1 with the local leader as the owner
 
-        leader.tell(new RegisterCandidateLocal(new Entity(ENTITY_TYPE, ENTITY_ID1)), kit.getRef());
+        leader.tell(new RegisterCandidateLocal(new DOMEntity(ENTITY_TYPE, ENTITY_ID1)), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
         verifyCommittedEntityCandidate(leader, ENTITY_TYPE, ENTITY_ID1, LOCAL_MEMBER_NAME);
 
@@ -454,7 +454,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         commitModification(leader, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID3, peerMemberName2), kit);
         verifyCommittedEntityCandidate(leader, ENTITY_TYPE, ENTITY_ID3, peerMemberName2);
 
-        leader.tell(new RegisterCandidateLocal(new Entity(ENTITY_TYPE, ENTITY_ID3)), kit.getRef());
+        leader.tell(new RegisterCandidateLocal(new DOMEntity(ENTITY_TYPE, ENTITY_ID3)), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
         verifyCommittedEntityCandidate(leader, ENTITY_TYPE, ENTITY_ID3, LOCAL_MEMBER_NAME);
 
@@ -598,8 +598,8 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
 
         shard.tell(new PeerAddressResolved(leaderId.toString(), leader.path().toString()), ActorRef.noSender());
 
-        Entity entity = new Entity(ENTITY_TYPE, ENTITY_ID1);
-        EntityOwnershipListener listener = mock(EntityOwnershipListener.class);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, ENTITY_ID1);
+        DOMEntityOwnershipListener listener = mock(DOMEntityOwnershipListener.class);
 
         shard.tell(new RegisterListenerLocal(listener, ENTITY_TYPE), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
@@ -608,7 +608,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
 
         shard.tell(new RegisterCandidateLocal(entity), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
-        verifyCommittedEntityCandidate(shard, entity.getType(), entity.getId(), LOCAL_MEMBER_NAME);
+        verifyCommittedEntityCandidate(shard, entity.getType(), entity.getIdentifier(), LOCAL_MEMBER_NAME);
         verify(listener, timeout(5000)).ownershipChanged(ownershipChange(entity, false, true, true));
         reset(listener);
 
@@ -621,7 +621,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
 
         // Since the the shard has a local candidate registered, it should re-add its candidate to the entity.
 
-        verifyCommittedEntityCandidate(shard, entity.getType(), entity.getId(), LOCAL_MEMBER_NAME);
+        verifyCommittedEntityCandidate(shard, entity.getType(), entity.getIdentifier(), LOCAL_MEMBER_NAME);
         verify(listener, timeout(5000)).ownershipChanged(ownershipChange(entity, false, true, true));
 
         // Unregister the local candidate and verify it's removed and no re-added.
@@ -629,9 +629,9 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         shard.tell(new UnregisterCandidateLocal(entity), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
 
-        verifyNoEntityCandidate(shard, entity.getType(), entity.getId(), LOCAL_MEMBER_NAME);
+        verifyNoEntityCandidate(shard, entity.getType(), entity.getIdentifier(), LOCAL_MEMBER_NAME);
         Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
-        verifyNoEntityCandidate(shard, entity.getType(), entity.getId(), LOCAL_MEMBER_NAME);
+        verifyNoEntityCandidate(shard, entity.getType(), entity.getIdentifier(), LOCAL_MEMBER_NAME);
     }
 
     @Test
@@ -642,11 +642,11 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         ShardDataTree shardDataTree = shard.underlyingActor().getDataStore();
 
         String otherEntityType = "otherEntityType";
-        Entity entity1 = new Entity(ENTITY_TYPE, ENTITY_ID1);
-        Entity entity2 = new Entity(ENTITY_TYPE, ENTITY_ID2);
-        Entity entity3 = new Entity(ENTITY_TYPE, ENTITY_ID3);
-        Entity entity4 = new Entity(otherEntityType, ENTITY_ID3);
-        EntityOwnershipListener listener = mock(EntityOwnershipListener.class);
+        DOMEntity entity1 = new DOMEntity(ENTITY_TYPE, ENTITY_ID1);
+        DOMEntity entity2 = new DOMEntity(ENTITY_TYPE, ENTITY_ID2);
+        DOMEntity entity3 = new DOMEntity(ENTITY_TYPE, ENTITY_ID3);
+        DOMEntity entity4 = new DOMEntity(otherEntityType, ENTITY_ID3);
+        DOMEntityOwnershipListener listener = mock(DOMEntityOwnershipListener.class);
 
         // Register listener
 
@@ -677,9 +677,9 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         // Register remote candidate for entity1
 
         String remoteMemberName = "remoteMember";
-        writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, entity1.getId(), remoteMemberName),
+        writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, entity1.getIdentifier(), remoteMemberName),
                 shardDataTree);
-        verifyCommittedEntityCandidate(shard, ENTITY_TYPE, entity1.getId(), remoteMemberName);
+        verifyCommittedEntityCandidate(shard, ENTITY_TYPE, entity1.getIdentifier(), remoteMemberName);
 
         // Unregister the local candidate for entity1 and verify listener is notified
 
@@ -697,9 +697,9 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         shard.tell(new RegisterCandidateLocal(entity3), kit.getRef());
         kit.expectMsgClass(SuccessReply.class);
 
-        verifyOwner(shard, ENTITY_TYPE, entity3.getId(), LOCAL_MEMBER_NAME);
+        verifyOwner(shard, ENTITY_TYPE, entity3.getIdentifier(), LOCAL_MEMBER_NAME);
         Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
-        verify(listener, never()).ownershipChanged(any(EntityOwnershipChange.class));
+        verify(listener, never()).ownershipChanged(any(DOMEntityOwnershipChange.class));
 
         // Re-register the listener and verify it gets notified of currently owned entities
 
@@ -898,7 +898,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
                 ImmutableMap.of(peerId.toString(), peer.path().toString())));
         ShardTestKit.waitUntilLeader(shard);
 
-        Entity entity = new Entity(ENTITY_TYPE, ENTITY_ID1);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, ENTITY_ID1);
         ShardDataTree shardDataTree = shard.underlyingActor().getDataStore();
 
         // Add a remote candidate
@@ -941,7 +941,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
                 ImmutableMap.of(follower1Id.toString(), follower2.path().toString(), follower2Id.toString(), follower2.path().toString())));
         ShardTestKit.waitUntilLeader(shard);
 
-        Entity entity = new Entity(ENTITY_TYPE, ENTITY_ID1);
+        DOMEntity entity = new DOMEntity(ENTITY_TYPE, ENTITY_ID1);
         ShardDataTree shardDataTree = shard.underlyingActor().getDataStore();
 
         // Add a remote candidate
index 814d492..2f4c64a 100644 (file)
@@ -2,13 +2,13 @@
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
 
-<!--   <reference id="domEntityOwnershipService" interface="org.opendaylight.mdsal.dom.api.clustering.DOMEntityOwnershipService" /> -->
+  <reference id="domEntityOwnershipService" interface="org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService"/>
 
-<!--   <bean id="legacyEntityOwnershipService" class="org.opendaylight.controller.md.sal.common.impl.clustering.LegacyEntityOwnershipServiceAdapter" -->
-<!--           destroy-method="close"> -->
-<!--     <argument ref="domEntityOwnershipService"/> -->
-<!--   </bean> -->
+  <bean id="legacyEntityOwnershipService" class="org.opendaylight.controller.md.sal.dom.clustering.impl.LegacyEntityOwnershipServiceAdapter"
+          destroy-method="close">
+    <argument ref="domEntityOwnershipService"/>
+  </bean>
 
-<!--   <service ref="legacyEntityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService" -->
-<!--         odl:type="default"/> -->
-</blueprint>
\ No newline at end of file
+  <service ref="legacyEntityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"
+        odl:type="default"/>
+</blueprint>

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.