Bug 4105: Remove EntityOwnershipCandidate
[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 javax.annotation.Nonnull;
12
13 /**
14  * <p>
15  * The EntityOwnershipService provides the means for a component/application to request ownership for a given
16  * Entity on the current cluster member. Entity ownership is always tied to a process and two components on the same
17  * process cannot register a candidate for a given Entity.
18  * </p>
19  * <p>
20  * A component/application may also register interest in the ownership status of an Entity. The listener would be
21  * notified whenever the ownership status changes.
22  * </p>
23  */
24 public interface EntityOwnershipService {
25
26     /**
27      * Registers a candidate for ownership of the given entity. Only one such request can be made per entity
28      * per process. If multiple requests for registering a candidate for a given entity are received in the
29      * current process a CandidateAlreadyRegisteredException will be thrown.
30      * <p>
31      * The registration is performed asynchronously and any registered {@link EntityOwnershipListener} is
32      * notified of ownership status changes for the entity.
33      *
34      * @param entity the entity which the Candidate wants to own
35      * @return a registration object that can be used to unregister the Candidate
36      * @throws org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException
37      */
38     EntityOwnershipCandidateRegistration registerCandidate(@Nonnull Entity entity)
39             throws CandidateAlreadyRegisteredException;
40
41     /**
42      * Registers a listener that is interested in ownership changes for entities of the given entity type. The
43      * listener is notified whenever its process instance is granted ownership of the entity and also whenever
44      * it loses ownership. On registration the listener will be notified of all entities its process instance
45      * currently owns at the time of registration.
46      *
47      * @param entityType the type of entities whose ownership status the Listener is interested in
48      * @param listener the listener that is interested in the entities
49      * @return a registration object that can be used to unregister the Listener
50      */
51     EntityOwnershipListenerRegistration registerListener(@Nonnull String entityType, @Nonnull EntityOwnershipListener listener);
52
53 }