Implementation of ModuleShardStrategy 83/8883/7
authorMoiz Raja <moraja@cisco.com>
Thu, 10 Jul 2014 02:03:54 +0000 (19:03 -0700)
committerMoiz Raja <moraja@cisco.com>
Mon, 28 Jul 2014 20:56:34 +0000 (13:56 -0700)
ModuleShardStrategy finds a shard based on a module name only. This will allow it partition a single
large DOM tree into multiple shards based on configuration

Change-Id: I6e287fc48a08da58d261e80b59419d4311164aa3
Signed-off-by: Moiz Raja <moraja@cisco.com>
15 files changed:
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Configuration.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConfigurationImpl.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockConfiguration.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java
opendaylight/md-sal/sal-distributed-datastore/src/test/resources/modules.conf

index dff1fd4..1c3a82a 100644 (file)
@@ -8,8 +8,15 @@
 
 package org.opendaylight.controller.cluster.datastore;
 
+import com.google.common.base.Optional;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
+
 import java.util.List;
+import java.util.Map;
 
 public interface Configuration {
     List<String> getMemberShardNames(String memberName);
+    Optional<String> getModuleNameFromNameSpace(String nameSpace);
+    Map<String, ShardStrategy> getModuleNameToShardStrategyMap();
+    List<String> getShardNamesFromModuleName(String moduleName);
 }
index c8c8299..1b8bf3e 100644 (file)
@@ -8,15 +8,24 @@
 
 package org.opendaylight.controller.cluster.datastore;
 
