]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Move debugging options under DevelopmentKeys 37/3037/1
authorAntti Villberg <antti.villberg@semantum.fi>
Fri, 19 Jul 2019 09:05:48 +0000 (12:05 +0300)
committerAntti Villberg <antti.villberg@semantum.fi>
Fri, 19 Jul 2019 10:31:04 +0000 (13:31 +0300)
gitlab #319

Change-Id: Iabeb7d88912781768d4ee13dd8ecb531d7a82215

12 files changed:
bundles/org.simantics.db.impl/src/org/simantics/db/impl/DebugPolicy.java [deleted file]
bundles/org.simantics.db.impl/src/org/simantics/db/impl/ResourceImpl.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/DelayedWriteGraph.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl2.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java
bundles/org.simantics.db/src/org/simantics/db/DevelopmentKeys.java

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 (file)
index 752991c..0000000
+++ /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;
-    
-}
index 3406d670031590beb58dfee439326cb2fb738e0c..78dacb98ff4ebad6997dcc1a027de5c0b902347e 100644 (file)
@@ -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=");
index f8797b251546b47cc169024f2e5cfb994f6fc529..84dd871c07929d32d84cd5208599023928c525a5 100644 (file)
@@ -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("]");
index 79fe974642d2a71e66054fe6de5d00a60424b7bf..cffbba51c75f852e44b215747e94efafa099e296 100644 (file)
@@ -6181,11 +6181,12 @@ public class ReadGraphImpl implements AsyncReadGraph {
     @Override
     public <T> 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.<Boolean>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.<Boolean>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);
     }
index 972bd381f222207b2ff91d02d33b13269321913c..cd5420656400917f5926fa6491b30f27089af6bc 100644 (file)
  *******************************************************************************/
 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<T> extends CacheEntryBase<AsyncProcedure<T>> i
 
     AsyncReadEntry(AsyncRead<T> request) {
         this.request = request;
-        if (DebugPolicy.QUERY_STATE)
-            System.out.println("[QUERY STATE]: created " + this);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) {
+                       System.err.println("[QUERY STATE]: created " + this);
+                       }
+               }
     }
 
     @Override
index 7fc0432f832f2f2d3fceaca007c2d1866c12a8b8..3a94e52b6f9dd58f55031b852df02776fc044874 100644 (file)
@@ -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<Procedure> extends CacheEntry<Procedure> {
     
     @Override
     public void discard() {
-       if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: discarded " + this);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) {
+                               System.err.println("[QUERY STATE]: discarded " + this);
+                       }
+               }
        statusOrException = DISCARDED;
     }
     
@@ -96,7 +102,11 @@ public abstract class CacheEntryBase<Procedure> extends CacheEntry<Procedure> {
     
     @Override
     final public void refute() {
-       if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: refuted " + this);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>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<Procedure> extends CacheEntry<Procedure> {
 
     @Override
     public void except(Throwable throwable) {
-       if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: excepted " + this);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) {
+                               System.err.println("[QUERY STATE]: excepted " + this);
+                       }
+               }
        if(statusOrException != DISCARDED) {
                statusOrException = EXCEPTED;
                result = throwable;
index 661076e8604bacd47504ed86607df88bca54eee8..ac07ad7eda1acb4e3f51884b35b4b5ff99ad8445 100644 (file)
@@ -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<T> extends CacheEntryBase<AsyncProcedure<T>> implements Listener<T> {
 
@@ -69,7 +71,12 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
     @Override
     public void except(Throwable t) {
        
-        if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: excepted " + this);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) {
+                               System.err.println("[QUERY STATE]: excepted " + this);
+                       }
+               }
+
         if(statusOrException != DISCARDED) {
             statusOrException = EXCEPTED;
             result = t;
index 6abaf6b6518e7b9239dad4830aa9acadd65492c5..446e9c641406464de62e4cb484c66d02df4ca70f 100644 (file)
@@ -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.<Boolean>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.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) {
+                               new Exception().printStackTrace();
+                               System.err.println("addListener -> " + list.size() + " " + entry + " " + base + " " + procedure);
+                       }
                }
 
                return result;
index 84273b81d63cf6921be763840b2c0cae172ba934..0efa49f56b7cfa3a03617669cf5ad892ef002d18 100644 (file)
@@ -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<CacheEntry, Boolean> collectables, ArrayList<CacheEntry> result) {
 
                if (entry.isDiscarded()) {
-                       if(DebugPolicy.COLLECT && DebugPolicy.VERBOSE)
-                               System.out.println("GC: discarded entry " + entry);
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                                       System.err.println("Collect took " + 1e-9*duration + "s.");
+                               }
+                       }
 
                } catch (Throwable t) {
                        t.printStackTrace();
index 5a37257e2531c051c39de0bea04af271e1adccce..7743907202eb8fbf54fd584330e3dc84fcdfac16 100644 (file)
@@ -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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>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();
index 9b0befc78442fa47d02022ca9e8863f01d1b5647..ed58556c7e570814bd4ce25e5473a6821f2c33bc 100644 (file)
@@ -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> 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.<Boolean>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.<Boolean>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.<Boolean>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.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+                               if(error != null) {
+                                       LOGGER.error(error);
+                                       throw new ValidationException(error);
+                               }
                        }
                }
                
index 20ba53e512451150b38ca9285fc45b985ddd404f..7f23b07b815c18988ca2aa4e58578d9822a2fa28 100644 (file)
@@ -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);