From 2476afbcb2d17ac2c0d5a541f75d6838a2c7ba37 Mon Sep 17 00:00:00 2001 From: nkeywal Date: Thu, 20 Feb 2014 15:07:45 +0000 Subject: [PATCH] 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 --- .../apache/hadoop/hbase/client/HBaseAdmin.java | 16 ++++++---------- .../hadoop/hbase/client/HTableMultiplexer.java | 15 +++++++++++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index 6eb0f5bc5b6..19a4b883bb5 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -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(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( diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTableMultiplexer.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTableMultiplexer.java index 480a139fefb..9d378aea3a6 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTableMultiplexer.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTableMultiplexer.java @@ -472,12 +472,14 @@ public class HTableMultiplexer { * buffer queue. **/ long frequency = conf.getLong(TABLE_MULTIPLEXER_FLUSH_FREQ_MS, 100); - + // initial delay try { Thread.sleep(frequency); } catch (InterruptedException e) { - } // Ignore + LOG.warn("Interrupted while sleeping"); + Thread.currentThread().interrupt(); + } long start, elapsed; int failedCount = 0; @@ -488,7 +490,7 @@ public class HTableMultiplexer { // Clear the processingList, putToStatusMap and failedCount processingList.clear(); failedCount = 0; - + // drain all the queued puts into the tmp list queue.drainTo(processingList); currentProcessingPutCount.set(processingList.size()); @@ -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