Search in sources :

Example 1 with IgniteDiagnosticAware

use of org.apache.ignite.internal.IgniteDiagnosticAware in project ignite by apache.

the class GridCachePartitionExchangeManager method dumpLongRunningOperations0.

/**
 * @param timeout Operation timeout.
 * @return {@code True} if found long running operations.
 */
private boolean dumpLongRunningOperations0(long timeout) {
    long curTime = U.currentTimeMillis();
    boolean found = false;
    IgniteTxManager tm = cctx.tm();
    GridCacheMvccManager mvcc = cctx.mvcc();
    final IgniteDiagnosticPrepareContext diagCtx = cctx.kernalContext().cluster().diagnosticEnabled() ? new IgniteDiagnosticPrepareContext(cctx.localNodeId()) : null;
    if (tm != null) {
        for (IgniteInternalTx tx : tm.activeTransactions()) {
            if (curTime - tx.startTime() > timeout) {
                found = true;
                U.warn(diagnosticLog, "Found long running transaction [startTime=" + formatTime(tx.startTime()) + ", curTime=" + formatTime(curTime) + ", tx=" + tx + ']');
            }
        }
    }
    if (mvcc != null) {
        for (GridCacheFuture<?> fut : mvcc.activeFutures()) {
            if (curTime - fut.startTime() > timeout) {
                found = true;
                U.warn(diagnosticLog, "Found long running cache future [startTime=" + formatTime(fut.startTime()) + ", curTime=" + formatTime(curTime) + ", fut=" + fut + ']');
                if (diagCtx != null && fut instanceof IgniteDiagnosticAware)
                    ((IgniteDiagnosticAware) fut).addDiagnosticRequest(diagCtx);
            }
        }
        for (GridCacheFuture<?> fut : mvcc.atomicFutures()) {
            if (curTime - fut.startTime() > timeout) {
                found = true;
                U.warn(diagnosticLog, "Found long running cache future [startTime=" + formatTime(fut.startTime()) + ", curTime=" + formatTime(curTime) + ", fut=" + fut + ']');
                if (diagCtx != null && fut instanceof IgniteDiagnosticAware)
                    ((IgniteDiagnosticAware) fut).addDiagnosticRequest(diagCtx);
            }
        }
    }
    if (diagCtx != null && !diagCtx.empty()) {
        try {
            cctx.kernalContext().closure().runLocal(new Runnable() {

                @Override
                public void run() {
                    diagCtx.send(cctx.kernalContext(), null);
                }
            }, SYSTEM_POOL);
        } catch (IgniteCheckedException e) {
            U.error(diagnosticLog, "Failed to submit diagnostic closure: " + e, e);
        }
    }
    return found;
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteDiagnosticPrepareContext(org.apache.ignite.internal.IgniteDiagnosticPrepareContext) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) IgniteDiagnosticAware(org.apache.ignite.internal.IgniteDiagnosticAware) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteDiagnosticAware (org.apache.ignite.internal.IgniteDiagnosticAware)1 IgniteDiagnosticPrepareContext (org.apache.ignite.internal.IgniteDiagnosticPrepareContext)1 IgniteInternalTx (org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx)1 IgniteTxManager (org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager)1