zhangmeng916 commented on a change in pull request #695: Modify participant
manager to add cluster auto registration logic
URL: https://github.com/apache/helix/pull/695#discussion_r373282881
##########
File path:
helix-core/src/main/java/org/apache/helix/manager/zk/ParticipantManager.java
##########
@@ -132,42 +139,102 @@ public void handleNewSession() throws Exception {
}
private void joinCluster() {
- // Read cluster config and see if instance can auto join the cluster
+ // Read cluster config and see if an instance can auto join or auto
register to the cluster
boolean autoJoin = false;
+ boolean autoRegistration = false;
try {
- HelixConfigScope scope =
- new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(
- _manager.getClusterName()).build();
- autoJoin =
- Boolean.parseBoolean(_configAccessor.get(scope,
- ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN));
+ HelixConfigScope scope = new
HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER)
+ .forCluster(_manager.getClusterName()).build();
+ autoJoin = Boolean
+ .parseBoolean(_configAccessor.get(scope,
ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN));
LOG.info("instance: " + _instanceName + " auto-joining " + _clusterName
+ " is " + autoJoin);
} catch (Exception e) {
// autoJoin is false
}
+ // Read cloud config and see if an instance can auto register to the
cluster
+ try {
+ autoRegistration =
+
Boolean.valueOf(_helixManagerProperty.getHelixCloudProperty().getCloudEnabled());
+ LOG.info("instance: " + _instanceName + " auto-register " + _clusterName
+ " is "
+ + autoRegistration);
+ } catch (Exception e) {
+ // autoRegistration is false
+ }
+
if (!ZKUtil.isInstanceSetup(_zkclient, _clusterName, _instanceName,
_instanceType)) {
if (!autoJoin) {
throw new HelixException("Initial cluster structure is not set up for
instance: "
+ _instanceName + ", instanceType: " + _instanceType);
} else {
- LOG.info(_instanceName + " is auto-joining cluster: " + _clusterName);
- InstanceConfig instanceConfig = new InstanceConfig(_instanceName);
- String hostName = _instanceName;
- String port = "";
- int lastPos = _instanceName.lastIndexOf("_");
- if (lastPos > 0) {
- hostName = _instanceName.substring(0, lastPos);
- port = _instanceName.substring(lastPos + 1);
+ if (!autoRegistration) {
+ LOG.info(_instanceName + " is auto-joining cluster: " +
_clusterName);
+ addInstanceConfig(null);
Review comment:
This is for backward compatibility with current "auto-join" logic. For
"auto-join", it will populate all instance config to Zookeeper except "domain"
information.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]