This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/master by this push:
new 41ddeaaa8 MaintenanceManagementService improvement - Allow
implementation of OperationInterface to return null (#2035)
41ddeaaa8 is described below
commit 41ddeaaa8af4d077865e0d862e5b168ed52eb0cc
Author: xyuanlu <[email protected]>
AuthorDate: Wed Apr 27 15:42:51 2022 -0700
MaintenanceManagementService improvement - Allow implementation of
OperationInterface to return null (#2035)
Allow implementation of OperationInterface to return null
---
.../MaintenanceManagementInstanceInfo.java | 52 ++++++++++++----------
.../helix/rest/server/TestOperationImpl.java | 3 +-
2 files changed, 29 insertions(+), 26 deletions(-)
diff --git
a/helix-rest/src/main/java/org/apache/helix/rest/clusterMaintenanceService/MaintenanceManagementInstanceInfo.java
b/helix-rest/src/main/java/org/apache/helix/rest/clusterMaintenanceService/MaintenanceManagementInstanceInfo.java
index 83b7fbc5f..f8cbec40d 100644
---
a/helix-rest/src/main/java/org/apache/helix/rest/clusterMaintenanceService/MaintenanceManagementInstanceInfo.java
+++
b/helix-rest/src/main/java/org/apache/helix/rest/clusterMaintenanceService/MaintenanceManagementInstanceInfo.java
@@ -30,53 +30,54 @@ public class MaintenanceManagementInstanceInfo {
FAILURE
}
- private String operationResult;
- private OperationalStatus status;
- private List<String> messages;
+ private String _operationResult;
+ private OperationalStatus _status;
+ private List<String> _messages;
public MaintenanceManagementInstanceInfo(OperationalStatus status) {
- this.status = status;
- this.messages = new ArrayList<>();
- this.operationResult = "";
+ this._status = status;
+ this._messages = new ArrayList<>();
+ this._operationResult = "";
}
public MaintenanceManagementInstanceInfo(OperationalStatus status,
List<String> messages) {
- this.status = status;
- this.messages = messages;
- this.operationResult = "";
+ this._status = status;
+ this._messages = messages;
+ this._operationResult = "";
}
public MaintenanceManagementInstanceInfo(OperationalStatus status, String
newOperationResult) {
- this.status = status;
- this.operationResult = newOperationResult;
- this.messages = new ArrayList<>();
+ this._status = status;
+ this._operationResult = newOperationResult;
+ this._messages = new ArrayList<>();
}
public List<String> getMessages() {
- return messages;
+ return _messages;
}
public String getOperationResult() {
- return operationResult;
+ return _operationResult;
}
public boolean hasOperationResult() {
- return !operationResult.isEmpty();
+ return !_operationResult.isEmpty();
}
public void setOperationResult(String result) {
- operationResult = result;
+ _operationResult = result;
}
public void addMessages(List<String> msg) {
- messages.addAll(msg);
+ _messages.addAll(msg);
}
+
public void addMessage(String meg) {
- messages.add(meg);
+ _messages.add(meg);
}
public boolean isSuccessful() {
- return status.equals(OperationalStatus.SUCCESS);
+ return _status.equals(OperationalStatus.SUCCESS);
}
public void mergeResult(MaintenanceManagementInstanceInfo info) {
@@ -84,13 +85,16 @@ public class MaintenanceManagementInstanceInfo {
}
public void mergeResult(MaintenanceManagementInstanceInfo info, boolean
nonBlockingFailure) {
- messages.addAll(info.getMessages());
- status =
- (info.isSuccessful() || nonBlockingFailure) && isSuccessful() ?
OperationalStatus.SUCCESS
+ if (info == null) {
+ return;
+ }
+ _messages.addAll(info.getMessages());
+ _status =
+ ((info.isSuccessful() || nonBlockingFailure) && isSuccessful()) ?
OperationalStatus.SUCCESS
: OperationalStatus.FAILURE;
if (info.hasOperationResult()) {
- operationResult =
- this.hasOperationResult() ? operationResult + "," +
info.getOperationResult()
+ _operationResult =
+ this.hasOperationResult() ? _operationResult + "," +
info.getOperationResult()
: info.getOperationResult();
}
}
diff --git
a/helix-rest/src/test/java/org/apache/helix/rest/server/TestOperationImpl.java
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestOperationImpl.java
index 997b1aa76..d5c42d795 100644
---
a/helix-rest/src/test/java/org/apache/helix/rest/server/TestOperationImpl.java
+++
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestOperationImpl.java
@@ -49,8 +49,7 @@ public class TestOperationImpl implements OperationInterface {
@Override
public MaintenanceManagementInstanceInfo
operationCheckForFreeSingleInstance(String instanceName, Map<String, String>
operationConfig, RestSnapShot sn) {
- return new MaintenanceManagementInstanceInfo(
- MaintenanceManagementInstanceInfo.OperationalStatus.SUCCESS);
+ return null;
}
@Override