You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2008/02/08 01:10:49 UTC
svn commit: r619694 - in /hadoop/hbase/trunk: CHANGES.txt
src/java/org/apache/hadoop/hbase/HConnectionManager.java
src/java/org/apache/hadoop/hbase/rest/Dispatcher.java
Author: stack
Date: Thu Feb 7 16:10:45 2008
New Revision: 619694
URL: http://svn.apache.org/viewvc?rev=619694&view=rev
Log:
HBASE-3 rest server: configure number of threads for jetty
HBASE-416 Add apache-style logging to REST server and add setting log level, etc.
Modified:
hadoop/hbase/trunk/CHANGES.txt
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConnectionManager.java
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java
Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=619694&r1=619693&r2=619694&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Thu Feb 7 16:10:45 2008
@@ -27,6 +27,10 @@
(Edward Yoon & Bryan Duxbury via Stack)
HBASE-56 Unnecessary HQLClient Object creation in a shell loop
(Edward Yoon via Stack)
+ HBASE-3 rest server: configure number of threads for jetty
+ (Bryan Duxbury via Stack)
+ HBASE-416 Add apache-style logging to REST server and add setting log
+ level, etc.
Branch 0.1
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConnectionManager.java?rev=619694&r1=619693&r2=619694&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConnectionManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConnectionManager.java Thu Feb 7 16:10:45 2008
@@ -381,7 +381,7 @@
if (location != null) {
return location;
}
- } else{
+ } else {
deleteCachedLocation(tableName, row);
}
@@ -509,7 +509,14 @@
// if there's something in the cache for this table.
if (!tableLocations.isEmpty()) {
if (tableLocations.containsKey(row)) {
- return tableLocations.get(row);
+ HRegionLocation rl = tableLocations.get(row);
+ if (rl != null && LOG.isDebugEnabled()) {
+ LOG.debug("Cache hit in table locations for row <" +
+ row + "> and tableName " + tableName +
+ ": location server " + rl.getServerAddress() +
+ ", location region name " + rl.getRegionInfo().getRegionName());
+ }
+ return rl;
}
// cut the cache so that we only get the part that could contain
@@ -532,6 +539,10 @@
// signifying that the region we're checking is actually the last
// region in the table.
if (endKey.equals(EMPTY_TEXT) || endKey.compareTo(row) > 0) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Found possible location for " + row + ", " +
+ possibleRegion);
+ }
return possibleRegion;
}
}
@@ -541,7 +552,6 @@
return null;
}
-
/**
* Delete a cached location, if it satisfies the table name and row
* requirements.
@@ -578,13 +588,17 @@
// otherwise it wouldn't be in the headMap.
if (endKey.compareTo(row) <= 0) {
// delete any matching entry
- tableLocations.remove(matchingRegions.lastKey());
+ HRegionLocation rl =
+ tableLocations.remove(matchingRegions.lastKey());
+ if (rl != null && LOG.isDebugEnabled()) {
+ LOG.debug("Removed " + rl.getRegionInfo().getRegionName() +
+ " from cache because of " + row);
+ }
}
}
- }
+ }
}
-
/**
* Put a newly discovered HRegionLocation into the cache.
*/
@@ -729,6 +743,9 @@
// if this works, then we're good, and we have an acceptable address,
// so we can stop doing retries and return the result.
server.getRegionInfo(HRegionInfo.rootRegionInfo.getRegionName());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Found ROOT " + HRegionInfo.rootRegionInfo);
+ }
break;
} catch (IOException e) {
if (tries == numRetries - 1) {
@@ -757,7 +774,7 @@
rootRegionAddress = null;
}
- // if the adress is null by this point, then the retries have failed,
+ // if the address is null by this point, then the retries have failed,
// and we're sort of sunk
if (rootRegionAddress == null) {
throw new NoServerForRegionException(
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java?rev=619694&r1=619693&r2=619694&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java Thu Feb 7 16:10:45 2008
@@ -22,13 +22,19 @@
import java.io.IOException;
import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HBaseAdmin;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.util.InfoServer;
+import org.apache.hadoop.mapred.StatusHttpServer;
+import org.mortbay.http.NCSARequestLog;
import org.mortbay.http.SocketListener;
+import org.mortbay.jetty.servlet.WebApplicationContext;
/**
* Servlet implementation class for hbase REST interface.
@@ -54,6 +60,7 @@
*/
public class Dispatcher extends javax.servlet.http.HttpServlet
implements javax.servlet.Servlet {
+ private static final Log LOG = LogFactory.getLog(Dispatcher.class.getName());
private MetaHandler metaHandler;
private TableHandler tableHandler;
private ScannerHandler scannerHandler;
@@ -179,7 +186,9 @@
System.out.println("Options:");
System.out.println(" port Port to listen on. Default: 60050.");
System.out.println(" bind Address to bind on. Default: 0.0.0.0.");
+ System.out.println(" max-num-threads The maximum number of threads for Jetty to run. Defaults to 256.");
System.out.println(" help Print this message and exit.");
+
System.exit(0);
}
@@ -194,11 +203,13 @@
int port = 60050;
String bindAddress = "0.0.0.0";
+ int numThreads = 256;
// Process command-line args. TODO: Better cmd-line processing
// (but hopefully something not as painful as cli options).
final String addressArgKey = "--bind=";
final String portArgKey = "--port=";
+ final String numThreadsKey = "--max-num-threads=";
for (String cmd: args) {
if (cmd.startsWith(addressArgKey)) {
bindAddress = cmd.substring(addressArgKey.length());
@@ -214,18 +225,29 @@
printUsageAndExit("To shutdown the REST server run " +
"bin/hbase-daemon.sh stop rest or send a kill signal to " +
"the REST server pid");
+ } else if (cmd.startsWith(numThreadsKey)) {
+ numThreads = Integer.parseInt(cmd.substring(numThreadsKey.length()));
+ continue;
}
// Print out usage if we get to here.
printUsageAndExit();
}
-
org.mortbay.jetty.Server webServer = new org.mortbay.jetty.Server();
SocketListener listener = new SocketListener();
listener.setPort(port);
listener.setHost(bindAddress);
+ listener.setMaxThreads(numThreads);
webServer.addListener(listener);
- webServer.addWebApplication("/api", InfoServer.getWebAppDir("rest"));
+ NCSARequestLog ncsa = new NCSARequestLog();
+ ncsa.setLogLatency(true);
+ webServer.setRequestLog(ncsa);
+ WebApplicationContext context =
+ webServer.addWebApplication("/api", InfoServer.getWebAppDir("rest"));
+ context.addServlet("stacks", "/stacks",
+ StatusHttpServer.StackServlet.class.getName());
+ context.addServlet("logLevel", "/logLevel",
+ org.apache.hadoop.log.LogLevel.Servlet.class.getName());
webServer.start();
}