You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by db...@apache.org on 2016/08/31 23:56:31 UTC

cassandra git commit: add Serializable to Stress settings for daemon mode

Repository: cassandra
Updated Branches:
  refs/heads/trunk 42bbe0031 -> 03a3f9552


add Serializable to Stress settings for daemon mode

patch by cbatey reviewed by dbrosius for CASSANDRA-12564


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/03a3f955
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/03a3f955
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/03a3f955

Branch: refs/heads/trunk
Commit: 03a3f9552c5edd07667c9846578780b4987f114a
Parents: 42bbe00
Author: Chris Batey <ch...@gmail.com>
Authored: Wed Aug 31 19:55:15 2016 -0400
Committer: Dave Brosius <db...@mebigfatguy.com>
Committed: Wed Aug 31 19:55:15 2016 -0400

----------------------------------------------------------------------
 .../stress/settings/GroupedOptions.java         |  9 ++---
 .../cassandra/stress/settings/Option.java       |  3 +-
 .../stress/settings/SettingsTokenRange.java     |  5 ++-
 .../stress/settings/StressSettingsTest.java     | 39 ++++++++++++++++++++
 4 files changed, 48 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/03a3f955/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java b/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java
index c0a5d35..403eaac 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/GroupedOptions.java
@@ -22,15 +22,14 @@ package org.apache.cassandra.stress.settings;
 
 
 import java.io.PrintStream;
+import java.io.Serializable;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
 import com.google.common.collect.ImmutableList;
 
-import org.apache.cassandra.stress.util.MultiPrintStream;
-
-public abstract class GroupedOptions
+public abstract class GroupedOptions implements Serializable
 {
 
     int accepted = 0;
@@ -142,12 +141,12 @@ public abstract class GroupedOptions
         return builder.build();
     }
 
-    public static String formatLong(String longDisplay, String description)
+    static String formatLong(String longDisplay, String description)
     {
         return String.format("%-40s %s", longDisplay, description);
     }
 
-    public static String formatMultiLine(String longDisplay, String description)
+    static String formatMultiLine(String longDisplay, String description)
     {
         return String.format("%-36s %s", longDisplay, description);
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/03a3f955/tools/stress/src/org/apache/cassandra/stress/settings/Option.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/Option.java b/tools/stress/src/org/apache/cassandra/stress/settings/Option.java
index 37701d6..24eb33a 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/Option.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/Option.java
@@ -21,9 +21,10 @@ package org.apache.cassandra.stress.settings;
  */
 
 
+import java.io.Serializable;
 import java.util.List;
 
-abstract class Option
+abstract class Option implements Serializable
 {
 
     abstract boolean accept(String param);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/03a3f955/tools/stress/src/org/apache/cassandra/stress/settings/SettingsTokenRange.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsTokenRange.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsTokenRange.java
index 51db62b..648823b 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsTokenRange.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsTokenRange.java
@@ -18,6 +18,7 @@
 
 package org.apache.cassandra.stress.settings;
 
+import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 
@@ -26,13 +27,13 @@ import com.google.common.primitives.Ints;
 
 import org.apache.cassandra.stress.util.MultiPrintStream;
 
-public class SettingsTokenRange
+public class SettingsTokenRange implements Serializable
 {
     public final boolean wrap;
     public final int splitFactor;
     private final TokenRangeOptions options;
 
-    public SettingsTokenRange(TokenRangeOptions options)
+    private SettingsTokenRange(TokenRangeOptions options)
     {
         this.options = options;
         this.wrap = options.wrap.setByUser();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/03a3f955/tools/stress/test/unit/org/apache/cassandra/stress/settings/StressSettingsTest.java
----------------------------------------------------------------------
diff --git a/tools/stress/test/unit/org/apache/cassandra/stress/settings/StressSettingsTest.java b/tools/stress/test/unit/org/apache/cassandra/stress/settings/StressSettingsTest.java
new file mode 100644
index 0000000..c664aee
--- /dev/null
+++ b/tools/stress/test/unit/org/apache/cassandra/stress/settings/StressSettingsTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.cassandra.stress.settings;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class StressSettingsTest
+{
+    @Test
+    public void isSerializable() throws Exception
+    {
+        Map<String, String[]> args = new HashMap<>();
+        args.put("write", new String[] {});
+        StressSettings settings = StressSettings.get(args);
+        // Will throw if not all settings are Serializable
+        new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(settings);
+    }
+}