2 * Copyright (c) 2014 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.datastore.shardstrategy;
11 import org.opendaylight.controller.cluster.datastore.Configuration;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import java.util.List;
16 public class ModuleShardStrategy implements ShardStrategy {
18 public static final String NAME = "module";
20 private final String moduleName;
21 private final Configuration configuration;
23 public ModuleShardStrategy(String moduleName, Configuration configuration){
24 this.moduleName = moduleName;
26 this.configuration = configuration;
29 @Override public String findShard(YangInstanceIdentifier path) {
30 List<String> shardNames =
31 configuration.getShardNamesFromModuleName(moduleName);
32 if(shardNames.size() == 0){
33 return DefaultShardStrategy.DEFAULT_SHARD;
35 return shardNames.get(0);