Skip to content

Commit

Permalink
add remark field to Node Data and TaskInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
flyunrain committed Mar 6, 2023
1 parent 5afc24f commit 7966cfc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class NodeData {
private String transportAddress;
private String host;
private String ip;
private String remark;
private final List<String> roles = new ArrayList<>();
private final Map<String, String> attributes = new HashMap<>();
private final List<TaskInfo> tasks = new ArrayList<>();
Expand Down Expand Up @@ -82,7 +83,13 @@ void setRoles(List<String> roles) {
this.roles.addAll(roles);
}
}
public String getRemark() {
return remark;
}

public void setRemark(String remark) {
this.remark = remark;
}
public String getNodeId() {
return nodeId;
}
Expand Down Expand Up @@ -136,6 +143,9 @@ public String toString() {
+ ", host='"
+ host
+ '\''
+ ", remark='"
+ remark
+ '\''
+ ", ip='"
+ ip
+ '\''
Expand All @@ -156,14 +166,15 @@ public boolean equals(Object o) {
&& Objects.equals(getTransportAddress(), nodeData.getTransportAddress())
&& Objects.equals(getHost(), nodeData.getHost())
&& Objects.equals(getIp(), nodeData.getIp())
&& Objects.equals(getRemark(), nodeData.getRemark())
&& Objects.equals(getRoles(), nodeData.getRoles())
&& Objects.equals(getAttributes(), nodeData.getAttributes())
&& Objects.equals(getTasks(), nodeData.getTasks());
}

@Override
public int hashCode() {
return Objects.hash(getNodeId(), getName(), getTransportAddress(), getHost(), getIp(), getRoles(), getAttributes(), getTasks());
return Objects.hash(getNodeId(), getName(),getRemark(), getTransportAddress(), getHost(), getIp(), getRoles(), getAttributes(), getTasks());
}

public static final ObjectParser.NamedObjectParser<NodeData, Void> PARSER;
Expand All @@ -173,6 +184,7 @@ public int hashCode() {
parser.declareString(NodeData::setName, new ParseField("name"));
parser.declareString(NodeData::setTransportAddress, new ParseField("transport_address"));
parser.declareString(NodeData::setHost, new ParseField("host"));
parser.declareString(NodeData::setRemark, new ParseField("remark"));
parser.declareString(NodeData::setIp, new ParseField("ip"));
parser.declareStringArray(NodeData::setRoles, new ParseField("roles"));
parser.declareField(NodeData::setAttributes, (p, c) -> p.mapStrings(), new ParseField("attributes"), ObjectParser.ValueType.OBJECT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class TaskInfo {
private boolean cancellable;
private boolean cancelled;
private TaskId parentTaskId;
private String remark;
private final Map<String, Object> status = new HashMap<>();
private final Map<String, String> headers = new HashMap<>();
private final Map<String, Object> resourceStats = new HashMap<>();
Expand Down Expand Up @@ -135,6 +136,14 @@ void setParentTaskId(String parentTaskId) {
this.parentTaskId = new TaskId(parentTaskId);
}

public String getRemark() {
return remark;
}

void setRemark(String remark) {
this.remark = remark;
}

public Map<String, String> getHeaders() {
return headers;
}
Expand Down Expand Up @@ -170,6 +179,7 @@ private void noOpParse(Object s) {}
// already provided in constructor: triggering a no-op
parser.declareLong(TaskInfo::noOpParse, new ParseField("id"));
parser.declareString(TaskInfo::setType, new ParseField("type"));
parser.declareString(TaskInfo::setRemark, new ParseField("remark"));
parser.declareString(TaskInfo::setAction, new ParseField("action"));
parser.declareObject(TaskInfo::setStatus, (p, c) -> p.map(), new ParseField("status"));
parser.declareString(TaskInfo::setDescription, new ParseField("description"));
Expand All @@ -196,6 +206,7 @@ && isCancelled() == taskInfo.isCancelled()
&& Objects.equals(getType(), taskInfo.getType())
&& Objects.equals(getAction(), taskInfo.getAction())
&& Objects.equals(getDescription(), taskInfo.getDescription())
&& Objects.equals(getRemark(), taskInfo.getRemark())
&& Objects.equals(getParentTaskId(), taskInfo.getParentTaskId())
&& Objects.equals(status, taskInfo.status)
&& Objects.equals(getHeaders(), taskInfo.getHeaders())
Expand All @@ -213,6 +224,7 @@ public int hashCode() {
getRunningTimeNanos(),
isCancellable(),
isCancelled(),
getRemark(),
getParentTaskId(),
status,
getHeaders(),
Expand All @@ -231,6 +243,8 @@ public String toString() {
+ ", action='"
+ action
+ '\''
+ ", remark='"
+ remark
+ ", description='"
+ description
+ '\''
Expand Down

0 comments on commit 7966cfc

Please sign in to comment.