hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1160889 - in /hbase/branches/0.90: ./ src/main/java/org/apache/hadoop/hbase/client/ src/main/java/org/apache/hadoop/hbase/regionserver/ src/test/java/org/apache/hadoop/hbase/regionserver/
Date Tue, 23 Aug 2011 21:29:55 GMT
Author: stack
Date: Tue Aug 23 21:29:55 2011
New Revision: 1160889

URL: http://svn.apache.org/viewvc?rev=1160889&view=rev
Log:
HBASE-4225 NoSuchColumnFamilyException in multi doesn't say which family is bad

Added:
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/OperationStatus.java
Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedWithDetailsException.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1160889&r1=1160888&r2=1160889&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Tue Aug 23 21:29:55 2011
@@ -18,6 +18,8 @@ Release 0.90.5 - Unreleased
                request of LogRoll is blocked (Jieshan Bean)
    HBASE-4065  TableOutputFormat ignores failure to create table instance  
                (Brock Noland)
+   HBASE-4225  NoSuchColumnFamilyException in multi doesn't say which family
+               is bad (ramkrishna.s.vasudevan)
 
   IMPROVEMENT
    HBASE-4205  Enhance HTable javadoc (Eric Charles)

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedWithDetailsException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedWithDetailsException.java?rev=1160889&r1=1160888&r2=1160889&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedWithDetailsException.java
(original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedWithDetailsException.java
Tue Aug 23 21:29:55 2011
@@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.client;
 
 import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
 
 import java.util.Collection;
 import java.util.HashMap;
@@ -115,7 +116,12 @@ public class RetriesExhaustedWithDetails
     Map<String, Integer> cls = new HashMap<String, Integer>();
     for (Throwable t : ths) {
       if (t == null) continue;
-      String name = t.getClass().getSimpleName();
+      String name = "";
+      if (t instanceof NoSuchColumnFamilyException) {
+        name = t.getMessage();
+      } else {
+        name = t.getClass().getSimpleName();
+      }
       Integer i = cls.get(name);
       if (i == null) {
         i = 0;

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1160889&r1=1160888&r2=1160889&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Tue
Aug 23 21:29:55 2011
@@ -1345,13 +1345,14 @@ public class HRegion implements HeapSize
    */
   private static class BatchOperationInProgress<T> {
     T[] operations;
-    OperationStatusCode[] retCodes;
     int nextIndexToProcess = 0;
+    OperationStatus[] retCodeDetails;
 
     public BatchOperationInProgress(T[] operations) {
       this.operations = operations;
-      retCodes = new OperationStatusCode[operations.length];
-      Arrays.fill(retCodes, OperationStatusCode.NOT_RUN);
+      this.retCodeDetails = new OperationStatus[operations.length];
+      Arrays.fill(this.retCodeDetails, new OperationStatus(
+          OperationStatusCode.NOT_RUN));
     }
 
     public boolean isDone() {
@@ -1363,7 +1364,7 @@ public class HRegion implements HeapSize
    * Perform a batch put with no pre-specified locks
    * @see HRegion#put(Pair[])
    */
-  public OperationStatusCode[] put(Put[] puts) throws IOException {
+  public OperationStatus[] put(Put[] puts) throws IOException {
     @SuppressWarnings("unchecked")
     Pair<Put, Integer> putsAndLocks[] = new Pair[puts.length];
 
@@ -1375,10 +1376,15 @@ public class HRegion implements HeapSize
 
   /**
    * Perform a batch of puts.
-   * @param putsAndLocks the list of puts paired with their requested lock IDs.
+   * 
+   * @param putsAndLocks
+   *          the list of puts paired with their requested lock IDs.
+   * @return an array of OperationStatus which internally contains the
+   *         OperationStatusCode and the exceptionMessage if any.
    * @throws IOException
    */
-  public OperationStatusCode[] put(Pair<Put, Integer>[] putsAndLocks) throws IOException
{
+  public OperationStatus[] put(
+      Pair<Put, Integer>[] putsAndLocks) throws IOException {
     BatchOperationInProgress<Pair<Put, Integer>> batchOp =
       new BatchOperationInProgress<Pair<Put,Integer>>(putsAndLocks);
 
@@ -1398,10 +1404,11 @@ public class HRegion implements HeapSize
         requestFlush();
       }
     }
-    return batchOp.retCodes;
+    return batchOp.retCodeDetails;
   }
 
-  private long doMiniBatchPut(BatchOperationInProgress<Pair<Put, Integer>> batchOp)
throws IOException {
+  private long doMiniBatchPut(
+      BatchOperationInProgress<Pair<Put, Integer>> batchOp) throws IOException
{
     long now = EnvironmentEdgeManager.currentTimeMillis();
     byte[] byteNow = Bytes.toBytes(now);
     boolean locked = false;
@@ -1428,7 +1435,8 @@ public class HRegion implements HeapSize
           checkFamilies(put.getFamilyMap().keySet());
         } catch (NoSuchColumnFamilyException nscf) {
           LOG.warn("No such column family in batch put", nscf);
-          batchOp.retCodes[lastIndexExclusive] = OperationStatusCode.BAD_FAMILY;
+          batchOp.retCodeDetails[lastIndexExclusive] = new OperationStatus(
+              OperationStatusCode.BAD_FAMILY, nscf.getMessage());
           lastIndexExclusive++;
           continue;
         }
@@ -1472,7 +1480,9 @@ public class HRegion implements HeapSize
       WALEdit walEdit = new WALEdit();
       for (int i = firstIndex; i < lastIndexExclusive; i++) {
         // Skip puts that were determined to be invalid during preprocessing
-        if (batchOp.retCodes[i] != OperationStatusCode.NOT_RUN) continue;
+        if (batchOp.retCodeDetails[i].getOperationStatusCode() != OperationStatusCode.NOT_RUN)
{
+          continue;
+        }
 
         Put p = batchOp.operations[i].getFirst();
         if (!p.getWriteToWAL()) continue;
@@ -1488,11 +1498,14 @@ public class HRegion implements HeapSize
       // ----------------------------------
       long addedSize = 0;
       for (int i = firstIndex; i < lastIndexExclusive; i++) {
-        if (batchOp.retCodes[i] != OperationStatusCode.NOT_RUN) continue;
+        if (batchOp.retCodeDetails[i].getOperationStatusCode() != OperationStatusCode.NOT_RUN)
{
+          continue;
+        }
 
         Put p = batchOp.operations[i].getFirst();
         addedSize += applyFamilyMapToMemstore(p.getFamilyMap());
-        batchOp.retCodes[i] = OperationStatusCode.SUCCESS;
+        batchOp.retCodeDetails[i] = new OperationStatus(
+            OperationStatusCode.SUCCESS);
       }
       success = true;
       return addedSize;
@@ -1505,8 +1518,9 @@ public class HRegion implements HeapSize
       }
       if (!success) {
         for (int i = firstIndex; i < lastIndexExclusive; i++) {
-          if (batchOp.retCodes[i] == OperationStatusCode.NOT_RUN) {
-            batchOp.retCodes[i] = OperationStatusCode.FAILURE;
+          if (batchOp.retCodeDetails[i].getOperationStatusCode() == OperationStatusCode.NOT_RUN)
{
+            batchOp.retCodeDetails[i] = new OperationStatus(
+                OperationStatusCode.FAILURE);
           }
         }
       }

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1160889&r1=1160888&r2=1160889&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Tue Aug 23 21:29:55 2011
@@ -1715,9 +1715,9 @@ public class HRegionServer implements HR
       }
 
       this.requestCount.addAndGet(puts.size());
-      OperationStatusCode[] codes = region.put(putsWithLocks);
+      OperationStatus codes[] = region.put(putsWithLocks);
       for (i = 0; i < codes.length; i++) {
-        if (codes[i] != OperationStatusCode.SUCCESS) {
+        if (codes[i].getOperationStatusCode() != OperationStatusCode.SUCCESS) {
           return i;
         }
       }
@@ -2590,19 +2590,19 @@ public class HRegionServer implements HR
 
           this.requestCount.addAndGet(puts.size());
 
-          OperationStatusCode[] codes =
+          OperationStatus[] codes =
               region.put(putsWithLocks.toArray(new Pair[]{}));
 
           for( int i = 0 ; i < codes.length ; i++) {
-            OperationStatusCode code = codes[i];
+            OperationStatus code = codes[i];
 
             Action theAction = puts.get(i);
             Object result = null;
 
-            if (code == OperationStatusCode.SUCCESS) {
+            if (code.getOperationStatusCode() == OperationStatusCode.SUCCESS) {
               result = new Result();
-            } else if (code == OperationStatusCode.BAD_FAMILY) {
-              result = new NoSuchColumnFamilyException();
+            } else if (code.getOperationStatusCode() == OperationStatusCode.BAD_FAMILY) {
+              result = new NoSuchColumnFamilyException(code.getExceptionMsg());
             }
             // FAILURE && NOT_RUN becomes null, aka: need to run again.
 

Added: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/OperationStatus.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/OperationStatus.java?rev=1160889&view=auto
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/OperationStatus.java
(added)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/OperationStatus.java
Tue Aug 23 21:29:55 2011
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.regionserver;
+
+import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
+/**
+ * 
+ * This class stores the Operation status code and the exception message
+ * that occurs in case of failure of operations like put, delete, etc.
+ * This class is added with a purpose of adding more details or info regarding
+ * the operation status in future.
+ *
+ */
+public class OperationStatus {
+
+  private OperationStatusCode code;
+
+  private String exceptionMsg;
+
+  public OperationStatus(OperationStatusCode code) {
+    this(code, "");
+  }
+
+  public OperationStatus(OperationStatusCode code, String exceptionMsg) {
+    this.code = code;
+    this.exceptionMsg = exceptionMsg;
+  }
+
+  
+  /**
+   * @return OperationStatusCode
+   */
+  public OperationStatusCode getOperationStatusCode() {
+    return code;
+  }
+
+  /**
+   * @return ExceptionMessge
+   */
+  public String getExceptionMsg() {
+    return exceptionMsg;
+  }
+
+}

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1160889&r1=1160888&r2=1160889&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
(original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Tue Aug 23 21:29:55 2011
@@ -362,10 +362,11 @@ public class TestHRegion extends HBaseTe
       puts[i].add(cf, qual, val);
     }
 
-    OperationStatusCode[] codes = this.region.put(puts);
+    OperationStatus[] codes = this.region.put(puts);
     assertEquals(10, codes.length);
     for (int i = 0; i < 10; i++) {
-      assertEquals(OperationStatusCode.SUCCESS, codes[i]);
+      assertEquals(OperationStatusCode.SUCCESS, codes[i]
+          .getOperationStatusCode());
     }
     assertEquals(1, HLog.getSyncOps());
 
@@ -375,7 +376,7 @@ public class TestHRegion extends HBaseTe
     assertEquals(10, codes.length);
     for (int i = 0; i < 10; i++) {
       assertEquals((i == 5) ? OperationStatusCode.BAD_FAMILY :
-        OperationStatusCode.SUCCESS, codes[i]);
+        OperationStatusCode.SUCCESS, codes[i].getOperationStatusCode());
     }
     assertEquals(1, HLog.getSyncOps());
 
@@ -384,8 +385,8 @@ public class TestHRegion extends HBaseTe
 
     MultithreadedTestUtil.TestContext ctx =
       new MultithreadedTestUtil.TestContext(HBaseConfiguration.create());
-    final AtomicReference<OperationStatusCode[]> retFromThread =
-      new AtomicReference<OperationStatusCode[]>();
+    final AtomicReference<OperationStatus[]> retFromThread =
+      new AtomicReference<OperationStatus[]>();
     TestThread putter = new TestThread(ctx) {
       @Override
       public void doWork() throws IOException {
@@ -413,7 +414,7 @@ public class TestHRegion extends HBaseTe
     codes = retFromThread.get();
     for (int i = 0; i < 10; i++) {
       assertEquals((i == 5) ? OperationStatusCode.BAD_FAMILY :
-        OperationStatusCode.SUCCESS, codes[i]);
+        OperationStatusCode.SUCCESS, codes[i].getOperationStatusCode());
     }
 
     LOG.info("Nexta, a batch put which uses an already-held lock");
@@ -430,7 +431,7 @@ public class TestHRegion extends HBaseTe
     LOG.info("...performed put");
     for (int i = 0; i < 10; i++) {
       assertEquals((i == 5) ? OperationStatusCode.BAD_FAMILY :
-        OperationStatusCode.SUCCESS, codes[i]);
+        OperationStatusCode.SUCCESS, codes[i].getOperationStatusCode());
     }
     // Make sure we didn't do an extra batch
     assertEquals(1, HLog.getSyncOps());



Mime
View raw message