Search in sources :

Example 1 with LogEntry

use of org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.log.LogEntry in project ignite by apache.

the class ToStringDumpProcessor method processDump.

/**
 * @param snapshot Process lock log snapshot.
 */
private void processDump(PageLockLogSnapshot snapshot, ThreadPageLockState threadState) {
    Map<Long, LockState> holdetLocks = new LinkedHashMap<>();
    SB logLocksStr = new SB();
    List<LogEntry> locklog = snapshot.locklog;
    int nextOp = snapshot.nextOp;
    long nextOpPageId = snapshot.nextOpPageId;
    int nextOpStructureId = snapshot.nextOpStructureId;
    for (LogEntry entry : locklog) {
        int op = entry.operation;
        long pageId = entry.pageId;
        int locksHolded = entry.holdedLocks;
        if (op == READ_LOCK || op == WRITE_LOCK || op == BEFORE_READ_LOCK || op == BEFORE_WRITE_LOCK) {
            LockState state = holdetLocks.get(pageId);
            if (state == null)
                holdetLocks.put(pageId, state = new LockState());
            if (op == READ_LOCK)
                state.readlock++;
            if (op == WRITE_LOCK)
                state.writelock++;
            logLocksStr.a("L=" + locksHolded + " -> " + buildPageInfo(entry) + U.nl());
        }
        if (op == READ_UNLOCK || op == WRITE_UNLOCK) {
            LockState state = holdetLocks.get(pageId);
            if (op == READ_UNLOCK)
                state.readlock--;
            if (op == WRITE_UNLOCK)
                state.writelock--;
            if (state.readlock == 0 && state.writelock == 0)
                holdetLocks.remove(pageId);
            logLocksStr.a("L=" + locksHolded + " <- " + buildPageInfo(entry) + U.nl());
        }
    }
    if (nextOpPageId != 0) {
        logLocksStr.a("-> " + operationToString(nextOp) + " nextOpPageId=" + nextOpPageId + ", nextOpStructureId=" + structureIdMapFunc.apply(nextOpStructureId) + " [pageIdHex=" + hexLong(nextOpPageId) + ", partId=" + partId(nextOpPageId) + ", pageIdx=" + pageIndex(nextOpPageId) + ", flags=" + hexInt(flag(nextOpPageId)) + "]" + U.nl());
    }
    if (threadState != null) {
        if (holdetLocks.isEmpty() && logLocksStr.length() == 0)
            return;
        appendThreadInfo(sb, threadState);
    }
    sb.append(lockedPagesInfo(holdetLocks)).append(U.nl());
    sb.append("Locked pages log: ").append(snapshot.name).append(" time=(").append(snapshot.time).append(", ").append(DATE_FMT.format(Instant.ofEpochMilli(snapshot.time))).append(")").append(U.nl());
    sb.append(logLocksStr).append(U.nl());
}
Also used : IgniteUtils.hexLong(org.apache.ignite.internal.util.IgniteUtils.hexLong) ThreadPageLockState(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.ThreadPageLockState) LogEntry(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.log.LogEntry) LinkedHashMap(java.util.LinkedHashMap) SB(org.apache.ignite.internal.util.typedef.internal.SB)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 ThreadPageLockState (org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.ThreadPageLockState)1 LogEntry (org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.log.LogEntry)1 IgniteUtils.hexLong (org.apache.ignite.internal.util.IgniteUtils.hexLong)1 SB (org.apache.ignite.internal.util.typedef.internal.SB)1