hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbau...@apache.org
Subject svn commit: r1391221 - in /hbase/branches/0.89-fb/src/main: java/org/apache/hadoop/hbase/ java/org/apache/hadoop/hbase/regionserver/ java/org/apache/hadoop/hbase/thrift/ java/org/apache/hadoop/hbase/thrift/generated/ resources/org/apache/hadoop/hbase/t...
Date Thu, 27 Sep 2012 21:07:52 GMT
Author: mbautin
Date: Thu Sep 27 21:07:52 2012
New Revision: 1391221

URL: http://svn.apache.org/viewvc?rev=1391221&view=rev
Log:
[jira] [HBASE-6882] [89-fb] Thrift IOError should include exception class

Author: mbautin

Summary: Return exception class as part of IOError thrown from the Thrift proxy or the embedded
Thrift server in the regionserver.

Test Plan:
Unit tests
Test through C++ HBase client

Reviewers: liyintang, kranganathan, aaiyer, chip

Reviewed By: liyintang

Differential Revision: https://reviews.facebook.net/D5679

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/RegionException.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/generated/IOError.java
    hbase/branches/0.89-fb/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/RegionException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/RegionException.java?rev=1391221&r1=1391220&r2=1391221&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/RegionException.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/RegionException.java Thu
Sep 27 21:07:52 2012
@@ -38,11 +38,12 @@ public class RegionException extends IOE
    * @param s message
    */
   public RegionException(String s) {
-    super(s, 0);
+    this(s, 0);
   }
 
   public RegionException(String s, long waitMillis) {
-    super(s, waitMillis);
+    super(s, waitMillis, "");
+    exceptionClass = getClass().getName();
   }
 
 }

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java?rev=1391221&r1=1391220&r2=1391221&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
Thu Sep 27 21:07:52 2012
@@ -131,13 +131,13 @@ public class HRegionThriftServer extends
                                        qualifier, amount, true);
       } catch (NotServingRegionException e) {
         if (!redirect) {
-          throw new IOError(e.getMessage(), 0);
+          throw new IOError(e.getMessage(), 0, e.getClass().getName());
         }
         LOG.info("ThriftServer redirecting atomicIncrement");
         return super.atomicIncrement(tableName, row, family,
                                      qualifier, amount);
       } catch (IOException e) {
-        throw new IOError(e.getMessage(), 0);
+        throw new IOError(e.getMessage(), 0, e.getClass().getName());
       }
     }
 

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java?rev=1391221&r1=1391220&r2=1391221&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
Thu Sep 27 21:07:52 2012
@@ -887,7 +887,7 @@ public class ThriftServerRunner implemen
       }
       try {
         if (!getHBaseAdmin().tableExists(tableNameBytes)) {
-          throw new IOError("table does not exist", 0);
+          throw new IOError("table does not exist", 0, "");
         }
         getHBaseAdmin().deleteTable(tableNameBytes);
       } catch (IOException e) {
@@ -1433,7 +1433,7 @@ public class ThriftServerRunner implemen
 
         processMultiPut(tableName, regionName, puts);
       } catch (IOException e) {
-        throw new IOError(e.getMessage(), 0);
+        throw new IOError(e.getMessage(), 0, e.getClass().getName());
       }
     }
 
@@ -1518,7 +1518,7 @@ public class ThriftServerRunner implemen
     if (e instanceof IOError) {
       return (IOError) e;
     }
-    return new IOError(e.getMessage(), 0);
+    return new IOError(e.getMessage(), 0, e.getClass().getName());
   }
 
   private static byte[] getQualifier(byte[][] familyAndQualifier) {

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/generated/IOError.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/generated/IOError.java?rev=1391221&r1=1391220&r2=1391221&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/generated/IOError.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/generated/IOError.java
Thu Sep 27 21:07:52 2012
@@ -37,6 +37,7 @@ public class IOError extends java.io.IOE
 
   private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message",
org.apache.thrift.protocol.TType.STRING, (short)1);
   private static final org.apache.thrift.protocol.TField BACKOFF_TIME_MILLIS_FIELD_DESC =
