SOLR-4805,SOLR-4843: SolreCore#reload should not call preRegister and publish a DOWN state to ZooKeeper.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1491310 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-06-09 22:51:21 +00:00
parent 7f90c7f8ea
commit d35702de9a
8 changed files with 50 additions and 22 deletions

View File

@ -124,6 +124,9 @@ Bug Fixes
* SOLR-4891: JsonLoader should preserve field value types from the JSON content stream. * SOLR-4891: JsonLoader should preserve field value types from the JSON content stream.
(Steve Rowe) (Steve Rowe)
* SOLR-4805: SolreCore#reload should not call preRegister and publish a DOWN state to
ZooKeeper. (Mark Miller, Jared Rodriguez)
Other Changes Other Changes
---------------------- ----------------------

View File

@ -1283,11 +1283,7 @@ public final class ZkController {
// before becoming available, make sure we are not live and active // before becoming available, make sure we are not live and active
// this also gets us our assigned shard id if it was not specified // this also gets us our assigned shard id if it was not specified
publish(cd, ZkStateReader.DOWN, false); publish(cd, ZkStateReader.DOWN, false);
// shardState and shardRange are for one-time use only, thereafter the actual values in the Slice should be used
if (Slice.CONSTRUCTION.equals(cd.getCloudDescriptor().getShardState())) {
cd.getCloudDescriptor().setShardState(null);
cd.getCloudDescriptor().setShardRange(null);
}
String coreNodeName = getCoreNodeName(cd); String coreNodeName = getCoreNodeName(cd);
// make sure the node name is set on the descriptor // make sure the node name is set on the descriptor

View File

@ -423,6 +423,9 @@ public class CoreContainer
public SolrCore call() { public SolrCore call() {
SolrCore c = null; SolrCore c = null;
try { try {
if (zkSys.getZkController() != null) {
preRegisterInZk(p);
}
c = create(p); c = create(p);
registerCore(p.isTransient(), name, c, false); registerCore(p.isTransient(), name, c, false);
} catch (Throwable t) { } catch (Throwable t) {
@ -629,22 +632,6 @@ public class CoreContainer
name.indexOf( '\\' ) >= 0 ){ name.indexOf( '\\' ) >= 0 ){
throw new RuntimeException( "Invalid core name: "+name ); throw new RuntimeException( "Invalid core name: "+name );
} }
if (zkSys.getZkController() != null) {
// this happens before we can receive requests
try {
zkSys.getZkController().preRegister(core.getCoreDescriptor());
} catch (KeeperException e) {
log.error("", e);
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
"", e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("", e);
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
"", e);
}
}
SolrCore old = null; SolrCore old = null;
@ -991,6 +978,9 @@ public class CoreContainer
// the wait as a consequence of shutting down. // the wait as a consequence of shutting down.
try { try {
if (core == null) { if (core == null) {
if (zkSys.getZkController() != null) {
preRegisterInZk(desc);
}
core = create(desc); // This should throw an error if it fails. core = create(desc); // This should throw an error if it fails.
core.open(); core.open();
registerCore(desc.isTransient(), name, core, false); registerCore(desc.isTransient(), name, core, false);
@ -1185,6 +1175,21 @@ public class CoreContainer
} }
} }
} }
public void preRegisterInZk(final CoreDescriptor p) {
try {
zkSys.getZkController().preRegister(p);
} catch (KeeperException e) {
log.error("", e);
throw new ZooKeeperException(
SolrException.ErrorCode.SERVER_ERROR, "", e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("", e);
throw new ZooKeeperException(
SolrException.ErrorCode.SERVER_ERROR, "", e);
}
}
public String getSolrHome() { public String getSolrHome() {
return solrHome; return solrHome;

View File

@ -851,6 +851,10 @@ public final class SolrCore implements SolrInfoMBean {
if (cc != null && cc.isZooKeeperAware() && Slice.CONSTRUCTION.equals(cd.getCloudDescriptor().getShardState())) { if (cc != null && cc.isZooKeeperAware() && Slice.CONSTRUCTION.equals(cd.getCloudDescriptor().getShardState())) {
// set update log to buffer before publishing the core // set update log to buffer before publishing the core
getUpdateHandler().getUpdateLog().bufferUpdates(); getUpdateHandler().getUpdateLog().bufferUpdates();
cd.getCloudDescriptor().setShardState(null);
cd.getCloudDescriptor().setShardRange(null);
} }
// For debugging // For debugging
// numOpens.incrementAndGet(); // numOpens.incrementAndGet();

View File

@ -505,7 +505,9 @@ public class CoreAdminHandler extends RequestHandlerBase {
} }
} }
dcore.setCoreProperties(coreProperties); dcore.setCoreProperties(coreProperties);
if (coreContainer.getZkController() != null) {
coreContainer.preRegisterInZk(dcore);
}
SolrCore core = coreContainer.create(dcore); SolrCore core = coreContainer.create(dcore);
coreContainer.register(name, core, false); coreContainer.register(name, core, false);

View File

@ -157,6 +157,10 @@ public class ClusterStateUpdateTest extends SolrTestCaseJ4 {
dcore.setDataDir(dataDir4.getAbsolutePath()); dcore.setDataDir(dataDir4.getAbsolutePath());
if (container1.getZkController() != null) {
container1.preRegisterInZk(dcore);
}
SolrCore core = container1.create(dcore); SolrCore core = container1.create(dcore);
container1.register(core, false); container1.register(core, false);

View File

@ -136,12 +136,21 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
CoreDescriptor dcore1 = new CoreDescriptor(h.getCoreContainer(), "split1", h.getCore().getCoreDescriptor().getInstanceDir()); CoreDescriptor dcore1 = new CoreDescriptor(h.getCoreContainer(), "split1", h.getCore().getCoreDescriptor().getInstanceDir());
dcore1.setDataDir(indexDir1.getAbsolutePath()); dcore1.setDataDir(indexDir1.getAbsolutePath());
dcore1.setSchemaName("schema12.xml"); dcore1.setSchemaName("schema12.xml");
if (h.getCoreContainer().getZkController() != null) {
h.getCoreContainer().preRegisterInZk(dcore1);
}
core1 = h.getCoreContainer().create(dcore1); core1 = h.getCoreContainer().create(dcore1);
h.getCoreContainer().register(core1, false); h.getCoreContainer().register(core1, false);
CoreDescriptor dcore2 = new CoreDescriptor(h.getCoreContainer(), "split2", h.getCore().getCoreDescriptor().getInstanceDir()); CoreDescriptor dcore2 = new CoreDescriptor(h.getCoreContainer(), "split2", h.getCore().getCoreDescriptor().getInstanceDir());
dcore2.setDataDir(indexDir2.getAbsolutePath()); dcore2.setDataDir(indexDir2.getAbsolutePath());
dcore2.setSchemaName("schema12.xml"); dcore2.setSchemaName("schema12.xml");
if (h.getCoreContainer().getZkController() != null) {
h.getCoreContainer().preRegisterInZk(dcore2);
}
core2 = h.getCoreContainer().create(dcore2); core2 = h.getCoreContainer().create(dcore2);
h.getCoreContainer().register(core2, false); h.getCoreContainer().register(core2, false);

View File

@ -207,6 +207,11 @@ public class TestHarness extends BaseTestHarness {
CoreDescriptor dcore = new CoreDescriptor(container, coreName, solrConfig.getResourceLoader().getInstanceDir()); CoreDescriptor dcore = new CoreDescriptor(container, coreName, solrConfig.getResourceLoader().getInstanceDir());
dcore.setConfigName(solrConfig.getResourceName()); dcore.setConfigName(solrConfig.getResourceName());
dcore.setSchemaName(indexSchema.getResourceName()); dcore.setSchemaName(indexSchema.getResourceName());
if (container.getZkController() != null) {
container.preRegisterInZk(dcore);
}
SolrCore core = new SolrCore(coreName, dataDirectory, solrConfig, indexSchema, dcore); SolrCore core = new SolrCore(coreName, dataDirectory, solrConfig, indexSchema, dcore);
container.register(coreName, core, false); container.register(coreName, core, false);