From: Antti Villberg Date: Fri, 19 Jul 2019 09:05:48 +0000 (+0300) Subject: Move debugging options under DevelopmentKeys X-Git-Tag: v1.43.0~136^2~133^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=6839744ff43f5adaa2fc38121952dba846690558 Move debugging options under DevelopmentKeys gitlab #319 Change-Id: Iabeb7d88912781768d4ee13dd8ecb531d7a82215 --- diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/DebugPolicy.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/DebugPolicy.java deleted file mode 100644 index 752991c48..000000000 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/DebugPolicy.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.simantics.db.impl; - - -/** - * @author Antti Villberg - */ -public final class DebugPolicy { - - public static final boolean QUERY_STATE = false; - - public static final boolean PERFORM = false; - - public static final boolean DEPENDENCIES = false; - - public static final boolean RECOMPUTE = false; - - public static final boolean CHANGES = false; - - public static final boolean LISTENER = false; - - public static final boolean SCHEDULE = false; - - public static final boolean COLLECT = false; - - public static final boolean VERBOSE = false; - -} diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ResourceImpl.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ResourceImpl.java index 3406d6700..78dacb98f 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ResourceImpl.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ResourceImpl.java @@ -11,6 +11,7 @@ *******************************************************************************/ package org.simantics.db.impl; +import org.simantics.db.DevelopmentKeys; import org.simantics.db.Resource; import org.simantics.db.impl.support.ResourceSupport; import org.simantics.db.service.ClusterUID; @@ -84,7 +85,7 @@ final public class ResourceImpl implements Resource { StringBuilder sb = new StringBuilder(32); try { long rid = getResourceId(); - if(DebugPolicy.VERBOSE) { + if(DevelopmentKeys.VERBOSE) { sb.append("[id="); sb.append(id); sb.append(" - rid="); @@ -111,7 +112,7 @@ final public class ResourceImpl implements Resource { public String toString(ClusterSupport support) { StringBuilder sb = new StringBuilder(32); long rid = getResourceId(); - if (DebugPolicy.VERBOSE) { + if (DevelopmentKeys.VERBOSE) { sb.append("[id="); sb.append(id); sb.append(" - rid="); diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/DelayedWriteGraph.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/DelayedWriteGraph.java index f8797b251..84dd871c0 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/DelayedWriteGraph.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/DelayedWriteGraph.java @@ -36,6 +36,7 @@ import org.simantics.databoard.binding.error.BindingConstructionException; import org.simantics.databoard.serialization.Serializer; import org.simantics.databoard.type.Datatype; import org.simantics.databoard.util.binary.RandomAccessBinary; +import org.simantics.db.DevelopmentKeys; import org.simantics.db.Metadata; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -54,7 +55,6 @@ import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; import org.simantics.db.exception.NoSingleResultException; import org.simantics.db.exception.ResourceNotFoundException; import org.simantics.db.exception.ServiceException; -import org.simantics.db.impl.DebugPolicy; import org.simantics.db.impl.ResourceImpl; import org.simantics.db.request.DelayedWrite; import org.simantics.db.request.WriteOnly; @@ -199,7 +199,7 @@ public class DelayedWriteGraph extends ReadGraphImpl implements WriteGraph, Byte @Override public String toString() { StringBuilder sb = new StringBuilder(32); - if(DebugPolicy.VERBOSE) { + if(DevelopmentKeys.VERBOSE) { sb.append("[delayed id="); sb.append(id); sb.append("]"); 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 79fe97464..cffbba51c 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 @@ -6181,11 +6181,12 @@ public class ReadGraphImpl implements AsyncReadGraph { @Override public T getRelatedValue2(Resource subject, Resource relation, Object context) throws DatabaseException { if(Development.DEVELOPMENT) { - String error = L0Validations.checkValueType(this, subject, relation); - if(error != null) { - Logger.defaultLogError(new ValidationException(error)); - //throw new ValidationException(error); - new ValidationException(error).printStackTrace(); + if(Development.getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) { + String error = L0Validations.checkValueType(this, subject, relation); + if(error != null) { + Logger.defaultLogError(new ValidationException(error)); + throw new ValidationException(error); + } } } return getValue2(getSingleObject(subject, relation), context); @@ -6194,12 +6195,13 @@ public class ReadGraphImpl implements AsyncReadGraph { @Override public Variant getRelatedVariantValue2(Resource subject, Resource relation, Object context) throws DatabaseException { if(Development.DEVELOPMENT) { - String error = L0Validations.checkValueType(this, subject, relation); - if(error != null) { - Logger.defaultLogError(new ValidationException(error)); - //throw new ValidationException(error); - new ValidationException(error).printStackTrace(); - } + if(Development.getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) { + String error = L0Validations.checkValueType(this, subject, relation); + if(error != null) { + Logger.defaultLogError(new ValidationException(error)); + throw new ValidationException(error); + } + } } return getVariantValue2(getSingleObject(subject, relation), context); } diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java index 972bd381f..cd5420656 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java @@ -11,16 +11,18 @@ *******************************************************************************/ package org.simantics.db.impl.query; +import org.simantics.databoard.Bindings; import org.simantics.db.AsyncReadGraph; +import org.simantics.db.DevelopmentKeys; import org.simantics.db.exception.DatabaseException; import org.simantics.db.impl.BlockingAsyncProcedure; -import org.simantics.db.impl.DebugPolicy; import org.simantics.db.impl.graph.AsyncBarrierImpl; import org.simantics.db.impl.graph.BarrierTracing; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.impl.query.QueryProcessor.SessionTask; import org.simantics.db.procedure.AsyncProcedure; import org.simantics.db.request.AsyncRead; +import org.simantics.utils.Development; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,8 +34,11 @@ final public class AsyncReadEntry extends CacheEntryBase> i AsyncReadEntry(AsyncRead request) { this.request = request; - if (DebugPolicy.QUERY_STATE) - System.out.println("[QUERY STATE]: created " + this); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) { + System.err.println("[QUERY STATE]: created " + this); + } + } } @Override diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java index 7fc0432f8..3a94e52b6 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java @@ -14,10 +14,12 @@ package org.simantics.db.impl.query; import java.util.ArrayList; import java.util.Iterator; +import org.simantics.databoard.Bindings; +import org.simantics.db.DevelopmentKeys; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.impl.DebugPolicy; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.impl.procedure.InternalProcedure; +import org.simantics.utils.Development; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,7 +87,11 @@ public abstract class CacheEntryBase extends CacheEntry { @Override public void discard() { - if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: discarded " + this); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) { + System.err.println("[QUERY STATE]: discarded " + this); + } + } statusOrException = DISCARDED; } @@ -96,7 +102,11 @@ public abstract class CacheEntryBase extends CacheEntry { @Override final public void refute() { - if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: refuted " + this); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) { + System.err.println("[QUERY STATE]: refuted " + this); + } + } statusOrException = REQUIRES_COMPUTATION; } @@ -107,7 +117,11 @@ public abstract class CacheEntryBase extends CacheEntry { @Override public void except(Throwable throwable) { - if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: excepted " + this); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) { + System.err.println("[QUERY STATE]: excepted " + this); + } + } if(statusOrException != DISCARDED) { statusOrException = EXCEPTED; result = throwable; diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java index 661076e86..ac07ad7ed 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java @@ -13,13 +13,15 @@ package org.simantics.db.impl.query; import java.util.LinkedList; +import org.simantics.databoard.Bindings; +import org.simantics.db.DevelopmentKeys; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.impl.DebugPolicy; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.procedure.AsyncProcedure; import org.simantics.db.procedure.Listener; import org.simantics.db.request.ExternalRead; import org.simantics.db.request.RequestFlags; +import org.simantics.utils.Development; final public class ExternalReadEntry extends CacheEntryBase> implements Listener { @@ -69,7 +71,12 @@ final public class ExternalReadEntry extends CacheEntryBase @Override public void except(Throwable t) { - if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: excepted " + this); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) { + System.err.println("[QUERY STATE]: excepted " + this); + } + } + if(statusOrException != DISCARDED) { statusOrException = EXCEPTED; result = t; diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java index 6abaf6b65..446e9c641 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java @@ -3,21 +3,19 @@ package org.simantics.db.impl.query; import java.util.ArrayList; import java.util.Collection; import java.util.concurrent.Semaphore; -import java.util.concurrent.atomic.AtomicBoolean; +import org.simantics.databoard.Bindings; import org.simantics.db.AsyncReadGraph; +import org.simantics.db.DevelopmentKeys; import org.simantics.db.ObjectResourceIdMap; import org.simantics.db.ReadGraph; import org.simantics.db.RelationInfo; import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.impl.DebugPolicy; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.impl.procedure.InternalProcedure; -import org.simantics.db.impl.query.QueryProcessor.SessionTask; import org.simantics.db.procedure.AsyncMultiProcedure; import org.simantics.db.procedure.AsyncProcedure; -import org.simantics.db.procedure.Listener; import org.simantics.db.procedure.ListenerBase; import org.simantics.db.procedure.Procedure; import org.simantics.db.procedure.SyncMultiProcedure; @@ -26,6 +24,7 @@ import org.simantics.db.request.AsyncRead; import org.simantics.db.request.ExternalRead; import org.simantics.db.request.MultiRead; import org.simantics.db.request.Read; +import org.simantics.utils.Development; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TObjectIntHashMap; @@ -328,7 +327,11 @@ public class QueryCacheBase { } catch (DatabaseException e) { Logger.defaultLogError(e); } - if(DebugPolicy.DEPENDENCIES) System.out.println(child + " -> " + parent); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_DEPENDENCIES, Bindings.BOOLEAN)) { + System.err.println(child + " -> " + parent); + } + } } if (listener != null) { @@ -376,9 +379,11 @@ public class QueryCacheBase { list.add(result); } - if(DebugPolicy.LISTENER) { - new Exception().printStackTrace(); - System.out.println("addListener -> " + list.size() + " " + entry + " " + base + " " + procedure); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) { + new Exception().printStackTrace(); + System.err.println("addListener -> " + list.size() + " " + entry + " " + base + " " + procedure); + } } return result; diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl2.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl2.java index 84273b81d..0efa49f56 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl2.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl2.java @@ -6,9 +6,10 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import org.simantics.databoard.Bindings; import org.simantics.databoard.util.IdentityHashSet; +import org.simantics.db.DevelopmentKeys; import org.simantics.db.common.exception.DebugException; -import org.simantics.db.impl.DebugPolicy; import org.simantics.db.impl.query.QueryProcessor.QueryCollectorSupport; import org.simantics.utils.Development; @@ -28,21 +29,29 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { private boolean findCollectables(CacheEntry entry, Map collectables, ArrayList result) { if (entry.isDiscarded()) { - if(DebugPolicy.COLLECT && DebugPolicy.VERBOSE) - System.out.println("GC: discarded entry " + entry); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("GC: discarded entry " + entry); + } + } return true; } if (entry.isPending()) { - if(DebugPolicy.COLLECT && DebugPolicy.VERBOSE) - System.out.println("GC: pending entry " + entry + " was not collected."); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("GC: pending entry " + entry + " was not collected."); + } + } collectables.remove(entry); return false; } if (this.queryProcessor.hasListenerAfterDisposing(entry)) { - if (DebugPolicy.COLLECT && DebugPolicy.VERBOSE) { - System.out.println("GC: listened entry " + entry + " was not collected. Entry=" + entry); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("GC: listened entry " + entry + " was not collected. Entry=" + entry); + } } collectables.remove(entry); return false; @@ -60,8 +69,11 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { } if(!parentIsCollectable) { - if(DebugPolicy.COLLECT && DebugPolicy.VERBOSE) - System.out.println("GC: due to bound parent " + parent + " the entry + " + entry + " was not collected."); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("GC: due to bound parent " + parent + " the entry + " + entry + " was not collected."); + } + } collectables.remove(entry); return false; } @@ -109,8 +121,11 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { // Compute amount of free queries int freeCount = collectables.size(); - if(DebugPolicy.COLLECT) - System.out.println("collector found " + freeCount + " free queries."); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("collector found " + freeCount + " free queries."); + } + } lastKnownFixedSize = currentSize - freeCount; @@ -119,8 +134,13 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { int target = freeCount - maxNumberOfCollectableQueries/2; - if(DebugPolicy.COLLECT) - System.out.println("collector removes " + target + " free queries."); + + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("collector found " + freeCount + " free queries."); + System.err.println("collector removes " + target + " free queries."); + } + } for(CacheEntry entry : collectables) { if(queryProcessor.removeQuery(entry)) @@ -139,8 +159,11 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { removals.clear(); } - if(DebugPolicy.COLLECT) { - System.out.println("collect found " + freeCount + " collectable entries."); + + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("collect found " + freeCount + " collectable entries."); + } } return; @@ -152,24 +175,34 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector { try { - int current = support.calculateCurrentSize(); - if(DebugPolicy.COLLECT) - new DebugException("checking the need for collecting queries (current=" + current + " , lastKnownFixedSize=" + lastKnownFixedSize + " max free=" + 0 + ")").printStackTrace(); + int current = support.calculateCurrentSize(); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + new DebugException("checking the need for collecting queries (current=" + current + " , lastKnownFixedSize=" + lastKnownFixedSize + " max free=" + 0 + ")").printStackTrace(); + } + } + queryProcessor.cache.collecting = true; long start = System.nanoTime(); doCollect(current, 0); - if(DebugPolicy.COLLECT) - System.out.println("collect finished with " + support.calculateCurrentSize() + " entries (lastKnownFixedSize=" + lastKnownFixedSize + ")."); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("collect finished with " + support.calculateCurrentSize() + " entries (lastKnownFixedSize=" + lastKnownFixedSize + ")."); + } + } long duration = System.nanoTime() - start; - if(DebugPolicy.COLLECT) - System.err.println("Collect took " + 1e-9*duration + "s."); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) { + System.err.println("Collect took " + 1e-9*duration + "s."); + } + } } catch (Throwable t) { t.printStackTrace(); diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java index 5a37257e2..774390720 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java @@ -49,7 +49,6 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; import org.simantics.db.exception.NoInverseException; import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.impl.DebugPolicy; import org.simantics.db.impl.ResourceImpl; import org.simantics.db.impl.graph.BarrierTracing; import org.simantics.db.impl.graph.ReadGraphImpl; @@ -713,7 +712,11 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap } catch (DatabaseException e) { Logger.defaultLogError(e); } - if(DebugPolicy.DEPENDENCIES) System.out.println(child + " -> " + parent); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_DEPENDENCIES, Bindings.BOOLEAN)) { + System.out.println(child + " -> " + parent); + } + } } if (listener != null) { @@ -963,9 +966,11 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap list.add(result); } - if(DebugPolicy.LISTENER) { - new Exception().printStackTrace(); - System.out.println("addListener -> " + list.size() + " " + entry + " " + base + " " + procedure); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) { + new Exception().printStackTrace(); + System.err.println("addListener -> " + list.size() + " " + entry + " " + base + " " + procedure); + } } return result; @@ -974,7 +979,11 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap private void scheduleListener(ListenerEntry entry) { assert (entry != null); - if(DebugPolicy.LISTENER) System.out.println("Scheduled " + entry.procedure); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) { + System.err.println("Scheduled " + entry.procedure); + } + } scheduledListeners.add(entry); } @@ -1426,8 +1435,6 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap CacheEntry entry = e.entry; - //System.err.println("updateQuery " + entry); - /* * If the dependency graph forms a DAG, some entries are inserted in the * todo list many times. They only need to be processed once though. @@ -1435,10 +1442,10 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap if (entry.isDiscarded()) { if (Development.DEVELOPMENT) { if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) { - System.out.print("D"); + System.err.print("D"); for (int i = 0; i < e.indent; i++) - System.out.print(" "); - System.out.println(entry.getQuery()); + System.err.print(" "); + System.err.println(entry.getQuery()); } } // System.err.println(" => DISCARDED"); @@ -1448,10 +1455,10 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap if (entry.isRefuted()) { if (Development.DEVELOPMENT) { if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) { - System.out.print("R"); + System.err.print("R"); for (int i = 0; i < e.indent; i++) - System.out.print(" "); - System.out.println(entry.getQuery()); + System.err.print(" "); + System.err.println(entry.getQuery()); } } return false; @@ -1460,7 +1467,7 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap if (entry.isExcepted()) { if (Development.DEVELOPMENT) { if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) { - System.out.print("E"); + System.err.print("E"); } } } @@ -1468,7 +1475,7 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap if (entry.isPending()) { if (Development.DEVELOPMENT) { if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) { - System.out.print("P"); + System.err.print("P"); } } } @@ -1477,10 +1484,10 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap if (Development.DEVELOPMENT) { if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) { - System.out.print("U "); + System.err.print("U "); for (int i = 0; i < e.indent; i++) - System.out.print(" "); - System.out.print(entry.getQuery()); + System.err.print(" "); + System.err.print(entry.getQuery()); } } @@ -1492,9 +1499,9 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap if (Development.DEVELOPMENT) { if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) { if(hasListener(entry)) { - System.out.println(" (L)"); + System.err.println(" (L)"); } else { - System.out.println(""); + System.err.println(""); } } } @@ -1616,7 +1623,11 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap Query query = entry.getQuery(); - if(DebugPolicy.RECOMPUTE) System.out.println("R " + query); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_RECOMPUTE, Bindings.BOOLEAN)) { + System.err.println("R " + query); + } + } entry.prepareRecompute(querySupport); @@ -1629,10 +1640,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap Object newValue = entry.getResult(); if (ListenerEntry.NO_VALUE == oldValue) { - if(DebugPolicy.CHANGES) { - System.out.println("C " + query); - System.out.println("- " + oldValue); - System.out.println("- " + newValue); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_CHANGES, Bindings.BOOLEAN)) { + System.out.println("C " + query); + System.out.println("- " + oldValue); + System.out.println("- " + newValue); + } } return newValue; } @@ -1648,10 +1661,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap } else changed = (oldValue != null); - if(DebugPolicy.CHANGES && changed) { - System.out.println("C " + query); - System.out.println("- " + oldValue); - System.out.println("- " + newValue); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_CHANGES, Bindings.BOOLEAN)) { + System.err.println("C " + query); + System.err.println("- " + oldValue); + System.err.println("- " + newValue); + } } return changed ? newValue : ListenerEntry.NOT_CHANGED; @@ -1696,7 +1711,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap for (ListenerEntry listenerEntry : entries) { if (pruneListener(listenerEntry)) { - if(DebugPolicy.LISTENER) System.out.println("Pruned " + listenerEntry.procedure); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) { + new Exception().printStackTrace(); + System.err.println("Pruned " + listenerEntry.procedure); + } + } continue; } @@ -1706,8 +1726,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap Object newValue = compareTo(graph, entry, listenerEntry.getLastKnown()); if (newValue != ListenerEntry.NOT_CHANGED) { - if(DebugPolicy.LISTENER) - System.out.println("Add to schedule " + listenerEntry.procedure + " with " + newValue); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) { + new Exception().printStackTrace(); + System.err.println("Add to schedule " + listenerEntry.procedure + " with " + newValue); + } + } schedule.add(listenerEntry); listenerEntry.setLastKnown(entry.getResult()); } @@ -1716,11 +1740,17 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap for(ListenerEntry listenerEntry : schedule) { final CacheEntry entry = listenerEntry.entry; - if(DebugPolicy.LISTENER) - System.out.println("Firing " + listenerEntry.procedure); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) { + System.err.println("Firing " + listenerEntry.procedure); + } + } try { - if(DebugPolicy.LISTENER) - System.out.println("Firing " + listenerEntry.procedure + " for " + listenerEntry.entry); + if (Development.DEVELOPMENT) { + if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) { + System.err.println("Firing " + listenerEntry.procedure + " for " + listenerEntry.entry); + } + } entry.performFromCache(graph, listenerEntry.procedure); } catch (Throwable t) { t.printStackTrace(); diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java index 9b0befc78..ed58556c7 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java @@ -11,6 +11,7 @@ import org.simantics.databoard.accessor.reference.ChildReference; import org.simantics.databoard.binding.Binding; import org.simantics.databoard.binding.impl.ObjectVariantBinding; import org.simantics.databoard.type.Datatype; +import org.simantics.db.DevelopmentKeys; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; @@ -19,7 +20,6 @@ import org.simantics.db.common.validation.L0Validations; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.DatatypeNotFoundException; import org.simantics.db.exception.ValidationException; -import org.simantics.db.exception.VariableException; import org.simantics.db.layer0.exception.InvalidVariableException; import org.simantics.db.layer0.exception.MissingVariableValueException; import org.simantics.db.layer0.exception.PendingVariableException; @@ -122,10 +122,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable { public T getValue(ReadGraph graph) throws DatabaseException { if(Development.DEVELOPMENT) { - String error = L0Validations.checkValueType(graph, parentResource, property.predicate); - if(error != null) { - LOGGER.error(error); - //throw new ValidationException(error); + if(Development.getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) { + String error = L0Validations.checkValueType(graph, parentResource, property.predicate); + if(error != null) { + LOGGER.error(error); + throw new ValidationException(error); + } } } @@ -141,10 +143,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable { return getValue(graph); if(Development.DEVELOPMENT) { - String error = L0Validations.checkValueType(graph, parentResource, property.predicate); - if(error != null) { - LOGGER.error(error); - throw new ValidationException(error); + if(Development.getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) { + String error = L0Validations.checkValueType(graph, parentResource, property.predicate); + if(error != null) { + LOGGER.error(error); + throw new ValidationException(error); + } } } @@ -180,10 +184,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable { public void setValue(WriteGraph graph, Object value, Binding binding) throws DatabaseException { if(Development.DEVELOPMENT) { - String error = L0Validations.checkValueType(graph, parentResource, property.predicate); - if(error != null) { - LOGGER.error(error); - //throw new ValidationException(error); + if(Development.getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) { + String error = L0Validations.checkValueType(graph, parentResource, property.predicate); + if(error != null) { + LOGGER.error(error); + throw new ValidationException(error); + } } } @@ -195,10 +201,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable { public void setValue(WriteGraph graph, Object value) throws DatabaseException { if(Development.DEVELOPMENT) { - String error = L0Validations.checkValueType(graph, parentResource, property.predicate); - if(error != null) { - LOGGER.error(error); - throw new ValidationException(error); + if(Development.getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) { + String error = L0Validations.checkValueType(graph, parentResource, property.predicate); + if(error != null) { + LOGGER.error(error); + throw new ValidationException(error); + } } } diff --git a/bundles/org.simantics.db/src/org/simantics/db/DevelopmentKeys.java b/bundles/org.simantics.db/src/org/simantics/db/DevelopmentKeys.java index 20ba53e51..7f23b07b8 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/DevelopmentKeys.java +++ b/bundles/org.simantics.db/src/org/simantics/db/DevelopmentKeys.java @@ -5,6 +5,10 @@ import org.simantics.utils.Development; public class DevelopmentKeys { + final public static boolean EVERYTHING = true; + + final public static boolean VERBOSE = false; + final public static String PRINT = "Development.print"; final public static String LOGGER_ECHO = trickToInitialize(); @@ -17,41 +21,69 @@ public class DevelopmentKeys { final public static String WRITELOGGER_LOG = "WriteLogger.log"; + final public static String QUERYPROCESSOR_RECOMPUTE = "QueryProcessor.recompute"; + + final public static String QUERYPROCESSOR_LISTENERS = "QueryProcessor.listeners"; + + final public static String QUERYPROCESSOR_CHANGES = "QueryProcessor.changes"; + final public static String QUERYPROCESSOR_UPDATE = "QueryProcessor.update"; + final public static String QUERYPROCESSOR_DEPENDENCIES = "QueryProcessor.dependencies"; + final public static String QUERYPROCESSOR_PUT = "QueryProcessor.put"; + final public static String QUERYCOLLECTOR = "QueryCollector"; + final public static String SESSION_LOG_WRITES = "Session.logWrites"; final public static String READGRAPH_COUNT = "ReadGraph.count"; + final public static String L0_VALIDATION = "L0.validation"; + + final public static String CACHE_ENTRY_STATE = "CacheEntry.state"; + final public static String CLUSTERTABLE_VALIDATE_ON_LOAD = "ClusterTable.validateOnLoad"; public static void initialize() { if(Development.DEVELOPMENT) { - Development.setProperty(DevelopmentKeys.PRINT, true, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.PRINT, EVERYTHING | false, Bindings.BOOLEAN); + + Development.setProperty(DevelopmentKeys.LOGGER_ECHO, EVERYTHING | false, Bindings.BOOLEAN); + + Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG, EVERYTHING | false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG_NAMES, EVERYTHING | false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG_STACK, EVERYTHING | false, Bindings.BOOLEAN); + + Development.setProperty(DevelopmentKeys.WRITEGRAPH_EXCEPTION_STACKTRACES, EVERYTHING | false, Bindings.BOOLEAN); + + Development.setProperty(DevelopmentKeys.READGRAPH_COUNT, EVERYTHING | false, Bindings.BOOLEAN); + + Development.setProperty(DevelopmentKeys.L0_VALIDATION, false, Bindings.BOOLEAN); + + Development.setProperty(DevelopmentKeys.CACHE_ENTRY_STATE, EVERYTHING | false, Bindings.BOOLEAN); + + Development.setProperty(DevelopmentKeys.WRITELOGGER_LOG, EVERYTHING | false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.LOGGER_ECHO, false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_RECOMPUTE, EVERYTHING | false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG, false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG_NAMES, false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG_STACK, false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, EVERYTHING | false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.WRITEGRAPH_EXCEPTION_STACKTRACES, false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_CHANGES, EVERYTHING | false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.READGRAPH_COUNT, false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, EVERYTHING | false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.WRITELOGGER_LOG, false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_DEPENDENCIES, EVERYTHING | false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_PUT, EVERYTHING | false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_PUT, false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.QUERYCOLLECTOR, EVERYTHING | false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.SESSION_LOG_WRITES, false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.SESSION_LOG_WRITES, EVERYTHING | false, Bindings.BOOLEAN); - Development.setProperty(DevelopmentKeys.CLUSTERTABLE_VALIDATE_ON_LOAD, false, Bindings.BOOLEAN); + Development.setProperty(DevelopmentKeys.CLUSTERTABLE_VALIDATE_ON_LOAD, EVERYTHING | false, Bindings.BOOLEAN);