use of org.apache.ignite.internal.IgniteDiagnosticPrepareContext 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) {
WarningsGroup warnings = new WarningsGroup("First %d long running transactions [total=%d]", diagnosticLog, DIAGNOSTIC_WARN_LIMIT);
synchronized (ltrDumpLimiter) {
for (IgniteInternalTx tx : tm.activeTransactions()) {
if (curTime - tx.startTime() > timeout) {
found = true;
if (warnings.canAddMessage()) {
warnings.add(longRunningTransactionWarning(tx, curTime));
if (cctx.tm().txOwnerDumpRequestsAllowed() && !Optional.ofNullable(cctx.kernalContext().config().isClientMode()).orElse(false) && tx.local() && tx.state() == TransactionState.ACTIVE && ltrDumpLimiter.allowAction(tx))
dumpLongRunningTransaction(tx);
} else
warnings.incTotal();
}
}
ltrDumpLimiter.trim();
}
warnings.printToLog();
}
if (mvcc != null) {
WarningsGroup activeWarnings = new WarningsGroup("First %d long running cache futures [total=%d]", diagnosticLog, DIAGNOSTIC_WARN_LIMIT);
for (GridCacheFuture<?> fut : mvcc.activeFutures()) {
if (curTime - fut.startTime() > timeout) {
found = true;
if (activeWarnings.canAddMessage()) {
activeWarnings.add(">>> Future [startTime=" + formatTime(fut.startTime()) + ", curTime=" + formatTime(curTime) + ", fut=" + fut + ']');
} else
activeWarnings.incTotal();
if (diagCtx != null && fut instanceof IgniteDiagnosticAware)
((IgniteDiagnosticAware) fut).addDiagnosticRequest(diagCtx);
}
}
activeWarnings.printToLog();
WarningsGroup atomicWarnings = new WarningsGroup("First %d long running cache futures [total=%d]", diagnosticLog, DIAGNOSTIC_WARN_LIMIT);
for (GridCacheFuture<?> fut : mvcc.atomicFutures()) {
if (curTime - fut.startTime() > timeout) {
found = true;
if (atomicWarnings.canAddMessage()) {
atomicWarnings.add(">>> Future [startTime=" + formatTime(fut.startTime()) + ", curTime=" + formatTime(curTime) + ", fut=" + fut + ']');
} else
atomicWarnings.incTotal();
if (diagCtx != null && fut instanceof IgniteDiagnosticAware)
((IgniteDiagnosticAware) fut).addDiagnosticRequest(diagCtx);
}
}
atomicWarnings.printToLog();
}
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;
}
use of org.apache.ignite.internal.IgniteDiagnosticPrepareContext in project ignite by apache.
the class GridCachePartitionExchangeManager method dumpDebugInfo.
/**
* @param exchFut Optional current exchange future.
* @throws Exception If failed.
*/
public void dumpDebugInfo(@Nullable GridDhtPartitionsExchangeFuture exchFut) throws Exception {
AffinityTopologyVersion exchTopVer = exchFut != null ? exchFut.initialVersion() : null;
U.warn(diagnosticLog, "Ready affinity version: " + exchFuts.readyTopVer());
U.warn(diagnosticLog, "Last exchange future: " + lastInitializedFut);
exchWorker.dumpExchangeDebugInfo();
if (!readyFuts.isEmpty()) {
int warningsLimit = IgniteSystemProperties.getInteger(IGNITE_DIAGNOSTIC_WARN_LIMIT, 5);
U.warn(diagnosticLog, "First " + warningsLimit + " pending affinity ready futures [total=" + readyFuts.size() + ']');
if (warningsLimit > 0) {
int cnt = 0;
for (AffinityReadyFuture fut : readyFuts.values()) {
U.warn(diagnosticLog, ">>> " + fut);
if (++cnt == warningsLimit)
break;
}
}
}
IgniteDiagnosticPrepareContext diagCtx = cctx.kernalContext().cluster().diagnosticEnabled() ? new IgniteDiagnosticPrepareContext(cctx.localNodeId()) : null;
if (diagCtx != null && exchFut != null)
exchFut.addDiagnosticRequest(diagCtx);
ExchangeFutureSet exchFuts = this.exchFuts;
if (exchFuts != null) {
U.warn(diagnosticLog, "Last " + DIAGNOSTIC_WARN_LIMIT + " exchange futures (total: " + exchFuts.size() + "):");
if (DIAGNOSTIC_WARN_LIMIT > 0) {
int cnt = 0;
for (GridDhtPartitionsExchangeFuture fut : exchFuts.values()) {
U.warn(diagnosticLog, ">>> " + fut.shortInfo());
if (++cnt == DIAGNOSTIC_WARN_LIMIT)
break;
}
}
}
U.warn(diagnosticLog, "Latch manager state: " + latchMgr);
dumpPendingObjects(exchTopVer, diagCtx);
for (CacheGroupContext grp : cctx.cache().cacheGroups()) {
GridCachePreloader preloader = grp.preloader();
if (preloader != null)
preloader.dumpDebugInfo();
}
cctx.affinity().dumpDebugInfo();
StringBuilder pendingMsgs = new StringBuilder();
cctx.io().dumpPendingMessages(pendingMsgs);
if (pendingMsgs.length() > 0 && diagnosticLog.isInfoEnabled())
diagnosticLog.info(pendingMsgs.toString());
if (IgniteSystemProperties.getBoolean(IGNITE_IO_DUMP_ON_TIMEOUT, false))
cctx.gridIO().dumpStats();
if (IgniteSystemProperties.getBoolean(IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT, false))
U.dumpThreads(diagnosticLog);
if (diagCtx != null)
diagCtx.send(cctx.kernalContext(), null);
}
use of org.apache.ignite.internal.IgniteDiagnosticPrepareContext in project ignite by apache.
the class IgniteDiagnosticMessagesTest method sendDiagnostic.
/**
* @throws Exception If failed.
*/
private void sendDiagnostic() throws Exception {
for (int i = 0; i < 5; i++) {
IgniteKernal node = (IgniteKernal) ignite(i);
for (int j = 0; j < 5; j++) {
if (i != j) {
ClusterNode dstNode = ignite(j).cluster().localNode();
final GridFutureAdapter<String> fut = new GridFutureAdapter<>();
IgniteDiagnosticPrepareContext ctx = new IgniteDiagnosticPrepareContext(node.localNodeId());
ctx.basicInfo(dstNode.id(), "Test diagnostic");
ctx.send(node.context(), new IgniteInClosure<IgniteInternalFuture<String>>() {
@Override
public void apply(IgniteInternalFuture<String> diagFut) {
try {
fut.onDone(diagFut.get());
} catch (Exception e) {
fut.onDone(e);
}
}
});
String msg = fut.get();
String searchMsg = "General node info [id=" + dstNode.id() + ", client=" + dstNode.isClient() + ", discoTopVer=AffinityTopologyVersion [topVer=5, minorTopVer=";
assertTrue("Unexpected message: " + msg, msg.contains("Test diagnostic") && msg.contains(searchMsg) && msg.contains("Partitions exchange info [readyVer=AffinityTopologyVersion [topVer=5, minorTopVer="));
}
}
}
}
Aggregations