Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify HintedHandoffTest

  • Loading branch information...
commit 7df37f1af0c13a7c2113b0de7a71a863742e12c5 1 parent 6deeafe
@afeinberg afeinberg authored
Showing with 37 additions and 33 deletions.
  1. +37 −33 test/unit/voldemort/store/routed/HintedHandoffTest.java
View
70 test/unit/voldemort/store/routed/HintedHandoffTest.java
@@ -9,11 +9,11 @@
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import voldemort.MutableStoreVerifier;
-import voldemort.ServerTestUtils;
import voldemort.TestUtils;
import voldemort.VoldemortException;
import voldemort.client.RoutingTier;
@@ -24,7 +24,6 @@
import voldemort.cluster.failuredetector.FailureDetector;
import voldemort.cluster.failuredetector.FailureDetectorConfig;
import voldemort.cluster.failuredetector.FailureDetectorUtils;
-import voldemort.cluster.failuredetector.ThresholdFailureDetector;
import voldemort.routing.RoutingStrategy;
import voldemort.routing.RoutingStrategyFactory;
import voldemort.routing.RoutingStrategyType;
@@ -216,14 +215,7 @@ public void testHintedHandoff() throws Exception {
Set<ByteArray> failedKeys = populateStore(failedNodes);
Map<ByteArray, byte[]> dataInSlops = Maps.newHashMap();
- Set<ByteArray> slopKeys = Sets.newHashSet();
-
- byte[] opCode = new byte[] { Slop.Operation.PUT.getOpCode() };
- byte[] spacer = new byte[] { (byte) 0 };
- byte[] storeName = ByteUtils.getBytes(STORE_NAME, "UTF-8");
-
- for(ByteArray key: failedKeys)
- slopKeys.add(new ByteArray(ByteUtils.cat(opCode, spacer, storeName, spacer, key.get())));
+ Set<ByteArray> slopKeys = makeSlopKeys(failedKeys, Slop.Operation.PUT);
for (Store<ByteArray, Slop> slopStore: slopStores.values()) {
Map<ByteArray, List<Versioned<Slop>>> res = slopStore.getAll(slopKeys);
@@ -248,23 +240,39 @@ public void testHintedHandoff() throws Exception {
}
+ private Set<ByteArray> makeSlopKeys(Set<ByteArray> failedKeys, Slop.Operation operation) {
+ Set<ByteArray> slopKeys = Sets.newHashSet();
+
+ for(ByteArray key: failedKeys) {
+ byte[] opCode = new byte[] { operation.getOpCode() };
+ byte[] spacer = new byte[] { (byte) 0 };
+ byte[] storeName = ByteUtils.getBytes(STORE_NAME, "UTF-8");
+ ByteArray slopKey = new ByteArray(ByteUtils.cat(opCode, spacer, storeName, spacer, key.get()));
+ slopKeys.add(slopKey);
+ }
+ return slopKeys;
+ }
+
@Test
+ @Ignore
public void testSlopPushers() throws Exception {
Set<Integer> failedNodes = getFailedNodes();
Set<ByteArray> failedKeys = populateStore(failedNodes);
reviveNodes(failedNodes);
- for(SlopPusherJob job: slopPusherJobs) {
- if (logger.isTraceEnabled())
- logger.trace("Started slop pusher job " + job);
+ for(int i = 0; i < 5; i++) {
+ for(SlopPusherJob job: slopPusherJobs) {
+ if (logger.isTraceEnabled())
+ logger.trace("Started slop pusher job " + job);
- job.run();
+ job.run();
- if (logger.isTraceEnabled())
- logger.trace("Finished slop pusher job " + job);
+ if (logger.isTraceEnabled())
+ logger.trace("Finished slop pusher job " + job);
+ }
}
- for(ByteArray key: keyValues.keySet()) {
+ for(ByteArray key: failedKeys) {
List<Versioned<byte[]>> values = store.get(key);
assertTrue("slop entry should be pushed for " +
@@ -285,10 +293,11 @@ private void reviveNodes(Set<Integer> failedNodes) {
logger.trace("Stopped failing requests to " + node);
}
- while(!failedNodes.isEmpty())
+ while(!failedNodes.isEmpty()) {
for(int node: failedNodes)
if(failureDetector.isAvailable(cluster.getNodeById(node)))
failedNodes.remove(node);
+ }
}
@Test
@@ -302,7 +311,6 @@ public void testDeleteHandoff() throws Exception {
Set<Integer> failedNodes = getFailedNodes();
Set<ByteArray> failedKeys = Sets.newHashSet();
- Random rand = new Random();
for(ByteArray key: keysToNodes.keySet()) {
Iterable<Integer> nodes = keysToNodes.get(key);
@@ -324,21 +332,19 @@ public void testDeleteHandoff() throws Exception {
}
}
- reviveNodes(failedNodes);
-
- for(SlopPusherJob job: slopPusherJobs) {
- if (logger.isTraceEnabled())
- logger.trace("Started slop pusher job " + job);
+ Set<ByteArray> slopKeys = makeSlopKeys(failedKeys, Slop.Operation.DELETE);
+ Set<ByteArray> keysInSlops = Sets.newHashSet();
- job.run();
-
- if (logger.isTraceEnabled())
- logger.trace("Finished slop pusher job " + job);
+ for (Store<ByteArray, Slop> slopStore: slopStores.values()) {
+ Map<ByteArray, List<Versioned<Slop>>> res = slopStore.getAll(slopKeys);
+ for(Map.Entry<ByteArray, List<Versioned<Slop>>> entry: res.entrySet()) {
+ Slop slop = entry.getValue().get(0).getValue();
+ keysInSlops.add(slop.getKey());
+ }
}
- for(ByteArray key: failedKeys) {
- List<Versioned<byte[]>> res = store.get(key);
- assertTrue("key should be deleted", res.size() == 0);
+ for(ByteArray failedKey: failedKeys) {
+ assertTrue("delete operation should be handed off", keysInSlops.contains(failedKey));
}
}
@@ -409,8 +415,6 @@ private void setFailureDetector(Map<Integer, Store<ByteArray, byte[]>> subStores
FailureDetectorConfig failureDetectorConfig = new FailureDetectorConfig();
failureDetectorConfig.setImplementationClassName(failureDetectorCls.getName());
failureDetectorConfig.setBannagePeriod(30);
- failureDetectorConfig.setThresholdInterval(15000);
- failureDetectorConfig.setRequestLengthThreshold(2000);
failureDetectorConfig.setNodes(cluster.getNodes());
failureDetectorConfig.setStoreVerifier(MutableStoreVerifier.create(subStores));

0 comments on commit 7df37f1

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