2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.md.sal.common.api.clustering;
11 import com.google.common.base.Optional;
12 import javax.annotation.Nonnull;
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.
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.
25 * @deprecated Use org.opendaylight.mdsal.binding.api.clustering.EntityOwnershipService or
26 * org.opendaylight.mdsal.dom.api.clustering.DOMEntityOwnershipService instead
29 public interface EntityOwnershipService {
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.
36 * The registration is performed asynchronously and any registered {@link EntityOwnershipListener} is
37 * notified of ownership status changes for the entity.
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
43 EntityOwnershipCandidateRegistration registerCandidate(@Nonnull Entity entity)
44 throws CandidateAlreadyRegisteredException;
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.
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
56 EntityOwnershipListenerRegistration registerListener(@Nonnull String entityType, @Nonnull EntityOwnershipListener listener);
59 * Gets the current ownership state information for an entity.
61 * @param forEntity the entity to query.
62 * @return an Optional EntityOwnershipState whose instance is present if the entity is found
64 Optional<EntityOwnershipState> getOwnershipState(@Nonnull Entity forEntity);
67 * Check if a local candidate is registered for the given entity
70 * @return true if a candidate was registered locally, false otherwise
72 boolean isCandidateRegistered(@Nonnull Entity entity);