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:
Yonik Seeley 2008-08-27 14:20:40 +00:00
parent 74a54a431f
commit 6c81041ea4
2 changed files with 25 additions and 1 deletions

View File

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

View File

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