Skip to content

Commit

Permalink
Add clarifying comments and use CONCATENATE_CONFIG_JOINER constant in…
Browse files Browse the repository at this point in the history
… ConfigStringUtil to check if FAULT_DOMAIN is complete or needs to have _instanceName added instead of hardcoding '='.
  • Loading branch information
zpinto committed Sep 20, 2023
1 parent eeec32e commit 1408f3a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

import com.google.common.collect.ImmutableMap;

/**
* Generic interface for cloud instance information which builds on top of CloudInstanceInformation.
* This interface adds a new method, getAll(), which returns all the key value pairs of a specific cloud instance.
* We call suffix the name of this interface with V2 to preserve backwards compatibility for all classes
* that implement CloudInstanceInformation.
*/
public interface CloudInstanceInformationV2 extends CloudInstanceInformation {
/**
* Get all the key value pairs of a specific cloud instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.apache.helix.participant.statemachine.StateModelFactory;
import org.apache.helix.task.TaskConstants;
import org.apache.helix.task.TaskUtil;
import org.apache.helix.util.ConfigStringUtil;
import org.apache.helix.zookeeper.api.client.RealmAwareZkClient;
import org.apache.helix.zookeeper.datamodel.ZNRecord;
import org.apache.helix.zookeeper.datamodel.ZNRecordBucketizer;
Expand Down Expand Up @@ -231,8 +232,13 @@ private void joinCluster() {
String cloudInstanceInformationFaultDomain = cloudInstanceInformation.get(
CloudInstanceInformation.CloudInstanceField.FAULT_DOMAIN.name());
instanceConfig = instanceConfigBuilder.setDomain(
cloudInstanceInformationFaultDomain.endsWith("=") ? cloudInstanceInformationFaultDomain
+ _instanceName : cloudInstanceInformationFaultDomain).build(_instanceName);
// Previously, the FAULT_DOMAIN was expected to end with the final DOMAIN field key without a value,
// like "rack=25, host=" or "cabinet=A, rack=25, host=". This is because ParticipantManager would append
// the _instanceName to populate the value. This check has been added to preserve backwards compatibility
// while also allowing the auto-registration to construct the full DOMAIN which includes the last value.
cloudInstanceInformationFaultDomain.endsWith(ConfigStringUtil.CONCATENATE_CONFIG_JOINER)
? cloudInstanceInformationFaultDomain + _instanceName
: cloudInstanceInformationFaultDomain).build(_instanceName);
}
instanceConfig.validateTopologySettingInInstanceConfig(
_configAccessor.getClusterConfig(_clusterName), _instanceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public final class ConfigStringUtil {
private static final String CONCATENATE_CONFIG_SPLITTER = ",";
private static final String CONCATENATE_CONFIG_JOINER = "=";
public static final String CONCATENATE_CONFIG_JOINER = "=";

private ConfigStringUtil() {
throw new java.lang.UnsupportedOperationException(
Expand Down

0 comments on commit 1408f3a

Please sign in to comment.