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
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.md.sal.common.api.clustering;
10
11 import com.google.common.base.Optional;
12 import javax.annotation.Nonnull;
13
14 /**
15  * <p>
16  * The EntityOwnershipService provides the means for a component/application to request ownership for a given
17  * Entity on the current cluster member. Entity ownership is always tied to a process and two components on the same
18  * process cannot register a candidate for a given Entity.
19  * </p>
20  * <p>
21  * A component/application may also register interest in the ownership status of an Entity. The listener would be
22  * notified whenever the ownership status changes.
23  * </p>
24  *
25  * @deprecated Use org.opendaylight.mdsal.binding.api.clustering.EntityOwnershipService or
26  *             org.opendaylight.mdsal.dom.api.clustering.DOMEntityOwnershipService instead
27  */
28 @Deprecated
29 public interface EntityOwnershipService {
30
31     /**
32      * Registers a candidate for ownership of the given entity. Only one such request can be made per entity
33      * per process. If multiple requests for registering a candidate for a given entity are received in the
34      * current process a CandidateAlreadyRegisteredException will be thrown.
35      * <p>
36      * The registration is performed asynchronously and any registered {@link EntityOwnershipListener} is
37      * notified of ownership status changes for the entity.
38      *
39      * @param entity the entity which the Candidate wants to own
40      * @return a registration object that can be used to unregister the Candidate
41      * @throws org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException
42      */
43     EntityOwnershipCandidateRegistration registerCandidate(@Nonnull Entity entity)
44             throws CandidateAlreadyRegisteredException;
45
46     /**
47      * Registers a listener that is interested in ownership changes for entities of the given entity type. The
48      * listener is notified whenever its process instance is granted ownership of the entity and also whenever
49      * it loses ownership. On registration the listener will be notified of all entities its process instance
50      * currently owns at the time of registration.
51      *
52      * @param entityType the type of entities whose ownership status the Listener is interested in
53      * @param listener the listener that is interested in the entities
54      * @return a registration object that can be used to unregister the Listener
55      */
56     EntityOwnershipListenerRegistration registerListener(@Nonnull String entityType, @Nonnull EntityOwnershipListener listener);
57
58     /**
59      * Gets the current ownership state information for an entity.
60      *
61      * @param forEntity the entity to query.
62      * @return an Optional EntityOwnershipState whose instance is present if the entity is found
63      */
64     Optional<EntityOwnershipState> getOwnershipState(@Nonnull Entity forEntity);
65
66     /**
67      * Check if a local candidate is registered for the given entity
68      *
69      * @param entity
70      * @return true if a candidate was registered locally, false otherwise
71      */
72     boolean isCandidateRegistered(@Nonnull Entity entity);
73 }