mirror of https://github.com/apache/lucene.git
SOLR-722: CoreContainer.reload should make core aliases point to reloaded core
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@689489 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
74a54a431f
commit
6c81041ea4
|
@ -137,6 +137,20 @@ SolrCore.log.info("CORES=" + cores + " : " + cores.getCoreNames());
|
||||||
assertEquals( 1, getSolrCore1().query( new SolrQuery( "id:BBB" ) ).getResults().size() );
|
assertEquals( 1, getSolrCore1().query( new SolrQuery( "id:BBB" ) ).getResults().size() );
|
||||||
assertEquals( 1, getSolrCore("corefoo").query( new SolrQuery( "id:BBB" ) ).getResults().size() );
|
assertEquals( 1, getSolrCore("corefoo").query( new SolrQuery( "id:BBB" ) ).getResults().size() );
|
||||||
|
|
||||||
|
// test that reload affects aliases
|
||||||
|
CoreAdminRequest.reloadCore("core1", coreadmin);
|
||||||
|
|
||||||
|
// this is only an effective test for embedded, where we have
|
||||||
|
// direct access to the core container.
|
||||||
|
SolrCore c1 = cores.getCore("core1");
|
||||||
|
SolrCore c2 = cores.getCore("corefoo");
|
||||||
|
assertTrue(c1 == c2);
|
||||||
|
if (c1 != null) c1.close();
|
||||||
|
if (c2 != null) c2.close();
|
||||||
|
|
||||||
|
// retest core query
|
||||||
|
assertEquals( 1, getSolrCore1().query( new SolrQuery( "id:BBB" ) ).getResults().size() );
|
||||||
|
|
||||||
// test close
|
// test close
|
||||||
CoreAdminRequest.unloadCore("corefoo",coreadmin);
|
CoreAdminRequest.unloadCore("corefoo",coreadmin);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -381,7 +381,17 @@ 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 );
|
||||||
|
|
||||||
register(name, create(core.getCoreDescriptor()), false);
|
SolrCore newCore = create(core.getCoreDescriptor());
|
||||||
|
|
||||||
|
// point all aliases to the reloaded core
|
||||||
|
for (String alias : getCoreNames(core)) {
|
||||||
|
if (!name.equals(alias)) {
|
||||||
|
newCore.open();
|
||||||
|
register(alias, newCore, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
register(name, newCore, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue