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 git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@652185 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
21da84cfea
commit
1deedc318a
|
@ -30,6 +30,8 @@ Hbase Change Log
|
|||
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
|
||||
|
||||
|
|
|
@ -835,7 +835,7 @@ public class HTable implements HConstants {
|
|||
*/
|
||||
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 @@ public class HTable implements HConstants {
|
|||
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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue