Skip to content
Browse files

Made ClientShell more zone friendly

  • Loading branch information...
1 parent bc0c32a commit 75f9cecad180dbb03b89e35e8d94e3ece3e2f19a @rsumbaly rsumbaly committed Jul 21, 2010
View
2 bin/voldemort-shell.sh
@@ -18,7 +18,7 @@
if [ $# -lt 2 ];
then
- echo 'USAGE: bin/voldemort-shell.sh store_name bootstrap_url [command_file]'
+ echo 'USAGE: bin/voldemort-shell.sh store_name bootstrap_url [command_file] [--client-zone-id <zone-id>]'
exit 1
fi
View
BIN config/test_config1/data/bdb/00000000.jdb
Binary file not shown.
View
0 config/test_config1/data/bdb/je.lck
No changes.
View
BIN config/test_config2/data/bdb/00000000.jdb
Binary file not shown.
View
0 config/test_config2/data/bdb/je.lck
No changes.
View
13 src/java/voldemort/VoldemortClientShell.java
@@ -60,13 +60,11 @@ public static void main(String[] args) throws Exception {
.withRequiredArg()
.describedAs("zone-id")
.ofType(Integer.class);
- parser.accepts("enable-pipeline-routed-store");
- parser.accepts("enable-zone-routing");
OptionSet options = parser.parse(args);
List<String> nonOptions = options.nonOptionArguments();
if(nonOptions.size() < 2 || nonOptions.size() > 3) {
- System.err.println("Usage: java VoldemortClientShell [options] store_name bootstrap_url [command_file]");
+ System.err.println("Usage: java VoldemortClientShell store_name bootstrap_url [command_file] [options]");
parser.printHelpOn(System.err);
System.exit(-1);
}
@@ -91,15 +89,8 @@ public static void main(String[] args) throws Exception {
ClientConfig clientConfig = new ClientConfig().setBootstrapUrls(bootstrapUrl);
if(options.has("client-zone-id")) {
- clientConfig.setClientZoneId(new Integer((String) options.valueOf("client-zone-id")).intValue());
- }
-
- if(options.has("enable-pipeline-routed-store")) {
clientConfig.setEnablePipelineRoutedStore(true);
- }
-
- if(options.has("enable-zone-routing")) {
- clientConfig.setEnableZoneRouting(true);
+ clientConfig.setClientZoneId((Integer) options.valueOf("client-zone-id"));
}
StoreClientFactory factory = new SocketStoreClientFactory(clientConfig);
View
14 src/java/voldemort/client/ClientConfig.java
@@ -55,7 +55,6 @@
private volatile boolean enableJmx = true;
private volatile boolean enablePipelineRoutedStore = false;
- private volatile boolean enableZoneRouting = false;
private volatile int clientZoneId = Zone.DEFAULT_ZONE_ID;
private volatile String failureDetectorImplementation = FailureDetectorConfig.DEFAULT_IMPLEMENTATION_CLASS_NAME;
@@ -90,7 +89,6 @@ public ClientConfig() {}
public static final String REQUEST_FORMAT_PROPERTY = "request_format";
public static final String ENABLE_JMX_PROPERTY = "enable_jmx";
public static final String ENABLE_PIPELINE_ROUTED_STORE_PROPERTY = "enable_pipeline_routed_store";
- public static final String ENABLE_ZONE_ROUTING_PROPERTY = "enable_zone_routing";
public static final String CLIENT_ZONE_ID = "client_zone_id";
public static final String FAILUREDETECTOR_IMPLEMENTATION_PROPERTY = "failuredetector_implementation";
public static final String FAILUREDETECTOR_BANNAGE_PERIOD_PROPERTY = "failuredetector_bannage_period";
@@ -164,9 +162,6 @@ public ClientConfig(Properties properties) {
if(props.containsKey(ENABLE_PIPELINE_ROUTED_STORE_PROPERTY))
this.setEnablePipelineRoutedStore(props.getBoolean(ENABLE_PIPELINE_ROUTED_STORE_PROPERTY));
- if(props.containsKey(ENABLE_ZONE_ROUTING_PROPERTY))
- this.setEnableZoneRouting(props.getBoolean(ENABLE_ZONE_ROUTING_PROPERTY));
-
if(props.containsKey(CLIENT_ZONE_ID))
this.setClientZoneId(props.getInt(CLIENT_ZONE_ID));
@@ -479,15 +474,6 @@ public ClientConfig setEnableJmx(boolean enableJmx) {
return this;
}
- public boolean isZoneRoutingEnabled() {
- return enableZoneRouting;
- }
-
- public ClientConfig setEnableZoneRouting(boolean enableZoneRouting) {
- this.enableZoneRouting = enableZoneRouting;
- return this;
- }
-
public ClientConfig setClientZoneId(int clientZoneId) {
this.clientZoneId = clientZoneId;
return this;
View
41 src/java/voldemort/store/routed/PipelineRoutedStore.java
@@ -27,6 +27,7 @@
import voldemort.cluster.Node;
import voldemort.cluster.Zone;
import voldemort.cluster.failuredetector.FailureDetector;
+import voldemort.routing.RoutingStrategyType;
import voldemort.store.Store;
import voldemort.store.StoreDefinition;
import voldemort.store.StoreRequest;
@@ -62,6 +63,7 @@
private final Map<Integer, NonblockingStore> nonblockingStores;
private Zone clientZone;
+ private boolean zoneRoutingEnabled;
/**
* Create a PipelineRoutedStore
@@ -94,9 +96,11 @@ public PipelineRoutedStore(String name,
SystemTime.INSTANCE);
this.clientZone = cluster.getZoneById(clientZoneId);
-
- if(this.clientZone == null)
- this.clientZone = cluster.getZoneById(Zone.DEFAULT_ZONE_ID);
+ if(storeDef.getRoutingStrategyType().compareTo(RoutingStrategyType.ZONE_STRATEGY) == 0) {
+ zoneRoutingEnabled = true;
+ } else {
+ zoneRoutingEnabled = false;
+ }
this.nonblockingStores = new ConcurrentHashMap<Integer, NonblockingStore>(nonblockingStores);
}
@@ -105,7 +109,10 @@ public PipelineRoutedStore(String name,
StoreUtils.assertValidKey(key);
BasicPipelineData<List<Versioned<byte[]>>> pipelineData = new BasicPipelineData<List<Versioned<byte[]>>>();
- pipelineData.setZonesRequired(storeDef.getZoneCountReads());
+ if(zoneRoutingEnabled)
+ pipelineData.setZonesRequired(storeDef.getZoneCountReads());
+ else
+ pipelineData.setZonesRequired(null);
final Pipeline pipeline = new Pipeline(Operation.GET, timeoutMs, TimeUnit.MILLISECONDS);
@@ -166,7 +173,7 @@ public void submit(Node node, NonblockingStore store, NonblockingStoreCallback c
nonblockingStores,
readRepairer));
- if(pipelineData.getZonesRequired() != null)
+ if(zoneRoutingEnabled)
pipeline.addEventAction(Event.INSUFFICIENT_ZONES,
new PerformZoneSerialRequests<List<Versioned<byte[]>>, BasicPipelineData<List<Versioned<byte[]>>>>(pipelineData,
repairReads ? Event.RESPONSES_RECEIVED
@@ -199,7 +206,10 @@ public void submit(Node node, NonblockingStore store, NonblockingStoreCallback c
StoreUtils.assertValidKeys(keys);
GetAllPipelineData pipelineData = new GetAllPipelineData();
- pipelineData.setZonesRequired(storeDef.getZoneCountReads());
+ if(zoneRoutingEnabled)
+ pipelineData.setZonesRequired(storeDef.getZoneCountReads());
+ else
+ pipelineData.setZonesRequired(null);
Pipeline pipeline = new Pipeline(Operation.GET_ALL, timeoutMs, TimeUnit.MILLISECONDS);
pipeline.addEventAction(Event.STARTED,
@@ -248,8 +258,10 @@ public void submit(Node node, NonblockingStore store, NonblockingStoreCallback c
StoreUtils.assertValidKey(key);
BasicPipelineData<List<Version>> pipelineData = new BasicPipelineData<List<Version>>();
- pipelineData.setZonesRequired(storeDef.getZoneCountReads());
-
+ if(zoneRoutingEnabled)
+ pipelineData.setZonesRequired(storeDef.getZoneCountReads());
+ else
+ pipelineData.setZonesRequired(null);
final Pipeline pipeline = new Pipeline(Operation.GET_VERSIONS,
timeoutMs,
TimeUnit.MILLISECONDS);
@@ -301,8 +313,10 @@ public boolean delete(final ByteArray key, final Version version) throws Voldemo
StoreUtils.assertValidKey(key);
BasicPipelineData<Boolean> pipelineData = new BasicPipelineData<Boolean>();
- pipelineData.setZonesRequired(storeDef.getZoneCountWrites());
-
+ if(zoneRoutingEnabled)
+ pipelineData.setZonesRequired(storeDef.getZoneCountWrites());
+ else
+ pipelineData.setZonesRequired(null);
final Pipeline pipeline = new Pipeline(Operation.DELETE, timeoutMs, TimeUnit.MILLISECONDS);
NonblockingStoreRequest nonblockingDelete = new NonblockingStoreRequest() {
@@ -352,7 +366,7 @@ public Boolean request(Store<ByteArray, byte[]> store) {
blockingDelete,
null));
- if(pipelineData.getZonesRequired() != null)
+ if(zoneRoutingEnabled)
pipeline.addEventAction(Event.INSUFFICIENT_ZONES,
new PerformZoneSerialRequests<Boolean, BasicPipelineData<Boolean>>(pipelineData,
repairReads ? Event.RESPONSES_RECEIVED
@@ -380,7 +394,10 @@ public void put(ByteArray key, Versioned<byte[]> versioned) throws VoldemortExce
StoreUtils.assertValidKey(key);
PutPipelineData pipelineData = new PutPipelineData();
- pipelineData.setZonesRequired(storeDef.getZoneCountWrites());
+ if(zoneRoutingEnabled)
+ pipelineData.setZonesRequired(storeDef.getZoneCountWrites());
+ else
+ pipelineData.setZonesRequired(null);
pipelineData.setStartTimeNs(System.nanoTime());
Pipeline pipeline = new Pipeline(Operation.PUT, timeoutMs, TimeUnit.MILLISECONDS);
View
8 src/java/voldemort/store/routed/RoutedStoreFactory.java
@@ -6,9 +6,11 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
+import voldemort.VoldemortException;
import voldemort.cluster.Cluster;
import voldemort.cluster.Zone;
import voldemort.cluster.failuredetector.FailureDetector;
+import voldemort.routing.RoutingStrategyType;
import voldemort.store.Store;
import voldemort.store.StoreDefinition;
import voldemort.store.nonblockingstore.NonblockingStore;
@@ -64,6 +66,12 @@ public RoutedStore create(Cluster cluster,
routingTimeoutMs,
failureDetector);
} else {
+ if(storeDefinition.getRoutingStrategyType()
+ .compareTo(RoutingStrategyType.ZONE_STRATEGY) == 0) {
+ throw new VoldemortException("Zone Routing for store '" + storeDefinition.getName()
+ + "' not supported using thread pool routed store.");
+ }
+
return new ThreadPoolRoutedStore(storeDefinition.getName(),
nodeStores,
cluster,
View
13 src/java/voldemort/xml/StoreDefinitionsMapper.java
@@ -209,6 +209,19 @@ private StoreDefinition readStore(Element store) {
retentionThrottleRate = Integer.parseInt(throttleRate.getText());
}
+ if(routingStrategyType.compareTo(RoutingStrategyType.ZONE_STRATEGY) == 0) {
+ if(zoneCountReads == null || zoneCountWrites == null || zoneReplicationFactor == null) {
+ throw new MappingException("Have not set one of the following correctly for store '"
+ + name
+ + "' - "
+ + STORE_ZONE_COUNT_READS
+ + ", "
+ + STORE_ZONE_COUNT_WRITES
+ + ", "
+ + STORE_ZONE_REPLICATION_FACTOR_ELMT);
+ }
+ }
+
return new StoreDefinitionBuilder().setName(name)
.setType(storeType)
.setKeySerializer(keySerializer)
View
2 test/integration/voldemort/performance/benchmark/Benchmark.java
@@ -343,7 +343,7 @@ public void initializeStore(Props benchmarkProps) throws Exception {
.setEnablePipelineRoutedStore(enablePipelineRouted);
if(clientZoneId >= 0) {
- clientConfig.setClientZoneId(clientZoneId).setEnableZoneRouting(true);
+ clientConfig.setClientZoneId(clientZoneId);
}
SocketStoreClientFactory socketFactory = new SocketStoreClientFactory(clientConfig);
this.storeClient = socketFactory.getStoreClient(storeName);

0 comments on commit 75f9cec

Please sign in to comment.
Something went wrong with that request. Please try again.