<feature version='${project.version}'>odl-mdsal-clustering-commons</feature>
<bundle>mvn:org.opendaylight.controller/cds-access-api/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.controller/cds-access-client/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.controller/cds-dom-api/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.controller/sal-distributed-datastore/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.controller/sal-cluster-admin-api/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.controller/sal-cluster-admin-impl/{{VERSION}}</bundle>
<groupId>${project.groupId}</groupId>
<artifactId>cds-access-client</artifactId>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>cds-dom-api</artifactId>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sal-distributed-datastore</artifactId>
<artifactId>sal-cluster-admin-impl</artifactId>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>bundle-parent</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>cds-dom-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yangtools-artifacts</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-actor_${scala.version}</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>concepts</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-dom-api</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <failOnError>true</failOnError>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <scm>
+ <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Architecture:Clustering</url>
+ </scm>
+</project>
--- /dev/null
+/*
+ * 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 javax.annotation.Nonnull;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
+
+/**
+ * An extension to {@link DOMDataTreeProducer}, which allows users access
+ * to information about the backing shard.
+ *
+ * @author Robert Varga
+ */
+@Beta
+public interface CDSDataTreeProducer extends DOMDataTreeProducer {
+ /**
+ * Return a {@link CDSShardAccess} handle. This handle will remain valid
+ * as long as this producer is operational. Returned handle can be accessed
+ * independently from this producer and is not subject to the usual access
+ * restrictions imposed on DOMDataTreeProducer state.
+ *
+ * @param subtree One of the subtrees to which are currently under control of this producer
+ * @return A shard access handle.
+ * @throws NullPointerException when subtree is null
+ * @throws IllegalArgumentException if the specified subtree is not controlled by this producer
+ * @throws IllegalStateException if this producer is no longer operational
+ * @throws IllegalThreadStateException if the access rules to this producer
+ * are violated, for example if this producer is bound and this thread
+ * is currently not executing from a listener context.
+ */
+ @Nonnull CDSShardAccess getShardAccess(@Nonnull DOMDataTreeIdentifier subtree);
+}
+
--- /dev/null
+/*
+ * 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.
+ *
+ * <p>
+ * 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.
+ *
+ * <p>
+ * 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<Void> 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 <L extends LeaderLocationListener> LeaderLocationListenerRegistration<L> registerLeaderLocationListener(
+ @Nonnull L listener);
+}
--- /dev/null
+/*
+ * 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;
+
+/**
+ * Enumeration of possible shard leader locations relative to the local node.
+ *
+ * @author Robert Varga
+ */
+@Beta
+public enum LeaderLocation {
+ /**
+ * The leader is co-located on this node.
+ */
+ LOCAL,
+ /**
+ * The leader is resident on a different node.
+ */
+ REMOTE,
+ /**
+ * The leader is residence is currently unknown. This is a transition state during a leader failure, which can be
+ * caused by a network partition. This state is not observed during a leadership transfer vote initiated by
+ * the leader shutting down.
+ */
+ UNKNOWN,
+}
--- /dev/null
+/*
+ * 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.EventListener;
+import javax.annotation.Nonnull;
+
+/**
+ * Listener for shard leader location changes.
+ *
+ * @author Robert Varga
+ */
+@Beta
+public interface LeaderLocationListener extends EventListener {
+ /**
+ * Invoked when shard leader location changes.
+ *
+ * @param location Current leader location as known by the local node.
+ */
+ void onLeaderLocationChanged(@Nonnull LeaderLocation location);
+}
--- /dev/null
+/*
+ * 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 org.opendaylight.yangtools.concepts.ListenerRegistration;
+
+/**
+ * Registration of a {@link LeaderLocationListener}.
+ *
+ * @author Robert Varga
+ *
+ * @param <T> Listener type
+ */
+@Beta
+public interface LeaderLocationListenerRegistration<T extends LeaderLocationListener> extends ListenerRegistration<T> {
+
+}
--- /dev/null
+/*
+ * 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
+ */
+/**
+ * This package defines extensions to org.opendaylight.mdsal.dom.api specific
+ * to Clustered Datastore implementation.
+ */
+package org.opendaylight.controller.cluster.dom.api;
<artifactId>sal-cluster-admin-impl</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>cds-dom-api</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
<!-- RESTCONF -->
<dependency>
<module>sal-clustering-commons</module>
<module>cds-access-api</module>
<module>cds-access-client</module>
+ <module>cds-dom-api</module>
<!-- sal clustering configuration -->
<module>sal-clustering-config</module>
<groupId>org.opendaylight.controller</groupId>
<artifactId>cds-access-client</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>cds-dom-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-akka-raft-example</artifactId>