2 * Copyright (c) 2016 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
8 package org.opendaylight.controller.cluster.dom.api;
10 import com.google.common.annotations.Beta;
11 import java.util.concurrent.CompletionStage;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
16 * Unprivileged access interface to shard information. Provides read-only access to operational details about a CDS
19 * @author Robert Varga
22 public interface CDSShardAccess {
24 * Return the shard identifier.
26 * @return Shard identifier.
27 * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated
28 * {@link CDSDataTreeProducer} is no longer valid.
30 @NonNull DOMDataTreeIdentifier getShardIdentifier();
33 * Return the shard leader location relative to the local node.
35 * @return Shard leader location.
36 * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated
37 * {@link CDSDataTreeProducer} is no longer valid.
39 @NonNull LeaderLocation getLeaderLocation();
42 * Request the shard leader to be moved to the local node. The request will be evaluated against shard state and
43 * satisfied if leader movement is possible. If current shard policy or state prevents the movement from happening,
44 * the returned {@link CompletionStage} will report an exception.
47 * This is a one-time operation, which does not prevent further movement happening in future. Even if this request
48 * succeeds, there is no guarantee that the leader will remain local in face of failures, shutdown or any future
49 * movement requests from other nodes.
52 * Note that due to asynchronous nature of CDS, the leader may no longer be local by the time the returned
53 * {@link CompletionStage} reports success.
55 * @return A {@link CompletionStage} representing the request.
56 * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated
57 * {@link CDSDataTreeProducer} is no longer valid.
59 @NonNull CompletionStage<Void> makeLeaderLocal();
62 * Register a listener to shard location changes. Each listener object can be registered at most once.
64 * @param listener Listener object
65 * @return A {@link LeaderLocationListenerRegistration} for the listener.
66 * @throws IllegalArgumentException if the specified listener is already registered.
67 * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated
68 * {@link CDSDataTreeProducer} is no longer valid.
69 * @throws NullPointerException if listener is null.
71 @NonNull <L extends LeaderLocationListener> LeaderLocationListenerRegistration<L> registerLeaderLocationListener(