Skip to content

Commit

Permalink
Minor TODO and copyright cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
jayjwylie committed Jun 20, 2013
1 parent 6a283ae commit c794504
Show file tree
Hide file tree
Showing 17 changed files with 142 additions and 44 deletions.
@@ -1,3 +1,19 @@
/*
* Copyright 2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package voldemort.client.rebalance.task;

import java.util.List;
Expand Down
16 changes: 16 additions & 0 deletions src/java/voldemort/client/rebalance/task/RebalanceTask.java
@@ -1,3 +1,19 @@
/*
* Copyright 2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package voldemort.client.rebalance.task;

import java.util.List;
Expand Down
@@ -1,3 +1,19 @@
/*
* Copyright 2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package voldemort.client.rebalance.task;

import java.util.concurrent.Semaphore;
Expand Down
2 changes: 1 addition & 1 deletion src/java/voldemort/routing/ConsistentRoutingStrategy.java
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2009 LinkedIn, Inc
* Copyright 2008-2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
2 changes: 1 addition & 1 deletion src/java/voldemort/routing/RouteToAllStrategy.java
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2009 LinkedIn, Inc
* Copyright 2008-2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
@@ -1,3 +1,19 @@
/*
* Copyright 2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package voldemort.server.rebalance.async;

import java.util.concurrent.ExecutorService;
Expand Down
2 changes: 1 addition & 1 deletion src/java/voldemort/store/StorageEngine.java
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2009 LinkedIn, Inc
* Copyright 2008-2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
2 changes: 1 addition & 1 deletion src/java/voldemort/store/rebalancing/RedirectingStore.java
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2010 LinkedIn, Inc
* Copyright 2008-2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
3 changes: 0 additions & 3 deletions src/java/voldemort/tools/RebalanceControllerCLI.java
Expand Up @@ -51,22 +51,19 @@ private static void setupParser() {
parser.accepts("url", "Url to bootstrap from ").withRequiredArg().describedAs("url");
parser.accepts("donor-based", "Execute donor-based rebalancing.");
parser.accepts("stealer-based", "Execute stealer-based rebalancing (default).");

// TODO: Can this option be deprecated?
parser.accepts("tries",
"Tries during stealer-based rebalance [ Default: "
+ RebalanceController.MAX_TRIES_REBALANCING + " ]")
.withRequiredArg()
.ofType(Integer.class)
.describedAs("num-tries");
// TODO: Can this option be described better?
parser.accepts("parallelism",
"Number of servers running stealer- or donor-based tasks in parallel [ Default:"
+ RebalanceController.MAX_PARALLEL_REBALANCING + " ]")
.withRequiredArg()
.ofType(Integer.class)
.describedAs("parallelism");

parser.accepts("final-cluster", "Path to target cluster xml")
.withRequiredArg()
.describedAs("cluster.xml");
Expand Down
35 changes: 17 additions & 18 deletions src/java/voldemort/tools/RebalancePlanCLI.java
Expand Up @@ -49,15 +49,15 @@ private static void setupParser() {
parser.accepts("current-cluster", "Path to current cluster xml")
.withRequiredArg()
.describedAs("cluster.xml");
parser.accepts("target-cluster", "Path to target cluster xml")
parser.accepts("final-cluster", "Path to final cluster xml")
.withRequiredArg()
.describedAs("cluster.xml");
parser.accepts("current-stores",
"Path to current store definition xml. Needed for cluster and zone expansion.")
.withRequiredArg()
.describedAs("stores.xml");
parser.accepts("target-stores",
"Path to target store definition xml. Needed for zone expansion.")
parser.accepts("final-stores",
"Path to final store definition xml. Needed for zone expansion.")
.withRequiredArg()
.describedAs("stores.xml");
parser.accepts("batch-size",
Expand All @@ -82,8 +82,8 @@ private static void printUsage() {
help.append(" --current-cluster <clusterXML>\n");
help.append(" --current-stores <storesXML>\n");
help.append(" Optional:\n");
help.append(" --target-cluster <clusterXML> [ Needed for cluster or zone expansion ]\n");
help.append(" --target-stores <storesXML> [ Needed for zone expansion ]\n");
help.append(" --final-cluster <clusterXML> [ Needed for cluster or zone expansion ]\n");
help.append(" --final-stores <storesXML> [ Needed for zone expansion ]\n");
help.append(" --batch <batch> [ Number of primary partitions to move in each rebalancing batch. ]\n");
help.append(" --output-dir <outputDir> [ Directory in which cluster metadata is dumped for each batch of the plan. ]\n");

Expand Down Expand Up @@ -117,14 +117,13 @@ private static OptionSet getValidOptions(String[] args) {
if(missing.size() > 0) {
printUsageAndDie("Missing required arguments: " + Joiner.on(", ").join(missing));
}
if(options.has("target-stores") && !options.has("target-cluster")) {
printUsageAndDie("target-stores specified, but target-cluster not specified.");
if(options.has("final-stores") && !options.has("final-cluster")) {
printUsageAndDie("final-stores specified, but final-cluster not specified.");
}

return options;
}

// TODO: (refactor) Rename target-cluster target-stores to final-*
public static void main(String[] args) throws Exception {
setupParser();
OptionSet options = getValidOptions(args);
Expand All @@ -134,19 +133,19 @@ public static void main(String[] args) throws Exception {
String currentStoresXML = (String) options.valueOf("current-stores");

// Required args for some use cases
String targetClusterXML = new String(currentClusterXML);
if(options.has("target-cluster")) {
targetClusterXML = (String) options.valueOf("target-cluster");
String finalClusterXML = new String(currentClusterXML);
if(options.has("final-cluster")) {
finalClusterXML = (String) options.valueOf("final-cluster");
}
String targetStoresXML = new String(currentStoresXML);
if(options.has("target-stores")) {
targetStoresXML = (String) options.valueOf("target-stores");
String finalStoresXML = new String(currentStoresXML);
if(options.has("final-stores")) {
finalStoresXML = (String) options.valueOf("final-stores");
}

Cluster currentCluster = new ClusterMapper().readCluster(new File(currentClusterXML));
List<StoreDefinition> currentStoreDefs = new StoreDefinitionsMapper().readStoreList(new File(currentStoresXML));
Cluster targetCluster = new ClusterMapper().readCluster(new File(targetClusterXML));
List<StoreDefinition> targetStoreDefs = new StoreDefinitionsMapper().readStoreList(new File(targetStoresXML));
Cluster finalCluster = new ClusterMapper().readCluster(new File(finalClusterXML));
List<StoreDefinition> finalStoreDefs = new StoreDefinitionsMapper().readStoreList(new File(finalStoresXML));

// Optional args
int batchSize = CmdUtils.valueOf(options, "batch-size", RebalancePlan.BATCH_SIZE);
Expand All @@ -158,8 +157,8 @@ public static void main(String[] args) throws Exception {

new RebalancePlan(currentCluster,
currentStoreDefs,
targetCluster,
targetStoreDefs,
finalCluster,
finalStoreDefs,
batchSize,
outputDir);
}
Expand Down
3 changes: 2 additions & 1 deletion test/common/voldemort/ClusterTestUtils.java
@@ -1,5 +1,5 @@
/*
* 2013 LinkedIn, Inc
* Copyright 2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand All @@ -13,6 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/

package voldemort;

import java.util.ArrayList;
Expand Down
Expand Up @@ -202,9 +202,6 @@ protected void rebalanceAndCheck(RebalancePlan rebalancePlan,
* @param baselineTuples
* @param baselineVersions
*/
// TODO: (atomic cluster/store update) change from storeDefs to
// currentStoreDefs and finalStoreDefs to
// handle zone expansion/shrink tests.
protected void checkEntriesPostRebalance(Cluster currentCluster,
Cluster targetCluster,
List<StoreDefinition> storeDefs,
Expand Down
@@ -1,3 +1,19 @@
/*
* Copyright 2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package voldemort.client.rebalance;

import static org.junit.Assert.assertEquals;
Expand Down
48 changes: 36 additions & 12 deletions test/unit/voldemort/routing/StoreRoutingPlanTest.java
@@ -1,3 +1,19 @@
/*
* Copyright 2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package voldemort.routing;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -109,16 +125,24 @@ public void testZonedStoreRoutingPlan() {

assertEquals("Replica owner should be 1",
1,
zonedRoutingPlan.getNodeIdForZoneNary(0, 1, samplePartitionKeysMap.get(2).get(0)));
zonedRoutingPlan.getNodeIdForZoneNary(0,
1,
samplePartitionKeysMap.get(2).get(0)));
assertEquals("Replica owner should be 1",
1,
zonedRoutingPlan.getNodeIdForZoneNary(0, 0, samplePartitionKeysMap.get(3).get(0)));
zonedRoutingPlan.getNodeIdForZoneNary(0,
0,
samplePartitionKeysMap.get(3).get(0)));
assertEquals("Replica owner should be 4",
4,
zonedRoutingPlan.getNodeIdForZoneNary(1, 1, samplePartitionKeysMap.get(1).get(0)));
zonedRoutingPlan.getNodeIdForZoneNary(1,
1,
samplePartitionKeysMap.get(1).get(0)));
assertEquals("Replica owner should be 3",
3,
zonedRoutingPlan.getNodeIdForZoneNary(1, 0, samplePartitionKeysMap.get(2).get(0)));
zonedRoutingPlan.getNodeIdForZoneNary(1,
0,
samplePartitionKeysMap.get(2).get(0)));
}

@Test
Expand All @@ -137,23 +161,23 @@ public void testNonZonedStoreRoutingPlan() {
assertEquals("Zone replica type should be 1",
1,
nonZonedRoutingPlan.getZoneNAry(Zone.DEFAULT_ZONE_ID,
2,
samplePartitionKeysMap.get(1).get(0)));
2,
samplePartitionKeysMap.get(1).get(0)));
assertEquals("Zone replica type should be 0",
0,
nonZonedRoutingPlan.getZoneNAry(Zone.DEFAULT_ZONE_ID,
1,
samplePartitionKeysMap.get(3).get(0)));
1,
samplePartitionKeysMap.get(3).get(0)));
assertEquals("Replica owner should be 2",
2,
nonZonedRoutingPlan.getNodeIdForZoneNary(Zone.DEFAULT_ZONE_ID,
1,
samplePartitionKeysMap.get(1).get(0)));
1,
samplePartitionKeysMap.get(1).get(0)));
assertEquals("Replica owner should be 1",
1,
nonZonedRoutingPlan.getNodeIdForZoneNary(Zone.DEFAULT_ZONE_ID,
0,
samplePartitionKeysMap.get(3).get(0)));
0,
samplePartitionKeysMap.get(3).get(0)));
}

@After
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2009 LinkedIn, Inc
* Copyright 2008-2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
2 changes: 1 addition & 1 deletion test/unit/voldemort/store/metadata/MetadataStoreTest.java
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2009 LinkedIn, Inc
* Copyright 2008-2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2010 LinkedIn, Inc
* Copyright 2008-2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down

0 comments on commit c794504

Please sign in to comment.