Search in sources :

Example 1 with PageMetaInfoStore

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

the class ToStringDumpProcessor method processDump.

/**
 * @param snapshot Process lock stack snapshot.
 */
private void processDump(PageLockStackSnapshot snapshot, ThreadPageLockState threadState) {
    int headIdx = snapshot.headIdx;
    PageMetaInfoStore pageIdLocksStack = snapshot.pageIdLocksStack;
    long nextOpPageId = snapshot.nextOpPageId;
    Map<Long, LockState> holdedLocks = new LinkedHashMap<>();
    SB stackStr = new SB();
    if (nextOpPageId != 0)
        stackStr.a("\t-> " + operationToString(snapshot.nextOp) + " structureId=" + structureIdMapFunc.apply(snapshot.nextOpStructureId) + " " + pageIdToString(nextOpPageId) + U.nl());
    for (int itemIdx = headIdx - 1; itemIdx >= 0; itemIdx--) {
        long pageId = pageIdLocksStack.getPageId(itemIdx);
        if (pageId == 0 && itemIdx == 0)
            break;
        int op;
        if (pageId == 0) {
            stackStr.a("\t -\n");
            continue;
        } else {
            op = pageIdLocksStack.getOperation(itemIdx) & LOCK_OP_MASK;
            int structureId = pageIdLocksStack.getStructureId(itemIdx);
            stackStr.a("\t" + operationToString(op) + " structureId=" + structureIdMapFunc.apply(structureId) + " " + pageIdToString(pageId) + U.nl());
        }
        if (op == READ_LOCK || op == WRITE_LOCK || op == BEFORE_READ_LOCK) {
            LockState state = holdedLocks.get(pageId);
            if (state == null)
                holdedLocks.put(pageId, state = new LockState());
            if (op == READ_LOCK)
                state.readlock++;
            if (op == WRITE_LOCK)
                state.writelock++;
        }
    }
    if (threadState != null) {
        if (holdedLocks.isEmpty())
            return;
        appendThreadInfo(sb, threadState);
    }
    sb.append(lockedPagesInfo(holdedLocks)).append(U.nl());
    sb.append("Locked pages stack: ").append(snapshot.name).append(" time=(").append(snapshot.time).append(", ").append(DATE_FMT.format(Instant.ofEpochMilli(snapshot.time))).append(")").append(U.nl());
    sb.append(stackStr).append(U.nl());
}
Also used : PageMetaInfoStore(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageMetaInfoStore) IgniteUtils.hexLong(org.apache.ignite.internal.util.IgniteUtils.hexLong) ThreadPageLockState(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.ThreadPageLockState) LinkedHashMap(java.util.LinkedHashMap) SB(org.apache.ignite.internal.util.typedef.internal.SB)

Aggregations

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