Deprecate legacy EOS API classes
[controller.git] / opendaylight / md-sal / sal-common-api / src / main / java / org / opendaylight / controller / md / sal / common / api / clustering / EntityOwnershipService.java
index fc15dac9d3d4a0cc24cc420f53a392ed15bdc7d6..07c93e780cdf0006f2e823891f5bd9126c226045 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.controller.md.sal.common.api.clustering;
 
+import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
+
 /**
  * <p>
  * The EntityOwnershipService provides the means for a component/application to request ownership for a given
@@ -18,30 +21,53 @@ package org.opendaylight.controller.md.sal.common.api.clustering;
  * A component/application may also register interest in the ownership status of an Entity. The listener would be
  * notified whenever the ownership status changes.
  * </p>
+ *
+ * @deprecated Use org.opendaylight.mdsal.binding.api.clustering.EntityOwnershipService or
+ *             org.opendaylight.mdsal.dom.api.clustering.DOMEntityOwnershipService instead
  */
+@Deprecated
 public interface EntityOwnershipService {
 
     /**
-     * Registers as a Candidate that wants to own the given Entity. Only one such request can be made per process.
-     * If multiple requests for registering a Candidate for a given Entity are received in the current process a
-     * CandidateAlreadyRegisteredException will be thrown
+     * Registers a candidate for ownership of the given entity. Only one such request can be made per entity
+     * per process. If multiple requests for registering a candidate for a given entity are received in the
+     * current process a CandidateAlreadyRegisteredException will be thrown.
+     * <p>
+     * The registration is performed asynchronously and any registered {@link EntityOwnershipListener} is
+     * notified of ownership status changes for the entity.
      *
      * @param entity the entity which the Candidate wants to own
-     * @param candidate the Candidate that wants to own the entity
      * @return a registration object that can be used to unregister the Candidate
      * @throws org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException
      */
-    EntityOwnershipCandidateRegistration registerCandidate(Entity entity, EntityOwnershipCandidate candidate)
+    EntityOwnershipCandidateRegistration registerCandidate(@Nonnull Entity entity)
             throws CandidateAlreadyRegisteredException;
 
     /**
-     * Registers a Listener that is interested in the ownership status of the given Entity. On registration the Listener
-     * will be notified of the ownership status of the given Entity at the time of registration.
+     * Registers a listener that is interested in ownership changes for entities of the given entity type. The
+     * listener is notified whenever its process instance is granted ownership of the entity and also whenever
+     * it loses ownership. On registration the listener will be notified of all entities its process instance
+     * currently owns at the time of registration.
      *
-     * @param entity the Entity whose ownership status the Listener is interested in
-     * @param listener the Listener that is interested in the entity
+     * @param entityType the type of entities whose ownership status the Listener is interested in
+     * @param listener the listener that is interested in the entities
      * @return a registration object that can be used to unregister the Listener
      */
-    EntityOwnershipListenerRegistration registerListener(Entity entity, EntityOwnershipListener listener);
+    EntityOwnershipListenerRegistration registerListener(@Nonnull String entityType, @Nonnull EntityOwnershipListener listener);
 
+    /**
+     * Gets the current ownership state information for an entity.
+     *
+     * @param forEntity the entity to query.
+     * @return an Optional EntityOwnershipState whose instance is present if the entity is found
+     */
+    Optional<EntityOwnershipState> getOwnershipState(@Nonnull Entity forEntity);
+
+    /**
+     * Check if a local candidate is registered for the given entity
+     *
+     * @param entity
+     * @return true if a candidate was registered locally, false otherwise
+     */
+    boolean isCandidateRegistered(@Nonnull Entity entity);
 }