Skip to content

Commit

Permalink
Renamed AdminStoreSwapper#swapStoreData() to #fetchAndSwapStoreData()
Browse files Browse the repository at this point in the history
Also clarified one of the logs so that BnP announces that it's about to fetch
(previously, it mentioned "swap" instead).
  • Loading branch information
FelixGV committed May 5, 2016
1 parent b01ad7a commit 205a6d5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ public void run() throws Exception {
pushVersion++;
}

// do the swap
info("Initiating swap of " + storeName + " with dataDir: " + dataDir);
// do the fetch, and if it succeeds, the swap
info("Initiating fetch of " + storeName + " with dataDir: " + dataDir);
AdminStoreSwapper swapper = new AdminStoreSwapper(
cluster,
executor,
Expand All @@ -154,7 +154,7 @@ public void run() throws Exception {
failedFetchStrategyList,
clusterName,
buildPrimaryReplicasOnly);
swapper.swapStoreData(storeName, modifiedDataDir, pushVersion);
swapper.fetchAndSwapStoreData(storeName, modifiedDataDir, pushVersion);
info("Swap complete.");
executor.shutdownNow();
executor.awaitTermination(10, TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public AdminStoreSwapper(Cluster cluster,
this(cluster, executor, adminClient, timeoutMs, false, new ArrayList<FailedFetchStrategy>(), null, false);
}

public void swapStoreData(String storeName, String basePath, long pushVersion) {
public void fetchAndSwapStoreData(String storeName, String basePath, long pushVersion) {
Map<Node, Response> fetchResponseMap = invokeFetch(storeName, basePath, pushVersion);
invokeSwap(storeName, fetchResponseMap);
for (AdminStoreSwapper.Response response: fetchResponseMap.values()) {
Expand Down Expand Up @@ -376,7 +376,7 @@ public static void main(String[] args) throws Exception {
if(rollbackStore) {
swapper.invokeRollback(storeName, pushVersion.longValue());
} else {
swapper.swapStoreData(storeName, filePath, pushVersion.longValue());
swapper.fetchAndSwapStoreData(storeName, filePath, pushVersion.longValue());
}
long end = System.currentTimeMillis();
swapper.logger.info("Succeeded on all nodes in " + ((end - start) / Time.MS_PER_SECOND)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ protected void populateData(Cluster cluster,
Executors.newFixedThreadPool(cluster.getNumberOfNodes()),
adminClient,
100000);
swapper.swapStoreData(testStoreNameRO, outputDir.getAbsolutePath(), 1L);
swapper.fetchAndSwapStoreData(testStoreNameRO, outputDir.getAbsolutePath(), 1L);
}
}
}
21 changes: 8 additions & 13 deletions test/unit/voldemort/store/readonly/swapper/StoreSwapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import voldemort.ServerTestUtils;
import voldemort.TestUtils;
import voldemort.VoldemortException;
Expand All @@ -36,7 +34,6 @@
import voldemort.store.StoreDefinition;
import voldemort.store.StoreDefinitionBuilder;
import voldemort.store.metadata.MetadataStore;
import voldemort.store.nonblockingstore.ThreadPoolBasedNonblockingStoreImpl;
import voldemort.store.readonly.ReadOnlyStorageConfiguration;
import voldemort.store.readonly.ReadOnlyUtils;
import voldemort.store.socket.SocketStoreFactory;
Expand All @@ -47,8 +44,6 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -258,7 +253,7 @@ public RuntimeException call(){

RuntimeException result = null;
try {
swapper.swapStoreData(STORE_NAME, tempDir.getAbsolutePath(), currentVersion + 1);
swapper.fetchAndSwapStoreData(STORE_NAME, tempDir.getAbsolutePath(), currentVersion + 1);
}catch (RuntimeException e){
result = e;
}
Expand Down Expand Up @@ -293,7 +288,7 @@ public void testFetchSwapWithoutRollback(AdminStoreSwapper swapper) throws Excep
+ " is not equal to others");
}

swapper.swapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 1);
swapper.fetchAndSwapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 1);

// Check the directories and entries
for(int nodeId = 0; nodeId < NUM_NODES; nodeId++) {
Expand All @@ -312,7 +307,7 @@ public void testFetchSwapWithoutRollback(AdminStoreSwapper swapper) throws Excep
Utils.mkdirs(new File(baseDirs[1], "version-" + Long.toString(currentVersion + 3)));

try {
swapper.swapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 3);
swapper.fetchAndSwapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 3);
fail("Should throw a VoldemortException during pushing to node 0");
} catch(VoldemortException e) {}

Expand Down Expand Up @@ -345,7 +340,7 @@ public void testFetchSwap(AdminStoreSwapper swapper) throws Exception {
+ " is not equal to others");
}

swapper.swapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 1);
swapper.fetchAndSwapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 1);

// Check the directories and entries
for(int nodeId = 0; nodeId < NUM_NODES; nodeId++) {
Expand All @@ -364,7 +359,7 @@ public void testFetchSwap(AdminStoreSwapper swapper) throws Exception {
Utils.mkdirs(new File(baseDirs[1], "version-" + Long.toString(currentVersion + 3)));

try {
swapper.swapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 3);
swapper.fetchAndSwapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 3);
fail("Should throw a VoldemortException during pushing to node 0");
} catch(VoldemortException e) {}

Expand Down Expand Up @@ -403,7 +398,7 @@ public void testFetchSwap(AdminStoreSwapper swapper) throws Exception {

// Try to fetch in v2, which should fail on all
try {
swapper.swapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 2);
swapper.fetchAndSwapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 2);
fail("Should throw a VoldemortException during pushing to node 0, 1");
} catch(VoldemortException e) {}

Expand All @@ -423,7 +418,7 @@ public void testFetchSwap(AdminStoreSwapper swapper) throws Exception {
MetadataStore.VoldemortState.REBALANCING_MASTER_SERVER);

try {
swapper.swapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 4);
swapper.fetchAndSwapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 4);
fail("Should have thrown exception during swapping");
} catch(VoldemortException e) {}

Expand All @@ -441,7 +436,7 @@ public void testFetchSwap(AdminStoreSwapper swapper) throws Exception {
servers[1].getMetadataStore().put(MetadataStore.SERVER_STATE_KEY,
MetadataStore.VoldemortState.NORMAL_SERVER);

swapper.swapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 5);
swapper.fetchAndSwapStoreData(STORE_NAME, temporaryDir.getAbsolutePath(), currentVersion + 5);

for(int nodeId = 0; nodeId < NUM_NODES; nodeId++) {
long currentNodeVersion = adminClient.readonlyOps.getROCurrentVersion(nodeId,
Expand Down

0 comments on commit 205a6d5

Please sign in to comment.