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

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1569733 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
nkeywal 2014-02-19 13:13:16 +00:00
parent 96a5ef9131
commit b165690999
3 changed files with 19 additions and 14 deletions

View File

@ -645,8 +645,8 @@ public abstract class FSUtils {
if (wait > 0) { if (wait > 0) {
Thread.sleep(wait); Thread.sleep(wait);
} }
} catch (InterruptedException ex) { } catch (InterruptedException ie) {
// ignore throw (InterruptedIOException)new InterruptedIOException().initCause(ie);
} }
retries--; retries--;
} else { } else {
@ -676,8 +676,8 @@ public abstract class FSUtils {
", retrying in "+wait+"msec: "+StringUtils.stringifyException(ioe)); ", retrying in "+wait+"msec: "+StringUtils.stringifyException(ioe));
try { try {
Thread.sleep(wait); Thread.sleep(wait);
} catch (InterruptedException ie) { } catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(ie); throw (InterruptedIOException)new InterruptedIOException().initCause(e);
} }
} else { } else {
throw ioe; throw ioe;
@ -783,9 +783,8 @@ public abstract class FSUtils {
", retrying in " + wait + "msec: " + StringUtils.stringifyException(ioe)); ", retrying in " + wait + "msec: " + StringUtils.stringifyException(ioe));
try { try {
Thread.sleep(wait); Thread.sleep(wait);
} catch (InterruptedException ie) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); throw (InterruptedIOException)new InterruptedIOException().initCause(e);
break;
} }
} else { } else {
throw ioe; throw ioe;
@ -852,7 +851,7 @@ public abstract class FSUtils {
try { try {
Thread.sleep(wait); Thread.sleep(wait);
} catch (InterruptedException e) { } catch (InterruptedException e) {
//continue throw (InterruptedIOException)new InterruptedIOException().initCause(e);
} }
} }
} }

View File

@ -4043,6 +4043,7 @@ public class HBaseFsck extends Configured {
LOG.info("Sleeping " + sleepBeforeRerun + "ms before re-checking after fix..."); LOG.info("Sleeping " + sleepBeforeRerun + "ms before re-checking after fix...");
Thread.sleep(sleepBeforeRerun); Thread.sleep(sleepBeforeRerun);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
LOG.warn("Interrupted while sleeping");
return this; return this;
} }
// Just report // Just report

View File

@ -18,6 +18,7 @@
*/ */
package org.apache.hadoop.hbase.util; package org.apache.hadoop.hbase.util;
import java.io.InterruptedIOException;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@ -184,7 +185,8 @@ public class JVMClusterUtil {
while (findActiveMaster(masters) == null) { while (findActiveMaster(masters) == null) {
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException ignored) { } catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
} }
if (System.currentTimeMillis() > startTime + 30000) { if (System.currentTimeMillis() > startTime + 30000) {
throw new RuntimeException("Master not active after 30 seconds"); throw new RuntimeException("Master not active after 30 seconds");
@ -211,8 +213,11 @@ public class JVMClusterUtil {
} }
// REMOVE // REMOVE
if (System.currentTimeMillis() > startTime + 10000) { if (System.currentTimeMillis() > startTime + 10000) {
try {
Threads.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
}
} }
if (System.currentTimeMillis() > startTime + maxwait) { if (System.currentTimeMillis() > startTime + maxwait) {
String msg = "Master not initialized after " + maxwait + "ms seconds"; String msg = "Master not initialized after " + maxwait + "ms seconds";
@ -222,8 +227,8 @@ public class JVMClusterUtil {
} }
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException ignored) { } catch (InterruptedException e) {
// Keep waiting throw (InterruptedIOException)new InterruptedIOException().initCause(e);
} }
} }
} }