another fix for the shutdown exceptions

This commit is contained in:
Michael Peter Christen 2014-02-28 01:53:32 +01:00
parent 133d41386c
commit 7c1b968378
3 changed files with 10 additions and 19 deletions

View File

@ -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;

View File

@ -35,14 +35,14 @@ public class InstanceMirror {
private EmbeddedInstance embeddedSolrInstance;
private ShardInstance remoteSolrInstance;
private Map<String, SolrConnector> mirrorConnectorCache;
private Map<String, ConcurrentUpdateSolrConnector> mirrorConnectorCache;
private Map<String, EmbeddedSolrConnector> embeddedConnectorCache;
private Map<String, RemoteSolrConnector> remoteConnectorCache;
public InstanceMirror() {
this.embeddedSolrInstance = null;
this.remoteSolrInstance = null;
this.mirrorConnectorCache = new ConcurrentHashMap<String, SolrConnector>();
this.mirrorConnectorCache = new ConcurrentHashMap<String, ConcurrentUpdateSolrConnector>();
this.embeddedConnectorCache = new ConcurrentHashMap<String, EmbeddedSolrConnector>();
this.remoteConnectorCache = new ConcurrentHashMap<String, RemoteSolrConnector>();
}
@ -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);

View File

@ -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) {