You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by dd...@apache.org on 2013/04/05 02:43:53 UTC
svn commit: r1464800 -
/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java
Author: ddas
Date: Fri Apr 5 00:43:52 2013
New Revision: 1464800
URL: http://svn.apache.org/r1464800
Log:
HBASE-8179. Fixes a problem to do with the json response for the cluster status
Modified:
hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java
Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java?rev=1464800&r1=1464799&r2=1464800&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java Fri Apr 5 00:43:52 2013
@@ -39,6 +39,8 @@ import org.apache.hadoop.net.DNS;
import java.util.List;
import java.util.ArrayList;
+import java.util.Map;
+import java.util.Map.Entry;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
@@ -47,6 +49,7 @@ import org.mortbay.jetty.servlet.Context
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.thread.QueuedThreadPool;
+import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.spi.container.servlet.ServletContainer;
/**
@@ -148,6 +151,20 @@ public class RESTServer implements Const
ResourceConfig.class.getCanonicalName());
sh.setInitParameter("com.sun.jersey.config.property.packages",
"jetty");
+ // The servlet holder below is instantiated to only handle the case
+ // of the /status/cluster returning arrays of nodes (live/dead). Without
+ // this servlet holder, the problem is that the node arrays in the response
+ // are collapsed to single nodes. We want to be able to treat the
+ // node lists as POJO in the response to /status/cluster servlet call,
+ // but not change the behavior for any of the other servlets
+ // Hence we don't use the servlet holder for all servlets / paths
+ ServletHolder shPojoMap = new ServletHolder(ServletContainer.class);
+ @SuppressWarnings("unchecked")
+ Map<String, String> shInitMap = sh.getInitParameters();
+ for (Entry<String, String> e : shInitMap.entrySet()) {
+ shPojoMap.setInitParameter(e.getKey(), e.getValue());
+ }
+ shPojoMap.setInitParameter(JSONConfiguration.FEATURE_POJO_MAPPING, "true");
// set up Jetty and run the embedded server
@@ -175,6 +192,7 @@ public class RESTServer implements Const
server.setStopAtShutdown(true);
// set up context
Context context = new Context(server, "/", Context.SESSIONS);
+ context.addServlet(shPojoMap, "/status/cluster");
context.addServlet(sh, "/*");
context.addFilter(GzipFilter.class, "/*", 0);