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
9 package org.opendaylight.controller.cluster.sharding;
11 import com.google.common.annotations.Beta;
12 import java.util.Collection;
13 import java.util.concurrent.CompletionStage;
14 import org.opendaylight.controller.cluster.access.concepts.MemberName;
15 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
16 import org.opendaylight.mdsal.dom.api.DOMDataTreeShardingConflictException;
19 * A factory that handles addition of new clustered shard's based on a prefix. This factory is a QoL class that handles
20 * all the boilerplate that comes with registration of a new clustered shard into the system and creating the backend
21 * shard/replicas that come along with it.
24 public interface DistributedShardFactory {
27 * Register a new shard that is rooted at the desired prefix with replicas on the provided members.
28 * Note to register a shard without replicas you still need to provide at least one Member for the shard.
30 * @param prefix Shard root
31 * @param replicaMembers Members that this shard is replicated on, has to have at least one Member even if the shard
32 * should not be replicated.
33 * @return A future that will be completed with a DistributedShardRegistration once the backend and frontend shards
35 * @throws DOMDataTreeShardingConflictException If the initial check for a conflict on the local node fails, the
36 * sharding configuration won't be updated if this exception is thrown.
38 CompletionStage<DistributedShardRegistration>
39 createDistributedShard(DOMDataTreeIdentifier prefix, Collection<MemberName> replicaMembers)
40 throws DOMDataTreeShardingConflictException;
43 * Registration of the CDS shard that allows you to remove the shard from the system by closing the registration.
44 * This removal is done asynchronously.
46 interface DistributedShardRegistration {
49 * Removes the shard from the system, this removal is done asynchronously, the future completes once the
50 * backend shard is no longer present.
52 CompletionStage<Void> close();