Added errors when requesting VC in caching process (resolved #47)
Change-Id: I005cf20113c3badfed938117a93a505b3fedd6b9
Change-Id: I005cf20113c3badfed938117a93a505b3fedd6b9
diff --git a/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java b/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java
index 014a057..eaa462e 100644
--- a/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java
+++ b/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java
@@ -137,13 +137,14 @@
private void cacheVC (String json, String filename)
throws IOException, QueryException {
+ config.setVcInCaching(filename);
long start, end;
start = System.currentTimeMillis();
KrillCollection collection = new KrillCollection(json);
collection.setIndex(searchKrill.getIndex());
- jlog.info("Store {} in cache ", filename);
+ jlog.info("Storing {} in cache ", filename);
if (collection != null) {
collection.storeInCache(filename);
}
@@ -153,5 +154,6 @@
jlog.debug("memory cache: "
+ KrillCollection.cache.calculateInMemorySize());
}
+ config.setVcInCaching("");
}
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewrite.java b/full/src/main/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewrite.java
index 39c76d4..3f25da1 100644
--- a/full/src/main/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewrite.java
+++ b/full/src/main/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewrite.java
@@ -26,6 +26,8 @@
public class VirtualCorpusRewrite implements RewriteTask.RewriteQuery {
@Autowired
+ private KustvaktConfiguration config;
+ @Autowired
private VirtualCorpusService vcService;
@Override
@@ -59,6 +61,15 @@
}
}
+ String vcInCaching = config.getVcInCaching();
+ if (vcName.equals(vcInCaching)) {
+ throw new KustvaktException(
+ de.ids_mannheim.korap.exceptions.StatusCodes.CACHING_VC,
+ "VC is currently busy and unaccessible due to "
+ + "caching process",
+ koralNode.get("ref"));
+ }
+
VirtualCorpus vc =
vcService.searchVCByName(username, vcName, vcOwner);
if (!vc.isCached()) {
diff --git a/full/src/main/resources/ehcache.xml b/full/src/main/resources/ehcache.xml
index cc06d48..da9acda 100644
--- a/full/src/main/resources/ehcache.xml
+++ b/full/src/main/resources/ehcache.xml
@@ -59,6 +59,6 @@
maxBytesLocalDisk="1G"
diskExpiryThreadIntervalSeconds = "120" >
<persistence strategy="localTempSwap"/>
- <sizeOfPolicy maxDepth="1000" maxDepthExceededBehavior="abort" />
+ <sizeOfPolicy maxDepth="2000" maxDepthExceededBehavior="abort" />
</cache>
</ehcache>