/** * 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; }
/** * 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; } }