Fix checkstyle violations in sal-common-api
[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      *
36      * <p>
37      * The registration is performed asynchronously and any registered {@link EntityOwnershipListener} is
38      * notified of ownership status changes for the entity.
39      *
40      * @param entity the entity which the Candidate wants to own
41      * @return a registration object that can be used to unregister the Candidate
42      * @throws CandidateAlreadyRegisteredException if the candidate is already registered
43      */
44     EntityOwnershipCandidateRegistration registerCandidate(@Nonnull Entity entity)
45             throws CandidateAlreadyRegisteredException;
46
47     /**
48      * Registers a listener that is interested in ownership changes for entities of the given entity type. The
49      * listener is notified whenever its process instance is granted ownership of the entity and also whenever
50      * it loses ownership. On registration the listener will be notified of all entities its process instance
51      * currently owns at the time of registration.
52      *
53      * @param entityType the type of entities whose ownership status the Listener is interested in
54      * @param listener the listener that is interested in the entities
55      * @return a registration object that can be used to unregister the Listener
56      */
57     EntityOwnershipListenerRegistration registerListener(@Nonnull String entityType,
58             @Nonnull EntityOwnershipListener listener);
59
60     /**
61      * Gets the current ownership state information for an entity.
62      *
63      * @param forEntity the entity to query.
64      * @return an Optional EntityOwnershipState whose instance is present if the entity is found
65      */
66     Optional<EntityOwnershipState> getOwnershipState(@Nonnull Entity forEntity);
67
68     /**
69      * Check if a local candidate is registered for the given entity.
70      *
71      * @param entity the entity
72      * @return true if a candidate was registered locally, false otherwise
73      */
74     boolean isCandidateRegistered(@Nonnull Entity entity);
75 }