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 com.google.common.base.Preconditions;
12 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
15 import java.util.concurrent.ConcurrentHashMap;
17 public class ShardStrategyFactory {
18 private static final Map<String, ShardStrategy> moduleNameToStrategyMap = new ConcurrentHashMap();
20 private static final String UNKNOWN_MODULE_NAME = "unknown";
22 public static ShardStrategy getStrategy(InstanceIdentifier path){
23 Preconditions.checkNotNull(path, "path should not be null");
25 String moduleName = getModuleName(path);
26 ShardStrategy shardStrategy = moduleNameToStrategyMap.get(moduleName);
27 if(shardStrategy == null){
28 return new DefaultShardStrategy();
35 private static String getModuleName(InstanceIdentifier path){
36 return UNKNOWN_MODULE_NAME;
40 * This is to be used in the future to register a custom shard strategy
43 * @param shardStrategy
45 public static void registerShardStrategy(String moduleName, ShardStrategy shardStrategy){
46 throw new UnsupportedOperationException("registering a custom shard strategy not supported yet");