Skip to content

Commit 26df079

Browse files
author
gitlab
committed
Merge branch 'fix/ZSTAC-82318' into '5.5.12'
<feature>[longjob]: standardize LongJob progress detail format See merge request zstackio/zstack!9308
2 parents c1f6673 + cb554df commit 26df079

9 files changed

Lines changed: 544 additions & 1 deletion

File tree

core/src/main/java/org/zstack/core/progress/ProgressReportService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ private TaskProgressInventory inventory(TaskProgressVO vo) {
225225
if (!StringUtils.isEmpty(vo.getArguments())) {
226226
inv.setArguments(vo.getArguments());
227227
}
228+
229+
inv.setProgressDetail(LongJobProgressDetailBuilder.fromTaskProgressVO(vo));
230+
228231
return inv;
229232
}
230233

header/src/main/java/org/zstack/header/core/progress/APIGetTaskProgressReply.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.List;
77
import static java.util.Arrays.asList;
88

9+
910
/**
1011
* Created by xing5 on 2017/3/21.
1112
*/
@@ -29,6 +30,17 @@ public static APIGetTaskProgressReply __example__() {
2930
inv.setTaskUuid("931102503f64436ea649939ff3957406");
3031
inv.setTime(DocUtils.date);
3132
inv.setType("Task");
33+
34+
LongJobProgressDetail detail = new LongJobProgressDetail();
35+
detail.setPercent(42);
36+
detail.setStage("downloading");
37+
detail.setState("running");
38+
detail.setProcessedBytes(440401920L);
39+
detail.setTotalBytes(1073741824L);
40+
detail.setSpeedBytesPerSecond(10485760L);
41+
detail.setEstimatedRemainingSeconds(60L);
42+
inv.setProgressDetail(detail);
43+
3244
msg.setInventories(asList(inv));
3345
return msg;
3446
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
package org.zstack.header.core.progress;
2+
3+
import java.util.Map;
4+
5+
/**
6+
* Standardized LongJob progress detail, parsed from TaskProgressVO.opaque.
7+
*
8+
* All fields are optional (nullable). Callers should null-check before use.
9+
* This is a pure read-only view — the database schema (TaskProgressVO) is unchanged.
10+
*/
11+
public class LongJobProgressDetail {
12+
/** Progress percentage 0-100, if known. */
13+
private Integer percent;
14+
15+
/** Human-readable stage label, e.g. "downloading", "extracting". */
16+
private String stage;
17+
18+
/** State identifier, e.g. "running", "paused". */
19+
private String state;
20+
21+
/** Human-readable reason for current state. */
22+
private String stateReason;
23+
24+
/** Bytes already processed. */
25+
private Long processedBytes;
26+
27+
/** Total bytes to process. */
28+
private Long totalBytes;
29+
30+
/** Items already processed (e.g. files, chunks). */
31+
private Long processedItems;
32+
33+
/** Total items to process. */
34+
private Long totalItems;
35+
36+
/** Transfer speed in bytes/s. */
37+
private Long speedBytesPerSecond;
38+
39+
/** Estimated remaining time in seconds. */
40+
private Long estimatedRemainingSeconds;
41+
42+
/**
43+
* Catch-all for any opaque fields that don't map to the standard schema.
44+
* Preserves unknown keys so no data is silently dropped.
45+
*/
46+
private Map<String, Object> extra;
47+
48+
public Integer getPercent() {
49+
return percent;
50+
}
51+
52+
public void setPercent(Integer percent) {
53+
this.percent = percent;
54+
}
55+
56+
public String getStage() {
57+
return stage;
58+
}
59+
60+
public void setStage(String stage) {
61+
this.stage = stage;
62+
}
63+
64+
public String getState() {
65+
return state;
66+
}
67+
68+
public void setState(String state) {
69+
this.state = state;
70+
}
71+
72+
public String getStateReason() {
73+
return stateReason;
74+
}
75+
76+
public void setStateReason(String stateReason) {
77+
this.stateReason = stateReason;
78+
}
79+
80+
public Long getProcessedBytes() {
81+
return processedBytes;
82+
}
83+
84+
public void setProcessedBytes(Long processedBytes) {
85+
this.processedBytes = processedBytes;
86+
}
87+
88+
public Long getTotalBytes() {
89+
return totalBytes;
90+
}
91+
92+
public void setTotalBytes(Long totalBytes) {
93+
this.totalBytes = totalBytes;
94+
}
95+
96+
public Long getProcessedItems() {
97+
return processedItems;
98+
}
99+
100+
public void setProcessedItems(Long processedItems) {
101+
this.processedItems = processedItems;
102+
}
103+
104+
public Long getTotalItems() {
105+
return totalItems;
106+
}
107+
108+
public void setTotalItems(Long totalItems) {
109+
this.totalItems = totalItems;
110+
}
111+
112+
public Long getSpeedBytesPerSecond() {
113+
return speedBytesPerSecond;
114+
}
115+
116+
public void setSpeedBytesPerSecond(Long speedBytesPerSecond) {
117+
this.speedBytesPerSecond = speedBytesPerSecond;
118+
}
119+
120+
public Long getEstimatedRemainingSeconds() {
121+
return estimatedRemainingSeconds;
122+
}
123+
124+
public void setEstimatedRemainingSeconds(Long estimatedRemainingSeconds) {
125+
this.estimatedRemainingSeconds = estimatedRemainingSeconds;
126+
}
127+
128+
public Map<String, Object> getExtra() {
129+
return extra;
130+
}
131+
132+
public void setExtra(Map<String, Object> extra) {
133+
this.extra = extra;
134+
}
135+
}

0 commit comments

Comments
 (0)