hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject [04/15] hbase git commit: HBASE-5238 Add a log4j category for all edits to META/ROOT
Date Thu, 26 Mar 2015 10:19:14 GMT
HBASE-5238 Add a log4j category for all edits to META/ROOT


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e26c4e4e
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e26c4e4e
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e26c4e4e

Branch: refs/heads/hbase-12439
Commit: e26c4e4e6733ea715fb33e4bd9df9ea2d32d5408
Parents: 134b955
Author: Andrey Stepachev <andrey.stepachev@wandisco.com>
Authored: Wed Mar 25 23:03:18 2015 +0000
Committer: Andrey Stepachev <andrey.stepachev@wandisco.com>
Committed: Wed Mar 25 23:03:18 2015 +0000

----------------------------------------------------------------------
 conf/log4j.properties                           |  1 +
 .../apache/hadoop/hbase/MetaTableAccessor.java  | 45 +++++++++++++++++++-
 2 files changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e26c4e4e/conf/log4j.properties
----------------------------------------------------------------------
diff --git a/conf/log4j.properties b/conf/log4j.properties
index 7b0acc0..8d6badb 100644
--- a/conf/log4j.properties
+++ b/conf/log4j.properties
@@ -76,6 +76,7 @@ log4j.appender.console.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}:
%m%
 log4j.logger.org.apache.zookeeper=INFO
 #log4j.logger.org.apache.hadoop.fs.FSNamesystem=DEBUG
 log4j.logger.org.apache.hadoop.hbase=INFO
+log4j.logger.org.apache.hadoop.hbase.META=INFO
 # Make these two classes INFO-level. Make them DEBUG to see more zk debug.
 log4j.logger.org.apache.hadoop.hbase.zookeeper.ZKUtil=INFO
 log4j.logger.org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher=INFO

http://git-wip-us.apache.org/repos/asf/hbase/blob/e26c4e4e/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java
index 4df58a2..88cc25e 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java
@@ -122,6 +122,7 @@ public class MetaTableAccessor {
    */
 
   private static final Log LOG = LogFactory.getLog(MetaTableAccessor.class);
+  private static final Log METALOG = LogFactory.getLog("org.apache.hadoop.hbase.META");
 
   static final byte [] META_REGION_PREFIX;
   static {
@@ -1354,6 +1355,9 @@ public class MetaTableAccessor {
    */
   private static void put(final Table t, final Put p) throws IOException {
     try {
+      if (METALOG.isDebugEnabled()) {
+        METALOG.debug(mutationToString(p));
+      }
       t.put(p);
     } finally {
       t.close();
@@ -1370,6 +1374,9 @@ public class MetaTableAccessor {
     throws IOException {
     Table t = getMetaHTable(connection);
     try {
+      if (METALOG.isDebugEnabled()) {
+        METALOG.debug(mutationsToString(ps));
+      }
       t.put(ps);
     } finally {
       t.close();
@@ -1399,6 +1406,9 @@ public class MetaTableAccessor {
     throws IOException {
     Table t = getMetaHTable(connection);
     try {
+      if (METALOG.isDebugEnabled()) {
+        METALOG.debug(mutationsToString(deletes));
+      }
       t.delete(deletes);
     } finally {
       t.close();
@@ -1443,7 +1453,10 @@ public class MetaTableAccessor {
     throws IOException {
     Table t = getMetaHTable(connection);
     try {
-      t.batch(mutations);
+      if (METALOG.isDebugEnabled()) {
+        METALOG.debug(mutationsToString(mutations));
+      }
+      t.batch(mutations, new Object[mutations.size()]);
     } catch (InterruptedException e) {
       InterruptedIOException ie = new InterruptedIOException(e.getMessage());
       ie.initCause(e);
@@ -1494,6 +1507,9 @@ public class MetaTableAccessor {
     Put put = makePutFromRegionInfo(regionInfo);
     addDaughtersToPut(put, splitA, splitB);
     meta.put(put);
+    if (METALOG.isDebugEnabled()) {
+      METALOG.debug(mutationToString(put));
+    }
     if (LOG.isDebugEnabled()) {
       LOG.debug("Added " + regionInfo.getRegionNameAsString());
     }
@@ -1705,6 +1721,9 @@ public class MetaTableAccessor {
     CoprocessorRpcChannel channel = table.coprocessorService(row);
     MultiRowMutationProtos.MutateRowsRequest.Builder mmrBuilder
       = MultiRowMutationProtos.MutateRowsRequest.newBuilder();
+    if (METALOG.isDebugEnabled()) {
+      METALOG.debug(mutationsToString(mutations));
+    }
     for (Mutation mutation : mutations) {
       if (mutation instanceof Put) {
         mmrBuilder.addMutationRequest(ProtobufUtil.toMutation(
@@ -1900,4 +1919,28 @@ public class MetaTableAccessor {
     p.addImmutable(getCatalogFamily(), getSeqNumColumn(replicaId), now, null);
     return p;
   }
+
+  private static String mutationsToString(Mutation ... mutations) throws IOException {
+    StringBuilder sb = new StringBuilder();
+    String prefix = "";
+    for (Mutation mutation : mutations) {
+      sb.append(prefix).append(mutationToString(mutation));
+      prefix = ", ";
+    }
+    return sb.toString();
+  }
+
+  private static String mutationsToString(List<? extends Mutation> mutations) throws
IOException {
+    StringBuilder sb = new StringBuilder();
+    String prefix = "";
+    for (Mutation mutation : mutations) {
+      sb.append(prefix).append(mutationToString(mutation));
+      prefix = ", ";
+    }
+    return sb.toString();
+  }
+
+  private static String mutationToString(Mutation p) throws IOException {
+    return p.getClass().getSimpleName() + p.toJSON();
+  }
 }


Mime
View raw message