mirror of https://github.com/apache/lucene.git
SOLR-15085 Prevent EmbeddedSolrServer calling shutdown on a CoreContainer that was passed to it
This commit is contained in:
parent
0d4769e174
commit
715caaae52
|
@ -210,6 +210,8 @@ Improvements
|
|||
---------------------
|
||||
* SOLR-15081: Metrics for a core: add SolrCloud "isLeader" and "replicaState". (David Smiley)
|
||||
|
||||
* SOLR-15085: Prevent EmbeddedSolrServer calling shutdown on a CoreContainer that was passed to it. (Tim Owen via Mike Drob)
|
||||
|
||||
Optimizations
|
||||
---------------------
|
||||
* SOLR-15079: Block Collapse - Faster collapse code when groups are co-located via Block Join style nested doc indexing.
|
||||
|
|
|
@ -71,6 +71,7 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
protected final String coreName;
|
||||
private final SolrRequestParsers _parser;
|
||||
private final RequestWriterSupplier supplier;
|
||||
private boolean containerIsLocal = false;
|
||||
|
||||
public enum RequestWriterSupplier {
|
||||
JavaBin(() -> new BinaryRequestWriter()), XML(() -> new RequestWriter());
|
||||
|
@ -94,6 +95,7 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
*/
|
||||
public EmbeddedSolrServer(Path solrHome, String defaultCoreName) {
|
||||
this(load(new CoreContainer(solrHome, new Properties())), defaultCoreName);
|
||||
containerIsLocal = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,6 +106,7 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
*/
|
||||
public EmbeddedSolrServer(NodeConfig nodeConfig, String defaultCoreName) {
|
||||
this(load(new CoreContainer(nodeConfig)), defaultCoreName);
|
||||
containerIsLocal = true;
|
||||
}
|
||||
|
||||
private static CoreContainer load(CoreContainer cc) {
|
||||
|
@ -120,9 +123,6 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
|
||||
/**
|
||||
* Create an EmbeddedSolrServer wrapping a CoreContainer.
|
||||
* <p>
|
||||
* Note that EmbeddedSolrServer will shutdown the wrapped CoreContainer when
|
||||
* {@link #close()} is called.
|
||||
*
|
||||
* @param coreContainer the core container
|
||||
* @param coreName the core to route requests to by default (optional)
|
||||
|
@ -133,8 +133,6 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
|
||||
/**
|
||||
* Create an EmbeddedSolrServer wrapping a CoreContainer.
|
||||
* <p>
|
||||
* Note that EmbeddedSolrServer will shutdown the wrapped CoreContainer when {@link #close()} is called.
|
||||
*
|
||||
* @param coreContainer
|
||||
* the core container
|
||||
|
@ -354,11 +352,13 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
}
|
||||
|
||||
/**
|
||||
* Shutdown all cores within the EmbeddedSolrServer instance
|
||||
* Closes any resources created by this instance
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
coreContainer.shutdown();
|
||||
if (containerIsLocal) {
|
||||
coreContainer.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -955,12 +955,7 @@ public class CoreContainer {
|
|||
name = "localhost";
|
||||
}
|
||||
cloudManager = null;
|
||||
client = new EmbeddedSolrServer(this, null) {
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// do nothing - we close the container ourselves
|
||||
}
|
||||
};
|
||||
client = new EmbeddedSolrServer(this, null);
|
||||
// enable local metrics unless specifically set otherwise
|
||||
initArgs.putIfAbsent(MetricsHistoryHandler.ENABLE_NODES_PROP, true);
|
||||
initArgs.putIfAbsent(MetricsHistoryHandler.ENABLE_REPLICAS_PROP, true);
|
||||
|
|
|
@ -58,13 +58,7 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
|
|||
|
||||
@Override
|
||||
public synchronized EmbeddedSolrServer getSolrClient() {
|
||||
return new EmbeddedSolrServer(h.getCoreContainer(), DEFAULT_CORE_NAME, getRequestWriterSupplier()) {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// do not close core container
|
||||
}
|
||||
};
|
||||
return new EmbeddedSolrServer(h.getCoreContainer(), DEFAULT_CORE_NAME, getRequestWriterSupplier());
|
||||
}
|
||||
|
||||
private static void assertQR(final String fieldName, final String queryValue, final int numFound) {
|
||||
|
|
|
@ -38,6 +38,17 @@ Detailed steps for upgrading a Solr cluster are in the section <<upgrading-a-sol
|
|||
|
||||
If you are upgrading from 7.x, see the section <<Upgrading from 7.x Releases>> below.
|
||||
|
||||
=== Solr 8.9
|
||||
|
||||
See the https://cwiki.apache.org/confluence/display/SOLR/ReleaseNote89[8.9 Release Notes^]
|
||||
for an overview of the main new features of Solr 8.9.
|
||||
|
||||
When upgrading to 8.9.x users should be aware of the following major changes from 8.8.
|
||||
|
||||
*Embedded Solr Server*
|
||||
|
||||
* When using EmbeddedSolrServer, it will no longer close CoreContainer instances that were passed to it.
|
||||
|
||||
=== Solr 8.8
|
||||
|
||||
See the https://cwiki.apache.org/confluence/display/SOLR/ReleaseNote88[8.8 Release Notes^]
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class TestEmbeddedSolrServer extends AbstractEmbeddedSolrServerTestCase {
|
||||
|
||||
@Rule
|
||||
public TestRule solrTestRules =
|
||||
public TestRule solrTestRules =
|
||||
RuleChain.outerRule(new SystemPropertiesRestoreRule());
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
@ -47,24 +47,24 @@ public class TestEmbeddedSolrServer extends AbstractEmbeddedSolrServerTestCase {
|
|||
Assert.assertEquals(cores, ((EmbeddedSolrServer)getSolrCore0()).getCoreContainer());
|
||||
Assert.assertEquals(cores, (getSolrCore1()).getCoreContainer());
|
||||
}
|
||||
|
||||
|
||||
public void testClose() throws IOException {
|
||||
|
||||
|
||||
EmbeddedSolrServer solrServer = (EmbeddedSolrServer) getSolrCore0();
|
||||
|
||||
|
||||
Assert.assertEquals(3, cores.getCores().size());
|
||||
List<SolrCore> solrCores = new ArrayList<>();
|
||||
for (SolrCore solrCore : cores.getCores()) {
|
||||
Assert.assertEquals(false, solrCore.isClosed());
|
||||
solrCores.add(solrCore);
|
||||
}
|
||||
|
||||
|
||||
solrServer.close();
|
||||
|
||||
Assert.assertEquals(0, cores.getCores().size());
|
||||
|
||||
|
||||
Assert.assertEquals(3, cores.getCores().size());
|
||||
|
||||
for (SolrCore solrCore : solrCores) {
|
||||
Assert.assertEquals(true, solrCore.isClosed());
|
||||
Assert.assertEquals(false, solrCore.isClosed());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,12 +75,7 @@ public class DirectJsonQueryRequestFacetingEmbeddedTest extends EmbeddedSolrServ
|
|||
final String schema = tempSolrHome.getAbsolutePath() + "/" + COLLECTION_NAME + "/conf/managed-schema";
|
||||
initCore(config, schema, tempSolrHome.getAbsolutePath(), COLLECTION_NAME);
|
||||
|
||||
client = new EmbeddedSolrServer(h.getCoreContainer(), COLLECTION_NAME) {
|
||||
@Override
|
||||
public void close() {
|
||||
// do not close core container
|
||||
}
|
||||
};
|
||||
client = new EmbeddedSolrServer(h.getCoreContainer(), COLLECTION_NAME);
|
||||
|
||||
ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
|
||||
up.setParam("collection", COLLECTION_NAME);
|
||||
|
|
|
@ -72,12 +72,7 @@ abstract public class EmbeddedSolrServerTestBase extends SolrTestCaseJ4 {
|
|||
* Create a new solr client. Subclasses should override for other options.
|
||||
*/
|
||||
public EmbeddedSolrServer createNewSolrClient() {
|
||||
return new EmbeddedSolrServer(h.getCoreContainer(), DEFAULT_CORE_NAME) {
|
||||
@Override
|
||||
public void close() {
|
||||
// do not close core container
|
||||
}
|
||||
};
|
||||
return new EmbeddedSolrServer(h.getCoreContainer(), DEFAULT_CORE_NAME);
|
||||
}
|
||||
|
||||
public void upload(final String collection, final ContentStream... contents) {
|
||||
|
|
Loading…
Reference in New Issue