protected SolrCore registerCore(String name, SolrCore core, boolean registerInZk) { if (core == null) { throw new RuntimeException("Can not register a null core."); } // We can register a core when creating them via the admin UI, so we need to ensure that the // dynamic descriptors // are up to date CoreDescriptor cd = core.getCoreDescriptor(); if ((cd.isTransient() || !cd.isLoadOnStartup()) && solrCores.getDynamicDescriptor(name) == null) { // Store it away for later use. includes non-transient but not // loaded at startup cores. solrCores.putDynamicDescriptor(name, cd); } SolrCore old; if (isShutDown) { core.close(); throw new IllegalStateException("This CoreContainer has been closed"); } if (cd.isTransient()) { old = solrCores.putTransientCore(cfg, name, core, loader); } else { old = solrCores.putCore(name, core); } /* * set both the name of the descriptor and the name of the * core, since the descriptors name is used for persisting. */ core.setName(name); coreInitFailures.remove(name); if (old == null || old == core) { log.info("registering core: " + name); if (registerInZk) { zkSys.registerInZk(core, false); } return null; } else { log.info("replacing core: " + name); old.close(); if (registerInZk) { zkSys.registerInZk(core, false); } return old; } }