Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'fd-after-rebalance'

  • Loading branch information...
commit e5e5a2e16350bbb661e22678f103121c7f920a07 2 parents e64bcd8 + 2856d51
Alex Feinberg afeinberg authored
3  src/java/voldemort/cluster/failuredetector/AbstractFailureDetector.java
View
@@ -220,6 +220,9 @@ protected NodeStatus getNodeStatus(Node node) {
nodeStatus = createNodeStatus(failureDetectorConfig.getTime().getMilliseconds());
nodeStatusMap.put(node, nodeStatus);
+ if(!failureDetectorConfig.getNodes().contains(node)) {
+ failureDetectorConfig.addNode(node);
+ }
}
return nodeStatus;
3  src/java/voldemort/cluster/failuredetector/BasicStoreVerifier.java
View
@@ -32,7 +32,7 @@
public class BasicStoreVerifier<K, V, T> implements StoreVerifier {
- private final Map<Integer, Store<K, V, T>> stores;
+ protected final Map<Integer, Store<K, V, T>> stores;
private final K key;
@@ -51,5 +51,4 @@ public void verifyStore(Node node) throws UnreachableStoreException, VoldemortEx
// This is our test.
store.get(key, null);
}
-
}
16 src/java/voldemort/cluster/failuredetector/FailureDetectorConfig.java
View
@@ -20,8 +20,10 @@
import java.net.NoRouteToHostException;
import java.net.UnknownHostException;
import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
+import com.google.common.collect.ImmutableSet;
import voldemort.client.ClientConfig;
import voldemort.cluster.Node;
import voldemort.server.VoldemortConfig;
@@ -542,8 +544,8 @@ public FailureDetectorConfig setRequestLengthThreshold(long requestLengthThresho
* @return Collection of Node instances, usually determined from the Cluster
*/
- public Collection<Node> getNodes() {
- return nodes;
+ public synchronized Collection<Node> getNodes() {
+ return ImmutableSet.copyOf(nodes);
}
/**
@@ -554,11 +556,17 @@ public FailureDetectorConfig setRequestLengthThreshold(long requestLengthThresho
* Cluster; must be non-null
*/
- public FailureDetectorConfig setNodes(Collection<Node> nodes) {
- this.nodes = Utils.notNull(nodes);
+ public synchronized FailureDetectorConfig setNodes(Collection<Node> nodes) {
+ Utils.notNull(nodes);
+ this.nodes = new HashSet<Node>(nodes);
return this;
}
+ public synchronized void addNode(Node node) {
+ Utils.notNull(node);
+ nodes.add(node);
+ }
+
public StoreVerifier getStoreVerifier() {
return storeVerifier;
}
1  test/common/voldemort/FailureDetectorTestUtils.java
View
@@ -18,6 +18,7 @@
import voldemort.cluster.Node;
import voldemort.cluster.failuredetector.FailureDetector;
+import voldemort.cluster.failuredetector.MutableStoreVerifier;
import voldemort.store.UnreachableStoreException;
public class FailureDetectorTestUtils {
7 test/common/voldemort/VoldemortTestConstants.java
View
@@ -62,6 +62,9 @@ public static Cluster getTwoNodeCluster() {
return new ClusterMapper().readCluster(new StringReader(getTwoNodeClusterXml()));
}
+ public static String getTenNodeClusterXml() {
+ return readString("config/ten-node-cluster.xml");
+ }
public static String getNineNodeClusterXml() {
return readString("config/nine-node-cluster.xml");
}
@@ -82,6 +85,10 @@ public static String getSingleStoreWithZonesXml() {
return readString("config/single-store-with-zones.xml");
}
+ public static Cluster getTenNodeCluster() {
+ return new ClusterMapper().readCluster(new StringReader(getTenNodeClusterXml()));
+ }
+
public static Cluster getNineNodeCluster() {
return new ClusterMapper().readCluster(new StringReader(getNineNodeClusterXml()));
}
68 test/common/voldemort/MutableStoreVerifier.java → ...cluster/failuredetector/MutableStoreVerifier.java
View
@@ -1,12 +1,12 @@
-package voldemort;
+package voldemort.cluster.failuredetector;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import voldemort.VoldemortException;
import voldemort.cluster.Node;
-import voldemort.cluster.failuredetector.BasicStoreVerifier;
import voldemort.store.Store;
import voldemort.store.StoreCapabilityType;
import voldemort.store.UnreachableStoreException;
@@ -45,6 +45,10 @@ public void setErrorStore(Node node, VoldemortException voldemortException) {
errorStores.put(node.getId(), voldemortException);
}
+ public void addStore(Node node) {
+ stores.put(node.getId(), createStore());
+ }
+
public static MutableStoreVerifier create(Map<Integer, Store<ByteArray, byte[], byte[]>> stores) {
return new MutableStoreVerifier(stores);
}
@@ -53,44 +57,48 @@ public static MutableStoreVerifier create(Collection<Node> nodes) {
Map<Integer, Store<ByteArray, byte[], byte[]>> stores = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>();
for(Node node: nodes) {
- stores.put(node.getId(), new Store<ByteArray, byte[], byte[]>() {
+ stores.put(node.getId(), createStore());
+ }
+
+ return new MutableStoreVerifier(stores);
+ }
- public void close() throws VoldemortException {}
+ private static Store<ByteArray, byte[], byte[]> createStore() {
+ return new Store<ByteArray, byte[], byte[]>() {
- public boolean delete(ByteArray key, Version version) throws VoldemortException {
- return false;
- }
+ public void close() throws VoldemortException {}
- public List<Versioned<byte[]>> get(ByteArray key, byte[] transforms)
- throws VoldemortException {
- return null;
- }
+ public boolean delete(ByteArray key, Version version) throws VoldemortException {
+ return false;
+ }
- public Map<ByteArray, List<Versioned<byte[]>>> getAll(Iterable<ByteArray> keys,
- Map<ByteArray, byte[]> transforms)
- throws VoldemortException {
- return null;
- }
+ public List<Versioned<byte[]>> get(ByteArray key, byte[] transforms)
+ throws VoldemortException {
+ return null;
+ }
- public Object getCapability(StoreCapabilityType capability) {
- return null;
- }
+ public Map<ByteArray, List<Versioned<byte[]>>> getAll(Iterable<ByteArray> keys,
+ Map<ByteArray, byte[]> transforms)
+ throws VoldemortException {
+ return null;
+ }
- public String getName() {
- return null;
- }
+ public Object getCapability(StoreCapabilityType capability) {
+ return null;
+ }
- public List<Version> getVersions(ByteArray key) {
- return null;
- }
+ public String getName() {
+ return null;
+ }
- public void put(ByteArray key, Versioned<byte[]> value, byte[] transforms)
- throws VoldemortException {}
+ public List<Version> getVersions(ByteArray key) {
+ return null;
+ }
- });
- }
+ public void put(ByteArray key, Versioned<byte[]> value, byte[] transforms)
+ throws VoldemortException {}
- return new MutableStoreVerifier(stores);
+ };
}
}
86 test/common/voldemort/config/ten-node-cluster.xml
View
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<cluster>
+ <name>mycluster</name>
+ <server>
+ <id>0</id>
+ <host>localhost</host>
+ <http-port>8080</http-port>
+ <socket-port>6666</socket-port>
+ <admin-port>7666</admin-port>
+ <partitions>16, 3, 21</partitions>
+ </server>
+ <server>
+ <id>1</id>
+ <host>localhost</host>
+ <http-port>8081</http-port>
+ <socket-port>6667</socket-port>
+ <admin-port>7667</admin-port>
+ <partitions>23, 18, 13</partitions>
+ </server>
+ <server>
+ <id>2</id>
+ <host>localhost</host>
+ <http-port>8082</http-port>
+ <socket-port>6668</socket-port>
+ <admin-port>7668</admin-port>
+ <partitions>22, 12</partitions>
+ </server>
+ <server>
+ <id>3</id>
+ <host>localhost</host>
+ <http-port>8083</http-port>
+ <socket-port>6669</socket-port>
+ <admin-port>7669</admin-port>
+ <partitions>2, 17, 24</partitions>
+ </server>
+ <server>
+ <id>4</id>
+ <host>localhost</host>
+ <http-port>8084</http-port>
+ <socket-port>6670</socket-port>
+ <admin-port>7670</admin-port>
+ <partitions>11, 25, 10</partitions>
+ </server>
+ <server>
+ <id>5</id>
+ <host>localhost</host>
+ <http-port>8085</http-port>
+ <socket-port>6671</socket-port>
+ <admin-port>7671</admin-port>
+ <partitions>
+ 4, 19, 5
+ </partitions>
+ </server>
+ <server>
+ <id>6</id>
+ <host>localhost</host>
+ <http-port>8086</http-port>
+ <socket-port>6672</socket-port>
+ <admin-port>7672</admin-port>
+ <partitions>0, 14</partitions>
+ </server>
+ <server>
+ <id>7</id>
+ <host>localhost</host>
+ <http-port>8087</http-port>
+ <socket-port>6673</socket-port>
+ <admin-port>7673</admin-port>
+ <partitions>1, 6</partitions>
+ </server>
+ <server>
+ <id>8</id>
+ <host>localhost</host>
+ <http-port>8088</http-port>
+ <socket-port>6674</socket-port>
+ <admin-port>7674</admin-port>
+ <partitions>8, 7</partitions>
+ </server>
+ <server>
+ <id>9</id>
+ <host>localhost</host>
+ <http-port>8089</http-port>
+ <socket-port>6675</socket-port>
+ <admin-port>7675</admin-port>
+ <partitions>15, 9, 20</partitions>
+ </server>
+</cluster>
3  test/integration/voldemort/cluster/failuredetector/FailureDetectorPerformanceTest.java
View
@@ -16,7 +16,7 @@
package voldemort.cluster.failuredetector;
-import static voldemort.MutableStoreVerifier.create;
+import static voldemort.cluster.failuredetector.MutableStoreVerifier.create;
import static voldemort.VoldemortTestConstants.getNineNodeCluster;
import static voldemort.cluster.failuredetector.FailureDetectorUtils.create;
@@ -24,7 +24,6 @@
import joptsimple.OptionParser;
import joptsimple.OptionSet;
-import voldemort.MutableStoreVerifier;
import voldemort.cluster.Cluster;
import voldemort.cluster.Node;
import voldemort.store.UnreachableStoreException;
2  test/integration/voldemort/performance/RoutedStoreParallelismTest.java
View
@@ -28,7 +28,7 @@
import joptsimple.OptionParser;
import joptsimple.OptionSet;
-import voldemort.MutableStoreVerifier;
+import voldemort.cluster.failuredetector.MutableStoreVerifier;
import voldemort.ServerTestUtils;
import voldemort.TestUtils;
import voldemort.VoldemortException;
2  test/unit/voldemort/cluster/TestCluster.java
View
@@ -16,7 +16,7 @@
package voldemort.cluster;
-import static voldemort.MutableStoreVerifier.create;
+import static voldemort.cluster.failuredetector.MutableStoreVerifier.create;
import static voldemort.cluster.failuredetector.FailureDetectorUtils.create;
import java.util.Arrays;
2  test/unit/voldemort/cluster/failuredetector/BannagePeriodFailureDetectorTest.java
View
@@ -20,7 +20,7 @@
import static org.junit.Assert.assertTrue;
import static voldemort.FailureDetectorTestUtils.recordException;
import static voldemort.FailureDetectorTestUtils.recordSuccess;
-import static voldemort.MutableStoreVerifier.create;
+import static voldemort.cluster.failuredetector.MutableStoreVerifier.create;
import static voldemort.cluster.failuredetector.FailureDetectorUtils.create;
import java.net.ConnectException;
23 test/unit/voldemort/cluster/failuredetector/ThresholdFailureDetectorTest.java
View
@@ -20,8 +20,9 @@
import static org.junit.Assert.assertTrue;
import static voldemort.FailureDetectorTestUtils.recordException;
import static voldemort.FailureDetectorTestUtils.recordSuccess;
-import static voldemort.MutableStoreVerifier.create;
+import static voldemort.cluster.failuredetector.MutableStoreVerifier.create;
import static voldemort.cluster.failuredetector.FailureDetectorUtils.create;
+import static voldemort.VoldemortTestConstants.getTenNodeCluster;
import java.net.ConnectException;
import java.net.NoRouteToHostException;
@@ -38,16 +39,18 @@
public class ThresholdFailureDetectorTest extends AbstractFailureDetectorTest {
+ private MutableStoreVerifier storeVerifier;
+
@Override
public FailureDetector createFailureDetector() throws Exception {
+ storeVerifier = create(cluster.getNodes());
FailureDetectorConfig failureDetectorConfig = new FailureDetectorConfig().setImplementationClassName(ThresholdFailureDetector.class.getName())
.setBannagePeriod(BANNAGE_MILLIS)
.setAsyncRecoveryInterval(250)
.setThresholdInterval(500)
.setNodes(cluster.getNodes())
- .setStoreVerifier(create(cluster.getNodes()))
+ .setStoreVerifier(storeVerifier)
.setTime(time);
-
return create(failureDetectorConfig, true);
}
@@ -166,4 +169,18 @@ public void testBorder() throws Exception {
recordSuccess(failureDetector, node);
}
+ @Test
+ public void testChangeMetadata() throws Exception {
+ cluster = getTenNodeCluster();
+ Node node = cluster.getNodeById(9);
+ storeVerifier.addStore(node);
+ failureDetector.recordException(node,
+ 0,
+ new UnreachableStoreException("intentionalerror",
+ new ConnectException("intentionalerror")));
+
+ assertEquals(false, failureDetector.isAvailable(node));
+ Thread.sleep(failureDetector.getConfig().getAsyncRecoveryInterval() * 2);
+ assertEquals(true, failureDetector.isAvailable(node));
+ }
}
2  test/unit/voldemort/store/routed/HintedHandoffTest.java
View
@@ -27,7 +27,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import voldemort.MutableStoreVerifier;
+import voldemort.cluster.failuredetector.MutableStoreVerifier;
import voldemort.ServerTestUtils;
import voldemort.TestUtils;
import voldemort.VoldemortException;
2  test/unit/voldemort/store/routed/ReadRepairerTest.java
View
@@ -21,7 +21,7 @@
import static org.junit.Assert.assertEquals;
import static voldemort.FailureDetectorTestUtils.recordException;
import static voldemort.FailureDetectorTestUtils.recordSuccess;
-import static voldemort.MutableStoreVerifier.create;
+import static voldemort.cluster.failuredetector.MutableStoreVerifier.create;
import static voldemort.TestUtils.getClock;
import static voldemort.cluster.failuredetector.FailureDetectorUtils.create;
2  test/unit/voldemort/store/routed/RoutedStoreTest.java
View
@@ -18,7 +18,7 @@
import static voldemort.FailureDetectorTestUtils.recordException;
import static voldemort.FailureDetectorTestUtils.recordSuccess;
-import static voldemort.MutableStoreVerifier.create;
+import static voldemort.cluster.failuredetector.MutableStoreVerifier.create;
import static voldemort.TestUtils.getClock;
import static voldemort.VoldemortTestConstants.getNineNodeCluster;
import static voldemort.cluster.failuredetector.FailureDetectorUtils.create;
Please sign in to comment.
Something went wrong with that request. Please try again.