Skip to content

Commit

Permalink
Merge branch 'master' of github.com:voldemort/voldemort
Browse files Browse the repository at this point in the history
  • Loading branch information
afeinberg committed Jul 28, 2011
2 parents cc8c363 + 8a9376a commit 66f5a79
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Expand Up @@ -1154,6 +1154,15 @@ public VAdminProto.AddStoreResponse handleAddStore(VAdminProto.AddStoreRequest r
// ConfigurationStorageEngine.put for details) // ConfigurationStorageEngine.put for details)


if(!storeRepository.hasLocalStore(def.getName())) { if(!storeRepository.hasLocalStore(def.getName())) {
if(def.getReplicationFactor() > metadataStore.getCluster().getNumberOfNodes()) {
throw new StoreOperationFailureException("Cannot add a store whose replication factor ( "
+ def.getReplicationFactor()
+ " ) is greater than the number of nodes ( "
+ metadataStore.getCluster()
.getNumberOfNodes()
+ " )");
}

logger.info("Adding new store '" + def.getName() + "'"); logger.info("Adding new store '" + def.getName() + "'");
// open the store // open the store
storageService.openStore(def); storageService.openStore(def);
Expand Down
21 changes: 20 additions & 1 deletion test/unit/voldemort/client/AdminServiceBasicTest.java
Expand Up @@ -213,18 +213,37 @@ public void testUpdateClusterMetadata() {
public void testAddStore() throws Exception { public void testAddStore() throws Exception {
AdminClient adminClient = getAdminClient(); AdminClient adminClient = getAdminClient();


// Try to add a store whose replication factor is greater than the
// number of nodes
StoreDefinition definition = new StoreDefinitionBuilder().setName("updateTest") StoreDefinition definition = new StoreDefinitionBuilder().setName("updateTest")
.setType(InMemoryStorageConfiguration.TYPE_NAME) .setType(InMemoryStorageConfiguration.TYPE_NAME)
.setKeySerializer(new SerializerDefinition("string")) .setKeySerializer(new SerializerDefinition("string"))
.setValueSerializer(new SerializerDefinition("string")) .setValueSerializer(new SerializerDefinition("string"))
.setRoutingPolicy(RoutingTier.CLIENT) .setRoutingPolicy(RoutingTier.CLIENT)
.setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY) .setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY)
.setReplicationFactor(1) .setReplicationFactor(3)
.setPreferredReads(1) .setPreferredReads(1)
.setRequiredReads(1) .setRequiredReads(1)
.setPreferredWrites(1) .setPreferredWrites(1)
.setRequiredWrites(1) .setRequiredWrites(1)
.build(); .build();
try {
adminClient.addStore(definition);
fail("Should have thrown an exception because we cannot add a store with a replication factor greater than number of nodes");
} catch(Exception e) {}

definition = new StoreDefinitionBuilder().setName("updateTest")
.setType(InMemoryStorageConfiguration.TYPE_NAME)
.setKeySerializer(new SerializerDefinition("string"))
.setValueSerializer(new SerializerDefinition("string"))
.setRoutingPolicy(RoutingTier.CLIENT)
.setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY)
.setReplicationFactor(1)
.setPreferredReads(1)
.setRequiredReads(1)
.setPreferredWrites(1)
.setRequiredWrites(1)
.build();
adminClient.addStore(definition); adminClient.addStore(definition);


// now test the store // now test the store
Expand Down

0 comments on commit 66f5a79

Please sign in to comment.