+import com.google.common.base.Optional;
 import com.typesafe.config.Config;
 import com.typesafe.config.ConfigFactory;
 import com.typesafe.config.ConfigObject;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.DefaultShardStrategy;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ModuleShardStrategy;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 public class ConfigurationImpl implements Configuration {
+
     private final List<ModuleShard> moduleShards = new ArrayList<>();
+
     private final List<Module> modules = new ArrayList<>();
 
 
@@ -30,8 +39,7 @@ public class ConfigurationImpl implements Configuration {
         readModules(modulesConfig);
     }
 
-    public List<String> getMemberShardNames(String memberName){
-
+    @Override public List<String> getMemberShardNames(String memberName){
         List<String> shards = new ArrayList();
         for(ModuleShard ms : moduleShards){
             for(Shard s : ms.getShards()){
@@ -46,6 +54,38 @@ public class ConfigurationImpl implements Configuration {
 
     }
 
+    @Override public Optional<String> getModuleNameFromNameSpace(String nameSpace) {
+        for(Module m : modules){
+            if(m.getNameSpace().equals(nameSpace)){
+                return Optional.of(m.getName());
+            }
+        }
+        return Optional.absent();
+    }
+
+    @Override public Map<String, ShardStrategy> getModuleNameToShardStrategyMap() {
+        Map<String, ShardStrategy> map = new HashMap<>();
+        for(Module m : modules){
+            map.put(m.getName(), m.getShardStrategy());
+        }
+        return map;
+    }
+
+    @Override public List<String> getShardNamesFromModuleName(String moduleName) {
+        for(ModuleShard m : moduleShards){
+            if(m.getModuleName().equals(moduleName)){
+                List<String> l = new ArrayList<>();
+                for(Shard s : m.getShards()){
+                    l.add(s.getName());
+                }
+                return l;
+            }
+        }
+
+        return Collections.EMPTY_LIST;
+    }
+
+
 
     private void readModules(Config modulesConfig) {
         List<? extends ConfigObject> modulesConfigObjectList =
@@ -54,7 +94,7 @@ public class ConfigurationImpl implements Configuration {
         for(ConfigObject o : modulesConfigObjectList){
             ConfigObjectWrapper w = new ConfigObjectWrapper(o);
             modules.add(new Module(w.stringValue("name"), w.stringValue(
-                "namespace"), w.stringValue("sharding-strategy")));
+                "namespace"), w.stringValue("shard-strategy")));
         }
     }
 
@@ -82,7 +122,7 @@ public class ConfigurationImpl implements Configuration {
     }
 
 
-    public static class ModuleShard {
+    private class ModuleShard {
         private final String moduleName;
         private final List<Shard> shards;
 
@@ -100,7 +140,7 @@ public class ConfigurationImpl implements Configuration {
         }
     }
 
-    public static class Shard {
+    private class Shard {
         private final String name;
         private final List<String> replicas;
 
@@ -118,16 +158,20 @@ public class ConfigurationImpl implements Configuration {
         }
     }
 
-    public static class Module {
+    private class Module {
 
         private final String name;
         private final String nameSpace;
-        private final String shardingStrategy;
+        private final ShardStrategy shardStrategy;
 
-        Module(String name, String nameSpace, String shardingStrategy) {
+        Module(String name, String nameSpace, String shardStrategy) {
             this.name = name;
             this.nameSpace = nameSpace;
-            this.shardingStrategy = shardingStrategy;
+            if(ModuleShardStrategy.NAME.equals(shardStrategy)){
+                this.shardStrategy = new ModuleShardStrategy(name, ConfigurationImpl.this);
+            } else {
+                this.shardStrategy = new DefaultShardStrategy();
+            }
         }
 
         public String getName() {
@@ -138,8 +182,8 @@ public class ConfigurationImpl implements Configuration {
             return nameSpace;
         }
 
-        public String getShardingStrategy() {
-            return shardingStrategy;
+        public ShardStrategy getShardStrategy() {
+            return shardStrategy;
         }
     }
 
index c7f811b..0c4fae0 100644 (file)
@@ -13,6 +13,7 @@ import akka.actor.ActorSystem;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply;
 import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
@@ -77,7 +78,9 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener, Au
         ActorRef dataChangeListenerActor = actorContext.getActorSystem().actorOf(
             DataChangeListener.props(listener));
 
-        Object result = actorContext.executeShardOperation(Shard.DEFAULT_NAME,
+        String shardName = ShardStrategyFactory.getStrategy(path).findShard(path);
+
+        Object result = actorContext.executeShardOperation(shardName,
             new RegisterChangeListener(path, dataChangeListenerActor.path(),
                 AsyncDataBroker.DataChangeScope.BASE).toSerializable(),
             ActorContext.ASK_DURATION
index 8123652..8fd13bd 100644 (file)
@@ -106,7 +106,6 @@ public class ShardManager extends AbstractUntypedActor {
             FindPrimary msg = ((FindPrimary) message);
             String shardName = msg.getShardName();
 
-
             if (Shard.DEFAULT_NAME.equals(shardName)) {
                 ActorPath defaultShardPath = localShards.get(shardName);
                 if(defaultShardPath == null){
index e30076d..2f784dc 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply;
 import org.opendaylight.controller.cluster.datastore.messages.ReadyTransaction;
 import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply;
 import org.opendaylight.controller.cluster.datastore.messages.WriteData;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages.CreateTransactionReply;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
@@ -79,15 +80,14 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
         this.executor = executor;
         this.schemaContext = schemaContext;
 
-        Object response = actorContext.executeShardOperation(Shard.DEFAULT_NAME, new CreateTransaction(identifier), ActorContext.ASK_DURATION);
-        if(response instanceof CreateTransactionReply){
-            CreateTransactionReply reply = (CreateTransactionReply) response;
-            remoteTransactionPaths.put(Shard.DEFAULT_NAME, actorContext.actorSelection(reply.getTransactionActorPath()));
-        }
+
     }
 
     @Override
     public ListenableFuture<Optional<NormalizedNode<?, ?>>> read(final InstanceIdentifier path) {
+
+        createTransactionIfMissing(actorContext, path);
+
         final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path);
 
         Callable<Optional<NormalizedNode<?,?>>> call = new Callable() {
@@ -119,18 +119,27 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
 
     @Override
     public void write(InstanceIdentifier path, NormalizedNode<?, ?> data) {
+
+        createTransactionIfMissing(actorContext, path);
+
         final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path);
         remoteTransaction.tell(new WriteData(path, data, schemaContext).toSerializable(), null);
     }
 
     @Override
     public void merge(InstanceIdentifier path, NormalizedNode<?, ?> data) {
+
+        createTransactionIfMissing(actorContext, path);
+
         final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path);
         remoteTransaction.tell(new MergeData(path, data, schemaContext).toSerializable(), null);
     }
 
     @Override
     public void delete(InstanceIdentifier path) {
+
+        createTransactionIfMissing(actorContext, path);
+
         final ActorSelection remoteTransaction = remoteTransactionFromIdentifier(path);
         remoteTransaction.tell(new DeleteData(path).toSerializable(), null);
     }
@@ -172,6 +181,26 @@ public class TransactionProxy implements DOMStoreReadWriteTransaction {
     }
 
     private String shardNameFromIdentifier(InstanceIdentifier path){
-        return Shard.DEFAULT_NAME;
+        return ShardStrategyFactory.getStrategy(path).findShard(path);
     }
+
+    private void createTransactionIfMissing(ActorContext actorContext, InstanceIdentifier path) {
+        String shardName = ShardStrategyFactory.getStrategy(path).findShard(path);
+
+        ActorSelection actorSelection =
+            remoteTransactionPaths.get(shardName);
+
+        if(actorSelection != null){
+            // A transaction already exists with that shard
+            return;
+        }
+
+        Object response = actorContext.executeShardOperation(shardName, new CreateTransaction(identifier), ActorContext.ASK_DURATION);
+        if(response instanceof CreateTransactionReply){
+            CreateTransactionReply reply = (CreateTransactionReply) response;
+            remoteTransactionPaths.put(shardName, actorContext.actorSelection(reply.getTransactionActorPath()));
+        }
+    }
+
+
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java
new file mode 100644 (file)
index 0000000..fe6f740
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.cluster.datastore.shardstrategy;
+
+import org.opendaylight.controller.cluster.datastore.Configuration;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+
+public class ModuleShardStrategy implements ShardStrategy {
+
+    public static final String NAME = "module";
+
+    private final String moduleName;
+    private final Configuration configuration;
+
+    public ModuleShardStrategy(String moduleName, Configuration configuration){
+        this.moduleName = moduleName;
+
+        this.configuration = configuration;
+    }
+
+    @Override public String findShard(InstanceIdentifier path) {
+        return configuration.getShardNamesFromModuleName(moduleName).get(0);
+    }
+}
index 2105379..8b077d6 100644 (file)
@@ -8,41 +8,53 @@
 
 package org.opendaylight.controller.cluster.datastore.shardstrategy;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import org.opendaylight.controller.cluster.datastore.Configuration;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 public class ShardStrategyFactory {
-  private static final Map<String, ShardStrategy> moduleNameToStrategyMap = new ConcurrentHashMap();
+    private static Map<String, ShardStrategy> moduleNameToStrategyMap =
+        new ConcurrentHashMap();
 
-  private static final String UNKNOWN_MODULE_NAME = "unknown";
+    private static final String UNKNOWN_MODULE_NAME = "unknown";
+    private static Configuration configuration;
 
-  public static ShardStrategy getStrategy(InstanceIdentifier path){
-    Preconditions.checkNotNull(path, "path should not be null");
 
-    String moduleName = getModuleName(path);
-    ShardStrategy shardStrategy = moduleNameToStrategyMap.get(moduleName);
-    if(shardStrategy == null){
-      return new DefaultShardStrategy();
+    public static void setConfiguration(Configuration configuration){
+        ShardStrategyFactory.configuration = configuration;
+        moduleNameToStrategyMap = configuration.getModuleNameToShardStrategyMap();
     }
 
-    return shardStrategy;
-  }
+    public static ShardStrategy getStrategy(InstanceIdentifier path) {
+        Preconditions.checkState(configuration != null, "configuration should not be missing");
+        Preconditions.checkNotNull(path, "path should not be null");
 
 
-  private static String getModuleName(InstanceIdentifier path){
-    return UNKNOWN_MODULE_NAME;
-  }
+        String moduleName = getModuleName(path);
+        ShardStrategy shardStrategy = moduleNameToStrategyMap.get(moduleName);
+        if (shardStrategy == null) {
+            return new DefaultShardStrategy();
+        }
 
-  /**
-   * This is to be used in the future to register a custom shard strategy
-   *
-   * @param moduleName
-   * @param shardStrategy
-   */
-  public static void registerShardStrategy(String moduleName, ShardStrategy shardStrategy){
-    throw new UnsupportedOperationException("registering a custom shard strategy not supported yet");
-  }
+        return shardStrategy;
+    }
+
+
+    private static String getModuleName(InstanceIdentifier path) {
+        String namespace = path.getLastPathArgument().getNodeType().getNamespace()
+            .toASCIIString();
+
+        Optional<String> optional =
+            configuration.getModuleNameFromNameSpace(namespace);
+
+        if(!optional.isPresent()){
+            return UNKNOWN_MODULE_NAME;
+        }
+
+        return optional.get();
+    }
 }
index 636c835..6a25328 100644 (file)
@@ -3,6 +3,7 @@ package org.opendaylight.controller.cluster.datastore;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.junit.Test;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory;
 import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper;
 import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
@@ -18,6 +19,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractActorTest {
 
     @Test
     public void integrationTest() throws Exception {
+        ShardStrategyFactory.setConfiguration(new MockConfiguration());
         DistributedDataStore distributedDataStore =
             new DistributedDataStore(getSystem(), "config", new MockClusterWrapper(), new MockConfiguration());
 
index 1c9e337..914f0db 100644 (file)
@@ -5,8 +5,10 @@ import akka.actor.Props;
 import junit.framework.Assert;
 
 import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory;
 import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor;
 import org.opendaylight.controller.cluster.datastore.utils.MockActorContext;
+import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
@@ -28,6 +30,7 @@ public class DistributedDataStoreTest extends AbstractActorTest{
 
     @org.junit.Before
     public void setUp() throws Exception {
+        ShardStrategyFactory.setConfiguration(new MockConfiguration());
         final Props props = Props.create(DoNothingActor.class);
 
         doNothingActorRef = getSystem().actorOf(props);
index 89cf7e7..62398ad 100644 (file)
@@ -204,6 +204,8 @@ public class TransactionProxyTest extends AbstractActorTest {
                 TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, TestModel.createTestContext());
 
 
+        transactionProxy.read(TestModel.TEST_PATH);
+
         DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
 
         Assert.assertTrue(ready instanceof ThreePhaseCommitCohortProxy);
@@ -242,6 +244,8 @@ public class TransactionProxyTest extends AbstractActorTest {
             new TransactionProxy(actorContext,
                 TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, TestModel.createTestContext());
 
+        transactionProxy.read(TestModel.TEST_PATH);
+
         transactionProxy.close();
 
         Object messages = testContext
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java
new file mode 100644 (file)
index 0000000..88753e4
--- /dev/null
@@ -0,0 +1,33 @@
+package org.opendaylight.controller.cluster.datastore.shardstrategy;
+
+import junit.framework.Assert;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.opendaylight.controller.cluster.datastore.Configuration;
+import org.opendaylight.controller.cluster.datastore.ConfigurationImpl;
+import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
+
+public class ModuleShardStrategyTest {
+    @Rule
+    public ExpectedException expectedEx = ExpectedException.none();
+
+    private static Configuration configuration;
+
+    @BeforeClass
+    public static void setUpClass(){
+        configuration = new ConfigurationImpl("module-shards.conf", "modules.conf");
+    }
+
+
+    @Test
+    public void testFindShard() throws Exception {
+        ModuleShardStrategy moduleShardStrategy =
+            new ModuleShardStrategy("cars", configuration);
+
+        String shard = moduleShardStrategy.findShard(CarsModel.BASE_PATH);
+
+        Assert.assertEquals("cars-1", shard);
+    }
+}
index 2cff981..0b34840 100644 (file)
@@ -1,29 +1,48 @@
 package org.opendaylight.controller.cluster.datastore.shardstrategy;
 
+import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.opendaylight.controller.cluster.datastore.ConfigurationImpl;
+import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 
 import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
 
 public class ShardStrategyFactoryTest {
 
-  @Rule
-  public ExpectedException expectedEx = ExpectedException.none();
+    @Rule
+    public ExpectedException expectedEx = ExpectedException.none();
 
-  @Test
-  public void testGetStrategy(){
-    ShardStrategy strategy = ShardStrategyFactory.getStrategy(TestModel.TEST_PATH);
-    assertNotNull(strategy);
-  }
+    @BeforeClass
+    public static void setUpClass(){
+        ShardStrategyFactory.setConfiguration(new ConfigurationImpl("module-shards.conf", "modules.conf"));
+    }
 
-  @Test
-  public void testGetStrategyNullPointerExceptionWhenPathIsNull(){
-    expectedEx.expect(NullPointerException.class);
-    expectedEx.expectMessage("path should not be null");
+    @Test
+    public void testGetStrategy() {
+        ShardStrategy strategy =
+            ShardStrategyFactory.getStrategy(TestModel.TEST_PATH);
+        assertNotNull(strategy);
+    }
 
-    ShardStrategyFactory.getStrategy(null);
-  }
+    @Test
+    public void testGetStrategyForKnownModuleName() {
+        ShardStrategy strategy =
+            ShardStrategyFactory.getStrategy(InstanceIdentifier.of(CarsModel.BASE_QNAME));
+        assertTrue(strategy instanceof ModuleShardStrategy);
+    }
 
-}
\ No newline at end of file
+
+    @Test
+    public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
+        expectedEx.expect(NullPointerException.class);
+        expectedEx.expectMessage("path should not be null");
+
+        ShardStrategyFactory.getStrategy(null);
+    }
+
+}
index a8877c7..470726e 100644 (file)
@@ -8,10 +8,14 @@
 
 package org.opendaylight.controller.cluster.datastore.utils;
 
+import com.google.common.base.Optional;
 import org.opendaylight.controller.cluster.datastore.Configuration;
+import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 
 public class MockConfiguration implements Configuration{
     @Override public List<String> getMemberShardNames(String memberName) {
@@ -19,4 +23,19 @@ public class MockConfiguration implements Configuration{
         shardNames.add("default");
         return shardNames;
     }
+
+    @Override public Optional<String> getModuleNameFromNameSpace(
+        String nameSpace) {
+        return Optional.absent();
+    }
+
+    @Override
+    public Map<String, ShardStrategy> getModuleNameToShardStrategyMap() {
+        return Collections.EMPTY_MAP;
+    }
+
+    @Override public List<String> getShardNamesFromModuleName(
+        String moduleName) {
+        return Collections.EMPTY_LIST;
+    }
 }
index e01730d..675be8e 100644 (file)
@@ -22,6 +22,8 @@ public class CarsModel {
     public static final QName BASE_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:cars", "2014-03-13",
         "cars");
 
+    public static final InstanceIdentifier BASE_PATH = InstanceIdentifier.of(BASE_QNAME);
+
     public static final QName CARS_QNAME = QName.create(BASE_QNAME, "cars");
     public static final QName CAR_QNAME = QName.create(CARS_QNAME, "car");
     public static final QName CAR_NAME_QNAME = QName.create(CAR_QNAME, "name");
index 5d2e556..52f249a 100644 (file)
@@ -2,12 +2,12 @@ modules = [
     {
         name = "people"
         namespace = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people"
-        sharding-strategy = "module"
+        shard-strategy = "module"
     },
     {
         name = "cars"
         namespace = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:cars"
-        sharding-strategy = "module"
+        shard-strategy = "module"
     }
 
 ]

©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.