From d6ebad6eca406a4e3da640c1e7572740a37e97eb Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Fri, 2 Oct 2020 12:46:07 +0300 Subject: [PATCH] Add more debug for AsyncBarrierImpl gitlab #5 Change-Id: I18300d27f6da7782335392a12f099eff1616001e --- .../db/impl/graph/AsyncBarrierImpl.java | 16 ++++++++-------- .../simantics/db/impl/graph/ReadGraphImpl.java | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/AsyncBarrierImpl.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/AsyncBarrierImpl.java index 048d70b9f..e37b9e800 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/AsyncBarrierImpl.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/AsyncBarrierImpl.java @@ -27,7 +27,7 @@ public class AsyncBarrierImpl extends AtomicInteger implements AsyncBarrier { static final int WAIT_TIME = 60000; - public static final boolean PRINT = false; + public static final boolean PRINT = BarrierTracing.BOOKKEEPING && true; final AsyncBarrierImpl caller; @@ -72,9 +72,9 @@ public class AsyncBarrierImpl extends AtomicInteger implements AsyncBarrier { void inc(Object id, String info) { if(PRINT) { - System.err.println("inc barrier[" + get() + "] " + this); + LOGGER.warn("inc barrier[" + get() + "] " + this); StackTraceElement[] elems = new Exception().getStackTrace(); - for(int i=0;i<4;i++) System.err.println(elems[i]); + for(int i=0;i<4;i++) LOGGER.warn("{}", elems[i]); } if (incrementAndGet() == 1) { @@ -93,9 +93,9 @@ public class AsyncBarrierImpl extends AtomicInteger implements AsyncBarrier { public void dec() { if(PRINT) { - System.err.println("dec barrier[" + get() + "] " + this); + LOGGER.warn("dec barrier[" + get() + "] " + this); StackTraceElement[] elems = new Exception().getStackTrace(); - for(int i=0;i<3;i++) System.err.println(elems[i]); + for(int i=0;i<3;i++) LOGGER.warn("{}", elems[i]); } int count = decrementAndGet(); @@ -125,7 +125,7 @@ public class AsyncBarrierImpl extends AtomicInteger implements AsyncBarrier { public static String report(AsyncBarrierImpl barrier) { CacheEntry e = BarrierTracing.entryMap.get(barrier); if(e != null) return e.toString(); - else return "Barrier@" + System.identityHashCode(barrier); + else return "[" + barrier.get() + " requests]: Barrier@" + System.identityHashCode(barrier); } public static void printReverse(AsyncBarrierImpl barrier, int indent) { @@ -134,7 +134,7 @@ public class AsyncBarrierImpl extends AtomicInteger implements AsyncBarrier { return; for (int i = 0; i < indent; i++) System.err.print(" "); - System.err.println("[" + barrier.get() + " requests]: " + report(barrier)); + System.err.println(report(barrier)); Collection children = BarrierTracing.reverseLookup.get(barrier); if (children != null) { @@ -169,7 +169,7 @@ public class AsyncBarrierImpl extends AtomicInteger implements AsyncBarrier { LOGGER.warn("AsyncBarrierImpl.waitBarrier(" + request + ") is taking long to execute, so far " - + (waitCount / 1000) + " s."); + + (waitCount / 1000) + " s. this.get() = " + get()); if (BarrierTracing.BOOKKEEPING) { synchronized (BarrierTracing.reverseLookup) { diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java index cc15c1eac..776b448bf 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java @@ -5752,7 +5752,7 @@ public class ReadGraphImpl implements AsyncReadGraph { @Override public String toString() { - return "ReadGraphImpl[thread=" + Thread.currentThread() + "]"; + return "ReadGraphImpl[thread=" + Thread.currentThread() + "] [parent=" + String.valueOf(parent) + "] [asyncBarrier=" + String.valueOf(asyncBarrier)+ "]"; } @Override -- 2.47.1