HBASE-11864 Enhance HLogPrettyPrinter to print information from WAL Header (Chuhan Yang)
This commit is contained in:
parent
b6756b39c2
commit
a9d7c49a59
|
@ -91,6 +91,9 @@ public class ProtobufLogReader extends ReaderBase {
|
|||
static {
|
||||
writerClsNames.add(ProtobufLogWriter.class.getSimpleName());
|
||||
}
|
||||
|
||||
// cell codec classname
|
||||
private String codecClsName = null;
|
||||
|
||||
enum WALHdrResult {
|
||||
EOF, // stream is at EOF when method starts
|
||||
|
@ -153,9 +156,16 @@ public class ProtobufLogReader extends ReaderBase {
|
|||
/*
|
||||
* Returns names of the accepted writer classes
|
||||
*/
|
||||
protected List<String> getWriterClsNames() {
|
||||
public List<String> getWriterClsNames() {
|
||||
return writerClsNames;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the cell codec classname
|
||||
*/
|
||||
public String getCodecClsName() {
|
||||
return codecClsName;
|
||||
}
|
||||
|
||||
protected WALHdrContext readHeader(Builder builder, FSDataInputStream stream)
|
||||
throws IOException {
|
||||
|
@ -207,6 +217,9 @@ public class ProtobufLogReader extends ReaderBase {
|
|||
LOG.trace("After reading the trailer: walEditsStopOffset: " + this.walEditsStopOffset
|
||||
+ ", fileLength: " + this.fileLength + ", " + "trailerPresent: " + trailerPresent);
|
||||
}
|
||||
|
||||
codecClsName = hdrCtxt.getCellCodecClsName();
|
||||
|
||||
return hdrCtxt.getCellCodecClsName();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SecureProtobufLogReader extends ProtobufLogReader {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getWriterClsNames() {
|
||||
public List<String> getWriterClsNames() {
|
||||
return writerClsNames;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.util.Bytes;
|
|||
import org.apache.hadoop.hbase.util.FSUtils;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
|
||||
import org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader;
|
||||
// imports for things that haven't moved yet.
|
||||
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
|
||||
|
||||
|
@ -242,11 +243,33 @@ public class WALPrettyPrinter {
|
|||
if (!fs.isFile(p)) {
|
||||
throw new IOException(p + " is not a file");
|
||||
}
|
||||
|
||||
WAL.Reader log = WALFactory.createReader(fs, p, conf);
|
||||
|
||||
if (log instanceof ProtobufLogReader) {
|
||||
List<String> writerClsNames = ((ProtobufLogReader) log).getWriterClsNames();
|
||||
if (writerClsNames != null && writerClsNames.size() > 0) {
|
||||
out.print("Writer Classes: ");
|
||||
for (int i = 0; i < writerClsNames.size(); i++) {
|
||||
out.print(writerClsNames.get(i));
|
||||
if (i != writerClsNames.size() - 1) {
|
||||
out.print(" ");
|
||||
}
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
|
||||
String cellCodecClsName = ((ProtobufLogReader) log).getCodecClsName();
|
||||
if (cellCodecClsName != null) {
|
||||
out.println("Cell Codec Class: " + cellCodecClsName);
|
||||
}
|
||||
}
|
||||
|
||||
if (outputJSON && !persistentOutput) {
|
||||
out.print("[");
|
||||
firstTxn = true;
|
||||
}
|
||||
WAL.Reader log = WALFactory.createReader(fs, p, conf);
|
||||
|
||||
try {
|
||||
WAL.Entry entry;
|
||||
while ((entry = log.next()) != null) {
|
||||
|
|
Loading…
Reference in New Issue