X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.indexing%2Fsrc%2Forg%2Fsimantics%2Fdb%2Findexing%2FIndexedRelationsImpl.java;h=1d027a8252c6c4894f9a3b87cc94ceb033f4a536;hp=bc9247e37818302ce53b3bdbfd5b35f9c406d21d;hb=8b8630b9;hpb=0242b51bcb69c03ea15aa785abc39ed70c9dbbd7 diff --git a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsImpl.java b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsImpl.java index bc9247e37..1d027a825 100644 --- a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsImpl.java +++ b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsImpl.java @@ -13,6 +13,7 @@ package org.simantics.db.indexing; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -37,6 +38,8 @@ import org.simantics.db.layer0.genericrelation.IndexedRelations; import org.simantics.db.service.QueryControl; import org.simantics.db.service.SerialisationSupport; import org.simantics.utils.datastructures.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Tuukka Lehtonen @@ -44,6 +47,8 @@ import org.simantics.utils.datastructures.Pair; */ public class IndexedRelationsImpl implements IndexedRelations { + private static final Logger LOGGER = LoggerFactory.getLogger(IndexedRelationsImpl.class); + Map indexLocks = new WeakHashMap(); static class LockHandle { @@ -370,7 +375,7 @@ public class IndexedRelationsImpl implements IndexedRelations { @Override public void insert(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation, - Resource relationResource, Resource input, Collection documents) { + Resource relationResource, Resource input, Collection documents) throws IndexException { // System.out.println("Inserting to index: " + input + " " + documents); @@ -413,7 +418,7 @@ public class IndexedRelationsImpl implements IndexedRelations { @Override public void remove(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation, - Resource relationResource, Resource input, String key, Collection keyValues) { + Resource relationResource, Resource input, String key, Collection keyValues) throws IndexException { if (relation == null) throw new IllegalArgumentException("null relation"); @@ -473,7 +478,7 @@ public class IndexedRelationsImpl implements IndexedRelations { @Override public boolean replace(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation, - Resource relationResource, Resource input, String key, Collection keyValues, Collection documents) { + Resource relationResource, Resource input, String key, Collection keyValues, Collection documents) throws IndexException { if (relation == null) throw new IllegalArgumentException("null relation"); @@ -521,16 +526,15 @@ public class IndexedRelationsImpl implements IndexedRelations { IndexedRelationsSearcherBase searcher = makeSearcher(processor, relationResource, input); LockHandle handle = lock(processor, Pair.make(relationResource, input), true); - + Path path = DatabaseIndexing.getIndexLocation(processor.getSession(), relationResource, input); try { searcher.changeState(monitor, processor.getSession(), State.NONE); if (!searcher.checkState(State.NONE)) throw new IndexException("Could not close index for input " + input + " before removing it"); - File path = DatabaseIndexing.getIndexLocation(processor.getSession(), relationResource, input); DatabaseIndexing.deleteIndex(path); - } catch (IOException e) { + LOGGER.error("Could not delete {}", path.toAbsolutePath(), e); throw new IndexException(e); } finally { handle.unlock();