]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/MemoryIndexing.java
Add logging to indexing & replace File-API with NIO Path-API
[simantics/platform.git] / bundles / org.simantics.db.indexing / src / org / simantics / db / indexing / MemoryIndexing.java
index 60b76100c2db49e6eb7507575359ac47fb5e133e..75c6b79bb51c6a1dc4da3b9c9e1064f3fbb93b25 100644 (file)
@@ -1,7 +1,7 @@
 package org.simantics.db.indexing;
 
-import java.io.File;
 import java.io.IOException;
+import java.nio.file.Path;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -20,9 +20,9 @@ import org.simantics.db.RequestProcessor;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
 import org.simantics.db.common.request.Adapt;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.indexing.IndexedRelationsSearcherBase.State;
 import org.simantics.db.layer0.adapter.GenericRelation;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Tuukka Lehtonen
@@ -30,6 +30,8 @@ import org.simantics.db.layer0.adapter.GenericRelation;
  */
 public class MemoryIndexing {
 
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(MemoryIndexing.class);
+
        final private Session session;
        
     final Map<String,Map<String,List<Map<String, Object>>>> persistentCache = new HashMap<String,Map<String,List<Map<String, Object>>>>();
@@ -44,14 +46,14 @@ public class MemoryIndexing {
        this.session = session;
     }
     
-    protected File getIndexDirectory(Resource relation, Resource input) {
+    protected Path getIndexDirectory(Resource relation, Resource input) {
         return DatabaseIndexing.getIndexLocation(session, relation, input);
     }
     
     public IndexedRelationsSearcher get(RequestProcessor processor, Resource relation, Resource input) {
+        Path location = getIndexDirectory(relation, input);
         try {
-            File location = getIndexDirectory(relation, input);
-            String key = location.getAbsolutePath();
+            String key = location.toAbsolutePath().toString();
             IndexedRelationsSearcher searcher = searchers.get(key);
             if (searcher == null) {
                 GenericRelation r = processor.sync(new Adapt<GenericRelation>(relation, GenericRelation.class));
@@ -60,15 +62,15 @@ public class MemoryIndexing {
             }
             return searcher;
         } catch (Exception e) {
-            Logger.defaultLogError(e);
+            LOGGER.error("Could not get searcher for relation {} and input {} in location {}", relation, input, location, e);
             return null;
         }
     }
 
     public IndexedRelationsSearcherBase getImmutable(RequestProcessor processor, Resource relation, Resource input) {
+        Path location = getIndexDirectory(relation, input);
         try {
-            File location = getIndexDirectory(relation, input);
-            String key = location.getAbsolutePath();
+            String key = location.toAbsolutePath().toString();
             IndexedRelationsSearcherBase searcher = immutableSearchers.get(key);
             if (searcher == null) {
                 searcher = new ImmutableIndexedRelationsSearcher(processor, relation, input);
@@ -76,7 +78,7 @@ public class MemoryIndexing {
             }
             return searcher;
         } catch (Exception e) {
-            Logger.defaultLogError(e);
+            LOGGER.error("Could not get searcher base for relation {} and input {} in location {}", relation, input, location, e);
             return null;
         }
     }