new org.apache.thrift.protocol.TField("backoffTimeMillis", org.apache.thrift.protocol.TType.I64,
(short)2);
+  private static final org.apache.thrift.protocol.TField EXCEPTION_CLASS_FIELD_DESC = new
org.apache.thrift.protocol.TField("exceptionClass", org.apache.thrift.protocol.TType.STRING,
(short)3);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes =
new HashMap<Class<? extends IScheme>, SchemeFactory>();
   static {
@@ -46,11 +47,13 @@ public class IOError extends java.io.IOE
 
   public String message; // required
   public long backoffTimeMillis; // required
+  public String exceptionClass; // required
 
   /** The set of fields this struct contains, along with convenience methods for finding
and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
     MESSAGE((short)1, "message"),
-    BACKOFF_TIME_MILLIS((short)2, "backoffTimeMillis");
+    BACKOFF_TIME_MILLIS((short)2, "backoffTimeMillis"),
+    EXCEPTION_CLASS((short)3, "exceptionClass");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -69,6 +72,8 @@ public class IOError extends java.io.IOE
           return MESSAGE;
         case 2: // BACKOFF_TIME_MILLIS
           return BACKOFF_TIME_MILLIS;
+        case 3: // EXCEPTION_CLASS
+          return EXCEPTION_CLASS;
         default:
           return null;
       }
@@ -118,6 +123,8 @@ public class IOError extends java.io.IOE
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     tmpMap.put(_Fields.BACKOFF_TIME_MILLIS, new org.apache.thrift.meta_data.FieldMetaData("backoffTimeMillis",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.EXCEPTION_CLASS, new org.apache.thrift.meta_data.FieldMetaData("exceptionClass",
org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(IOError.class, metaDataMap);
   }
@@ -127,12 +134,14 @@ public class IOError extends java.io.IOE
 
   public IOError(
     String message,
-    long backoffTimeMillis)
+    long backoffTimeMillis,
+    String exceptionClass)
   {
     this();
     this.message = message;
     this.backoffTimeMillis = backoffTimeMillis;
     setBackoffTimeMillisIsSet(true);
+    this.exceptionClass = exceptionClass;
   }
 
   /**
@@ -145,6 +154,9 @@ public class IOError extends java.io.IOE
       this.message = other.message;
     }
     this.backoffTimeMillis = other.backoffTimeMillis;
+    if (other.isSetExceptionClass()) {
+      this.exceptionClass = other.exceptionClass;
+    }
   }
 
   public IOError deepCopy() {
@@ -156,6 +168,7 @@ public class IOError extends java.io.IOE
     this.message = null;
     setBackoffTimeMillisIsSet(false);
     this.backoffTimeMillis = 0;
+    this.exceptionClass = null;
   }
 
   public String getMessage() {
@@ -205,6 +218,30 @@ public class IOError extends java.io.IOE
     __isset_bit_vector.set(__BACKOFFTIMEMILLIS_ISSET_ID, value);
   }
 
+  public String getExceptionClass() {
+    return this.exceptionClass;
+  }
+
+  public IOError setExceptionClass(String exceptionClass) {
+    this.exceptionClass = exceptionClass;
+    return this;
+  }
+
+  public void unsetExceptionClass() {
+    this.exceptionClass = null;
+  }
+
+  /** Returns true if field exceptionClass is set (has been assigned a value) and false otherwise
*/
+  public boolean isSetExceptionClass() {
+    return this.exceptionClass != null;
+  }
+
+  public void setExceptionClassIsSet(boolean value) {
+    if (!value) {
+      this.exceptionClass = null;
+    }
+  }
+
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
     case MESSAGE:
@@ -223,6 +260,14 @@ public class IOError extends java.io.IOE
       }
       break;
 
+    case EXCEPTION_CLASS:
+      if (value == null) {
+        unsetExceptionClass();
+      } else {
+        setExceptionClass((String)value);
+      }
+      break;
+
     }
   }
 
@@ -234,6 +279,9 @@ public class IOError extends java.io.IOE
     case BACKOFF_TIME_MILLIS:
       return Long.valueOf(getBackoffTimeMillis());
 
+    case EXCEPTION_CLASS:
+      return getExceptionClass();
+
     }
     throw new IllegalStateException();
   }
@@ -249,6 +297,8 @@ public class IOError extends java.io.IOE
       return isSetMessage();
     case BACKOFF_TIME_MILLIS:
       return isSetBackoffTimeMillis();
