Any chance of getting the address of the server that threw the exception
into the message?
Helps debugging.
St.Ack
[EMAIL PROTECTED] wrote:
Author: bryanduxbury
Date: Tue Apr 29 16:03:20 2008
New Revision: 652185
URL: http://svn.apache.org/viewvc?rev=652185&view=rev
Log:
HBASE-603 When an exception bubbles out of getRegionServerWithRetries, wrap the
exception with a RetriesExhaustedException
-Added RetriesExhaustedException to client package
-HTable now throws REE when retries run out
Added:
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
Modified:
hadoop/hbase/trunk/CHANGES.txt
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java
Modified: hadoop/hbase/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=652185&r1=652184&r2=652185&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Tue Apr 29 16:03:20 2008
@@ -30,6 +30,8 @@
HBASE-596 DemoClient.py (Ivan Begtin via Stack)
HBASE-581 Allow adding filters to TableInputFormat (At same time, ensure
TIF
is subclassable) (David Alves via Stack)
+ HBASE-603 When an exception bubbles out of getRegionServerWithRetries, wrap
+ the exception with a RetriesExhaustedException
Release 0.1.1 - 04/11/2008
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java
URL:
http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java?rev=652185&r1=652184&r2=652185&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java
(original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java Tue
Apr 29 16:03:20 2008
@@ -835,7 +835,7 @@
*/
protected <T> T getRegionServerWithRetries(ServerCallable<T> callable)
throws IOException, RuntimeException {
- List<IOException> exceptions = new ArrayList<IOException>();
+ List<Exception> exceptions = new ArrayList<Exception>();
for(int tries = 0; tries < numRetries; tries++) {
try {
callable.instantiateServer(tries != 0);
@@ -845,20 +845,10 @@
e = RemoteExceptionHandler.decodeRemoteException((RemoteException)
e);
}
if (tries == numRetries - 1) {
- if (LOG.isDebugEnabled()) {
- String message = "Trying to contact region server for row '" +
- callable.row + "', but failed after " + (tries + 1) +
- " attempts.\n";
- int i = 1;
- for (IOException e2 : exceptions) {
- message = message + "Exception " + i++ + ":\n" + e2;
- }
- LOG.debug(message);
- }
- throw e;
+ throw new RetriesExhaustedException(callable.row, tries, exceptions);
}
+ exceptions.add(e);
if (LOG.isDebugEnabled()) {
- exceptions.add(e);
LOG.debug("reloading table servers because: " + e.getMessage());
}
} catch (Exception e) {
Added:
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
URL:
http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java?rev=652185&view=auto
==============================================================================
---
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
(added)
+++
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
Tue Apr 29 16:03:20 2008
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed 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.client;
+
+import java.io.IOException;
+import java.util.List;
+import org.apache.hadoop.io.Text;
+
+/**
+ * Exception thrown by HTable methods when an attempt to do something (like
+ * commit changes) fails after a bunch of retries.
+ */
+public class RetriesExhaustedException extends IOException {
+ /**
+ * Create a new RetriesExhaustedException from the list of prior failures.
+ * @param row The row we were pursuing when we ran out of retries
+ * @param numTries The number of tries we made
+ * @param exceptions List of exceptions that failed before giving up
+ */
+ public RetriesExhaustedException(Text row, int numTries,
+ List<Exception> exceptions) {
+ super(getMessage(row, numTries, exceptions));
+ }
+
+ private static String getMessage(Text row, int numTries,
+ List<Exception> exceptions) {
+ String buffer = "Trying to contact region server for row '" +
+ row + "', but failed after " + (numTries + 1) + " attempts.\nExceptions:\n";
+
+ for (Exception e : exceptions) {
+ buffer += e.toString() + "\n";
+ }
+ return buffer;
+ }
+}
\ No newline at end of file