use of org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALHeader in project hbase by apache.
the class WALProcedureStore method rollWriter.
private boolean rollWriter(final long logId) throws IOException {
assert logId > flushLogId : "logId=" + logId + " flushLogId=" + flushLogId;
assert lock.isHeldByCurrentThread() : "expected to be the lock owner. " + lock.isLocked();
ProcedureWALHeader header = ProcedureWALHeader.newBuilder().setVersion(ProcedureWALFormat.HEADER_VERSION).setType(ProcedureWALFormat.LOG_TYPE_STREAM).setMinProcId(storeTracker.getActiveMinProcId()).setLogId(logId).build();
FSDataOutputStream newStream = null;
Path newLogFile = null;
long startPos = -1;
newLogFile = getLogFilePath(logId);
try {
newStream = fs.create(newLogFile, false);
} catch (FileAlreadyExistsException e) {
LOG.error("Log file with id=" + logId + " already exists", e);
return false;
} catch (RemoteException re) {
LOG.warn("failed to create log file with id=" + logId, re);
return false;
}
try {
ProcedureWALFormat.writeHeader(newStream, header);
startPos = newStream.getPos();
} catch (IOException ioe) {
LOG.warn("Encountered exception writing header", ioe);
newStream.close();
return false;
}
closeCurrentLogStream();
storeTracker.resetUpdates();
stream = newStream;
flushLogId = logId;
totalSynced.set(0);
long rollTs = System.currentTimeMillis();
lastRollTs.set(rollTs);
logs.add(new ProcedureWALFile(fs, newLogFile, header, startPos, rollTs));
// if it's the first next WAL being added, build the holding cleanup tracker
if (logs.size() == 2) {
buildHoldingCleanupTracker();
} else if (logs.size() > walCountWarnThreshold) {
LOG.warn("procedure WALs count=" + logs.size() + " above the warning threshold " + walCountWarnThreshold + ". check running procedures to see if something is stuck.");
}
if (LOG.isDebugEnabled()) {
LOG.debug("Roll new state log: " + logId);
}
return true;
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALHeader in project hbase by apache.
the class ProcedureWALPrettyPrinter method processProcedureWALFile.
public void processProcedureWALFile(ProcedureWALFile log) throws IOException {
log.open();
ProcedureWALHeader header = log.getHeader();
printHeader(header);
FSDataInputStream stream = log.getStream();
try {
boolean hasMore = true;
while (hasMore) {
ProcedureWALEntry entry = ProcedureWALFormat.readEntry(stream);
if (entry == null) {
out.println("No more entry, exiting with missing EOF");
hasMore = false;
break;
}
switch(entry.getType()) {
case PROCEDURE_WAL_EOF:
hasMore = false;
break;
default:
printEntry(entry);
}
}
} catch (IOException e) {
out.println("got an exception while reading the procedure WAL " + e.getMessage());
} finally {
log.close();
}
}
Aggregations