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:
Michael Stack 2011-09-17 18:26:03 +00:00
parent b2f97dc4e3
commit f70dd57e1e
22 changed files with 134 additions and 3 deletions

View File

@ -508,6 +508,8 @@ Release 0.91.0 - Unreleased
(David Revell)
HBASE-4424 Provide coprocessors access to createTable() via
MasterServices
HBASE-4247 Add isAborted method to the Abortable interface
(Akash Ashok)
TASKS
HBASE-3559 Move report of split to master OFF the heartbeat channel

View File

@ -34,4 +34,10 @@ public interface Abortable {
* @param e Throwable that caused abort. Can be null.
*/
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();
}

View File

@ -85,6 +85,7 @@ public class HBaseAdmin implements Abortable, Closeable {
// numRetries is for 'normal' stuff... Mutliply by this factor when
// want to wait a long time.
private final int retryLongerMultiplier;
private boolean aborted;
/**
* Constructor
@ -154,8 +155,14 @@ public class HBaseAdmin implements Abortable, Closeable {
@Override
public void abort(String why, Throwable e) {
// Currently does nothing but throw the passed message and exception
this.aborted = true;
throw new RuntimeException(why, e);
}
@Override
public boolean isAborted(){
return this.aborted;
}
/** @return HConnection used by this object. */
public HConnection getConnection() {

View File

@ -446,6 +446,7 @@ public class HConnectionManager {
private final Object masterLock = new Object();
private volatile boolean closed;
private volatile boolean aborted;
private volatile HMasterInterface master;
private volatile boolean masterChecked;
// ZooKeeper reference
@ -1660,8 +1661,14 @@ public class HConnectionManager {
}
if (t != null) LOG.fatal(msg, t);
else LOG.fatal(msg);
this.aborted = true;
this.closed = true;
}
@Override
public boolean isAborted(){
return this.aborted;
}
public int getCurrentNrHRS() throws IOException {
try {

View File

@ -1308,7 +1308,7 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server {
return this.stopped;
}
boolean isAborted() {
public boolean isAborted() {
return this.abort;
}

View File

@ -1521,6 +1521,10 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
abort(reason, null);
}
public boolean isAborted() {
return this.abortRequested;
}
/*
* 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

View File

@ -46,6 +46,7 @@ public class ReplicationLogCleaner implements LogCleanerDelegate, Abortable {
private ReplicationZookeeper zkHelper;
private Set<String> hlogs = new HashSet<String>();
private boolean stopped = false;
private boolean aborted;
/**
* Instantiates the cleaner, does nothing more.
@ -166,6 +167,12 @@ public class ReplicationLogCleaner implements LogCleanerDelegate, Abortable {
@Override
public void abort(String why, Throwable e) {
LOG.warn("Aborting ReplicationLogCleaner because " + why, e);
this.aborted = true;
stop(why);
}
@Override
public boolean isAborted() {
return this.aborted;
}
}

View File

@ -365,6 +365,11 @@ public class HBaseFsck {
LOG.error(why, e);
System.exit(1);
}
@Override
public boolean isAborted(){
return false;
}
});
rootRegionTracker.start();
ServerName sn = null;

View File

@ -395,4 +395,9 @@ public class ZooKeeperWatcher implements Watcher, Abortable {
public void abort(String why, Throwable e) {
this.abortable.abort(why, e);
}
@Override
public boolean isAborted() {
return this.abortable.isAborted();
}
}

View File

@ -82,6 +82,11 @@ public class TestCatalogTracker {
public void abort(String why, Throwable e) {
LOG.info(why, e);
}
@Override
public boolean isAborted() {
return false;
}
};
this.watcher = new ZooKeeperWatcher(UTIL.getConfiguration(),
this.getClass().getSimpleName(), this.abortable, true);

View File

@ -52,6 +52,11 @@ public class TestCatalogTrackerOnCluster {
public void abort(String why, Throwable e) {
LOG.error("Abort was called on 'bad root location writer'", e);
}
@Override
public boolean isAborted() {
return false;
}
});
ServerName nonsense =
new ServerName("example.org", 1234, System.currentTimeMillis());

View File

@ -61,6 +61,12 @@ public class TestMetaReaderEditor {
LOG.info(why, e);
abort.set(true);
}
@Override
public boolean isAborted() {
return abort.get();
}
};
@BeforeClass public static void beforeClass() throws Exception {

View File

@ -245,6 +245,11 @@ public class TestActiveMasterManager {
@Override
public void abort(final String msg, final Throwable t) {}
@Override
public boolean isAborted() {
return false;
}
@Override
public Configuration getConfiguration() {

View File

@ -102,6 +102,11 @@ public class TestCatalogJanitor {
public void abort(String why, Throwable e) {
//no-op
}
@Override
public boolean isAborted() {
return false;
}
@Override
public boolean isStopped() {
@ -182,6 +187,11 @@ public class TestCatalogJanitor {
public void abort(String why, Throwable e) {
//no-op
}
@Override
public boolean isAborted() {
return false;
}
@Override
public void stop(String why) {

View File

@ -65,6 +65,11 @@ public class TestClockSkewDetection {
@Override
public void abort(String why, Throwable e) {}
@Override
public boolean isAborted() {
return false;
}
@Override
public boolean isStopped() {

View File

@ -155,6 +155,11 @@ public class TestLogsCleaner {
@Override
public void abort(String why, Throwable e) {}
@Override
public boolean isAborted() {
return false;
}
@Override
public void stop(String why) {}

View File

@ -228,10 +228,18 @@ public class TestMasterFailover {
// Create a ZKW to use in the test
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
"unittest", new Abortable() {
boolean aborted = false;
@Override
public void abort(String why, Throwable e) {
this.aborted = true;
throw new RuntimeException("Fatal ZK error, why=" + why, e);
}
@Override
public boolean isAborted() {
return this.aborted;
}
});
// get all the master threads
@ -545,11 +553,18 @@ public class TestMasterFailover {
// Create a ZKW to use in the test
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
"unittest", new Abortable() {
@Override
public void abort(String why, Throwable e) {
LOG.error("Fatal ZK Error: " + why, e);
org.junit.Assert.assertFalse("Fatal ZK error", true);
}
@Override
public boolean isAborted() {
return false;
}
});
// get all the master threads

View File

@ -132,4 +132,10 @@ class MockRegionServerServices implements RegionServerServices {
public boolean isStopped() {
return false;
}
@Override
public boolean isAborted() {
// TODO Auto-generated method stub
return false;
}
}

View File

@ -34,8 +34,10 @@ import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
*/
class MockServer implements Server {
static final Log LOG = LogFactory.getLog(MockServer.class);
boolean stopped = false;
final static ServerName NAME = new ServerName("MockServer", 123, -1);
boolean stopped;
boolean aborted;
final ZooKeeperWatcher zk;
final HBaseTestingUtility htu;
@ -67,7 +69,8 @@ class MockServer implements Server {
@Override
public void abort(String why, Throwable e) {
LOG.fatal("Abort why=" + why, e);
this.stopped = true;
stop(why);
this.aborted = true;
}
@Override
@ -100,4 +103,10 @@ class MockServer implements Server {
public ServerName getServerName() {
return NAME;
}
@Override
public boolean isAborted() {
// TODO Auto-generated method stub
return this.aborted;
}
}

View File

@ -233,6 +233,11 @@ public class TestReplicationSourceManager {
public void abort(String why, Throwable e) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public boolean isAborted() {
return false;
}
@Override
public void stop(String why) {

View File

@ -58,6 +58,12 @@ public class TestZKTable {
public void abort(String why, Throwable e) {
LOG.info(why, e);
}
@Override
public boolean isAborted() {
return false;
}
};
ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
name, abortable, true);

View File

@ -300,6 +300,12 @@ public class TestZooKeeperNodeTracker {
public static class StubAbortable implements Abortable {
@Override
public void abort(final String msg, final Throwable t) {}
@Override
public boolean isAborted() {
return false;
}
}
public static class StubWatcher implements Watcher {