HBASE-4247 Add isAborted method to the Abortable interface
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1172039 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b2f97dc4e3
commit
f70dd57e1e
|
@ -508,6 +508,8 @@ Release 0.91.0 - Unreleased
|
||||||
(David Revell)
|
(David Revell)
|
||||||
HBASE-4424 Provide coprocessors access to createTable() via
|
HBASE-4424 Provide coprocessors access to createTable() via
|
||||||
MasterServices
|
MasterServices
|
||||||
|
HBASE-4247 Add isAborted method to the Abortable interface
|
||||||
|
(Akash Ashok)
|
||||||
|
|
||||||
TASKS
|
TASKS
|
||||||
HBASE-3559 Move report of split to master OFF the heartbeat channel
|
HBASE-3559 Move report of split to master OFF the heartbeat channel
|
||||||
|
|
|
@ -34,4 +34,10 @@ public interface Abortable {
|
||||||
* @param e Throwable that caused abort. Can be null.
|
* @param e Throwable that caused abort. Can be null.
|
||||||
*/
|
*/
|
||||||
public void abort(String why, Throwable e);
|
public void abort(String why, Throwable e);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the server or client was aborted.
|
||||||
|
* @return true if the server or client was aborted, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean isAborted();
|
||||||
}
|
}
|
|
@ -85,6 +85,7 @@ public class HBaseAdmin implements Abortable, Closeable {
|
||||||
// numRetries is for 'normal' stuff... Mutliply by this factor when
|
// numRetries is for 'normal' stuff... Mutliply by this factor when
|
||||||
// want to wait a long time.
|
// want to wait a long time.
|
||||||
private final int retryLongerMultiplier;
|
private final int retryLongerMultiplier;
|
||||||
|
private boolean aborted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -154,8 +155,14 @@ public class HBaseAdmin implements Abortable, Closeable {
|
||||||
@Override
|
@Override
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
// Currently does nothing but throw the passed message and exception
|
// Currently does nothing but throw the passed message and exception
|
||||||
|
this.aborted = true;
|
||||||
throw new RuntimeException(why, e);
|
throw new RuntimeException(why, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted(){
|
||||||
|
return this.aborted;
|
||||||
|
}
|
||||||
|
|
||||||
/** @return HConnection used by this object. */
|
/** @return HConnection used by this object. */
|
||||||
public HConnection getConnection() {
|
public HConnection getConnection() {
|
||||||
|
|
|
@ -446,6 +446,7 @@ public class HConnectionManager {
|
||||||
|
|
||||||
private final Object masterLock = new Object();
|
private final Object masterLock = new Object();
|
||||||
private volatile boolean closed;
|
private volatile boolean closed;
|
||||||
|
private volatile boolean aborted;
|
||||||
private volatile HMasterInterface master;
|
private volatile HMasterInterface master;
|
||||||
private volatile boolean masterChecked;
|
private volatile boolean masterChecked;
|
||||||
// ZooKeeper reference
|
// ZooKeeper reference
|
||||||
|
@ -1660,8 +1661,14 @@ public class HConnectionManager {
|
||||||
}
|
}
|
||||||
if (t != null) LOG.fatal(msg, t);
|
if (t != null) LOG.fatal(msg, t);
|
||||||
else LOG.fatal(msg);
|
else LOG.fatal(msg);
|
||||||
|
this.aborted = true;
|
||||||
this.closed = true;
|
this.closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted(){
|
||||||
|
return this.aborted;
|
||||||
|
}
|
||||||
|
|
||||||
public int getCurrentNrHRS() throws IOException {
|
public int getCurrentNrHRS() throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1308,7 +1308,7 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server {
|
||||||
return this.stopped;
|
return this.stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isAborted() {
|
public boolean isAborted() {
|
||||||
return this.abort;
|
return this.abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1521,6 +1521,10 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
||||||
abort(reason, null);
|
abort(reason, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAborted() {
|
||||||
|
return this.abortRequested;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simulate a kill -9 of this server. Exits w/o closing regions or cleaninup
|
* Simulate a kill -9 of this server. Exits w/o closing regions or cleaninup
|
||||||
* logs but it does close socket in case want to bring up server on old
|
* logs but it does close socket in case want to bring up server on old
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class ReplicationLogCleaner implements LogCleanerDelegate, Abortable {
|
||||||
private ReplicationZookeeper zkHelper;
|
private ReplicationZookeeper zkHelper;
|
||||||
private Set<String> hlogs = new HashSet<String>();
|
private Set<String> hlogs = new HashSet<String>();
|
||||||
private boolean stopped = false;
|
private boolean stopped = false;
|
||||||
|
private boolean aborted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates the cleaner, does nothing more.
|
* Instantiates the cleaner, does nothing more.
|
||||||
|
@ -166,6 +167,12 @@ public class ReplicationLogCleaner implements LogCleanerDelegate, Abortable {
|
||||||
@Override
|
@Override
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
LOG.warn("Aborting ReplicationLogCleaner because " + why, e);
|
LOG.warn("Aborting ReplicationLogCleaner because " + why, e);
|
||||||
|
this.aborted = true;
|
||||||
stop(why);
|
stop(why);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return this.aborted;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -365,6 +365,11 @@ public class HBaseFsck {
|
||||||
LOG.error(why, e);
|
LOG.error(why, e);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public boolean isAborted(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
rootRegionTracker.start();
|
rootRegionTracker.start();
|
||||||
ServerName sn = null;
|
ServerName sn = null;
|
||||||
|
|
|
@ -395,4 +395,9 @@ public class ZooKeeperWatcher implements Watcher, Abortable {
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
this.abortable.abort(why, e);
|
this.abortable.abort(why, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return this.abortable.isAborted();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,11 @@ public class TestCatalogTracker {
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
LOG.info(why, e);
|
LOG.info(why, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
this.watcher = new ZooKeeperWatcher(UTIL.getConfiguration(),
|
this.watcher = new ZooKeeperWatcher(UTIL.getConfiguration(),
|
||||||
this.getClass().getSimpleName(), this.abortable, true);
|
this.getClass().getSimpleName(), this.abortable, true);
|
||||||
|
|
|
@ -52,6 +52,11 @@ public class TestCatalogTrackerOnCluster {
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
LOG.error("Abort was called on 'bad root location writer'", e);
|
LOG.error("Abort was called on 'bad root location writer'", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ServerName nonsense =
|
ServerName nonsense =
|
||||||
new ServerName("example.org", 1234, System.currentTimeMillis());
|
new ServerName("example.org", 1234, System.currentTimeMillis());
|
||||||
|
|
|
@ -61,6 +61,12 @@ public class TestMetaReaderEditor {
|
||||||
LOG.info(why, e);
|
LOG.info(why, e);
|
||||||
abort.set(true);
|
abort.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return abort.get();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@BeforeClass public static void beforeClass() throws Exception {
|
@BeforeClass public static void beforeClass() throws Exception {
|
||||||
|
|
|
@ -245,6 +245,11 @@ public class TestActiveMasterManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void abort(final String msg, final Throwable t) {}
|
public void abort(final String msg, final Throwable t) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Configuration getConfiguration() {
|
public Configuration getConfiguration() {
|
||||||
|
|
|
@ -102,6 +102,11 @@ public class TestCatalogJanitor {
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
//no-op
|
//no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStopped() {
|
public boolean isStopped() {
|
||||||
|
@ -182,6 +187,11 @@ public class TestCatalogJanitor {
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
//no-op
|
//no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop(String why) {
|
public void stop(String why) {
|
||||||
|
|
|
@ -65,6 +65,11 @@ public class TestClockSkewDetection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void abort(String why, Throwable e) {}
|
public void abort(String why, Throwable e) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStopped() {
|
public boolean isStopped() {
|
||||||
|
|
|
@ -155,6 +155,11 @@ public class TestLogsCleaner {
|
||||||
@Override
|
@Override
|
||||||
public void abort(String why, Throwable e) {}
|
public void abort(String why, Throwable e) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop(String why) {}
|
public void stop(String why) {}
|
||||||
|
|
||||||
|
|
|
@ -228,10 +228,18 @@ public class TestMasterFailover {
|
||||||
// Create a ZKW to use in the test
|
// Create a ZKW to use in the test
|
||||||
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||||
"unittest", new Abortable() {
|
"unittest", new Abortable() {
|
||||||
|
boolean aborted = false;
|
||||||
@Override
|
@Override
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
|
this.aborted = true;
|
||||||
throw new RuntimeException("Fatal ZK error, why=" + why, e);
|
throw new RuntimeException("Fatal ZK error, why=" + why, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return this.aborted;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// get all the master threads
|
// get all the master threads
|
||||||
|
@ -545,11 +553,18 @@ public class TestMasterFailover {
|
||||||
// Create a ZKW to use in the test
|
// Create a ZKW to use in the test
|
||||||
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||||
"unittest", new Abortable() {
|
"unittest", new Abortable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
LOG.error("Fatal ZK Error: " + why, e);
|
LOG.error("Fatal ZK Error: " + why, e);
|
||||||
org.junit.Assert.assertFalse("Fatal ZK error", true);
|
org.junit.Assert.assertFalse("Fatal ZK error", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// get all the master threads
|
// get all the master threads
|
||||||
|
|
|
@ -132,4 +132,10 @@ class MockRegionServerServices implements RegionServerServices {
|
||||||
public boolean isStopped() {
|
public boolean isStopped() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -34,8 +34,10 @@ import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
||||||
*/
|
*/
|
||||||
class MockServer implements Server {
|
class MockServer implements Server {
|
||||||
static final Log LOG = LogFactory.getLog(MockServer.class);
|
static final Log LOG = LogFactory.getLog(MockServer.class);
|
||||||
boolean stopped = false;
|
|
||||||
final static ServerName NAME = new ServerName("MockServer", 123, -1);
|
final static ServerName NAME = new ServerName("MockServer", 123, -1);
|
||||||
|
|
||||||
|
boolean stopped;
|
||||||
|
boolean aborted;
|
||||||
final ZooKeeperWatcher zk;
|
final ZooKeeperWatcher zk;
|
||||||
final HBaseTestingUtility htu;
|
final HBaseTestingUtility htu;
|
||||||
|
|
||||||
|
@ -67,7 +69,8 @@ class MockServer implements Server {
|
||||||
@Override
|
@Override
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
LOG.fatal("Abort why=" + why, e);
|
LOG.fatal("Abort why=" + why, e);
|
||||||
this.stopped = true;
|
stop(why);
|
||||||
|
this.aborted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,4 +103,10 @@ class MockServer implements Server {
|
||||||
public ServerName getServerName() {
|
public ServerName getServerName() {
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return this.aborted;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,6 +233,11 @@ public class TestReplicationSourceManager {
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
//To change body of implemented methods use File | Settings | File Templates.
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop(String why) {
|
public void stop(String why) {
|
||||||
|
|
|
@ -58,6 +58,12 @@ public class TestZKTable {
|
||||||
public void abort(String why, Throwable e) {
|
public void abort(String why, Throwable e) {
|
||||||
LOG.info(why, e);
|
LOG.info(why, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||||
name, abortable, true);
|
name, abortable, true);
|
||||||
|
|
|
@ -300,6 +300,12 @@ public class TestZooKeeperNodeTracker {
|
||||||
public static class StubAbortable implements Abortable {
|
public static class StubAbortable implements Abortable {
|
||||||
@Override
|
@Override
|
||||||
public void abort(final String msg, final Throwable t) {}
|
public void abort(final String msg, final Throwable t) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAborted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class StubWatcher implements Watcher {
|
public static class StubWatcher implements Watcher {
|
||||||
|
|
Loading…
Reference in New Issue