Skip to content

Commit

Permalink
Incorporate feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
zpinto committed Jan 18, 2025
1 parent 5485375 commit ec96370
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
* Instance configurations
*/
public class InstanceConfig extends HelixProperty {
private static final Logger logger = LoggerFactory.getLogger(InstanceConfig.class.getName());

/**
* Configurable characteristics of an instance
*/
Expand All @@ -75,6 +77,8 @@ public enum InstanceConfigProperty {
}

public static class InstanceOperation {
private static final String DEFAULT_INSTANCE_OPERATION_SOURCE =
InstanceConstants.InstanceOperationSource.USER.name();
private final Map<String, String> _properties;

private enum InstanceOperationProperties {
Expand Down Expand Up @@ -115,7 +119,11 @@ public Builder setOperation(@Nullable InstanceConstants.InstanceOperation operat
* @param reason the reason for this instance operation.
*/
public Builder setReason(String reason) {
_properties.put(InstanceOperationProperties.REASON.name(), reason != null ? reason : "");
if (reason == null) {
logger.error("Reason cannot be set to null. Skipped setting the field.");
return this;
}
_properties.put(InstanceOperationProperties.REASON.name(), reason);
return this;
}

Expand All @@ -127,7 +135,7 @@ public Builder setReason(String reason) {
*/
public Builder setSource(InstanceConstants.InstanceOperationSource source) {
_properties.put(InstanceOperationProperties.SOURCE.name(),
source == null ? InstanceConstants.InstanceOperationSource.USER.name() : source.name());
source == null ? DEFAULT_INSTANCE_OPERATION_SOURCE : source.name());
return this;
}

Expand All @@ -140,6 +148,7 @@ public Builder setSource(InstanceConstants.InstanceOperationSource source) {
*/
private Builder setLegacyDisabledType(InstanceConstants.InstanceDisabledType disabledType) {
if (disabledType == null) {
logger.error("LEGACY_DISABLED_TYPE cannot be set to null. Skipped setting the field.");
return this;
}
_properties.put(InstanceOperationProperties.LEGACY_DISABLED_TYPE.name(),
Expand All @@ -153,7 +162,7 @@ public InstanceOperation build() throws IllegalArgumentException {
"Instance operation type is not set, this is a required field.");
}
_properties.putIfAbsent(InstanceOperationProperties.SOURCE.name(),
InstanceConstants.InstanceOperationSource.USER.name());
DEFAULT_INSTANCE_OPERATION_SOURCE);
_properties.put(InstanceOperationProperties.TIMESTAMP.name(),
String.valueOf(System.currentTimeMillis()));
return new InstanceOperation(_properties);
Expand Down

0 comments on commit ec96370

Please sign in to comment.