HBASE-2889 Tool to look at HLogs -- parse and tail -f; fix for suppression of EOFEs by Nicolas
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1000697 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0f3c62e19b
commit
a85ee11f3b
|
@ -22,7 +22,10 @@ package org.apache.hadoop.hbase.regionserver.wal;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.Class;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.FSDataInputStream;
|
import org.apache.hadoop.fs.FSDataInputStream;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
|
@ -98,6 +101,7 @@ public class SequenceFileLogReader implements HLog.Reader {
|
||||||
// Needed logging exceptions
|
// Needed logging exceptions
|
||||||
Path path;
|
Path path;
|
||||||
int edit = 0;
|
int edit = 0;
|
||||||
|
long entryStart = 0;
|
||||||
|
|
||||||
public SequenceFileLogReader() { }
|
public SequenceFileLogReader() { }
|
||||||
|
|
||||||
|
@ -125,6 +129,7 @@ public class SequenceFileLogReader implements HLog.Reader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HLog.Entry next(HLog.Entry reuse) throws IOException {
|
public HLog.Entry next(HLog.Entry reuse) throws IOException {
|
||||||
|
this.entryStart = this.reader.getPosition();
|
||||||
HLog.Entry e = reuse;
|
HLog.Entry e = reuse;
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
HLogKey key = HLog.newKey(conf);
|
HLogKey key = HLog.newKey(conf);
|
||||||
|
@ -163,15 +168,28 @@ public class SequenceFileLogReader implements HLog.Reader {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.warn("Failed getting position to add to throw", e);
|
Log.warn("Failed getting position to add to throw", e);
|
||||||
}
|
}
|
||||||
// Preserve EOFE because these are treated differently if it comes up during
|
|
||||||
// a split of logs
|
// See what SequenceFile.Reader thinks is the end of the file
|
||||||
|
long end = Long.MAX_VALUE;
|
||||||
|
try {
|
||||||
|
Field fEnd = SequenceFile.Reader.class.getDeclaredField("end");
|
||||||
|
fEnd.setAccessible(true);
|
||||||
|
end = fEnd.getLong(this.reader);
|
||||||
|
} catch(Exception e) { /* reflection fail. keep going */ }
|
||||||
|
|
||||||
String msg = (this.path == null? "": this.path.toString()) +
|
String msg = (this.path == null? "": this.path.toString()) +
|
||||||
", pos=" + pos + ", edit=" + this.edit;
|
", entryStart=" + entryStart + ", pos=" + pos +
|
||||||
if (ioe instanceof EOFException) {
|
((end == Long.MAX_VALUE) ? "" : ", end=" + end) +
|
||||||
EOFException eof = new EOFException(msg);
|
", edit=" + this.edit;
|
||||||
eof.initCause(ioe);
|
|
||||||
return eof;
|
// Enhance via reflection so we don't change the original class type
|
||||||
}
|
try {
|
||||||
return new IOException(msg, ioe);
|
return (IOException) ioe.getClass()
|
||||||
|
.getConstructor(String.class)
|
||||||
|
.newInstance(msg)
|
||||||
|
.initCause(ioe);
|
||||||
|
} catch(Exception e) { /* reflection fail. keep going */ }
|
||||||
|
|
||||||
|
return ioe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue