mirror of https://github.com/apache/lucene.git
SOLR-2651: The new SolrCore#reload method does not create a ZkSolrResourceLoader in ZooKeeper mode
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1146905 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6556cedcbb
commit
d0c71f9702
|
@ -206,7 +206,7 @@ Bug Fixes
|
||||||
* SOLR-2275: fix DisMax 'mm' parsing to be tolerant of whitespace
|
* SOLR-2275: fix DisMax 'mm' parsing to be tolerant of whitespace
|
||||||
(Erick Erickson via hossman)
|
(Erick Erickson via hossman)
|
||||||
|
|
||||||
* SOLR-2193, SOLR-2565: SolrCores now properly share IndexWriters across SolrCore reloads.
|
* SOLR-2193, SOLR-2565, SOLR-2651: SolrCores now properly share IndexWriters across SolrCore reloads.
|
||||||
(Mark Miller, Robert Muir)
|
(Mark Miller, Robert Muir)
|
||||||
|
|
||||||
* SOLR-2535: REGRESSION: in Solr 3.x and trunk the admin/file handler
|
* SOLR-2535: REGRESSION: in Solr 3.x and trunk the admin/file handler
|
||||||
|
|
|
@ -39,7 +39,6 @@ import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.cloud.ZooKeeperException;
|
import org.apache.solr.common.cloud.ZooKeeperException;
|
||||||
import org.apache.solr.common.params.CoreAdminParams;
|
import org.apache.solr.common.params.CoreAdminParams;
|
||||||
import org.apache.solr.common.util.DOMUtil;
|
import org.apache.solr.common.util.DOMUtil;
|
||||||
import org.apache.solr.common.util.XML;
|
|
||||||
import org.apache.solr.common.util.FileUtils;
|
import org.apache.solr.common.util.FileUtils;
|
||||||
import org.apache.solr.common.util.SystemIdResolver;
|
import org.apache.solr.common.util.SystemIdResolver;
|
||||||
import org.apache.solr.core.SolrXMLSerializer.SolrCoreXMLDef;
|
import org.apache.solr.core.SolrXMLSerializer.SolrCoreXMLDef;
|
||||||
|
@ -713,7 +712,42 @@ public class CoreContainer
|
||||||
if (core == null)
|
if (core == null)
|
||||||
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "No such core: " + name );
|
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "No such core: " + name );
|
||||||
|
|
||||||
SolrCore newCore = core.reload(libLoader);
|
CoreDescriptor cd = core.getCoreDescriptor();
|
||||||
|
|
||||||
|
File instanceDir = new File(cd.getInstanceDir());
|
||||||
|
if (!instanceDir.isAbsolute()) {
|
||||||
|
instanceDir = new File(getSolrHome(), instanceDir.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
SolrResourceLoader solrLoader;
|
||||||
|
if(zkController == null) {
|
||||||
|
solrLoader = new SolrResourceLoader(instanceDir.getAbsolutePath(), libLoader, getCoreProps(instanceDir.getAbsolutePath(), cd.getPropertiesName(),cd.getCoreProperties()));
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
String collection = cd.getCloudDescriptor().getCollectionName();
|
||||||
|
zkController.createCollectionZkNode(cd.getCloudDescriptor());
|
||||||
|
|
||||||
|
String zkConfigName = zkController.readConfigName(collection);
|
||||||
|
if (zkConfigName == null) {
|
||||||
|
log.error("Could not find config name for collection:" + collection);
|
||||||
|
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
||||||
|
"Could not find config name for collection:" + collection);
|
||||||
|
}
|
||||||
|
solrLoader = new ZkSolrResourceLoader(instanceDir.getAbsolutePath(), zkConfigName, libLoader, getCoreProps(instanceDir.getAbsolutePath(), cd.getPropertiesName(),cd.getCoreProperties()), zkController);
|
||||||
|
} catch (KeeperException e) {
|
||||||
|
log.error("", e);
|
||||||
|
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
||||||
|
"", e);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// Restore the interrupted status
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
log.error("", e);
|
||||||
|
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
||||||
|
"", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SolrCore newCore = core.reload(solrLoader);
|
||||||
register(name, newCore, false);
|
register(name, newCore, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.solr.core;
|
||||||
import org.apache.lucene.index.IndexDeletionPolicy;
|
import org.apache.lucene.index.IndexDeletionPolicy;
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.index.IndexWriter;
|
import org.apache.lucene.index.IndexWriter;
|
||||||
import org.apache.lucene.index.codecs.Codec;
|
|
||||||
import org.apache.lucene.index.codecs.CodecProvider;
|
import org.apache.lucene.index.codecs.CodecProvider;
|
||||||
import org.apache.lucene.search.BooleanQuery;
|
import org.apache.lucene.search.BooleanQuery;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
|
@ -297,20 +296,18 @@ public final class SolrCore implements SolrInfoMBean {
|
||||||
responseWriters.put(name, responseWriter);
|
responseWriters.put(name, responseWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SolrCore reload(ClassLoader libLoader) throws IOException, ParserConfigurationException, SAXException {
|
public SolrCore reload(SolrResourceLoader resourceLoader) throws IOException,
|
||||||
// TODO - null descriptor and what if indexwriter settings have changed
|
ParserConfigurationException, SAXException {
|
||||||
SolrResourceLoader solrLoader = new SolrResourceLoader(getResourceLoader()
|
// TODO - what if indexwriter settings have changed
|
||||||
.getInstanceDir(), libLoader, CoreContainer.getCoreProps(
|
|
||||||
getResourceLoader().getInstanceDir(),
|
SolrConfig config = new SolrConfig(resourceLoader,
|
||||||
coreDescriptor.getPropertiesName(), coreDescriptor.getCoreProperties()));
|
getSolrConfig().getName(), null);
|
||||||
SolrConfig config = new SolrConfig(solrLoader,
|
|
||||||
coreDescriptor.getConfigName(), null);
|
|
||||||
|
|
||||||
IndexSchema schema = new IndexSchema(config,
|
IndexSchema schema = new IndexSchema(config,
|
||||||
coreDescriptor.getSchemaName(), null);
|
getSchema().getResourceName(), null);
|
||||||
|
|
||||||
updateHandler.incref();
|
updateHandler.incref();
|
||||||
SolrCore core = new SolrCore(coreDescriptor.getName(), null, config,
|
SolrCore core = new SolrCore(getName(), null, config,
|
||||||
schema, coreDescriptor, updateHandler);
|
schema, coreDescriptor, updateHandler);
|
||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.solr.update.DirectUpdateHandler2;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.xml.sax.SAXParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -94,13 +95,14 @@ public class BasicZkTest extends AbstractZkTestCase {
|
||||||
assertU(a, a);
|
assertU(a, a);
|
||||||
}
|
}
|
||||||
assertU(commit());
|
assertU(commit());
|
||||||
|
int zkPort = zkServer.getPort();
|
||||||
|
|
||||||
zkServer.shutdown();
|
zkServer.shutdown();
|
||||||
|
|
||||||
Thread.sleep(300);
|
Thread.sleep(300);
|
||||||
|
|
||||||
// try a reconnect from disconnect
|
// try a reconnect from disconnect
|
||||||
zkServer = new ZkTestServer(zkDir);
|
zkServer = new ZkTestServer(zkDir, zkPort);
|
||||||
zkServer.run();
|
zkServer.run();
|
||||||
|
|
||||||
Thread.sleep(300);
|
Thread.sleep(300);
|
||||||
|
@ -129,6 +131,20 @@ public class BasicZkTest extends AbstractZkTestCase {
|
||||||
assertU(delQ("id:[100 TO 110]"));
|
assertU(delQ("id:[100 TO 110]"));
|
||||||
assertU(commit());
|
assertU(commit());
|
||||||
assertQ(req("id:[100 TO 110]"), "//*[@numFound='0']");
|
assertQ(req("id:[100 TO 110]"), "//*[@numFound='0']");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// SOLR-2651: test that reload still gets config files from zookeeper
|
||||||
|
zkController.getZkClient().setData("/configs/conf1/solrconfig.xml", new byte[0]);
|
||||||
|
|
||||||
|
// we set the solrconfig to nothing, so this reload should fail
|
||||||
|
try {
|
||||||
|
h.getCoreContainer().reload(h.getCore().getName());
|
||||||
|
fail("The reloaded SolrCore did not pick up configs from zookeeper");
|
||||||
|
} catch(SAXParseException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
|
|
@ -124,6 +124,9 @@ public class TestJmxIntegration extends AbstractSolrTestCase {
|
||||||
int oldNumberOfObjects = oldBeans.size();
|
int oldNumberOfObjects = oldBeans.size();
|
||||||
h.getCoreContainer().reload(coreName);
|
h.getCoreContainer().reload(coreName);
|
||||||
|
|
||||||
|
// chill for a moment, so our beans can get ready
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
Set<ObjectInstance> newBeans = mbeanServer.queryMBeans(null, null);
|
Set<ObjectInstance> newBeans = mbeanServer.queryMBeans(null, null);
|
||||||
int newNumberOfObjects = newBeans.size();
|
int newNumberOfObjects = newBeans.size();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue