You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/05/06 21:42:49 UTC

incubator-tinkerpop git commit: Add a configuration tester for gremlin-driver.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master a1e634cd0 -> 1b28d109b


Add a configuration tester for gremlin-driver.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/1b28d109
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/1b28d109
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/1b28d109

Branch: refs/heads/master
Commit: 1b28d109b181aeb7c5f7ffb523a843ee6c4d8832
Parents: a1e634c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 6 15:42:28 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed May 6 15:42:28 2015 -0400

----------------------------------------------------------------------
 gremlin-driver/src/main/bin/config-eval.sh      | 45 +++++++++++
 .../driver/util/ConfigurationEvaluator.java     | 84 ++++++++++++++++++++
 .../driver/util/ProfilingApplication.java       | 14 +++-
 3 files changed, 139 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1b28d109/gremlin-driver/src/main/bin/config-eval.sh
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/bin/config-eval.sh b/gremlin-driver/src/main/bin/config-eval.sh
new file mode 100644
index 0000000..c55ebf5
--- /dev/null
+++ b/gremlin-driver/src/main/bin/config-eval.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+#
+# 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.
+#
+case `uname` in
+  CYGWIN*)
+    CP="`dirname $0`"/../config/
+    CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /;/g')
+    ;;
+  *)
+    CP="`dirname $0`"/../config/
+    CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /:/g')
+esac
+#echo $CP
+
+# Find Java
+if [ "$JAVA_HOME" = "" ] ; then
+    JAVA="java -server"
+else
+    JAVA="$JAVA_HOME/bin/java -server"
+fi
+
+# Set Java options
+if [ "$JAVA_OPTIONS" = "" ] ; then
+    JAVA_OPTIONS="-Xms1024m -Xmx1024m"
+fi
+
+# Execute the application and return its exit code
+exec $JAVA -Dlog4j.configuration=conf/log4j-driver.properties $JAVA_OPTIONS -cp $CP org.apache.tinkerpop.gremlin.driver.util.ConfigurationEvaluator "$@"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1b28d109/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ConfigurationEvaluator.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ConfigurationEvaluator.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ConfigurationEvaluator.java
new file mode 100644
index 0000000..e3a8bbe
--- /dev/null
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ConfigurationEvaluator.java
@@ -0,0 +1,84 @@
+/*
+ * 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.tinkerpop.gremlin.driver.util;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Stream;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class ConfigurationEvaluator {
+
+    private final List<Integer> minConnectionPoolSizeRange = Arrays.asList(1,4,8,12,16,32,64,96,128,160,192,224,256,384,512);
+    private final List<Integer> maxConnectionPoolSizeRange = Arrays.asList(4,8,12,16,32,64,96,128,160,192,224,256,384,512);
+    private final List<Integer> maxSimultaneousRequestsPerConnectionRange = Arrays.asList(2,3,4,5,8,16,24,32,64,96,128);
+    private final List<Integer> maxInProcessPerConnectionRange = Arrays.asList(1,2,4,8,12,16,32,64,96,128);
+    private final List<Integer> workerPoolSizeRange = Arrays.asList(1,2,3,4,8,16,32);
+
+    public Stream<String[]> generate(final String [] args) {
+        final Set<Set<Integer>> configsTried = new HashSet<>();
+        for (int iv = 0; iv < workerPoolSizeRange.size(); iv++) {
+            for (int iw = 0; iw < maxInProcessPerConnectionRange.size(); iw++) {
+                for (int ix = 0; ix < minConnectionPoolSizeRange.size(); ix++) {
+                    for (int iy = 0; iy < maxConnectionPoolSizeRange.size(); iy++) {
+                        for (int iz = 0; iz < maxSimultaneousRequestsPerConnectionRange.size(); iz++) {
+                            if (minConnectionPoolSizeRange.get(ix) <= maxConnectionPoolSizeRange.get(iy)) {
+                                final Set s = new HashSet(Arrays.asList(iv, iw, ix, iy, iz));
+                                if (!configsTried.contains(s)) {
+                                    final Object[] argsToProfiler =
+                                            Stream.of("workerPoolSize", workerPoolSizeRange.get(iv).toString(),
+                                                      "maxInProcessPerConnection", maxInProcessPerConnectionRange.get(iw).toString(),
+                                                      "minConnectionPoolSize", minConnectionPoolSizeRange.get(ix).toString(),
+                                                      "maxConnectionPoolSize", maxConnectionPoolSizeRange.get(iy).toString(),
+                                                      "maxSimultaneousRequestsPerConnection", maxSimultaneousRequestsPerConnectionRange.get(iz).toString(),
+                                                      "noExit", Boolean.TRUE.toString()).toArray();
+
+                                    final Object[] withExtraArgs = args.length > 0 ? Stream.concat(Stream.of(args), Stream.of(argsToProfiler)).toArray() : argsToProfiler;
+
+                                    final String[] stringProfilerArgs = Arrays.copyOf(withExtraArgs, withExtraArgs.length, String[].class);
+                                    System.out.println("Testing with: " + Arrays.toString(stringProfilerArgs));
+                                    ProfilingApplication.main(stringProfilerArgs);
+
+                                    configsTried.add(s);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        System.out.println(configsTried.size());
+        return null;
+    }
+
+    public static void main(final String [] args) {
+        try {
+            new ConfigurationEvaluator().generate(args);
+            System.exit(0);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(1);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1b28d109/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
index 5032f7b..a4a5c80 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java
@@ -22,8 +22,10 @@ import org.apache.tinkerpop.gremlin.driver.Client;
 import org.apache.tinkerpop.gremlin.driver.Cluster;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 
+import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
+import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.PrintWriter;
 import java.util.List;
@@ -33,6 +35,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
@@ -126,8 +129,10 @@ public class ProfilingApplication {
     }
 
     public static void main(final String[] args) {
+        final Map<String,Object> options = ElementHelper.asMap(args);
+        final boolean noExit = Boolean.parseBoolean(options.getOrDefault("noExit", "false").toString());
+
         try {
-            final Map<String,Object> options = ElementHelper.asMap(args);
             final String host = options.getOrDefault("host", "localhost").toString();
             final int warmups = Integer.parseInt(options.getOrDefault("warmups", "5").toString());
             final int executions = Integer.parseInt(options.getOrDefault("executions", "10").toString());
@@ -149,7 +154,7 @@ public class ProfilingApplication {
 
             final Object fileName = options.get("store");
             final File f = null == fileName ? null : new File(fileName.toString());
-            if (f != null) {
+            if (f != null && f.length() == 0) {
                 try (final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(f, true)))) {
                     writer.println("clients\tminConnectionPoolSize\tmaxConnectionPoolSize\tmaxSimultaneousRequestsPerConnection\tmaxInProcessPerConnection\tworkerPoolSize\trequestPerSecond");
                 }
@@ -175,10 +180,11 @@ public class ProfilingApplication {
                     writer.println(String.join("\t", String.valueOf(clients), String.valueOf(minConnectionPoolSize), String.valueOf(maxConnectionPoolSize), String.valueOf(maxSimultaneousRequestsPerConnection), String.valueOf(maxInProcessPerConnection), String.valueOf(workerPoolSize), String.valueOf(averageRequestPerSecond)));
                 }
             }
-            System.exit(0);
+
+            if (!noExit) System.exit(0);
         } catch (Exception ex) {
             ex.printStackTrace();
-            System.exit(1);
+            if (!noExit) System.exit(1);
         }
     }
 }