From 281959a2d727d9c38f0d62aec4b8f91b5db91429 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Wed, 29 May 2013 13:09:34 +0200 Subject: [PATCH] added option to re-boot the embedded solr during run-time. Added also API recording for this method so it can be repeated automatically. The index dump generation is now also available for API recording. Added some synchronization in backend which was necessary for this. --- htroot/IndexControlURLs_p.html | 9 +++++ htroot/IndexControlURLs_p.java | 6 +++ source/net/yacy/search/index/Fulltext.java | 46 ++++++++++++++++------ 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/htroot/IndexControlURLs_p.html b/htroot/IndexControlURLs_p.html index 8dc15f2c9..c22c46516 100644 --- a/htroot/IndexControlURLs_p.html +++ b/htroot/IndexControlURLs_p.html @@ -161,6 +161,15 @@ function updatepage(str) { + +
+
Reboot Solr Core +
+
 
+
+
+
+
:: #(/dumprestore)# diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.java index 6d3fe2e59..69f43c97a 100644 --- a/htroot/IndexControlURLs_p.java +++ b/htroot/IndexControlURLs_p.java @@ -270,6 +270,7 @@ public class IndexControlURLs_p { final File dump = segment.fulltext().dumpSolr(); prop.put("indexdump", 1); prop.put("indexdump_dumpfile", dump.getAbsolutePath()); + sb.tables.recordAPICall(post, "IndexControlURLs_p.html", WorkTables.TABLE_API_TYPE_STEERING, "solr dump generation"); } if (post.containsKey("indexrestore")) { @@ -277,6 +278,11 @@ public class IndexControlURLs_p { segment.fulltext().restoreSolr(dump); } + if (post.containsKey("rebootsolr")) { + segment.fulltext().rebootSolr(); + sb.tables.recordAPICall(post, "IndexControlURLs_p.html", WorkTables.TABLE_API_TYPE_STEERING, "solr reboot"); + } + if (post.containsKey("deletedomain")) { final String domain = post.get("domain"); segment.fulltext().deleteDomainHostname(domain, null); diff --git a/source/net/yacy/search/index/Fulltext.java b/source/net/yacy/search/index/Fulltext.java index 54c5d8694..3e61c6975 100644 --- a/source/net/yacy/search/index/Fulltext.java +++ b/source/net/yacy/search/index/Fulltext.java @@ -221,11 +221,15 @@ public final class Fulltext { } public SolrConnector getDefaultConnector() { - return this.solrInstances.getDefaultMirrorConnector(); + synchronized (this.solrInstances) { + return this.solrInstances.getDefaultMirrorConnector(); + } } public SolrConnector getWebgraphConnector() { - return this.solrInstances.getMirrorConnector(WebgraphSchema.CORE_NAME); + synchronized (this.solrInstances) { + return this.solrInstances.getMirrorConnector(WebgraphSchema.CORE_NAME); + } } public void clearCache() { @@ -247,20 +251,24 @@ public final class Fulltext { } public void clearLocalSolr() throws IOException { - EmbeddedInstance instance = this.solrInstances.getSolr0(); - if (instance != null) { - for (String name: instance.getCoreNames()) new EmbeddedSolrConnector(instance, name).clear(); + synchronized (this.solrInstances) { + EmbeddedInstance instance = this.solrInstances.getSolr0(); + if (instance != null) { + for (String name: instance.getCoreNames()) new EmbeddedSolrConnector(instance, name).clear(); + } + this.commit(false); + this.solrInstances.clearCache(); } - this.commit(false); - this.solrInstances.clearCache(); } public void clearRemoteSolr() throws IOException { - ShardInstance instance = this.solrInstances.getSolr1(); - if (instance != null) { - for (String name: instance.getCoreNames()) new RemoteSolrConnector(instance, name).clear(); + synchronized (this.solrInstances) { + ShardInstance instance = this.solrInstances.getSolr1(); + if (instance != null) { + for (String name: instance.getCoreNames()) new RemoteSolrConnector(instance, name).clear(); + } + this.solrInstances.clearCache(); } - this.solrInstances.clearCache(); } /** @@ -822,6 +830,22 @@ public final class Fulltext { } } + /** + * reboot solr (experimental to check resource management + */ + public void rebootSolr() { + synchronized (this.solrInstances) { + this.disconnectLocalSolr(); + this.solrInstances.close(); + this.solrInstances = new InstanceMirror(); + try { + this.connectLocalSolr(); + } catch (IOException e) { + Log.logException(e); + } + } + } + // export methods public Export export(final File f, final String filter, final int format, final boolean dom) { if ((this.exportthread != null) && (this.exportthread.isAlive())) {