]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java
Do not wait forever for querythreads to dispose
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / SessionImplSocket.java
index 9b152f2da02f16e80a1b16a2dbbe7e8e9579e981..aff219622d6b91254823d1b8fcad7df722749429 100644 (file)
@@ -143,6 +143,7 @@ import org.simantics.db.service.ClusteringSupport;
 import org.simantics.db.service.CollectionSupport;
 import org.simantics.db.service.DebugSupport;
 import org.simantics.db.service.DirectQuerySupport;
+import org.simantics.db.service.EventSupport;
 import org.simantics.db.service.GraphChangeListenerSupport;
 import org.simantics.db.service.InitSupport;
 import org.simantics.db.service.LifecycleSupport;
@@ -166,6 +167,7 @@ import org.simantics.utils.DataContainer;
 import org.simantics.utils.Development;
 import org.simantics.utils.threads.logger.ITask;
 import org.simantics.utils.threads.logger.ThreadLogger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.procedure.TLongProcedure;
 import gnu.trove.set.hash.TLongHashSet;
@@ -173,6 +175,8 @@ import gnu.trove.set.hash.TLongHashSet;
 
 public abstract class SessionImplSocket implements Session, WriteRequestScheduleSupport {
 
+    private static org.slf4j.Logger LOGGER = LoggerFactory.getLogger(SessionImplSocket.class);
+
     protected static final boolean DEBUG        = false;
 
     private static final boolean DIAGNOSTICS       = false;
@@ -289,6 +293,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
         serviceLocator.registerService(ExternalValueSupport.class, new ExternalValueSupportImpl(this));
         serviceLocator.registerService(RandomAccessValueSupport.class, new RandomAccessValueSupportImpl());
         serviceLocator.registerService(ServiceActivityMonitor.class, new ServiceActivityMonitorImpl());
+        serviceLocator.registerService(EventSupport.class, new EventSupportImpl());
         ServiceActivityUpdaterForWriteTransactions.register(this);
 
         this.virtualGraphServerSupport = new VirtualGraphServerSupportImpl(this, t);
@@ -1340,7 +1345,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
 
         } catch (Throwable e) {
 
-            e.printStackTrace();
+            LOGGER.error("Could not perform write only for request {}", request, e);
 
             releaseWriteOnly(writeState.getGraph());
 
@@ -2481,7 +2486,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
                     try {
                         l.graphChanged(e2);
                     } catch (Throwable ex) {
-                        ex.printStackTrace();
+                        LOGGER.error("Could not invoke listener {} with event {}", l, e2, ex);
                     }
                 }
 
@@ -2490,7 +2495,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
             }
 
         } catch (Throwable t) {
-            t.printStackTrace();
+            LOGGER.error("Could not fire metadata listeners {} {}", graph, cs2, t);
         }
 
     }
@@ -2666,7 +2671,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
                 // Serialize as '<resource index>_<cluster id>'
                 return "" + r + "_" + getCluster(resourceImpl);
             } catch (Throwable e) {
-                e.printStackTrace();
+                LOGGER.error("Could not create random access id for resource {}", resource, e);
                 throw new InvalidResourceReferenceException(e);
             } finally {
             }
@@ -2714,7 +2719,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
             } catch (NumberFormatException e) {
                 throw new InvalidResourceReferenceException(e);
             } catch (Throwable e) {
-                e.printStackTrace();
+                LOGGER.error("Could not get resource for randomAccessId {}", randomAccessId, e);
                 throw new InvalidResourceReferenceException(e);
             } finally {
             }
@@ -3457,7 +3462,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
 
             }
         } catch (InterruptedException e) {
-            e.printStackTrace();
+            LOGGER.error("Acquiring was interrupted", e);
             // FIXME: Should perhaps do something else in this case ??
         }
     }