|
@@ -20,6 +20,7 @@ import org.apache.commons.logging.LogFactory;
|
|
import org.apache.hadoop.io.*;
|
|
import org.apache.hadoop.io.*;
|
|
import org.apache.hadoop.fs.*;
|
|
import org.apache.hadoop.fs.*;
|
|
import org.apache.hadoop.ipc.*;
|
|
import org.apache.hadoop.ipc.*;
|
|
|
|
+import org.apache.hadoop.util.StringUtils;
|
|
import org.apache.hadoop.conf.*;
|
|
import org.apache.hadoop.conf.*;
|
|
|
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
@@ -45,7 +46,7 @@ public class HRegionServer
|
|
|
|
|
|
private static final Log LOG = LogFactory.getLog(HRegionServer.class);
|
|
private static final Log LOG = LogFactory.getLog(HRegionServer.class);
|
|
|
|
|
|
- private boolean stopRequested;
|
|
|
|
|
|
+ private volatile boolean stopRequested;
|
|
private Path regionDir;
|
|
private Path regionDir;
|
|
private HServerAddress address;
|
|
private HServerAddress address;
|
|
private Configuration conf;
|
|
private Configuration conf;
|
|
@@ -82,12 +83,10 @@ public class HRegionServer
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
// Grab a list of regions to check
|
|
// Grab a list of regions to check
|
|
-
|
|
|
|
Vector<HRegion> checkSplit = new Vector<HRegion>();
|
|
Vector<HRegion> checkSplit = new Vector<HRegion>();
|
|
locker.readLock().lock();
|
|
locker.readLock().lock();
|
|
try {
|
|
try {
|
|
checkSplit.addAll(regions.values());
|
|
checkSplit.addAll(regions.values());
|
|
-
|
|
|
|
} finally {
|
|
} finally {
|
|
locker.readLock().unlock();
|
|
locker.readLock().unlock();
|
|
}
|
|
}
|
|
@@ -132,13 +131,15 @@ public class HRegionServer
|
|
= (oldRegion.find(META_TABLE_NAME.toString()) == 0)
|
|
= (oldRegion.find(META_TABLE_NAME.toString()) == 0)
|
|
? ROOT_TABLE_NAME : META_TABLE_NAME;
|
|
? ROOT_TABLE_NAME : META_TABLE_NAME;
|
|
|
|
|
|
- LOG.debug("region split complete. updating meta");
|
|
|
|
|
|
+ if(LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("region split complete. updating meta");
|
|
|
|
+ }
|
|
|
|
|
|
client.openTable(tableToUpdate);
|
|
client.openTable(tableToUpdate);
|
|
long lockid = client.startUpdate(oldRegion);
|
|
long lockid = client.startUpdate(oldRegion);
|
|
- client.delete(lockid, META_COL_REGIONINFO);
|
|
|
|
- client.delete(lockid, META_COL_SERVER);
|
|
|
|
- client.delete(lockid, META_COL_STARTCODE);
|
|
|
|
|
|
+ client.delete(lockid, COL_REGIONINFO);
|
|
|
|
+ client.delete(lockid, COL_SERVER);
|
|
|
|
+ client.delete(lockid, COL_STARTCODE);
|
|
client.commit(lockid);
|
|
client.commit(lockid);
|
|
|
|
|
|
for(int i = 0; i < newRegions.length; i++) {
|
|
for(int i = 0; i < newRegions.length; i++) {
|
|
@@ -147,13 +148,15 @@ public class HRegionServer
|
|
newRegions[i].getRegionInfo().write(out);
|
|
newRegions[i].getRegionInfo().write(out);
|
|
|
|
|
|
lockid = client.startUpdate(newRegions[i].getRegionName());
|
|
lockid = client.startUpdate(newRegions[i].getRegionName());
|
|
- client.put(lockid, META_COL_REGIONINFO, bytes.toByteArray());
|
|
|
|
|
|
+ client.put(lockid, COL_REGIONINFO, bytes.toByteArray());
|
|
client.commit(lockid);
|
|
client.commit(lockid);
|
|
}
|
|
}
|
|
|
|
|
|
// Now tell the master about the new regions
|
|
// Now tell the master about the new regions
|
|
|
|
|
|
- LOG.debug("reporting region split to master");
|
|
|
|
|
|
+ if(LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("reporting region split to master");
|
|
|
|
+ }
|
|
|
|
|
|
reportSplit(newRegions[0].getRegionInfo(), newRegions[1].getRegionInfo());
|
|
reportSplit(newRegions[0].getRegionInfo(), newRegions[1].getRegionInfo());
|
|
|
|
|
|
@@ -172,18 +175,24 @@ public class HRegionServer
|
|
}
|
|
}
|
|
|
|
|
|
// Sleep
|
|
// Sleep
|
|
-
|
|
|
|
- long waitTime =
|
|
|
|
- splitCheckFrequency - (System.currentTimeMillis() - startTime);
|
|
|
|
-
|
|
|
|
- if(waitTime > 0) {
|
|
|
|
|
|
+ long waitTime = stopRequested ? 0
|
|
|
|
+ : splitCheckFrequency - (System.currentTimeMillis() - startTime);
|
|
|
|
+ if (waitTime > 0) {
|
|
try {
|
|
try {
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Sleep splitChecker");
|
|
|
|
+ }
|
|
Thread.sleep(waitTime);
|
|
Thread.sleep(waitTime);
|
|
-
|
|
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Wake splitChecker");
|
|
|
|
+ }
|
|
} catch(InterruptedException iex) {
|
|
} catch(InterruptedException iex) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("splitChecker exiting");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -221,18 +230,25 @@ public class HRegionServer
|
|
}
|
|
}
|
|
|
|
|
|
// Sleep
|
|
// Sleep
|
|
-
|
|
|
|
- long waitTime =
|
|
|
|
- threadWakeFrequency - (System.currentTimeMillis() - startTime);
|
|
|
|
|
|
+ long waitTime = stopRequested ? 0
|
|
|
|
+ : threadWakeFrequency - (System.currentTimeMillis() - startTime);
|
|
|
|
|
|
if(waitTime > 0) {
|
|
if(waitTime > 0) {
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Sleep cacheFlusher");
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
Thread.sleep(waitTime);
|
|
Thread.sleep(waitTime);
|
|
-
|
|
|
|
} catch(InterruptedException iex) {
|
|
} catch(InterruptedException iex) {
|
|
}
|
|
}
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Wake cacheFlusher");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("cacheFlusher exiting");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -249,24 +265,31 @@ public class HRegionServer
|
|
private class LogRoller implements Runnable {
|
|
private class LogRoller implements Runnable {
|
|
public void run() {
|
|
public void run() {
|
|
while(! stopRequested) {
|
|
while(! stopRequested) {
|
|
-
|
|
|
|
// If the number of log entries is high enough, roll the log. This is a
|
|
// If the number of log entries is high enough, roll the log. This is a
|
|
// very fast operation, but should not be done too frequently.
|
|
// very fast operation, but should not be done too frequently.
|
|
-
|
|
|
|
if(log.getNumEntries() > maxLogEntries) {
|
|
if(log.getNumEntries() > maxLogEntries) {
|
|
try {
|
|
try {
|
|
log.rollWriter();
|
|
log.rollWriter();
|
|
-
|
|
|
|
} catch(IOException iex) {
|
|
} catch(IOException iex) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- try {
|
|
|
|
- Thread.sleep(threadWakeFrequency);
|
|
|
|
-
|
|
|
|
- } catch(InterruptedException iex) {
|
|
|
|
|
|
+
|
|
|
|
+ if(!stopRequested) {
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Sleep logRoller");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep(threadWakeFrequency);
|
|
|
|
+ } catch(InterruptedException iex) {
|
|
|
|
+ }
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Wake logRoller");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("logRoller exiting");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -290,11 +313,11 @@ public class HRegionServer
|
|
}
|
|
}
|
|
|
|
|
|
/** Start a HRegionServer at an indicated location */
|
|
/** Start a HRegionServer at an indicated location */
|
|
- public HRegionServer(Path regionDir, HServerAddress address, Configuration conf)
|
|
|
|
- throws IOException {
|
|
|
|
|
|
+ public HRegionServer(Path regionDir, HServerAddress address,
|
|
|
|
+ Configuration conf)
|
|
|
|
+ throws IOException {
|
|
|
|
|
|
// Basic setup
|
|
// Basic setup
|
|
-
|
|
|
|
this.stopRequested = false;
|
|
this.stopRequested = false;
|
|
this.regionDir = regionDir;
|
|
this.regionDir = regionDir;
|
|
this.conf = conf;
|
|
this.conf = conf;
|
|
@@ -302,69 +325,70 @@ public class HRegionServer
|
|
this.regions = new TreeMap<Text, HRegion>();
|
|
this.regions = new TreeMap<Text, HRegion>();
|
|
this.locker = new ReentrantReadWriteLock();
|
|
this.locker = new ReentrantReadWriteLock();
|
|
this.outboundMsgs = new Vector<HMsg>();
|
|
this.outboundMsgs = new Vector<HMsg>();
|
|
- this.scanners = Collections.synchronizedMap(new TreeMap<Text, HScannerInterface>());
|
|
|
|
|
|
+ this.scanners =
|
|
|
|
+ Collections.synchronizedMap(new TreeMap<Text, HInternalScannerInterface>());
|
|
|
|
|
|
// Config'ed params
|
|
// Config'ed params
|
|
-
|
|
|
|
- this.threadWakeFrequency = conf.getLong("hbase.hregionserver.thread.wakefrequency", 10 * 1000);
|
|
|
|
- this.maxLogEntries = conf.getInt("hbase.hregionserver.maxlogentries", 30 * 1000);
|
|
|
|
- this.msgInterval = conf.getLong("hbase.hregionserver.msginterval", 15 * 1000);
|
|
|
|
- this.splitCheckFrequency = conf.getLong("hbase.hregionserver.thread.splitcheckfrequency", 60 * 1000);
|
|
|
|
|
|
+ this.threadWakeFrequency = conf.getLong(THREAD_WAKE_FREQUENCY, 10 * 1000);
|
|
|
|
+ this.maxLogEntries = conf.getInt("hbase.regionserver.maxlogentries", 30 * 1000);
|
|
|
|
+ this.msgInterval = conf.getLong("hbase.regionserver.msginterval",
|
|
|
|
+ 15 * 1000);
|
|
|
|
+ this.splitCheckFrequency =
|
|
|
|
+ conf.getLong("hbase.regionserver.thread.splitcheckfrequency", 60 * 1000);
|
|
|
|
|
|
// Cache flushing
|
|
// Cache flushing
|
|
-
|
|
|
|
this.cacheFlusher = new Flusher();
|
|
this.cacheFlusher = new Flusher();
|
|
- this.cacheFlusherThread = new Thread(cacheFlusher, "HRegionServer.cacheFlusher");
|
|
|
|
|
|
+ this.cacheFlusherThread =
|
|
|
|
+ new Thread(cacheFlusher, "HRegionServer.cacheFlusher");
|
|
|
|
|
|
// Check regions to see if they need to be split
|
|
// Check regions to see if they need to be split
|
|
-
|
|
|
|
this.splitChecker = new SplitChecker();
|
|
this.splitChecker = new SplitChecker();
|
|
- this.splitCheckerThread = new Thread(splitChecker, "HRegionServer.splitChecker");
|
|
|
|
|
|
+ this.splitCheckerThread =
|
|
|
|
+ new Thread(splitChecker, "HRegionServer.splitChecker");
|
|
|
|
|
|
// Process requests from Master
|
|
// Process requests from Master
|
|
-
|
|
|
|
this.toDo = new Vector<HMsg>();
|
|
this.toDo = new Vector<HMsg>();
|
|
this.worker = new Worker();
|
|
this.worker = new Worker();
|
|
this.workerThread = new Thread(worker, "HRegionServer.worker");
|
|
this.workerThread = new Thread(worker, "HRegionServer.worker");
|
|
|
|
|
|
try {
|
|
try {
|
|
-
|
|
|
|
// Server to handle client requests
|
|
// Server to handle client requests
|
|
-
|
|
|
|
this.server = RPC.getServer(this, address.getBindAddress().toString(),
|
|
this.server = RPC.getServer(this, address.getBindAddress().toString(),
|
|
- address.getPort(), conf.getInt("hbase.hregionserver.handler.count", 10), false, conf);
|
|
|
|
|
|
+ address.getPort(), conf.getInt("hbase.regionserver.handler.count", 10),
|
|
|
|
+ false, conf);
|
|
|
|
|
|
this.address = new HServerAddress(server.getListenerAddress());
|
|
this.address = new HServerAddress(server.getListenerAddress());
|
|
|
|
|
|
// Local file paths
|
|
// Local file paths
|
|
-
|
|
|
|
- String serverName = this.address.getBindAddress() + "_" + this.address.getPort();
|
|
|
|
|
|
+ String serverName =
|
|
|
|
+ this.address.getBindAddress() + "_" + this.address.getPort();
|
|
Path newlogdir = new Path(regionDir, "log" + "_" + serverName);
|
|
Path newlogdir = new Path(regionDir, "log" + "_" + serverName);
|
|
this.oldlogfile = new Path(regionDir, "oldlogfile" + "_" + serverName);
|
|
this.oldlogfile = new Path(regionDir, "oldlogfile" + "_" + serverName);
|
|
|
|
|
|
// Logging
|
|
// Logging
|
|
-
|
|
|
|
this.fs = FileSystem.get(conf);
|
|
this.fs = FileSystem.get(conf);
|
|
HLog.consolidateOldLog(newlogdir, oldlogfile, fs, conf);
|
|
HLog.consolidateOldLog(newlogdir, oldlogfile, fs, conf);
|
|
|
|
+ // TODO: Now we have a consolidated log for all regions, sort and
|
|
|
|
+ // then split result by region passing the splits as reconstruction
|
|
|
|
+ // logs to HRegions on start. Or, rather than consolidate, split logs
|
|
|
|
+ // into per region files.
|
|
this.log = new HLog(fs, newlogdir, conf);
|
|
this.log = new HLog(fs, newlogdir, conf);
|
|
this.logRoller = new LogRoller();
|
|
this.logRoller = new LogRoller();
|
|
this.logRollerThread = new Thread(logRoller, "HRegionServer.logRoller");
|
|
this.logRollerThread = new Thread(logRoller, "HRegionServer.logRoller");
|
|
|
|
|
|
// Remote HMaster
|
|
// Remote HMaster
|
|
-
|
|
|
|
- this.hbaseMaster = (HMasterRegionInterface)
|
|
|
|
- RPC.waitForProxy(HMasterRegionInterface.class,
|
|
|
|
- HMasterRegionInterface.versionID,
|
|
|
|
- new HServerAddress(conf.get(MASTER_ADDRESS)).getInetSocketAddress(),
|
|
|
|
- conf);
|
|
|
|
|
|
+ this.hbaseMaster = (HMasterRegionInterface)RPC.
|
|
|
|
+ waitForProxy(HMasterRegionInterface.class,
|
|
|
|
+ HMasterRegionInterface.versionID,
|
|
|
|
+ new HServerAddress(conf.get(MASTER_ADDRESS)).getInetSocketAddress(),
|
|
|
|
+ conf);
|
|
|
|
|
|
// Threads
|
|
// Threads
|
|
-
|
|
|
|
this.workerThread.start();
|
|
this.workerThread.start();
|
|
this.cacheFlusherThread.start();
|
|
this.cacheFlusherThread.start();
|
|
this.splitCheckerThread.start();
|
|
this.splitCheckerThread.start();
|
|
this.logRollerThread.start();
|
|
this.logRollerThread.start();
|
|
- this.leases = new Leases(conf.getLong("hbase.hregionserver.lease.period",
|
|
|
|
|
|
+ this.leases = new Leases(conf.getLong("hbase.regionserver.lease.period",
|
|
3 * 60 * 1000), threadWakeFrequency);
|
|
3 * 60 * 1000), threadWakeFrequency);
|
|
|
|
|
|
// Server
|
|
// Server
|
|
@@ -380,56 +404,44 @@ public class HRegionServer
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Stop all the HRegionServer threads and close everything down. All ongoing
|
|
|
|
- * transactions will be aborted all threads will be shut down. This method
|
|
|
|
- * will return immediately. The caller should call join to wait for all
|
|
|
|
- * processing to cease.
|
|
|
|
|
|
+ * Set a flag that will cause all the HRegionServer threads to shut down
|
|
|
|
+ * in an orderly fashion.
|
|
*/
|
|
*/
|
|
- public void stop() throws IOException {
|
|
|
|
- if(! stopRequested) {
|
|
|
|
- stopRequested = true;
|
|
|
|
-
|
|
|
|
- closeAllRegions();
|
|
|
|
- log.close();
|
|
|
|
- fs.close();
|
|
|
|
- server.stop();
|
|
|
|
- }
|
|
|
|
- LOG.info("stopping server at: " + address.toString());
|
|
|
|
|
|
+ public synchronized void stop() throws IOException {
|
|
|
|
+ stopRequested = true;
|
|
|
|
+ notifyAll(); // Wakes run() if it is sleeping
|
|
}
|
|
}
|
|
|
|
|
|
- /** Call join to wait for all the threads to finish */
|
|
|
|
|
|
+ /** Wait on all threads to finish.
|
|
|
|
+ * Presumption is that all closes and stops have already been called.
|
|
|
|
+ */
|
|
public void join() {
|
|
public void join() {
|
|
try {
|
|
try {
|
|
this.workerThread.join();
|
|
this.workerThread.join();
|
|
-
|
|
|
|
} catch(InterruptedException iex) {
|
|
} catch(InterruptedException iex) {
|
|
}
|
|
}
|
|
-
|
|
|
|
try {
|
|
try {
|
|
this.logRollerThread.join();
|
|
this.logRollerThread.join();
|
|
-
|
|
|
|
} catch(InterruptedException iex) {
|
|
} catch(InterruptedException iex) {
|
|
}
|
|
}
|
|
-
|
|
|
|
try {
|
|
try {
|
|
this.cacheFlusherThread.join();
|
|
this.cacheFlusherThread.join();
|
|
-
|
|
|
|
} catch(InterruptedException iex) {
|
|
} catch(InterruptedException iex) {
|
|
}
|
|
}
|
|
-
|
|
|
|
- this.leases.close();
|
|
|
|
-
|
|
|
|
|
|
+ try {
|
|
|
|
+ this.splitCheckerThread.join();
|
|
|
|
+ } catch(InterruptedException iex) {
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
this.server.join();
|
|
this.server.join();
|
|
-
|
|
|
|
} catch(InterruptedException iex) {
|
|
} catch(InterruptedException iex) {
|
|
}
|
|
}
|
|
LOG.info("server stopped at: " + address.toString());
|
|
LOG.info("server stopped at: " + address.toString());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The HRegionServer sticks in this loop until close. It repeatedly checks in
|
|
|
|
- * with the HMaster, sending heartbeats & reports, and receiving HRegion
|
|
|
|
|
|
+ * The HRegionServer sticks in this loop until closed. It repeatedly checks
|
|
|
|
+ * in with the HMaster, sending heartbeats & reports, and receiving HRegion
|
|
* load/unload instructions.
|
|
* load/unload instructions.
|
|
*/
|
|
*/
|
|
public void run() {
|
|
public void run() {
|
|
@@ -439,27 +451,40 @@ public class HRegionServer
|
|
long waitTime;
|
|
long waitTime;
|
|
|
|
|
|
// Let the master know we're here
|
|
// Let the master know we're here
|
|
-
|
|
|
|
try {
|
|
try {
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Telling master we are up");
|
|
|
|
+ }
|
|
|
|
+
|
|
hbaseMaster.regionServerStartup(info);
|
|
hbaseMaster.regionServerStartup(info);
|
|
|
|
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Done telling master we are up");
|
|
|
|
+ }
|
|
} catch(IOException e) {
|
|
} catch(IOException e) {
|
|
- waitTime = msgInterval - (System.currentTimeMillis() - lastMsg);
|
|
|
|
-
|
|
|
|
|
|
+ waitTime = stopRequested ? 0
|
|
|
|
+ : msgInterval - (System.currentTimeMillis() - lastMsg);
|
|
|
|
+
|
|
if(waitTime > 0) {
|
|
if(waitTime > 0) {
|
|
- try {
|
|
|
|
- Thread.sleep(waitTime);
|
|
|
|
-
|
|
|
|
- } catch(InterruptedException iex) {
|
|
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Sleep");
|
|
|
|
+ }
|
|
|
|
+ synchronized(this) {
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep(waitTime);
|
|
|
|
+ } catch(InterruptedException iex) {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Wake");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- // Now ask the master what it wants us to do and tell it what we have done.
|
|
|
|
-
|
|
|
|
- while(! stopRequested) {
|
|
|
|
- if((System.currentTimeMillis() - lastMsg) >= msgInterval) {
|
|
|
|
|
|
+ // Now ask master what it wants us to do and tell it what we have done.
|
|
|
|
+ while (!stopRequested) {
|
|
|
|
+ if ((System.currentTimeMillis() - lastMsg) >= msgInterval) {
|
|
|
|
|
|
HMsg outboundArray[] = null;
|
|
HMsg outboundArray[] = null;
|
|
synchronized(outboundMsgs) {
|
|
synchronized(outboundMsgs) {
|
|
@@ -474,28 +499,43 @@ public class HRegionServer
|
|
// Queue up the HMaster's instruction stream for processing
|
|
// Queue up the HMaster's instruction stream for processing
|
|
|
|
|
|
synchronized(toDo) {
|
|
synchronized(toDo) {
|
|
- boolean restartOrStop = false;
|
|
|
|
- for(int i = 0; i < msgs.length; i++) {
|
|
|
|
|
|
+ boolean restart = false;
|
|
|
|
+ for(int i = 0; i < msgs.length && !stopRequested && !restart; i++) {
|
|
switch(msgs[i].getMsg()) {
|
|
switch(msgs[i].getMsg()) {
|
|
|
|
|
|
case HMsg.MSG_CALL_SERVER_STARTUP:
|
|
case HMsg.MSG_CALL_SERVER_STARTUP:
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Got call server startup message");
|
|
|
|
+ }
|
|
|
|
+ toDo.clear();
|
|
closeAllRegions();
|
|
closeAllRegions();
|
|
- restartOrStop = true;
|
|
|
|
|
|
+ restart = true;
|
|
break;
|
|
break;
|
|
|
|
|
|
- case HMsg.MSG_REGIONSERVER_ALREADY_RUNNING:
|
|
|
|
- stop();
|
|
|
|
- restartOrStop = true;
|
|
|
|
|
|
+ case HMsg.MSG_REGIONSERVER_STOP:
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Got regionserver stop message");
|
|
|
|
+ }
|
|
|
|
+ toDo.clear();
|
|
|
|
+ closeAllRegions();
|
|
|
|
+ stopRequested = true;
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Got default message");
|
|
|
|
+ }
|
|
toDo.add(msgs[i]);
|
|
toDo.add(msgs[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
if(toDo.size() > 0) {
|
|
if(toDo.size() > 0) {
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("notify on todo");
|
|
|
|
+ }
|
|
toDo.notifyAll();
|
|
toDo.notifyAll();
|
|
}
|
|
}
|
|
- if(restartOrStop) {
|
|
|
|
|
|
+ if(restart || stopRequested) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -505,16 +545,47 @@ public class HRegionServer
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- waitTime = msgInterval - (System.currentTimeMillis() - lastMsg);
|
|
|
|
-
|
|
|
|
- if(waitTime > 0) {
|
|
|
|
- try {
|
|
|
|
- Thread.sleep(waitTime);
|
|
|
|
- } catch(InterruptedException iex) {
|
|
|
|
|
|
+ waitTime = stopRequested ? 0
|
|
|
|
+ : msgInterval - (System.currentTimeMillis() - lastMsg);
|
|
|
|
+ if (waitTime > 0) {
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Sleep");
|
|
|
|
+ }
|
|
|
|
+ synchronized(this) {
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep(waitTime);
|
|
|
|
+ } catch(InterruptedException iex) {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Wake");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ try {
|
|
|
|
+ LOG.info("stopping server at: " + address.toString());
|
|
|
|
+
|
|
|
|
+ // Send interrupts to wake up threads if sleeping so they notice shutdown.
|
|
|
|
+
|
|
|
|
+ this.logRollerThread.interrupt();
|
|
|
|
+ this.cacheFlusherThread.interrupt();
|
|
|
|
+ this.splitCheckerThread.interrupt();
|
|
|
|
+
|
|
|
|
+ this.worker.stop();
|
|
|
|
+ this.server.stop();
|
|
|
|
+
|
|
|
|
+ closeAllRegions();
|
|
|
|
+ log.close();
|
|
|
|
+ leases.close();
|
|
|
|
+ join();
|
|
|
|
+
|
|
|
|
+ } catch(IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ if(LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("main thread exiting");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/** Add to the outbound message buffer */
|
|
/** Add to the outbound message buffer */
|
|
@@ -556,48 +627,83 @@ public class HRegionServer
|
|
private Worker worker;
|
|
private Worker worker;
|
|
private Thread workerThread;
|
|
private Thread workerThread;
|
|
private class Worker implements Runnable {
|
|
private class Worker implements Runnable {
|
|
|
|
+ public void stop() {
|
|
|
|
+ synchronized(toDo) {
|
|
|
|
+ toDo.notifyAll();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public void run() {
|
|
public void run() {
|
|
- while(!stopRequested) {
|
|
|
|
- HMsg msg = null;
|
|
|
|
|
|
+ for(HMsg msg = null; !stopRequested; ) {
|
|
synchronized(toDo) {
|
|
synchronized(toDo) {
|
|
- while(toDo.size() == 0) {
|
|
|
|
|
|
+ while(toDo.size() == 0 && !stopRequested) {
|
|
try {
|
|
try {
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Wait on todo");
|
|
|
|
+ }
|
|
toDo.wait();
|
|
toDo.wait();
|
|
-
|
|
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("Wake on todo");
|
|
|
|
+ }
|
|
} catch(InterruptedException e) {
|
|
} catch(InterruptedException e) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(stopRequested) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
msg = toDo.remove(0);
|
|
msg = toDo.remove(0);
|
|
}
|
|
}
|
|
|
|
+
|
|
try {
|
|
try {
|
|
switch(msg.getMsg()) {
|
|
switch(msg.getMsg()) {
|
|
|
|
|
|
case HMsg.MSG_REGION_OPEN: // Open a region
|
|
case HMsg.MSG_REGION_OPEN: // Open a region
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("MSG_REGION_OPEN");
|
|
|
|
+ }
|
|
openRegion(msg.getRegionInfo());
|
|
openRegion(msg.getRegionInfo());
|
|
break;
|
|
break;
|
|
|
|
|
|
case HMsg.MSG_REGION_CLOSE: // Close a region
|
|
case HMsg.MSG_REGION_CLOSE: // Close a region
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("MSG_REGION_CLOSE");
|
|
|
|
+ }
|
|
closeRegion(msg.getRegionInfo(), true);
|
|
closeRegion(msg.getRegionInfo(), true);
|
|
break;
|
|
break;
|
|
|
|
|
|
case HMsg.MSG_REGION_MERGE: // Merge two regions
|
|
case HMsg.MSG_REGION_MERGE: // Merge two regions
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("MSG_REGION_MERGE");
|
|
|
|
+ }
|
|
//TODO ???
|
|
//TODO ???
|
|
throw new IOException("TODO: need to figure out merge");
|
|
throw new IOException("TODO: need to figure out merge");
|
|
//break;
|
|
//break;
|
|
|
|
|
|
case HMsg.MSG_CALL_SERVER_STARTUP: // Close regions, restart
|
|
case HMsg.MSG_CALL_SERVER_STARTUP: // Close regions, restart
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("MSG_CALL_SERVER_STARTUP");
|
|
|
|
+ }
|
|
closeAllRegions();
|
|
closeAllRegions();
|
|
continue;
|
|
continue;
|
|
|
|
|
|
- case HMsg.MSG_REGIONSERVER_ALREADY_RUNNING: // Go away
|
|
|
|
- stop();
|
|
|
|
|
|
+ case HMsg.MSG_REGIONSERVER_STOP: // Go away
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("MSG_REGIONSERVER_STOP");
|
|
|
|
+ }
|
|
|
|
+ stopRequested = true;
|
|
continue;
|
|
continue;
|
|
|
|
|
|
case HMsg.MSG_REGION_CLOSE_WITHOUT_REPORT: // Close a region, don't reply
|
|
case HMsg.MSG_REGION_CLOSE_WITHOUT_REPORT: // Close a region, don't reply
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("MSG_REGION_CLOSE_WITHOUT_REPORT");
|
|
|
|
+ }
|
|
closeRegion(msg.getRegionInfo(), false);
|
|
closeRegion(msg.getRegionInfo(), false);
|
|
break;
|
|
break;
|
|
|
|
|
|
case HMsg.MSG_REGION_CLOSE_AND_DELETE:
|
|
case HMsg.MSG_REGION_CLOSE_AND_DELETE:
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("MSG_REGION_CLOSE_AND_DELETE");
|
|
|
|
+ }
|
|
closeAndDeleteRegion(msg.getRegionInfo());
|
|
closeAndDeleteRegion(msg.getRegionInfo());
|
|
break;
|
|
break;
|
|
|
|
|
|
@@ -608,15 +714,17 @@ public class HRegionServer
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("worker thread exiting");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void openRegion(HRegionInfo regionInfo) throws IOException {
|
|
private void openRegion(HRegionInfo regionInfo) throws IOException {
|
|
-
|
|
|
|
this.locker.writeLock().lock();
|
|
this.locker.writeLock().lock();
|
|
try {
|
|
try {
|
|
- HRegion region = new HRegion(regionDir, log, fs, conf, regionInfo, null, oldlogfile);
|
|
|
|
-
|
|
|
|
|
|
+ HRegion region =
|
|
|
|
+ new HRegion(regionDir, log, fs, conf, regionInfo, null, oldlogfile);
|
|
regions.put(region.getRegionName(), region);
|
|
regions.put(region.getRegionName(), region);
|
|
reportOpen(region);
|
|
reportOpen(region);
|
|
|
|
|
|
@@ -661,12 +769,20 @@ public class HRegionServer
|
|
}
|
|
}
|
|
|
|
|
|
/** Called either when the master tells us to restart or from stop() */
|
|
/** Called either when the master tells us to restart or from stop() */
|
|
- private void closeAllRegions() throws IOException {
|
|
|
|
|
|
+ private void closeAllRegions() {
|
|
this.locker.writeLock().lock();
|
|
this.locker.writeLock().lock();
|
|
try {
|
|
try {
|
|
for(Iterator<HRegion> it = regions.values().iterator(); it.hasNext(); ) {
|
|
for(Iterator<HRegion> it = regions.values().iterator(); it.hasNext(); ) {
|
|
HRegion region = it.next();
|
|
HRegion region = it.next();
|
|
- region.close();
|
|
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("closing region " + region.getRegionName());
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ region.close();
|
|
|
|
+
|
|
|
|
+ } catch(IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
regions.clear();
|
|
regions.clear();
|
|
|
|
|
|
@@ -722,9 +838,12 @@ public class HRegionServer
|
|
throw new IOException("Not serving region " + regionName);
|
|
throw new IOException("Not serving region " + regionName);
|
|
}
|
|
}
|
|
|
|
|
|
- byte results[] = region.get(row, column);
|
|
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("get " + row.toString() + ", " + column.toString());
|
|
|
|
+ }
|
|
|
|
+ BytesWritable results = region.get(row, column);
|
|
if(results != null) {
|
|
if(results != null) {
|
|
- return new BytesWritable(results);
|
|
|
|
|
|
+ return results;
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -738,15 +857,9 @@ public class HRegionServer
|
|
throw new IOException("Not serving region " + regionName);
|
|
throw new IOException("Not serving region " + regionName);
|
|
}
|
|
}
|
|
|
|
|
|
- byte results[][] = region.get(row, column, numVersions);
|
|
|
|
|
|
+ BytesWritable[] results = region.get(row, column, numVersions);
|
|
if(results != null) {
|
|
if(results != null) {
|
|
- BytesWritable realResults[] = new BytesWritable[results.length];
|
|
|
|
- for(int i = 0; i < realResults.length; i++) {
|
|
|
|
- if(results[i] != null) {
|
|
|
|
- realResults[i] = new BytesWritable(results[i]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return realResults;
|
|
|
|
|
|
+ return results;
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -760,15 +873,9 @@ public class HRegionServer
|
|
throw new IOException("Not serving region " + regionName);
|
|
throw new IOException("Not serving region " + regionName);
|
|
}
|
|
}
|
|
|
|
|
|
- byte results[][] = region.get(row, column, timestamp, numVersions);
|
|
|
|
|
|
+ BytesWritable[] results = region.get(row, column, timestamp, numVersions);
|
|
if(results != null) {
|
|
if(results != null) {
|
|
- BytesWritable realResults[] = new BytesWritable[results.length];
|
|
|
|
- for(int i = 0; i < realResults.length; i++) {
|
|
|
|
- if(results[i] != null) {
|
|
|
|
- realResults[i] = new BytesWritable(results[i]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return realResults;
|
|
|
|
|
|
+ return results;
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -780,12 +887,12 @@ public class HRegionServer
|
|
throw new IOException("Not serving region " + regionName);
|
|
throw new IOException("Not serving region " + regionName);
|
|
}
|
|
}
|
|
|
|
|
|
- TreeMap<Text, byte[]> map = region.getFull(row);
|
|
|
|
|
|
+ TreeMap<Text, BytesWritable> map = region.getFull(row);
|
|
LabelledData result[] = new LabelledData[map.size()];
|
|
LabelledData result[] = new LabelledData[map.size()];
|
|
int counter = 0;
|
|
int counter = 0;
|
|
for(Iterator<Text> it = map.keySet().iterator(); it.hasNext(); ) {
|
|
for(Iterator<Text> it = map.keySet().iterator(); it.hasNext(); ) {
|
|
Text colname = it.next();
|
|
Text colname = it.next();
|
|
- byte val[] = map.get(colname);
|
|
|
|
|
|
+ BytesWritable val = map.get(colname);
|
|
result[counter++] = new LabelledData(colname, val);
|
|
result[counter++] = new LabelledData(colname, val);
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
@@ -842,7 +949,7 @@ public class HRegionServer
|
|
leases.renewLease(new Text(String.valueOf(clientid)),
|
|
leases.renewLease(new Text(String.valueOf(clientid)),
|
|
new Text(String.valueOf(lockid)));
|
|
new Text(String.valueOf(lockid)));
|
|
|
|
|
|
- region.put(lockid, column, val.get());
|
|
|
|
|
|
+ region.put(lockid, column, val);
|
|
}
|
|
}
|
|
|
|
|
|
/** Remove a cell from the HBase. */
|
|
/** Remove a cell from the HBase. */
|
|
@@ -911,7 +1018,7 @@ public class HRegionServer
|
|
// remote scanner interface
|
|
// remote scanner interface
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
- private Map<Text, HScannerInterface> scanners;
|
|
|
|
|
|
+ private Map<Text, HInternalScannerInterface> scanners;
|
|
private class ScannerListener extends LeaseListener {
|
|
private class ScannerListener extends LeaseListener {
|
|
private Text scannerName;
|
|
private Text scannerName;
|
|
|
|
|
|
@@ -920,7 +1027,7 @@ public class HRegionServer
|
|
}
|
|
}
|
|
|
|
|
|
public void leaseExpired() {
|
|
public void leaseExpired() {
|
|
- HScannerInterface s = scanners.remove(scannerName);
|
|
|
|
|
|
+ HInternalScannerInterface s = scanners.remove(scannerName);
|
|
if(s != null) {
|
|
if(s != null) {
|
|
try {
|
|
try {
|
|
s.close();
|
|
s.close();
|
|
@@ -943,7 +1050,7 @@ public class HRegionServer
|
|
|
|
|
|
long scannerId = -1L;
|
|
long scannerId = -1L;
|
|
try {
|
|
try {
|
|
- HScannerInterface s = r.getScanner(cols, firstRow);
|
|
|
|
|
|
+ HInternalScannerInterface s = r.getScanner(cols, firstRow);
|
|
scannerId = rand.nextLong();
|
|
scannerId = rand.nextLong();
|
|
Text scannerName = new Text(String.valueOf(scannerId));
|
|
Text scannerName = new Text(String.valueOf(scannerId));
|
|
scanners.put(scannerName, s);
|
|
scanners.put(scannerName, s);
|
|
@@ -959,18 +1066,30 @@ public class HRegionServer
|
|
public LabelledData[] next(long scannerId, HStoreKey key) throws IOException {
|
|
public LabelledData[] next(long scannerId, HStoreKey key) throws IOException {
|
|
|
|
|
|
Text scannerName = new Text(String.valueOf(scannerId));
|
|
Text scannerName = new Text(String.valueOf(scannerId));
|
|
- HScannerInterface s = scanners.get(scannerName);
|
|
|
|
|
|
+ HInternalScannerInterface s = scanners.get(scannerName);
|
|
if(s == null) {
|
|
if(s == null) {
|
|
throw new IOException("unknown scanner");
|
|
throw new IOException("unknown scanner");
|
|
}
|
|
}
|
|
leases.renewLease(scannerName, scannerName);
|
|
leases.renewLease(scannerName, scannerName);
|
|
- TreeMap<Text, byte[]> results = new TreeMap<Text, byte[]>();
|
|
|
|
|
|
+ TreeMap<Text, BytesWritable> results = new TreeMap<Text, BytesWritable>();
|
|
ArrayList<LabelledData> values = new ArrayList<LabelledData>();
|
|
ArrayList<LabelledData> values = new ArrayList<LabelledData>();
|
|
if(s.next(key, results)) {
|
|
if(s.next(key, results)) {
|
|
- for(Iterator<Map.Entry<Text, byte[]>> it = results.entrySet().iterator();
|
|
|
|
|
|
+ for(Iterator<Map.Entry<Text, BytesWritable>> it
|
|
|
|
+ = results.entrySet().iterator();
|
|
it.hasNext(); ) {
|
|
it.hasNext(); ) {
|
|
- Map.Entry<Text, byte[]> e = it.next();
|
|
|
|
- values.add(new LabelledData(e.getKey(), e.getValue()));
|
|
|
|
|
|
+
|
|
|
|
+ Map.Entry<Text, BytesWritable> e = it.next();
|
|
|
|
+ BytesWritable val = e.getValue();
|
|
|
|
+ if(val.getSize() == DELETE_BYTES.getSize()
|
|
|
|
+ && val.compareTo(DELETE_BYTES) == 0) {
|
|
|
|
+
|
|
|
|
+ // Value is deleted. Don't return a value
|
|
|
|
+
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ values.add(new LabelledData(e.getKey(), val));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return values.toArray(new LabelledData[values.size()]);
|
|
return values.toArray(new LabelledData[values.size()]);
|
|
@@ -978,7 +1097,7 @@ public class HRegionServer
|
|
|
|
|
|
public void close(long scannerId) throws IOException {
|
|
public void close(long scannerId) throws IOException {
|
|
Text scannerName = new Text(String.valueOf(scannerId));
|
|
Text scannerName = new Text(String.valueOf(scannerId));
|
|
- HScannerInterface s = scanners.remove(scannerName);
|
|
|
|
|
|
+ HInternalScannerInterface s = scanners.remove(scannerName);
|
|
if(s == null) {
|
|
if(s == null) {
|
|
throw new IOException("unknown scanner");
|
|
throw new IOException("unknown scanner");
|
|
}
|
|
}
|
|
@@ -991,33 +1110,53 @@ public class HRegionServer
|
|
leases.cancelLease(scannerName, scannerName);
|
|
leases.cancelLease(scannerName, scannerName);
|
|
}
|
|
}
|
|
|
|
|
|
- //////////////////////////////////////////////////////////////////////////////
|
|
|
|
- // Main program
|
|
|
|
- //////////////////////////////////////////////////////////////////////////////
|
|
|
|
-
|
|
|
|
- private static void printUsage() {
|
|
|
|
|
|
+ private static void printUsageAndExit() {
|
|
|
|
+ printUsageAndExit(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static void printUsageAndExit(final String message) {
|
|
|
|
+ if (message != null) {
|
|
|
|
+ System.err.println(message);
|
|
|
|
+ }
|
|
System.err.println("Usage: java " +
|
|
System.err.println("Usage: java " +
|
|
- "org.apache.hbase.HRegionServer [--bind=hostname:port]");
|
|
|
|
|
|
+ "org.apache.hbase.HRegionServer [--bind=hostname:port] start");
|
|
|
|
+ System.exit(0);
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String [] args) throws IOException {
|
|
public static void main(String [] args) throws IOException {
|
|
|
|
+ if (args.length < 1) {
|
|
|
|
+ printUsageAndExit();
|
|
|
|
+ }
|
|
|
|
+
|
|
Configuration conf = new HBaseConfiguration();
|
|
Configuration conf = new HBaseConfiguration();
|
|
|
|
|
|
// Process command-line args. TODO: Better cmd-line processing
|
|
// Process command-line args. TODO: Better cmd-line processing
|
|
// (but hopefully something not as painful as cli options).
|
|
// (but hopefully something not as painful as cli options).
|
|
|
|
+ final String addressArgKey = "--bind=";
|
|
for (String cmd: args) {
|
|
for (String cmd: args) {
|
|
- if (cmd.equals("-h") || cmd.startsWith("--h")) {
|
|
|
|
- printUsage();
|
|
|
|
- return;
|
|
|
|
|
|
+ if (cmd.startsWith(addressArgKey)) {
|
|
|
|
+ conf.set(REGIONSERVER_ADDRESS, cmd.substring(addressArgKey.length()));
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
|
|
- final String addressArgKey = "--bind=";
|
|
|
|
- if (cmd.startsWith(addressArgKey)) {
|
|
|
|
- conf.set(REGIONSERVER_ADDRESS,
|
|
|
|
- cmd.substring(addressArgKey.length()));
|
|
|
|
|
|
+ if (cmd.equals("start")) {
|
|
|
|
+ try {
|
|
|
|
+ (new Thread(new HRegionServer(conf))).start();
|
|
|
|
+ } catch (Throwable t) {
|
|
|
|
+ LOG.error( "Can not start master because "+
|
|
|
|
+ StringUtils.stringifyException(t) );
|
|
|
|
+ System.exit(-1);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (cmd.equals("stop")) {
|
|
|
|
+ printUsageAndExit("There is no regionserver stop mechanism. To stop " +
|
|
|
|
+ "regionservers, shutdown the hbase master");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Print out usage if we get to here.
|
|
|
|
+ printUsageAndExit();
|
|
}
|
|
}
|
|
-
|
|
|
|
- new HRegionServer(conf);
|
|
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|