HBASE-2449 Local HBase does not stop properly
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@945836 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b560475837
commit
ea52d836b4
|
@ -332,6 +332,7 @@ Release 0.21.0 - Unreleased
|
||||||
HBASE-2457 RS gets stuck compacting region ad infinitum
|
HBASE-2457 RS gets stuck compacting region ad infinitum
|
||||||
HBASE-2562 bin/hbase doesn't work in-situ in maven
|
HBASE-2562 bin/hbase doesn't work in-situ in maven
|
||||||
(Todd Lipcon via Stack)
|
(Todd Lipcon via Stack)
|
||||||
|
HBASE-2449 Local HBase does not stop properly
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
HBASE-1760 Cleanup TODOs in HTable
|
HBASE-1760 Cleanup TODOs in HTable
|
||||||
|
|
|
@ -41,12 +41,12 @@ fi
|
||||||
distMode=`$bin/hbase org.apache.hadoop.hbase.HBaseConfTool hbase.cluster.distributed`
|
distMode=`$bin/hbase org.apache.hadoop.hbase.HBaseConfTool hbase.cluster.distributed`
|
||||||
|
|
||||||
|
|
||||||
if [ $distMode == 'false' ]
|
if [ "$distMode" == 'false' ]
|
||||||
then
|
then
|
||||||
"$bin"/hbase-daemon.sh start master
|
"$bin"/hbase-daemon.sh start master
|
||||||
else
|
else
|
||||||
"$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" start zookeeper
|
"$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" start zookeeper
|
||||||
"$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" start master
|
"$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" start master
|
||||||
"$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" \
|
"$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" \
|
||||||
--hosts "${HBASE_REGIONSERVERS}" start regionserver
|
--hosts "${HBASE_REGIONSERVERS}" start regionserver
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -30,4 +30,8 @@ bin=`cd "$bin"; pwd`
|
||||||
. "$bin"/hbase-config.sh
|
. "$bin"/hbase-config.sh
|
||||||
|
|
||||||
"$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" stop master
|
"$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" stop master
|
||||||
"$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" stop zookeeper
|
distMode=`$bin/hbase org.apache.hadoop.hbase.HBaseConfTool hbase.cluster.distributed`
|
||||||
|
if [ "$distMode" == 'true' ]
|
||||||
|
then
|
||||||
|
"$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" stop zookeeper
|
||||||
|
fi
|
||||||
|
|
|
@ -57,6 +57,7 @@ import org.apache.hadoop.hbase.ipc.HMasterRegionInterface;
|
||||||
import org.apache.hadoop.hbase.ipc.HRegionInterface;
|
import org.apache.hadoop.hbase.ipc.HRegionInterface;
|
||||||
import org.apache.hadoop.hbase.master.metrics.MasterMetrics;
|
import org.apache.hadoop.hbase.master.metrics.MasterMetrics;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||||
|
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.HLog;
|
import org.apache.hadoop.hbase.regionserver.wal.HLog;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.apache.hadoop.hbase.util.FSUtils;
|
import org.apache.hadoop.hbase.util.FSUtils;
|
||||||
|
@ -1158,6 +1159,33 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Version of master that will shutdown the passed zk cluster on its way out.
|
||||||
|
*/
|
||||||
|
static class LocalHMaster extends HMaster {
|
||||||
|
private MiniZooKeeperCluster zkcluster = null;
|
||||||
|
|
||||||
|
public LocalHMaster(Configuration conf) throws IOException {
|
||||||
|
super(conf);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
super.run();
|
||||||
|
if (this.zkcluster != null) {
|
||||||
|
try {
|
||||||
|
this.zkcluster.shutdown();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setZKCluster(final MiniZooKeeperCluster zkcluster) {
|
||||||
|
this.zkcluster = zkcluster;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected static void doMain(String [] args,
|
protected static void doMain(String [] args,
|
||||||
Class<? extends HMaster> masterClass) {
|
Class<? extends HMaster> masterClass) {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
|
@ -1185,14 +1213,13 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
||||||
// If 'local', defer to LocalHBaseCluster instance. Starts master
|
// If 'local', defer to LocalHBaseCluster instance. Starts master
|
||||||
// and regionserver both in the one JVM.
|
// and regionserver both in the one JVM.
|
||||||
if (LocalHBaseCluster.isLocal(conf)) {
|
if (LocalHBaseCluster.isLocal(conf)) {
|
||||||
// TODO make zookeepercluster a field and do an orderly shutdown
|
final MiniZooKeeperCluster zooKeeperCluster =
|
||||||
MiniZooKeeperCluster zooKeeperCluster = new MiniZooKeeperCluster();
|
new MiniZooKeeperCluster();
|
||||||
File zkDataPath = new File(conf.get("hbase.zookeeper.property.dataDir"));
|
File zkDataPath = new File(conf.get("hbase.zookeeper.property.dataDir"));
|
||||||
int zkClientPort = conf.getInt("hbase.zookeeper.property.clientPort", 0);
|
int zkClientPort = conf.getInt("hbase.zookeeper.property.clientPort", 0);
|
||||||
if (zkClientPort == 0) {
|
if (zkClientPort == 0) {
|
||||||
throw new IOException("No config value for hbase.zookeeper.property.clientPort");
|
throw new IOException("No config value for hbase.zookeeper.property.clientPort");
|
||||||
}
|
}
|
||||||
|
|
||||||
zooKeeperCluster.setTickTime(conf.getInt("hbase.zookeeper.property.tickTime", 3000));
|
zooKeeperCluster.setTickTime(conf.getInt("hbase.zookeeper.property.tickTime", 3000));
|
||||||
zooKeeperCluster.setClientPort(zkClientPort);
|
zooKeeperCluster.setClientPort(zkClientPort);
|
||||||
int clientPort = zooKeeperCluster.startup(zkDataPath);
|
int clientPort = zooKeeperCluster.startup(zkDataPath);
|
||||||
|
@ -1203,8 +1230,14 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
||||||
System.err.println(errorMsg);
|
System.err.println(errorMsg);
|
||||||
throw new IOException(errorMsg);
|
throw new IOException(errorMsg);
|
||||||
}
|
}
|
||||||
conf.set("hbase.zookeeper.property.clientPort", Integer.toString(clientPort));
|
conf.set("hbase.zookeeper.property.clientPort",
|
||||||
(new LocalHBaseCluster(conf)).startup();
|
Integer.toString(clientPort));
|
||||||
|
// Need to have the zk cluster shutdown when master is shutdown.
|
||||||
|
// Run a subclass that does the zk cluster shutdown on its way out.
|
||||||
|
LocalHBaseCluster cluster = new LocalHBaseCluster(conf, 1,
|
||||||
|
LocalHMaster.class, HRegionServer.class);
|
||||||
|
((LocalHMaster)cluster.getMaster()).setZKCluster(zooKeeperCluster);
|
||||||
|
cluster.startup();
|
||||||
} else {
|
} else {
|
||||||
HMaster master = constructMaster(masterClass, conf);
|
HMaster master = constructMaster(masterClass, conf);
|
||||||
if (master.shutdownRequested.get()) {
|
if (master.shutdownRequested.get()) {
|
||||||
|
|
|
@ -797,7 +797,7 @@ public class ServerManager implements HConstants {
|
||||||
LOG.info("Waiting on following regionserver(s) to go down " +
|
LOG.info("Waiting on following regionserver(s) to go down " +
|
||||||
this.serversToServerInfo.values());
|
this.serversToServerInfo.values());
|
||||||
try {
|
try {
|
||||||
this.serversToServerInfo.wait(1);
|
this.serversToServerInfo.wait(500);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// continue
|
// continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,10 +231,6 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
||||||
// The main region server thread.
|
// The main region server thread.
|
||||||
private Thread regionServerThread;
|
private Thread regionServerThread;
|
||||||
|
|
||||||
// Run HDFS shutdown on exit if this is set. We clear this out when
|
|
||||||
// doing a restart() to prevent closing of HDFS.
|
|
||||||
public final AtomicBoolean shutdownHDFS = new AtomicBoolean(true);
|
|
||||||
|
|
||||||
private final String machineName;
|
private final String machineName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -293,7 +289,6 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
||||||
private void reinitialize() throws IOException {
|
private void reinitialize() throws IOException {
|
||||||
this.abortRequested = false;
|
this.abortRequested = false;
|
||||||
this.stopRequested.set(false);
|
this.stopRequested.set(false);
|
||||||
this.shutdownHDFS.set(true);
|
|
||||||
|
|
||||||
// Server to handle client requests
|
// Server to handle client requests
|
||||||
this.server = HBaseRPC.getServer(this, address.getBindAddress(),
|
this.server = HBaseRPC.getServer(this, address.getBindAddress(),
|
||||||
|
@ -361,7 +356,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
||||||
type + ", path: " + event.getPath());
|
type + ", path: " + event.getPath());
|
||||||
|
|
||||||
// Ignore events if we're shutting down.
|
// Ignore events if we're shutting down.
|
||||||
if (stopRequested.get()) {
|
if (this.stopRequested.get()) {
|
||||||
LOG.debug("Ignoring ZooKeeper event while shutting down");
|
LOG.debug("Ignoring ZooKeeper event while shutting down");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -394,7 +389,6 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
||||||
|
|
||||||
private void restart() {
|
private void restart() {
|
||||||
LOG.info("Restarting Region Server");
|
LOG.info("Restarting Region Server");
|
||||||
shutdownHDFS.set(false);
|
|
||||||
abort();
|
abort();
|
||||||
Threads.shutdown(regionServerThread);
|
Threads.shutdown(regionServerThread);
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
@ -670,8 +664,8 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
join();
|
|
||||||
this.zooKeeperWrapper.close();
|
this.zooKeeperWrapper.close();
|
||||||
|
join();
|
||||||
}
|
}
|
||||||
LOG.info(Thread.currentThread().getName() + " exiting");
|
LOG.info(Thread.currentThread().getName() + " exiting");
|
||||||
}
|
}
|
||||||
|
@ -750,12 +744,6 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
||||||
this.conf.set("fs.defaultFS", this.conf.get("hbase.rootdir"));
|
this.conf.set("fs.defaultFS", this.conf.get("hbase.rootdir"));
|
||||||
this.conf.setBoolean("fs.automatic.close", false);
|
this.conf.setBoolean("fs.automatic.close", false);
|
||||||
this.fs = FileSystem.get(this.conf);
|
this.fs = FileSystem.get(this.conf);
|
||||||
|
|
||||||
// Register shutdown hook for HRegionServer, runs an orderly shutdown
|
|
||||||
// when a kill signal is recieved. Shuts down hdfs too if its supposed.
|
|
||||||
Runtime.getRuntime().addShutdownHook(new ShutdownThread(this,
|
|
||||||
Thread.currentThread(), this.shutdownHDFS));
|
|
||||||
|
|
||||||
this.rootDir = new Path(this.conf.get(HConstants.HBASE_DIR));
|
this.rootDir = new Path(this.conf.get(HConstants.HBASE_DIR));
|
||||||
this.hlog = setupHLog();
|
this.hlog = setupHLog();
|
||||||
// Init in here rather than in constructor after thread name has been set
|
// Init in here rather than in constructor after thread name has been set
|
||||||
|
@ -770,12 +758,6 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShutdownHDFS(final boolean b) {
|
|
||||||
this.shutdownHDFS.set(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getShutdownHDFS() {return this.shutdownHDFS.get();}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @param r Region to get RegionLoad for.
|
* @param r Region to get RegionLoad for.
|
||||||
* @return RegionLoad instance.
|
* @return RegionLoad instance.
|
||||||
|
@ -897,47 +879,6 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
||||||
return this.fsOk;
|
return this.fsOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Thread to shutdown the region server in an orderly manner. This thread
|
|
||||||
* is registered as a shutdown hook in the HRegionServer constructor and is
|
|
||||||
* only called when the HRegionServer receives a kill signal.
|
|
||||||
*/
|
|
||||||
private static class ShutdownThread extends Thread {
|
|
||||||
private final HRegionServer instance;
|
|
||||||
private final Thread mainThread;
|
|
||||||
private final AtomicBoolean shutdownHDFS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param instance
|
|
||||||
* @param mainThread
|
|
||||||
* @param shutdownHDFS
|
|
||||||
*/
|
|
||||||
public ShutdownThread(final HRegionServer instance, final Thread mainThread,
|
|
||||||
final AtomicBoolean shutdownHDFS) {
|
|
||||||
this.instance = instance;
|
|
||||||
this.mainThread = mainThread;
|
|
||||||
this.shutdownHDFS = shutdownHDFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
LOG.info("Starting shutdown thread");
|
|
||||||
|
|
||||||
// tell the region server to stop
|
|
||||||
this.instance.stop();
|
|
||||||
|
|
||||||
// Wait for main thread to exit.
|
|
||||||
Threads.shutdown(this.mainThread);
|
|
||||||
try {
|
|
||||||
if (this.shutdownHDFS.get()) FileSystem.closeAll();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.info("Shutdown thread complete");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Inner class that runs on a long period checking if regions need major
|
* Inner class that runs on a long period checking if regions need major
|
||||||
* compaction.
|
* compaction.
|
||||||
|
|
|
@ -625,7 +625,7 @@ public class ZooKeeperWrapper implements HConstants {
|
||||||
public void close() {
|
public void close() {
|
||||||
try {
|
try {
|
||||||
zooKeeper.close();
|
zooKeeper.close();
|
||||||
LOG.debug("Closed connection with ZooKeeper");
|
LOG.debug("Closed connection with ZooKeeper; " + this.rootRegionZNode);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LOG.warn("Failed to close connection with ZooKeeper");
|
LOG.warn("Failed to close connection with ZooKeeper");
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,29 +53,6 @@
|
||||||
<unpack>false</unpack>
|
<unpack>false</unpack>
|
||||||
</binaries>
|
</binaries>
|
||||||
</moduleSet>
|
</moduleSet>
|
||||||
<moduleSet>
|
|
||||||
<includes>
|
|
||||||
<include>org.apache.hbase:hbase-contrib-stargate*</include>
|
|
||||||
</includes>
|
|
||||||
<binaries>
|
|
||||||
<outputDirectory>contrib/stargate/</outputDirectory>
|
|
||||||
<unpack>false</unpack>
|
|
||||||
<dependencySets>
|
|
||||||
<dependencySet>
|
|
||||||
<outputDirectory>lib</outputDirectory>
|
|
||||||
</dependencySet>
|
|
||||||
</dependencySets>
|
|
||||||
</binaries>
|
|
||||||
</moduleSet>
|
|
||||||
<moduleSet>
|
|
||||||
<includes>
|
|
||||||
<include>org.apache.hbase:hbase-contrib-transactional</include>
|
|
||||||
</includes>
|
|
||||||
<binaries>
|
|
||||||
<outputDirectory>contrib/transactional/</outputDirectory>
|
|
||||||
<unpack>false</unpack>
|
|
||||||
</binaries>
|
|
||||||
</moduleSet>
|
|
||||||
</moduleSets>
|
</moduleSets>
|
||||||
<fileSets>
|
<fileSets>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
|
|
Loading…
Reference in New Issue