cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject git commit: stress tool to return appropriate exit code on failure patch by Tyler Patterson; reviewed by Pavel Yaskevich for CASSANDRA-4188
Date Thu, 03 May 2012 00:37:40 GMT
Updated Branches:
  refs/heads/cassandra-1.0 48a22695f -> f20badb68


stress tool to return appropriate exit code on failure
patch by Tyler Patterson; reviewed by Pavel Yaskevich for CASSANDRA-4188


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

Branch: refs/heads/cassandra-1.0
Commit: f20badb685393e60f74b236edf623c7c9264f1eb
Parents: 48a2269
Author: Pavel Yaskevich <xedin@apache.org>
Authored: Thu May 3 03:29:34 2012 +0300
Committer: Pavel Yaskevich <xedin@apache.org>
Committed: Thu May 3 03:34:58 2012 +0300

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../src/org/apache/cassandra/stress/Stress.java    |    7 ++-
 .../org/apache/cassandra/stress/StressAction.java  |   34 ++++++++++++++-
 3 files changed, 38 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f20badb6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index bd508c6..ad301db 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,7 @@
  * Avoids possible deadlock during bootstrap (CASSANDRA-4159)
  * fix stress tool that hangs forever on timeout or error (CASSANDRA-4128)
  * Fix super columns bug where cache is not updated (CASSANDRA-4190)
+ * stress tool to return appropriate exit code on failure (CASSANDRA-4188)
 
 
 1.0.9

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f20badb6/tools/stress/src/org/apache/cassandra/stress/Stress.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/Stress.java b/tools/stress/src/org/apache/cassandra/stress/Stress.java
index c5e65f8..b490d69 100644
--- a/tools/stress/src/org/apache/cassandra/stress/Stress.java
+++ b/tools/stress/src/org/apache/cassandra/stress/Stress.java
@@ -66,7 +66,7 @@ public final class Stress
             {
                 while (!socket.isClosed() && (line = inp.readLine()) != null)
                 {
-                    if (line.equals("END"))
+                    if (line.equals("END") || line.equals("FAILURE"))
                     {
                         out.writeInt(1);
                         break;
@@ -88,7 +88,10 @@ public final class Stress
         }
         else
         {
-            new StressAction(session, outStream).start();
+            StressAction stressAction = new StressAction(session, outStream);
+            stressAction.start();
+            stressAction.join();
+            System.exit(stressAction.getReturnCode());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f20badb6/tools/stress/src/org/apache/cassandra/stress/StressAction.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/StressAction.java b/tools/stress/src/org/apache/cassandra/stress/StressAction.java
index f0a9f49..d043b66 100644
--- a/tools/stress/src/org/apache/cassandra/stress/StressAction.java
+++ b/tools/stress/src/org/apache/cassandra/stress/StressAction.java
@@ -37,6 +37,11 @@ public class StressAction extends Thread
 
     private volatile boolean stop = false;
 
+    public static final int SUCCESS = 0;
+    public static final int FAILURE = 1;
+
+    private volatile int returnCode = -1;
+
     public StressAction(Session session, PrintStream out)
     {
         client = session;
@@ -137,11 +142,28 @@ public class StressAction extends Thread
             }
         }
 
+        // if any consumer failed, set the return code to failure.
+        returnCode = SUCCESS;
         if (producer.isAlive())
+        {
             producer.interrupt(); // if producer is still alive it means that we had errors
in the consumers
+            returnCode = FAILURE;
+        }
+        for (Consumer consumer : consumers)
+            if (consumer.getReturnCode() == FAILURE)
+                returnCode = FAILURE;
+
+        if (returnCode == SUCCESS)
+            // marking an end of the output to the client
+            output.println("END");
+        else
+            output.println("FAILURE");
 
-        // marking an end of the output to the client
-        output.println("END");
+    }
+
+    public int getReturnCode()
+    {
+        return returnCode;
     }
 
     /**
@@ -184,6 +206,7 @@ public class StressAction extends Thread
     {
         private final int items;
         private volatile boolean stop = false;
+        private volatile int returnCode = StressAction.SUCCESS;
 
         public Consumer(int toConsume)
         {
@@ -208,11 +231,13 @@ public class StressAction extends Thread
                     if (output == null)
                     {
                         System.err.println(e.getMessage());
+                        returnCode = StressAction.FAILURE;
                         System.exit(-1);
                     }
 
 
                     output.println(e.getMessage());
+                    returnCode = StressAction.FAILURE;
                     break;
                 }
             }
@@ -222,6 +247,11 @@ public class StressAction extends Thread
         {
             stop = true;
         }
+
+        public int getReturnCode()
+        {
+            return returnCode;
+        }
     }
 
     private Operation createOperation(int index)


Mime
View raw message