fba71ab11771d1fd60e91c9b24e1ee4f2b7ab8b7
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / sharding / DistributedShardFactory.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.sharding;
9
10 import com.google.common.annotations.Beta;
11 import java.util.Collection;
12 import java.util.concurrent.CompletionStage;
13 import org.opendaylight.controller.cluster.access.concepts.MemberName;
14 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
15 import org.opendaylight.mdsal.dom.api.DOMDataTreeShardingConflictException;
16
17 /**
18  * A factory that handles addition of new clustered shard's based on a prefix. This factory is a QoL class that handles
19  * all the boilerplate that comes with registration of a new clustered shard into the system and creating the backend
20  * shard/replicas that come along with it.
21  */
22 @Beta
23 public interface DistributedShardFactory {
24     /**
25      * Register a new shard that is rooted at the desired prefix with replicas on the provided members.
26      * Note to register a shard without replicas you still need to provide at least one Member for the shard.
27      *
28      * @param prefix         Shard root
29      * @param replicaMembers Members that this shard is replicated on, has to have at least one Member even if the shard
30      *                       should not be replicated.
31      * @return A future that will be completed with a DistributedShardRegistration once the backend and frontend shards
32      *         are spawned.
33      * @throws DOMDataTreeShardingConflictException If the initial check for a conflict on the local node fails, the
34      *         sharding configuration won't be updated if this exception is thrown.
35      */
36     CompletionStage<DistributedShardRegistration>
37         createDistributedShard(DOMDataTreeIdentifier prefix, Collection<MemberName> replicaMembers)
38             throws DOMDataTreeShardingConflictException;
39 }