hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r1464821 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java
Date Fri, 05 Apr 2013 04:47:03 GMT
Author: ddas
Date: Fri Apr  5 04:47:03 2013
New Revision: 1464821

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

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java?rev=1464821&r1=1464820&r2=1464821&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/rest/Main.java Fri Apr  5 04:47:03
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 Main implements Constants {
       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
 
@@ -176,6 +193,7 @@ public class Main implements Constants {
 
     // 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