Skip to content

Commit

Permalink
Updated toString to name for all InstanceConfigProperty enums.
Browse files Browse the repository at this point in the history
  • Loading branch information
zpinto committed Sep 19, 2023
1 parent 28ecab3 commit fd86b55
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,31 @@ public InstanceConfig(ZNRecord record) {
* @return the host name
*/
public String getHostName() {
return _record.getSimpleField(InstanceConfigProperty.HELIX_HOST.toString());
return _record.getSimpleField(InstanceConfigProperty.HELIX_HOST.name());
}

/**
* Set the host name of the instance
* @param hostName the host name
*/
public void setHostName(String hostName) {
_record.setSimpleField(InstanceConfigProperty.HELIX_HOST.toString(), hostName);
_record.setSimpleField(InstanceConfigProperty.HELIX_HOST.name(), hostName);
}

/**
* Get the port that the instance can be reached at
* @return the port
*/
public String getPort() {
return _record.getSimpleField(InstanceConfigProperty.HELIX_PORT.toString());
return _record.getSimpleField(InstanceConfigProperty.HELIX_PORT.name());
}

/**
* Set the port that the instance can be reached at
* @param port the port
*/
public void setPort(String port) {
_record.setSimpleField(InstanceConfigProperty.HELIX_PORT.toString(), port);
_record.setSimpleField(InstanceConfigProperty.HELIX_PORT.name(), port);
}

/**
Expand Down Expand Up @@ -200,7 +200,7 @@ public void setWeight(int weight) {
* @return a list of tags
*/
public List<String> getTags() {
List<String> tags = getRecord().getListField(InstanceConfigProperty.TAG_LIST.toString());
List<String> tags = getRecord().getListField(InstanceConfigProperty.TAG_LIST.name());
if (tags == null) {
tags = new ArrayList<String>(0);
}
Expand All @@ -212,22 +212,22 @@ public List<String> getTags() {
* @param tag an arbitrary property of the instance
*/
public void addTag(String tag) {
List<String> tags = getRecord().getListField(InstanceConfigProperty.TAG_LIST.toString());
List<String> tags = getRecord().getListField(InstanceConfigProperty.TAG_LIST.name());
if (tags == null) {
tags = new ArrayList<String>(0);
}
if (!tags.contains(tag)) {
tags.add(tag);
}
getRecord().setListField(InstanceConfigProperty.TAG_LIST.toString(), tags);
getRecord().setListField(InstanceConfigProperty.TAG_LIST.name(), tags);
}

/**
* Remove a tag from this instance
* @param tag a property of this instance
*/
public void removeTag(String tag) {
List<String> tags = getRecord().getListField(InstanceConfigProperty.TAG_LIST.toString());
List<String> tags = getRecord().getListField(InstanceConfigProperty.TAG_LIST.name());
if (tags == null) {
return;
}
Expand All @@ -242,7 +242,7 @@ public void removeTag(String tag) {
* @return true if the instance contains the tag, false otherwise
*/
public boolean containsTag(String tag) {
List<String> tags = getRecord().getListField(InstanceConfigProperty.TAG_LIST.toString());
List<String> tags = getRecord().getListField(InstanceConfigProperty.TAG_LIST.name());
if (tags == null) {
return false;
}
Expand All @@ -254,7 +254,7 @@ public boolean containsTag(String tag) {
* @return true if enabled, false if disabled
*/
public boolean getInstanceEnabled() {
return _record.getBooleanField(InstanceConfigProperty.HELIX_ENABLED.toString(),
return _record.getBooleanField(InstanceConfigProperty.HELIX_ENABLED.name(),
HELIX_ENABLED_DEFAULT_VALUE);
}

Expand All @@ -265,7 +265,7 @@ public boolean getInstanceEnabled() {
* @param enabled true to enable, false to disable
*/
public void setInstanceEnabled(boolean enabled) {
_record.setBooleanField(InstanceConfigProperty.HELIX_ENABLED.toString(), enabled);
_record.setBooleanField(InstanceConfigProperty.HELIX_ENABLED.name(), enabled);
_record.setLongField(InstanceConfigProperty.HELIX_ENABLED_TIMESTAMP.name(),
System.currentTimeMillis());
if (enabled) {
Expand All @@ -277,8 +277,8 @@ public void setInstanceEnabled(boolean enabled) {
* Removes HELIX_DISABLED_REASON and HELIX_DISABLED_TYPE entry from simple field.
*/
public void resetInstanceDisabledTypeAndReason() {
_record.getSimpleFields().remove(InstanceConfigProperty.HELIX_DISABLED_REASON.toString());
_record.getSimpleFields().remove(InstanceConfigProperty.HELIX_DISABLED_TYPE.toString());
_record.getSimpleFields().remove(InstanceConfigProperty.HELIX_DISABLED_REASON.name());
_record.getSimpleFields().remove(InstanceConfigProperty.HELIX_DISABLED_TYPE.name());
}

/**
Expand All @@ -287,7 +287,7 @@ public void resetInstanceDisabledTypeAndReason() {
*/
public void setInstanceDisabledReason(String disabledReason) {
if (!getInstanceEnabled()) {
_record.setSimpleField(InstanceConfigProperty.HELIX_DISABLED_REASON.toString(), disabledReason);
_record.setSimpleField(InstanceConfigProperty.HELIX_DISABLED_REASON.name(), disabledReason);
}
}

Expand All @@ -297,16 +297,16 @@ public void setInstanceDisabledReason(String disabledReason) {
*/
public void setInstanceDisabledType(InstanceConstants.InstanceDisabledType disabledType) {
if (!getInstanceEnabled()) {
_record.setSimpleField(InstanceConfigProperty.HELIX_DISABLED_TYPE.toString(),
disabledType.toString());
_record.setSimpleField(InstanceConfigProperty.HELIX_DISABLED_TYPE.name(),
disabledType.name());
}
}

/**
* @return Return instance disabled reason. Default is am empty string.
*/
public String getInstanceDisabledReason() {
return _record.getStringField(InstanceConfigProperty.HELIX_DISABLED_REASON.toString(), "");
return _record.getStringField(InstanceConfigProperty.HELIX_DISABLED_REASON.name(), "");
}

/**
Expand All @@ -318,8 +318,8 @@ public String getInstanceDisabledType() {
if (getInstanceEnabled()) {
return InstanceConstants.INSTANCE_NOT_DISABLED;
}
return _record.getStringField(InstanceConfigProperty.HELIX_DISABLED_TYPE.toString(),
InstanceConstants.InstanceDisabledType.DEFAULT_INSTANCE_DISABLE_TYPE.toString());
return _record.getStringField(InstanceConfigProperty.HELIX_DISABLED_TYPE.name(),
InstanceConstants.InstanceDisabledType.DEFAULT_INSTANCE_DISABLE_TYPE.name());
}

/**
Expand Down Expand Up @@ -456,7 +456,7 @@ public Map<String, List<String>> getDisabledPartitionsMap() {
@Deprecated
public void setInstanceEnabledForPartition(String partitionName, boolean enabled) {
List<String> list =
_record.getListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.toString());
_record.getListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.name());
Set<String> disabledPartitions = new HashSet<String>();
if (list != null) {
disabledPartitions.addAll(list);
Expand All @@ -470,7 +470,7 @@ public void setInstanceEnabledForPartition(String partitionName, boolean enabled

list = new ArrayList<String>(disabledPartitions);
Collections.sort(list);
_record.setListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.toString(), list);
_record.setListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.name(), list);
}

public void setInstanceEnabledForPartition(String resourceName, String partitionName,
Expand Down

0 comments on commit fd86b55

Please sign in to comment.