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 @Deprecated(forRemoval = true)
23 public interface CDSShardAccess {
25 * Return the shard identifier.
27 * @return Shard identifier.
28 * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated
29 * {@link CDSDataTreeProducer} is no longer valid.
31 @NonNull DOMDataTreeIdentifier getShardIdentifier();
34 * Return the shard leader location relative to the local node.
36 * @return Shard leader location.
37 * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated
38 * {@link CDSDataTreeProducer} is no longer valid.
40 @NonNull LeaderLocation getLeaderLocation();
43 * Request the shard leader to be moved to the local node. The request will be evaluated against shard state and
44 * satisfied if leader movement is possible. If current shard policy or state prevents the movement from happening,
45 * the returned {@link CompletionStage} will report an exception.
48 * This is a one-time operation, which does not prevent further movement happening in future. Even if this request
49 * succeeds, there is no guarantee that the leader will remain local in face of failures, shutdown or any future
50 * movement requests from other nodes.
53 * Note that due to asynchronous nature of CDS, the leader may no longer be local by the time the returned
54 * {@link CompletionStage} reports success.
56 * @return A {@link CompletionStage} representing the request.
57 * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated
58 * {@link CDSDataTreeProducer} is no longer valid.
60 @NonNull CompletionStage<Void> makeLeaderLocal();
63 * Register a listener to shard location changes. Each listener object can be registered at most once.
65 * @param listener Listener object
66 * @return A {@link LeaderLocationListenerRegistration} for the listener.
67 * @throws IllegalArgumentException if the specified listener is already registered.
68 * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated
69 * {@link CDSDataTreeProducer} is no longer valid.
70 * @throws NullPointerException if listener is null.
72 @NonNull <L extends LeaderLocationListener> LeaderLocationListenerRegistration<L> registerLeaderLocationListener(