/** * Dumps stack trace of the thread to the given log at warning level. * * @param t Thread to be dumped. * @param log Logger. */ public static void dumpThread(Thread t, @Nullable IgniteLogger log) { ThreadMXBean mxBean = ManagementFactory.getThreadMXBean(); GridStringBuilder sb = new GridStringBuilder(); printThreadInfo(mxBean.getThreadInfo(t.getId()), sb, Collections.emptySet()); warn(log, sb.toString()); }
/** * Creates String key used for equality and hashing. */ private String createEqualityKey() { GridStringBuilder sb = new GridStringBuilder("(").a(usr).a(")@"); if (uri.getScheme() != null) sb.a(uri.getScheme().toLowerCase()); sb.a("://"); if (uri.getAuthority() != null) sb.a(uri.getAuthority().toLowerCase()); return sb.toString(); }
/** * Performs thread dump and prints all available info to the given log. * * @param log Logger. */ public static void dumpThreads(@Nullable IgniteLogger log) { ThreadMXBean mxBean = ManagementFactory.getThreadMXBean(); final Set<Long> deadlockedThreadsIds = getDeadlockedThreadIds(mxBean); if (deadlockedThreadsIds.isEmpty()) warn(log, "No deadlocked threads detected."); else warn(log, "Deadlocked threads detected (see thread dump below) " + "[deadlockedThreadsCnt=" + deadlockedThreadsIds.size() + ']'); ThreadInfo[] threadInfos = mxBean.dumpAllThreads(mxBean.isObjectMonitorUsageSupported(), mxBean.isSynchronizerUsageSupported()); GridStringBuilder sb = new GridStringBuilder("Thread dump at ") .a(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss z").format(new Date(U.currentTimeMillis()))).a(NL); for (ThreadInfo info : threadInfos) { printThreadInfo(info, sb, deadlockedThreadsIds); sb.a(NL); if (info.getLockedSynchronizers() != null && info.getLockedSynchronizers().length > 0) { printSynchronizersInfo(info.getLockedSynchronizers(), sb); sb.a(NL); } } sb.a(NL); warn(log, sb.toString()); }
/** * @param ids Ids. */ private String composeNodeInfo(final Set<UUID> ids) { final GridStringBuilder sb = new GridStringBuilder(); sb.a("["); String delim = ""; for (UUID id : ids) { sb .a(delim) .a(composeNodeInfo(id)); delim = ", "; } sb.a("]"); return sb.toString(); }
/** * @param addr Address. */ public static String printPage(long addr, int pageSize) throws IgniteCheckedException { PageIO io = getPageIO(addr); GridStringBuilder sb = new GridStringBuilder("Header [\n\ttype="); sb.a(getType(addr)).a(" (").a(io.getClass().getSimpleName()) .a("),\n\tver=").a(getVersion(addr)).a(",\n\tcrc=").a(getCrc(addr)) .a(",\n\t").a(PageIdUtils.toDetailString(getPageId(addr))) .a("\n],\n"); io.printPage(addr, pageSize, sb); return sb.toString(); } }
/** * Checks starvation in striped pool. Maybe too verbose * but this is needed to faster debug possible issues. * * @return Flag representing presence of possible starvation in striped pool. */ public boolean detectStarvation() { boolean starvationDetected = false; for (Stripe stripe : stripes) { boolean active = stripe.active; long lastStartedTs = stripe.lastStartedTs; if (active && lastStartedTs + threshold < U.currentTimeMillis()) { starvationDetected = true; boolean deadlockPresent = U.deadlockPresent(); GridStringBuilder sb = new GridStringBuilder(); sb.a(">>> Possible starvation in striped pool.").a(U.nl()) .a(" Thread name: ").a(stripe.thread.getName()).a(U.nl()) .a(" Queue: ").a(stripe.queueToString()).a(U.nl()) .a(" Deadlock: ").a(deadlockPresent).a(U.nl()) .a(" Completed: ").a(stripe.completedCnt).a(U.nl()); U.printStackTrace( stripe.thread.getId(), sb); String msg = sb.toString(); U.warn(log, msg); } } return starvationDetected; }
GridStringBuilder b = new GridStringBuilder("CREATE TABLE \"NameTest\" (id int primary key, x varchar) WITH " + "wrap_key,wrap_value");
/** * Dumps stack trace of the thread to the given log at warning level. * * @param t Thread to be dumped. * @param log Logger. */ public static void dumpThread(Thread t, @Nullable IgniteLogger log) { ThreadMXBean mxBean = ManagementFactory.getThreadMXBean(); GridStringBuilder sb = new GridStringBuilder(); printThreadInfo(mxBean.getThreadInfo(t.getId()), sb, Collections.emptySet()); warn(log, sb.toString()); }
/** * Performs thread dump and prints all available info to the given log. * * @param log Logger. */ public static void dumpThreads(@Nullable IgniteLogger log) { ThreadMXBean mxBean = ManagementFactory.getThreadMXBean(); final Set<Long> deadlockedThreadsIds = getDeadlockedThreadIds(mxBean); if (deadlockedThreadsIds.isEmpty()) warn(log, "No deadlocked threads detected."); else warn(log, "Deadlocked threads detected (see thread dump below) " + "[deadlockedThreadsCnt=" + deadlockedThreadsIds.size() + ']'); ThreadInfo[] threadInfos = mxBean.dumpAllThreads(mxBean.isObjectMonitorUsageSupported(), mxBean.isSynchronizerUsageSupported()); GridStringBuilder sb = new GridStringBuilder("Thread dump at ") .a(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss z").format(new Date(U.currentTimeMillis()))).a(NL); for (ThreadInfo info : threadInfos) { printThreadInfo(info, sb, deadlockedThreadsIds); sb.a(NL); if (info.getLockedSynchronizers() != null && info.getLockedSynchronizers().length > 0) { printSynchronizersInfo(info.getLockedSynchronizers(), sb); sb.a(NL); } } sb.a(NL); warn(log, sb.toString()); }
/** * @param ids Ids. */ private String composeNodeInfo(final Set<UUID> ids) { final GridStringBuilder sb = new GridStringBuilder(); sb.a("["); String delim = ""; for (UUID id : ids) { sb .a(delim) .a(composeNodeInfo(id)); delim = ", "; } sb.a("]"); return sb.toString(); }
/** * @param addr Address. */ public static String printPage(long addr, int pageSize) throws IgniteCheckedException { PageIO io = getPageIO(addr); GridStringBuilder sb = new GridStringBuilder("Header [\n\ttype="); sb.a(getType(addr)).a(" (").a(io.getClass().getSimpleName()) .a("),\n\tver=").a(getVersion(addr)).a(",\n\tcrc=").a(getCrc(addr)) .a(",\n\t").a(PageIdUtils.toDetailString(getPageId(addr))) .a("\n],\n"); io.printPage(addr, pageSize, sb); return sb.toString(); } }
/** * Checks starvation in striped pool. Maybe too verbose * but this is needed to faster debug possible issues. */ public void checkStarvation() { for (int i = 0; i < stripes.length; i++) { Stripe stripe = stripes[i]; long completedCnt = stripe.completedCnt; boolean active = stripe.active; if (completedCntrs[i] != -1 && completedCntrs[i] == completedCnt && active) { boolean deadlockPresent = U.deadlockPresent(); GridStringBuilder sb = new GridStringBuilder(); sb.a(">>> Possible starvation in striped pool.").a(U.nl()) .a(" Thread name: ").a(stripe.thread.getName()).a(U.nl()) .a(" Queue: ").a(stripe.queueToString()).a(U.nl()) .a(" Deadlock: ").a(deadlockPresent).a(U.nl()) .a(" Completed: ").a(completedCnt).a(U.nl()); U.printStackTrace( stripe.thread.getId(), sb); String msg = sb.toString(); U.warn(log, msg); } if (active || completedCnt > 0) completedCntrs[i] = completedCnt; } }