Search in sources :

Example 1 with ProcedureWALHeader

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;
}
Also used : Path(org.apache.hadoop.fs.Path) FileAlreadyExistsException(org.apache.hadoop.fs.FileAlreadyExistsException) ProcedureWALHeader(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALHeader) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) IOException(java.io.IOException) RemoteException(org.apache.hadoop.ipc.RemoteException)

Example 2 with ProcedureWALHeader

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();
    }
}
Also used : FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) ProcedureWALHeader(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALHeader) IOException(java.io.IOException) ProcedureWALEntry(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALEntry)

Aggregations

IOException (java.io.IOException)2 ProcedureWALHeader (org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALHeader)2 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)1 Path (org.apache.hadoop.fs.Path)1 ProcedureWALEntry (org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALEntry)1 RemoteException (org.apache.hadoop.ipc.RemoteException)1