HBASE-10522 Correct wrong handling and add proper handling for swallowed InterruptedException thrown by Thread.sleep in client (Feng Honghua)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1570216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
nkeywal 2014-02-20 15:07:45 +00:00
parent 1d52d528c9
commit 2476afbcb2
2 changed files with 17 additions and 14 deletions

View File

@ -696,7 +696,8 @@ public class HBaseAdmin implements Abortable, Closeable {
try {
Thread.sleep(getPauseTime(tries));
} catch (InterruptedException e) {
// continue
throw new InterruptedIOException("Interrupted when waiting" +
" for table to be deleted");
}
}
@ -2708,10 +2709,8 @@ public class HBaseAdmin implements Abortable, Closeable {
LOG.debug("(#" + tries + ") Sleeping: " + sleep +
"ms while waiting for snapshot completion.");
Thread.sleep(sleep);
} catch (InterruptedException e) {
LOG.debug("Interrupted while waiting for snapshot " + snapshot + " to complete");
Thread.currentThread().interrupt();
throw (InterruptedIOException)new InterruptedIOException("Interrupted").initCause(e);
}
LOG.debug("Getting current status of snapshot from master...");
done = executeCallable(new MasterCallable<IsSnapshotDoneResponse>(getConnection()) {
@ -2720,7 +2719,7 @@ public class HBaseAdmin implements Abortable, Closeable {
return master.isSnapshotDone(null, request);
}
});
};
}
if (!done.getDone()) {
throw new SnapshotCreationException("Snapshot '" + snapshot.getName()
+ "' wasn't completed in expectedTime:" + max + " ms", snapshot);
@ -3048,10 +3047,8 @@ public class HBaseAdmin implements Abortable, Closeable {
LOG.debug("(#" + tries + ") Sleeping: " + sleep +
"ms while waiting for procedure completion.");
Thread.sleep(sleep);
} catch (InterruptedException e) {
LOG.debug("Interrupted while waiting for procedure " + signature + " to complete");
Thread.currentThread().interrupt();
throw (InterruptedIOException)new InterruptedIOException("Interrupted").initCause(e);
}
LOG.debug("Getting current status of procedure from master...");
done = isProcedureFinished(signature, instance, props);
@ -3132,8 +3129,7 @@ public class HBaseAdmin implements Abortable, Closeable {
LOG.debug(tries + ") Sleeping: " + sleep + " ms while we wait for snapshot restore to complete.");
Thread.sleep(sleep);
} catch (InterruptedException e) {
LOG.debug("Interrupted while waiting for snapshot " + snapshot + " restore to complete");
Thread.currentThread().interrupt();
throw (InterruptedIOException)new InterruptedIOException("Interrupted").initCause(e);
}
LOG.debug("Getting current status of snapshot restore from master...");
done = executeCallable(new MasterCallable<IsRestoreSnapshotDoneResponse>(

View File

@ -477,7 +477,9 @@ public class HTableMultiplexer {
try {
Thread.sleep(frequency);
} catch (InterruptedException e) {
} // Ignore
LOG.warn("Interrupted while sleeping");
Thread.currentThread().interrupt();
}
long start, elapsed;
int failedCount = 0;
@ -567,7 +569,12 @@ public class HTableMultiplexer {
elapsed = EnvironmentEdgeManager.currentTimeMillis() - start;
}
if (elapsed < frequency) {
Thread.sleep(frequency - elapsed);
try {
Thread.sleep(frequency - elapsed);
} catch (InterruptedException e) {
LOG.warn("Interrupted while sleeping");
Thread.currentThread().interrupt();
}
}
} catch (Exception e) {
// Log all the exceptions and move on