From 7c1b9683782febaa08229567b86519a33290bb1f Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Fri, 28 Feb 2014 01:53:32 +0100 Subject: [PATCH] another fix for the shutdown exceptions --- .../solr/instance/EmbeddedInstance.java | 1 + .../solr/instance/InstanceMirror.java | 26 +++++++------------ source/net/yacy/search/index/Fulltext.java | 2 -- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.java b/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.java index f94fce2ee..c9eb0b1e6 100644 --- a/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.java +++ b/source/net/yacy/cora/federate/solr/instance/EmbeddedInstance.java @@ -212,6 +212,7 @@ public class EmbeddedInstance implements SolrInstance { @Override public synchronized void close() { + for (SolrCore core: cores.values()) core.close(); if (this.coreContainer != null) try { this.coreContainer.shutdown(); this.coreContainer = null; diff --git a/source/net/yacy/cora/federate/solr/instance/InstanceMirror.java b/source/net/yacy/cora/federate/solr/instance/InstanceMirror.java index 0a5955c5d..e2c974d26 100644 --- a/source/net/yacy/cora/federate/solr/instance/InstanceMirror.java +++ b/source/net/yacy/cora/federate/solr/instance/InstanceMirror.java @@ -35,14 +35,14 @@ public class InstanceMirror { private EmbeddedInstance embeddedSolrInstance; private ShardInstance remoteSolrInstance; - private Map mirrorConnectorCache; + private Map mirrorConnectorCache; private Map embeddedConnectorCache; private Map remoteConnectorCache; public InstanceMirror() { this.embeddedSolrInstance = null; this.remoteSolrInstance = null; - this.mirrorConnectorCache = new ConcurrentHashMap(); + this.mirrorConnectorCache = new ConcurrentHashMap(); this.embeddedConnectorCache = new ConcurrentHashMap(); this.remoteConnectorCache = new ConcurrentHashMap(); } @@ -61,14 +61,10 @@ public class InstanceMirror { } public void disconnectEmbedded() { + mirrorConnectorCache.clear(); if (this.embeddedSolrInstance == null) return; - for (EmbeddedSolrConnector connector: this.embeddedConnectorCache.values()) { - this.mirrorConnectorCache.values().remove(connector); - connector.close(); - } + for (EmbeddedSolrConnector connector: this.embeddedConnectorCache.values()) connector.close(); this.embeddedConnectorCache.clear(); - for (SolrConnector connector: this.mirrorConnectorCache.values()) connector.close(); - this.mirrorConnectorCache.clear(); this.embeddedSolrInstance.close(); this.embeddedSolrInstance = null; } @@ -87,21 +83,17 @@ public class InstanceMirror { } public void disconnectRemote() { + mirrorConnectorCache.clear(); if (this.remoteSolrInstance == null) return; - for (RemoteSolrConnector connector: this.remoteConnectorCache.values()) { - this.mirrorConnectorCache.values().remove(connector); - connector.close(); - } + for (RemoteSolrConnector connector: this.remoteConnectorCache.values()) connector.close(); this.remoteConnectorCache.clear(); - for (SolrConnector connector: this.mirrorConnectorCache.values()) connector.close(); - this.mirrorConnectorCache.clear(); this.remoteSolrInstance.close(); this.remoteSolrInstance = null; } public synchronized void close() { - this.disconnectEmbedded(); - this.disconnectRemote(); + for (SolrConnector connector: this.mirrorConnectorCache.values()) connector.close(); + this.mirrorConnectorCache.clear(); } public String getDefaultCoreName() { @@ -163,7 +155,7 @@ public class InstanceMirror { } public SolrConnector getGenericMirrorConnector(String corename) { - SolrConnector msc = this.mirrorConnectorCache.get(corename); + ConcurrentUpdateSolrConnector msc = this.mirrorConnectorCache.get(corename); if (msc != null) return msc; EmbeddedSolrConnector esc = getEmbeddedConnector(corename); RemoteSolrConnector rsc = getRemoteConnector(corename); diff --git a/source/net/yacy/search/index/Fulltext.java b/source/net/yacy/search/index/Fulltext.java index 9b1463735..ed06dcd59 100644 --- a/source/net/yacy/search/index/Fulltext.java +++ b/source/net/yacy/search/index/Fulltext.java @@ -529,13 +529,11 @@ public final class Fulltext { File zipOut = new File(this.archivePath, storagePath.getName() + "_" + GenericFormatter.SHORT_DAY_FORMATTER.format() + ".zip"); synchronized (this.solrInstances) { this.disconnectLocalSolr(); - this.solrInstances.close(); try { ZIPWriter.zip(storagePath, zipOut); } catch (final IOException e) { ConcurrentLog.logException(e); } finally { - this.solrInstances = new InstanceMirror(); try { this.connectLocalSolr(); } catch (final IOException e) {