Repository: cassandra
Updated Branches:
  refs/heads/trunk 00ed8017f -> 019471a56


sysexit on cassandra-stress main thread error

patch by benedict; reviewed by ryan for CASSANDRA-9864


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

Branch: refs/heads/trunk
Commit: 019471a567ca7f42930a952fa279fc96bb0b01a0
Parents: 00ed801
Author: Benedict Elliott Smith <[email protected]>
Authored: Wed Jul 22 23:38:51 2015 +0100
Committer: Benedict Elliott Smith <[email protected]>
Committed: Wed Jul 22 23:38:51 2015 +0100

----------------------------------------------------------------------
 .../src/org/apache/cassandra/stress/Stress.java | 90 +++++++++++---------
 1 file changed, 51 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/019471a5/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 a4ec8a0..bc6d027 100644
--- a/tools/stress/src/org/apache/cassandra/stress/Stress.java
+++ b/tools/stress/src/org/apache/cassandra/stress/Stress.java
@@ -57,66 +57,78 @@ public final class Stress
         if (FBUtilities.isWindows())
             WindowsTimer.startTimerPeriod(1);
 
-        final StressSettings settings;
         try
         {
-            settings = StressSettings.parse(arguments);
-        }
-        catch (IllegalArgumentException e)
-        {
-            printHelpMessage();
-            e.printStackTrace();
-            return;
-        }
 
-        PrintStream logout = settings.log.getOutput();
+            final StressSettings settings;
+            try
+            {
+                settings = StressSettings.parse(arguments);
+            }
+            catch (IllegalArgumentException e)
+            {
+                printHelpMessage();
+                e.printStackTrace();
+                return;
+            }
 
-        if (settings.sendToDaemon != null)
-        {
-            Socket socket = new Socket(settings.sendToDaemon, 2159);
+            PrintStream logout = settings.log.getOutput();
 
-            ObjectOutputStream out = new 
ObjectOutputStream(socket.getOutputStream());
-            BufferedReader inp = new BufferedReader(new 
InputStreamReader(socket.getInputStream()));
+            if (settings.sendToDaemon != null)
+            {
+                Socket socket = new Socket(settings.sendToDaemon, 2159);
 
-            Runtime.getRuntime().addShutdownHook(new ShutDown(socket, out));
+                ObjectOutputStream out = new 
ObjectOutputStream(socket.getOutputStream());
+                BufferedReader inp = new BufferedReader(new 
InputStreamReader(socket.getInputStream()));
 
-            out.writeObject(settings);
+                Runtime.getRuntime().addShutdownHook(new ShutDown(socket, 
out));
 
-            String line;
+                out.writeObject(settings);
 
-            try
-            {
-                while (!socket.isClosed() && (line = inp.readLine()) != null)
+                String line;
+
+                try
                 {
-                    if (line.equals("END") || line.equals("FAILURE"))
+                    while (!socket.isClosed() && (line = inp.readLine()) != 
null)
                     {
-                        out.writeInt(1);
-                        break;
-                    }
+                        if (line.equals("END") || line.equals("FAILURE"))
+                        {
+                            out.writeInt(1);
+                            break;
+                        }
 
-                    logout.println(line);
+                        logout.println(line);
+                    }
+                }
+                catch (SocketException e)
+                {
+                    if (!stopped)
+                        e.printStackTrace();
                 }
+
+                out.close();
+                inp.close();
+
+                socket.close();
             }
-            catch (SocketException e)
+            else
             {
-                if (!stopped)
-                    e.printStackTrace();
+                StressAction stressAction = new StressAction(settings, logout);
+                stressAction.run();
             }
 
-            out.close();
-            inp.close();
-
-            socket.close();
         }
-        else
+        catch (Throwable t)
         {
-            StressAction stressAction = new StressAction(settings, logout);
-            stressAction.run();
+            t.printStackTrace();
+        }
+        finally
+        {
+            if (FBUtilities.isWindows())
+                WindowsTimer.endTimerPeriod(1);
+            System.exit(0);
         }
 
-        if (FBUtilities.isWindows())
-            WindowsTimer.endTimerPeriod(1);
-        System.exit(0);
     }
 
     /**

Reply via email to