cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject svn commit: r1060558 - in /cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress: tests/IndexedRangeSlicer.java tests/Inserter.java tests/MultiGetter.java tests/RangeSlicer.java tests/Reader.java util/OperationThread.java
Date Tue, 18 Jan 2011 20:22:14 GMT
Author: brandonwilliams
Date: Tue Jan 18 20:22:14 2011
New Revision: 1060558

URL: http://svn.apache.org/viewvc?rev=1060558&view=rev
Log:
Improve stress.java error handling.
Patch by Pavel Yaskevich, reviewed by brandonwilliams for CASSANDRA-1973

Modified:
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/IndexedRangeSlicer.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/Inserter.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/MultiGetter.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/RangeSlicer.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/Reader.java
    cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/OperationThread.java

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/IndexedRangeSlicer.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/IndexedRangeSlicer.java?rev=1060558&r1=1060557&r2=1060558&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/IndexedRangeSlicer.java
(original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/IndexedRangeSlicer.java
Tue Jan 18 20:22:14 2011
@@ -68,19 +68,15 @@ public class IndexedRangeSlicer extends 
 
                     if (results.size() == 0)
                     {
-                        throw new RuntimeException("No indexed values from offset received:
" + startOffset);
-                    }
-                }
-                catch (InvalidRequestException e)
-                {
-                    System.err.println(e.getWhy());
+                        System.err.printf("No indexed values from offset received: %s%n",
startOffset);
 
-                    if (!session.ignoreErrors())
-                        return;
+                        if (!session.ignoreErrors())
+                            break;
+                    }
                 }
                 catch (Exception e)
                 {
-                    System.err.println(e.getMessage());
+                    System.err.printf("Error on get_indexed_slices call for offset  %s -
%s%n", startOffset, getExceptionMessage(e));
 
                     if (!session.ignoreErrors())
                         return;

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/Inserter.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/Inserter.java?rev=1060558&r1=1060557&r2=1060558&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/Inserter.java
(original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/Inserter.java
Tue Jan 18 20:22:14 2011
@@ -19,10 +19,8 @@ package org.apache.cassandra.contrib.str
 
 import org.apache.cassandra.contrib.stress.util.OperationThread;
 import org.apache.cassandra.db.ColumnFamilyType;
-import org.apache.cassandra.thrift.Column;
-import org.apache.cassandra.thrift.ColumnOrSuperColumn;
-import org.apache.cassandra.thrift.Mutation;
-import org.apache.cassandra.thrift.SuperColumn;
+import org.apache.cassandra.thrift.*;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
@@ -85,7 +83,7 @@ public class Inserter extends OperationT
             }
             catch (Exception e)
             {
-                System.err.println(e.getMessage());
+                System.err.printf("Error while inserting key %s - %s%n", ByteBufferUtil.string(key),
getExceptionMessage(e));
 
                 if (!session.ignoreErrors())
                     return;

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/MultiGetter.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/MultiGetter.java?rev=1060558&r1=1060557&r2=1060558&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/MultiGetter.java
(original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/MultiGetter.java
Tue Jan 18 20:22:14 2011
@@ -61,19 +61,15 @@ public class MultiGetter extends Operati
 
                         if (results.size() == 0)
                         {
-                            throw new RuntimeException(String.format("Keys %s not found",
keys));
-                        }
-                    }
-                    catch (InvalidRequestException e)
-                    {
-                        System.err.println(e.getWhy());
+                            System.err.printf("Keys %s were not found.%n", keys);
 
-                        if (!session.ignoreErrors())
-                            return;
+                            if (!session.ignoreErrors())
+                                break;
+                        }
                     }
                     catch (Exception e)
                     {
-                        System.err.println(e.getMessage());
+                        System.err.printf("Error on multiget_slice call - %s%n", getExceptionMessage(e));
 
                         if (!session.ignoreErrors())
                             return;
@@ -103,19 +99,15 @@ public class MultiGetter extends Operati
 
                     if (results.size() == 0)
                     {
-                        throw new RuntimeException(String.format("Keys %s not found", keys));
-                    }
-                }
-                catch (InvalidRequestException e)
-                {
-                    System.err.println(e.getWhy());
+                        System.err.printf("Keys %s were not found.%n", keys);
 
-                    if (!session.ignoreErrors())
-                        return;
+                        if (!session.ignoreErrors())
+                            break;
+                    }
                 }
                 catch (Exception e)
                 {
-                    System.err.println(e.getMessage());
+                    System.err.printf("Error on multiget_slice call - %s%n", getExceptionMessage(e));
 
                     if (!session.ignoreErrors())
                         return;

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/RangeSlicer.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/RangeSlicer.java?rev=1060558&r1=1060557&r2=1060558&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/RangeSlicer.java
(original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/RangeSlicer.java
Tue Jan 18 20:22:14 2011
@@ -70,19 +70,15 @@ public class RangeSlicer extends Operati
 
                         if (slices.size() == 0)
                         {
-                            throw new RuntimeException(String.format("Key %s not found.",
superColumnName));
-                        }
-                    }
-                    catch (InvalidRequestException e)
-                    {
-                        System.err.println(e.getWhy());
+                            System.err.printf("Range %s->%s not found in Super Column
%s.%n", new String(start), new String(end), superColumnName);
 
-                        if (!session.ignoreErrors())
-                            return;
+                            if (!session.ignoreErrors())
+                                break;
+                        }
                     }
                     catch (Exception e)
                     {
-                        System.err.println(e.getMessage());
+                        System.err.printf("Error while reading Super Column %s - %s%n", superColumnName,
getExceptionMessage(e));
 
                         if (!session.ignoreErrors())
                             return;
@@ -117,20 +113,15 @@ public class RangeSlicer extends Operati
 
                     if (slices.size() == 0)
                     {
-                        throw new RuntimeException(String.format("Range %s %s not found.",
String.format(format, current),
-                                                                                        
  String.format(format, last)));
-                    }
-                }
-                catch (InvalidRequestException e)
-                {
-                    System.err.println(e.getWhy());
+                        System.err.printf("Range %s->%s not found.%n", String.format(format,
current), String.format(format, last));
 
-                    if (!session.ignoreErrors())
-                        return;
+                        if (!session.ignoreErrors())
+                            break;
+                    }
                 }
                 catch (Exception e)
                 {
-                    System.err.println(e.getMessage());
+                    System.err.printf("Error while reading range %s->%s - %s%n", String.format(format,
current), String.format(format, last), getExceptionMessage(e));
 
                     if (!session.ignoreErrors())
                         return;

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/Reader.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/Reader.java?rev=1060558&r1=1060557&r2=1060558&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/Reader.java
(original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/tests/Reader.java
Tue Jan 18 20:22:14 2011
@@ -19,10 +19,8 @@ package org.apache.cassandra.contrib.str
 
 import org.apache.cassandra.contrib.stress.util.OperationThread;
 import org.apache.cassandra.db.ColumnFamilyType;
-import org.apache.cassandra.thrift.ColumnOrSuperColumn;
-import org.apache.cassandra.thrift.ColumnParent;
-import org.apache.cassandra.thrift.SlicePredicate;
-import org.apache.cassandra.thrift.SliceRange;
+import org.apache.cassandra.thrift.*;
+import org.apache.cassandra.utils.ByteBufferUtil;
 
 import java.nio.ByteBuffer;
 import java.util.List;
@@ -77,7 +75,7 @@ public class Reader extends OperationThr
 
                     if (columns.size() == 0)
                     {
-                        System.err.println(String.format("Key %s not found.", superColumn));
+                        System.err.printf("Key %s not found in Super Column %s.%n", ByteBufferUtil.string(key),
superColumn);
 
                         if (!session.ignoreErrors())
                             break;
@@ -85,7 +83,7 @@ public class Reader extends OperationThr
                 }
                 catch (Exception e)
                 {
-                    System.err.println(e.getMessage());
+                    System.err.printf("Error while reading Super Column %s key %s - %s%n",
superColumn, ByteBufferUtil.string(key), getExceptionMessage(e));
 
                     if (!session.ignoreErrors())
                         break;
@@ -124,7 +122,7 @@ public class Reader extends OperationThr
             }
             catch (Exception e)
             {
-                System.err.println(e.getMessage());
+                System.err.printf("Error while reading key %s - %s%n", new String(key), getExceptionMessage(e));
 
                 if (!session.ignoreErrors())
                     break;

Modified: cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/OperationThread.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/OperationThread.java?rev=1060558&r1=1060557&r2=1060558&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/OperationThread.java
(original)
+++ cassandra/branches/cassandra-0.7/contrib/stress/src/org/apache/cassandra/contrib/stress/util/OperationThread.java
Tue Jan 18 20:22:14 2011
@@ -20,6 +20,7 @@ package org.apache.cassandra.contrib.str
 import org.apache.cassandra.contrib.stress.Session;
 import org.apache.cassandra.contrib.stress.Stress;
 import org.apache.cassandra.thrift.Cassandra;
+import org.apache.cassandra.thrift.InvalidRequestException;
 
 import java.math.BigInteger;
 import java.security.MessageDigest;
@@ -178,4 +179,11 @@ public abstract class OperationThread ex
         return result.toString();
     }
 
+    protected String getExceptionMessage(Exception e)
+    {
+        String className = e.getClass().getSimpleName();
+        String message = (e instanceof InvalidRequestException) ? ((InvalidRequestException)
e).getWhy() : e.getMessage();
+        return (message == null) ? "(" + className + ")" : String.format("(%s): %s", className,
message);
+    }
+
 }



Mime
View raw message