Search in sources :

Example 1 with ProcedureWALTrailer

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALTrailer in project hbase by apache.

the class ProcedureWALFile method readTracker.

public void readTracker() throws IOException {
    ProcedureWALTrailer trailer = readTrailer();
    try {
        stream.seek(trailer.getTrackerPos());
        final ProcedureProtos.ProcedureStoreTracker trackerProtoBuf = ProcedureProtos.ProcedureStoreTracker.parseDelimitedFrom(stream);
        tracker.resetToProto(trackerProtoBuf);
    } finally {
        stream.seek(startPos);
    }
}
Also used : ProcedureWALTrailer(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALTrailer) ProcedureProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos)

Example 2 with ProcedureWALTrailer

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALTrailer in project hbase by apache.

the class ProcedureWALFormat method readTrailer.

public static ProcedureWALTrailer readTrailer(FSDataInputStream stream, long startPos, long size) throws IOException {
    // Beginning of the Trailer Jump. 17 = 1 byte version + 8 byte magic + 8 byte offset
    long trailerPos = size - 17;
    if (trailerPos < startPos) {
        throw new InvalidWALDataException("Missing trailer: size=" + size + " startPos=" + startPos);
    }
    stream.seek(trailerPos);
    int version = stream.read();
    if (version != TRAILER_VERSION) {
        throw new InvalidWALDataException("Invalid Trailer version. got " + version + " expected " + TRAILER_VERSION);
    }
    long magic = StreamUtils.readLong(stream);
    if (magic != TRAILER_MAGIC) {
        throw new InvalidWALDataException("Invalid Trailer magic. got " + magic + " expected " + TRAILER_MAGIC);
    }
    long trailerOffset = StreamUtils.readLong(stream);
    stream.seek(trailerOffset);
    ProcedureWALEntry entry = readEntry(stream);
    if (entry.getType() != ProcedureWALEntry.Type.PROCEDURE_WAL_EOF) {
        throw new InvalidWALDataException("Invalid Trailer begin");
    }
    ProcedureWALTrailer trailer = ProcedureWALTrailer.newBuilder().setVersion(version).setTrackerPos(stream.getPos()).build();
    return trailer;
}
Also used : ProcedureWALTrailer(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALTrailer) ProcedureWALEntry(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALEntry)

Aggregations

ProcedureWALTrailer (org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALTrailer)2 ProcedureProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos)1 ProcedureWALEntry (org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALEntry)1