]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QuerySupportImpl.java
Working towards multiple readers.
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / QuerySupportImpl.java
index b3b403ea7175cdf94bb98f15d58d87e9ca53e572..07282029a77d94e46cf1d29fd6f78314d225e81d 100644 (file)
@@ -33,11 +33,14 @@ import org.simantics.db.procore.cluster.ClusterImpl;
 import org.simantics.db.procore.cluster.ClusterSmall;
 import org.simantics.db.service.SerialisationSupport;
 import org.simantics.utils.DataContainer;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.set.hash.TIntHashSet;
 
 public class QuerySupportImpl implements QuerySupport {
-       
+
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(QuerySupportImpl.class);
+
        final SessionImplSocket session;
        final State state;
        final ClusterTable clusterTable;
@@ -212,7 +215,11 @@ public class QuerySupportImpl implements QuerySupport {
 
 //                    int suggestSchedule = graph.processor.processor.resourceThread(id);
 //                    if(graph.callerThread == suggestSchedule) {
-                       procedure.execute(graph, new ResourceImpl(resourceSupport, id));
+                       try {
+                                                       procedure.execute(graph, new ResourceImpl(resourceSupport, id));
+                                               } catch (DatabaseException e) {
+                                                       LOGGER.error("Unexpected exception while handling object", e);
+                                               }
 //                    } else {
 //                     graph.processor.processor.schedule(graph.callerThread, new SessionTask(suggestSchedule) {
 //             
@@ -226,7 +233,11 @@ public class QuerySupportImpl implements QuerySupport {
                        
                 }
                        }
-                       procedure.finished(graph);
+               try {
+                       procedure.finished(graph);
+                       } catch (DatabaseException e) {
+                               LOGGER.error("Unexpected exception while handling objects", e);
+                       }
 //             graph.dec();
                return;
                
@@ -234,14 +245,12 @@ public class QuerySupportImpl implements QuerySupport {
                
         final ClusterImpl cluster = (ClusterImpl)clusterTable.getClusterByResourceKey(subject);
         if(!cluster.isLoaded()) {
-               cluster.load(session.clusterTranslator, new Runnable() {
-
-                               @Override
-                               public void run() {
-                                       getObjects4(graph, subject, procedure);
-                               }
-                       
-               });
+               try {
+                               cluster.load();
+                       } catch (DatabaseException e) {
+                               LOGGER.error("Unexpected exception while handling objects", e);
+                       }
+               getObjects4(graph, subject, procedure);
                return;
         }
                
@@ -249,9 +258,15 @@ public class QuerySupportImpl implements QuerySupport {
                        
                        for(TransientGraph g : virtualGraphServerSupport.providers) {
                 for (final int id : g.getObjects(subject, procedure.predicateKey)) {
+                       try {
+                       procedure.execute(graph, new ResourceImpl(resourceSupport, id));
+                               } catch (DatabaseException e) {
+                                       LOGGER.error("Unexpected exception while handling objects", e);
+                               }
+                       
+                       
 //                    int suggestSchedule = graph.processor.processor.resourceThread(id);
 //                    if(graph.callerThread == suggestSchedule) {
-                       procedure.execute(graph, new ResourceImpl(resourceSupport, id));
 //                    } else {
 //                     graph.processor.processor.schedule(graph.callerThread, new SessionTask(suggestSchedule) {
 //             
@@ -292,7 +307,15 @@ public class QuerySupportImpl implements QuerySupport {
 
 //                    int suggestSchedule = graph.processor.processor.resourceThread(id);
 //                    if(graph.callerThread == suggestSchedule) {
-                       procedure.execute(graph, context, new ResourceImpl(resourceSupport, id));
+                       
+                       try {
+                               procedure.execute(graph, context, new ResourceImpl(resourceSupport, id));
+                               } catch (DatabaseException e) {
+                                       LOGGER.error("Unexpected exception while handling objects", e);
+                               }
+                       
+                       
+                       
 //                    } else {
 //                     graph.processor.processor.schedule(graph.callerThread, new SessionTask(suggestSchedule) {
 //             
@@ -306,7 +329,14 @@ public class QuerySupportImpl implements QuerySupport {
                        
                 }
                        }
-                       procedure.finished(graph, context);
+                       
+               try {
+                       procedure.finished(graph, context);
+                       } catch (DatabaseException e) {
+                               LOGGER.error("Unexpected exception while handling objects", e);
+                       }
+
+                       
 //             graph.dec();
                return;
                
@@ -331,7 +361,11 @@ public class QuerySupportImpl implements QuerySupport {
                 for (final int id : g.getObjects(subject, procedure.predicateKey)) {
 //                    int suggestSchedule = graph.processor.processor.resourceThread(id);
 //                    if(graph.callerThread == suggestSchedule) {
-                       procedure.execute(graph, context, new ResourceImpl(resourceSupport, id));
+                       try {
+                               procedure.execute(graph, context, new ResourceImpl(resourceSupport, id));
+                               } catch (DatabaseException e) {
+                                       LOGGER.error("Unexpected exception while handling objects", e);
+                               }
 //                    } else {
 //                     graph.processor.processor.schedule(graph.callerThread, new SessionTask(suggestSchedule) {
 //