hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1501839 - in /hbase/branches/0.95: hbase-client/src/main/java/org/apache/hadoop/hbase/client/ hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/ hbase-server/src/main/java...
Date Wed, 10 Jul 2013 16:37:56 GMT
Author: stack
Date: Wed Jul 10 16:37:55 2013
New Revision: 1501839

URL: http://svn.apache.org/r1501839
Log:
HBASE-8916 Optimize usage of Jackson's ObjectMapper

Modified:
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Operation.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/MonitoredTaskImpl.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogPrettyPrinter.java

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Operation.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Operation.java?rev=1501839&r1=1501838&r2=1501839&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Operation.java
(original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Operation.java
Wed Jul 10 16:37:55 2013
@@ -37,6 +37,8 @@ public abstract class Operation {
   // TODO Do we need this anymore now we have protobuffed it all?
   private static final int DEFAULT_MAX_COLS = 5;
 
+  private static final ObjectMapper MAPPER = new ObjectMapper();
+
   /**
    * Produces a Map containing a fingerprint which identifies the type and 
    * the static schema components of a query (i.e. column families)
@@ -67,8 +69,7 @@ public abstract class Operation {
    * @return a JSONObject containing this Operation's information, as a string
    */
   public String toJSON(int maxCols) throws IOException {
-    ObjectMapper mapper = new ObjectMapper();
-    return mapper.writeValueAsString(toMap(maxCols));
+    return MAPPER.writeValueAsString(toMap(maxCols));
   }
 
   /**
@@ -110,4 +111,4 @@ public abstract class Operation {
   public String toString() {
     return toString(DEFAULT_MAX_COLS);
   }
-}
\ No newline at end of file
+}

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java?rev=1501839&r1=1501838&r2=1501839&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
Wed Jul 10 16:37:55 2013
@@ -213,7 +213,7 @@ public class RpcServer implements RpcSer
   protected final boolean tcpKeepAlive; // if T then use keepalives
   protected final long purgeTimeout;    // in milliseconds
 
-  volatile protected boolean running = true;         // true while server runs
+  protected volatile boolean running = true;         // true while server runs
   protected BlockingQueue<Call> callQueue; // queued calls
   protected final Counter callQueueSize = new Counter();
   protected BlockingQueue<Call> priorityCallQueue;
@@ -243,6 +243,8 @@ public class RpcServer implements RpcSer
   private static final int DEFAULT_WARN_RESPONSE_TIME = 10000; // milliseconds
   private static final int DEFAULT_WARN_RESPONSE_SIZE = 100 * 1024 * 1024;
 
+  private static final ObjectMapper MAPPER = new ObjectMapper();
+
   private final int warnResponseTime;
   private final int warnResponseSize;
   private final Object serverInstance;
@@ -2179,8 +2181,6 @@ public class RpcServer implements RpcSer
       String clientAddress, long startTime, int processingTime, int qTime,
       long responseSize)
           throws IOException {
-    // for JSON encoding
-    ObjectMapper mapper = new ObjectMapper();
     // base information that is reported regardless of type of call
     Map<String, Object> responseInfo = new HashMap<String, Object>();
     responseInfo.put("starttimems", startTime);
@@ -2202,19 +2202,19 @@ public class RpcServer implements RpcSer
       responseInfo.putAll(((Operation) params[1]).toMap());
       // report to the log file
       LOG.warn("(operation" + tag + "): " +
-          mapper.writeValueAsString(responseInfo));
+               MAPPER.writeValueAsString(responseInfo));
     } else if (params.length == 1 && serverInstance instanceof HRegionServer &&
         params[0] instanceof Operation) {
       // annotate the response map with operation details
       responseInfo.putAll(((Operation) params[0]).toMap());
       // report to the log file
       LOG.warn("(operation" + tag + "): " +
-          mapper.writeValueAsString(responseInfo));
+               MAPPER.writeValueAsString(responseInfo));
     } else {
       // can't get JSON details, so just report call.toString() along with
       // a more generic tag.
       responseInfo.put("call", call);
-      LOG.warn("(response" + tag + "): " + mapper.writeValueAsString(responseInfo));
+      LOG.warn("(response" + tag + "): " + MAPPER.writeValueAsString(responseInfo));
     }
   }
 

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/MonitoredTaskImpl.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/MonitoredTaskImpl.java?rev=1501839&r1=1501838&r2=1501839&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/MonitoredTaskImpl.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/monitoring/MonitoredTaskImpl.java
Wed Jul 10 16:37:55 2013
@@ -35,7 +35,9 @@ class MonitoredTaskImpl implements Monit
   private volatile String description;
   
   protected volatile State state = State.RUNNING;
-  
+
+  private static final ObjectMapper MAPPER = new ObjectMapper();
+
   public MonitoredTaskImpl() {
     startTime = System.currentTimeMillis();
     statusTime = startTime;
@@ -158,8 +160,7 @@ class MonitoredTaskImpl implements Monit
 
   @Override
   public String toJSON() throws IOException {
-    ObjectMapper mapper = new ObjectMapper();
-    return mapper.writeValueAsString(toMap());
+    return MAPPER.writeValueAsString(toMap());
   }
 
   @Override

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogPrettyPrinter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogPrettyPrinter.java?rev=1501839&r1=1501838&r2=1501839&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogPrettyPrinter.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogPrettyPrinter.java
Wed Jul 10 16:37:55 2013
@@ -72,7 +72,7 @@ public class HLogPrettyPrinter {
   // useful for programatic capture of JSON output
   private PrintStream out;
   // for JSON encoding
-  private ObjectMapper mapper;
+  private static final ObjectMapper MAPPER = new ObjectMapper();
 
   /**
    * Basic constructor that simply initializes values to reasonable defaults.
@@ -86,7 +86,6 @@ public class HLogPrettyPrinter {
     persistentOutput = false;
     firstTxn = true;
     out = System.out;
-    mapper = new ObjectMapper();
   }
 
   /**
@@ -277,7 +276,7 @@ public class HLogPrettyPrinter {
           else
             out.print(",");
           // encode and print JSON
-          out.print(mapper.writeValueAsString(txn));
+          out.print(MAPPER.writeValueAsString(txn));
         } else {
           // Pretty output, complete with indentation by atomic action
           out.println("Sequence " + txn.get("sequence") + " "



Mime
View raw message