X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-dom-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdom%2Fapi%2FCDSShardAccess.java;fp=opendaylight%2Fmd-sal%2Fcds-dom-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdom%2Fapi%2FCDSShardAccess.java;h=d08b99a50f88b8e8c5432ec2bffed2e00fb7fd4c;hb=212081e3f3f8b88b15e2cf1c0d6fd96cb260fe22;hp=0000000000000000000000000000000000000000;hpb=c55d6cccb33e3de942e521e31404a60c1738b768;p=controller.git diff --git a/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSShardAccess.java b/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSShardAccess.java new file mode 100644 index 0000000000..d08b99a50f --- /dev/null +++ b/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSShardAccess.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.dom.api; + +import com.google.common.annotations.Beta; +import java.util.concurrent.CompletionStage; +import javax.annotation.Nonnull; +import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; + +/** + * Unprivileged access interface to shard information. Provides read-only access to operational details about a CDS + * shard. + * + * @author Robert Varga + */ +@Beta +public interface CDSShardAccess { + /** + * Return the shard identifier. + * + * @return Shard identifier. + * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated + * {@link CDSDataTreeProducer} is no longer valid. + */ + @Nonnull DOMDataTreeIdentifier getShardIdentifier(); + + /** + * Return the shard leader location relative to the local node. + * + * @return Shard leader location. + * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated + * {@link CDSDataTreeProducer} is no longer valid. + */ + @Nonnull LeaderLocation getLeaderLocation(); + + /** + * Request the shard leader to be moved to the local node. The request will be evaluated against shard state and + * satisfied if leader movement is possible. If current shard policy or state prevents the movement from happening, + * the returned {@link CompletionStage} will report an exception. + * + *

+ * This is a one-time operation, which does not prevent further movement happening in future. Even if this request + * succeeds, there is no guarantee that the leader will remain local in face of failures, shutdown or any future + * movement requests from other nodes. + * + *

+ * Note that due to asynchronous nature of CDS, the leader may no longer be local by the time the returned + * {@link CompletionStage} reports success. + * + * @return A {@link CompletionStage} representing the request. + * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated + * {@link CDSDataTreeProducer} is no longer valid. + */ + @Nonnull CompletionStage makeLeaderLocal(); + + /** + * Register a listener to shard location changes. Each listener object can be registered at most once. + * + * @param listener Listener object + * @return A {@link LeaderLocationListenerRegistration} for the listener. + * @throws IllegalArgumentException if the specified listener is already registered. + * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated + * {@link CDSDataTreeProducer} is no longer valid. + * @throws NullPointerException if listener is null. + */ + @Nonnull LeaderLocationListenerRegistration registerLeaderLocationListener( + @Nonnull L listener); +}