hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r1464797 - /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java
Date Fri, 05 Apr 2013 00:36:02 GMT
Author: ddas
Date: Fri Apr  5 00:36:02 2013
New Revision: 1464797

URL: http://svn.apache.org/r1464797
Log:
HBASE-8179. Fixes a problem to do with the json response for the cluster status

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java?rev=1464797&r1=1464796&r2=1464797&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java Fri
Apr  5 00:36:02 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);
 



Mime
View raw message