HBASE-5238 Add a log4j category for all edits to META/ROOT

This commit is contained in:
Andrey Stepachev 2015-03-25 23:03:18 +00:00
parent 134b95579c
commit e26c4e4e67
2 changed files with 45 additions and 1 deletions

View File

@ -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.zookeeper=INFO
#log4j.logger.org.apache.hadoop.fs.FSNamesystem=DEBUG #log4j.logger.org.apache.hadoop.fs.FSNamesystem=DEBUG
log4j.logger.org.apache.hadoop.hbase=INFO 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. # 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.ZKUtil=INFO
log4j.logger.org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher=INFO log4j.logger.org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher=INFO

View File

@ -122,6 +122,7 @@ public class MetaTableAccessor {
*/ */
private static final Log LOG = LogFactory.getLog(MetaTableAccessor.class); 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 final byte [] META_REGION_PREFIX;
static { static {
@ -1354,6 +1355,9 @@ public class MetaTableAccessor {
*/ */
private static void put(final Table t, final Put p) throws IOException { private static void put(final Table t, final Put p) throws IOException {
try { try {
if (METALOG.isDebugEnabled()) {
METALOG.debug(mutationToString(p));
}
t.put(p); t.put(p);
} finally { } finally {
t.close(); t.close();
@ -1370,6 +1374,9 @@ public class MetaTableAccessor {
throws IOException { throws IOException {
Table t = getMetaHTable(connection); Table t = getMetaHTable(connection);
try { try {
if (METALOG.isDebugEnabled()) {
METALOG.debug(mutationsToString(ps));
}
t.put(ps); t.put(ps);
} finally { } finally {
t.close(); t.close();
@ -1399,6 +1406,9 @@ public class MetaTableAccessor {
throws IOException { throws IOException {
Table t = getMetaHTable(connection); Table t = getMetaHTable(connection);
try { try {
if (METALOG.isDebugEnabled()) {
METALOG.debug(mutationsToString(deletes));
}
t.delete(deletes); t.delete(deletes);
} finally { } finally {
t.close(); t.close();
@ -1443,7 +1453,10 @@ public class MetaTableAccessor {
throws IOException { throws IOException {
Table t = getMetaHTable(connection); Table t = getMetaHTable(connection);
try { try {
t.batch(mutations); if (METALOG.isDebugEnabled()) {
METALOG.debug(mutationsToString(mutations));
}
t.batch(mutations, new Object[mutations.size()]);
} catch (InterruptedException e) { } catch (InterruptedException e) {
InterruptedIOException ie = new InterruptedIOException(e.getMessage()); InterruptedIOException ie = new InterruptedIOException(e.getMessage());
ie.initCause(e); ie.initCause(e);
@ -1494,6 +1507,9 @@ public class MetaTableAccessor {
Put put = makePutFromRegionInfo(regionInfo); Put put = makePutFromRegionInfo(regionInfo);
addDaughtersToPut(put, splitA, splitB); addDaughtersToPut(put, splitA, splitB);
meta.put(put); meta.put(put);
if (METALOG.isDebugEnabled()) {
METALOG.debug(mutationToString(put));
}
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Added " + regionInfo.getRegionNameAsString()); LOG.debug("Added " + regionInfo.getRegionNameAsString());
} }
@ -1705,6 +1721,9 @@ public class MetaTableAccessor {
CoprocessorRpcChannel channel = table.coprocessorService(row); CoprocessorRpcChannel channel = table.coprocessorService(row);
MultiRowMutationProtos.MutateRowsRequest.Builder mmrBuilder MultiRowMutationProtos.MutateRowsRequest.Builder mmrBuilder
= MultiRowMutationProtos.MutateRowsRequest.newBuilder(); = MultiRowMutationProtos.MutateRowsRequest.newBuilder();
if (METALOG.isDebugEnabled()) {
METALOG.debug(mutationsToString(mutations));
}
for (Mutation mutation : mutations) { for (Mutation mutation : mutations) {
if (mutation instanceof Put) { if (mutation instanceof Put) {
mmrBuilder.addMutationRequest(ProtobufUtil.toMutation( mmrBuilder.addMutationRequest(ProtobufUtil.toMutation(
@ -1900,4 +1919,28 @@ public class MetaTableAccessor {
p.addImmutable(getCatalogFamily(), getSeqNumColumn(replicaId), now, null); p.addImmutable(getCatalogFamily(), getSeqNumColumn(replicaId), now, null);
return p; 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();
}
} }