+    case EXCEPTION_CLASS:
+      return isSetExceptionClass();
     }
     throw new IllegalStateException();
   }
@@ -284,6 +334,15 @@ public class IOError extends java.io.IOE
         return false;
     }
 
+    boolean this_present_exceptionClass = true && this.isSetExceptionClass();
+    boolean that_present_exceptionClass = true && that.isSetExceptionClass();
+    if (this_present_exceptionClass || that_present_exceptionClass) {
+      if (!(this_present_exceptionClass && that_present_exceptionClass))
+        return false;
+      if (!this.exceptionClass.equals(that.exceptionClass))
+        return false;
+    }
+
     return true;
   }
 
@@ -320,6 +379,16 @@ public class IOError extends java.io.IOE
         return lastComparison;
       }
     }
+    lastComparison = Boolean.valueOf(isSetExceptionClass()).compareTo(typedOther.isSetExceptionClass());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetExceptionClass()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.exceptionClass, typedOther.exceptionClass);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     return 0;
   }
 
@@ -351,6 +420,14 @@ public class IOError extends java.io.IOE
     sb.append("backoffTimeMillis:");
     sb.append(this.backoffTimeMillis);
     first = false;
+    if (!first) sb.append(", ");
+    sb.append("exceptionClass:");
+    if (this.exceptionClass == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.exceptionClass);
+    }
+    first = false;
     sb.append(")");
     return sb.toString();
   }
@@ -411,6 +488,14 @@ public class IOError extends java.io.IOE
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
+          case 3: // EXCEPTION_CLASS
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.exceptionClass = iprot.readString();
+              struct.setExceptionClassIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
           default:
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
         }
@@ -434,6 +519,11 @@ public class IOError extends java.io.IOE
       oprot.writeFieldBegin(BACKOFF_TIME_MILLIS_FIELD_DESC);
       oprot.writeI64(struct.backoffTimeMillis);
       oprot.writeFieldEnd();
+      if (struct.exceptionClass != null) {
+        oprot.writeFieldBegin(EXCEPTION_CLASS_FIELD_DESC);
+        oprot.writeString(struct.exceptionClass);
+        oprot.writeFieldEnd();
+      }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
     }
@@ -458,19 +548,25 @@ public class IOError extends java.io.IOE
       if (struct.isSetBackoffTimeMillis()) {
         optionals.set(1);
       }
-      oprot.writeBitSet(optionals, 2);
+      if (struct.isSetExceptionClass()) {
+        optionals.set(2);
+      }
+      oprot.writeBitSet(optionals, 3);
       if (struct.isSetMessage()) {
         oprot.writeString(struct.message);
       }
       if (struct.isSetBackoffTimeMillis()) {
         oprot.writeI64(struct.backoffTimeMillis);
       }
+      if (struct.isSetExceptionClass()) {
+        oprot.writeString(struct.exceptionClass);
+      }
     }
 
     @Override
     public void read(org.apache.thrift.protocol.TProtocol prot, IOError struct) throws org.apache.thrift.TException
{
       TTupleProtocol iprot = (TTupleProtocol) prot;
-      BitSet incoming = iprot.readBitSet(2);
+      BitSet incoming = iprot.readBitSet(3);
       if (incoming.get(0)) {
         struct.message = iprot.readString();
         struct.setMessageIsSet(true);
@@ -479,6 +575,10 @@ public class IOError extends java.io.IOE
         struct.backoffTimeMillis = iprot.readI64();
         struct.setBackoffTimeMillisIsSet(true);
       }
+      if (incoming.get(2)) {
+        struct.exceptionClass = iprot.readString();
+        struct.setExceptionClassIsSet(true);
+      }
     }
   }
 

Modified: hbase/branches/0.89-fb/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift?rev=1391221&r1=1391220&r2=1391221&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
(original)
+++ hbase/branches/0.89-fb/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
Thu Sep 27 21:07:52 2012
@@ -146,7 +146,8 @@ struct TScan {
  */
 exception IOError {
   1: string message,
-  2: i64 backoffTimeMillis
+  2: i64 backoffTimeMillis,
+  3: string exceptionClass
 }
 
 /**



Mime
View raw message