Renamed isAllowVnodes and disallowVNodes to allow more control over when vnode or single token are supported (#32)


patch by David Capwell; reviewed by Alex Petrov, Josh McKenzie for CASSANDRA-17332
diff --git a/CHANGES.txt b/CHANGES.txt
index 31963b0..707813c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+# 0.0.13
+
+CASSANDRA-17332: Add support for vnodes in jvm-dtest
+
 # 0.0.12
 
 CASSANDRA-17214:Add IInstance.isValid() with default true return value
diff --git a/src/main/java/org/apache/cassandra/distributed/shared/AbstractBuilder.java b/src/main/java/org/apache/cassandra/distributed/shared/AbstractBuilder.java
index 665cdc5..c9712df 100644
--- a/src/main/java/org/apache/cassandra/distributed/shared/AbstractBuilder.java
+++ b/src/main/java/org/apache/cassandra/distributed/shared/AbstractBuilder.java
@@ -42,6 +42,8 @@
 
 public abstract class AbstractBuilder<I extends IInstance, C extends ICluster, B extends AbstractBuilder<I, C, B>>
 {
+    private enum VNodeState
+    { SUPPORT_ALL, ONLY_SINGLE_TOKEN, ONLY_VNODE }
     public interface Factory<I extends IInstance, C extends ICluster, B extends AbstractBuilder<I, C, B>>
     {
         C newCluster(B builder);
@@ -65,7 +67,7 @@
     private final List<Rack> racks = new ArrayList<>();
     private boolean finalised;
     private int tokenCount = getDefaultTokenCount();
-    private boolean allowVnodes = true;
+    private VNodeState vnodeState = VNodeState.SUPPORT_ALL;
 
     protected int getDefaultTokenCount() {
         String key = "cassandra.dtest.num_tokens";
@@ -149,8 +151,13 @@
         return tokenCount;
     }
 
-    public boolean isAllowVnodes() {
-        return allowVnodes;
+    public boolean isVNodeAllowed() {
+        return vnodeState != VNodeState.ONLY_SINGLE_TOKEN;
+    }
+
+    public boolean isSingleTokenAllowed()
+    {
+        return vnodeState != VNodeState.ONLY_VNODE;
     }
 
     public C start() throws IOException
@@ -387,9 +394,15 @@
         return (B) this;
     }
 
-    public B disallowVNodes()
+    public B withVNodes()
     {
-        this.allowVnodes = false;
+        vnodeState = VNodeState.ONLY_VNODE;
+        return (B) this;
+    }
+
+    public B withoutVNodes()
+    {
+        vnodeState = VNodeState.ONLY_SINGLE_TOKEN;
         return (B) this;
     }