BUG 2138: Introduce prefix based shards into ShardManager
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / 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
9 package org.opendaylight.controller.cluster.datastore;
10
11 import java.util.Collection;
12 import org.opendaylight.controller.cluster.access.concepts.MemberName;
13 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
14 import org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException;
15 import org.opendaylight.mdsal.dom.api.DOMDataTreeShardingConflictException;
16 import org.opendaylight.yangtools.concepts.Registration;
17
18 /**
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.
22  */
23 public interface DistributedShardFactory {
24
25     /**
26      * Register a new shard that is rooted at the desired prefix with replicas on the provided members.
27      * Note to register a shard without replicas you still need to provide at least one Member for the shard.
28      *
29      * @param prefix         Shard root
30      * @param replicaMembers Members that this shard is replicated on, has to have at least one Member even if the shard
31      *                       should not be replicated.
32      * @return ShardRegistration that should be closed if the shard should be destroyed
33      * @throws DOMDataTreeShardingConflictException If the prefix already has a shard registered
34      * @throws DOMDataTreeProducerException in case there is a problem closing the initial producer that is used to
35      *                                      register the shard into the ShardingService
36      */
37     DistributedShardRegistration createDistributedShard(DOMDataTreeIdentifier prefix,
38                                                         Collection<MemberName> replicaMembers)
39             throws DOMDataTreeShardingConflictException, DOMDataTreeProducerException;
40
41     interface DistributedShardRegistration extends Registration {
42         @Override
43         void close();
44     }
45 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.