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_r373587419
##########
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 {
Review comment:
The logic is only when an instance is not setup, we will check auto join, if
auto join is false, an exception will be thrown since no one will add instance,
if auto join is true, we will continue to check auto registration, and decide
whether we do auto join or auto registration. This is also for the backward
compatibility.
----------------------------------------------------------------
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]