14
14
import org .elasticsearch .action .support .tasks .BaseTasksResponse ;
15
15
import org .elasticsearch .common .io .stream .StreamInput ;
16
16
import org .elasticsearch .common .io .stream .StreamOutput ;
17
+ import org .elasticsearch .common .io .stream .Writeable ;
17
18
import org .elasticsearch .common .unit .ByteSizeUnit ;
18
19
import org .elasticsearch .common .unit .ByteSizeValue ;
19
20
import org .elasticsearch .common .unit .TimeValue ;
20
21
import org .elasticsearch .common .xcontent .ToXContentObject ;
21
22
import org .elasticsearch .common .xcontent .XContentBuilder ;
23
+ import org .elasticsearch .index .shard .ShardId ;
22
24
import org .elasticsearch .tasks .Task ;
23
25
24
26
import java .io .IOException ;
@@ -45,7 +47,7 @@ public TasksResponse newResponse() {
45
47
46
48
public static class TasksResponse extends BaseTasksResponse implements ToXContentObject {
47
49
48
- private final List <TransportCcrStatsAction . TaskResponse > taskResponses ;
50
+ private final List <TaskResponse > taskResponses ;
49
51
50
52
public TasksResponse () {
51
53
this (Collections .emptyList (), Collections .emptyList (), Collections .emptyList ());
@@ -54,25 +56,25 @@ public TasksResponse() {
54
56
TasksResponse (
55
57
final List <TaskOperationFailure > taskFailures ,
56
58
final List <? extends FailedNodeException > nodeFailures ,
57
- final List <TransportCcrStatsAction . TaskResponse > taskResponses ) {
59
+ final List <TaskResponse > taskResponses ) {
58
60
super (taskFailures , nodeFailures );
59
61
this .taskResponses = taskResponses ;
60
62
}
61
63
62
64
@ Override
63
65
public XContentBuilder toXContent (final XContentBuilder builder , final Params params ) throws IOException {
64
- final Map <String , Map <Integer , TransportCcrStatsAction . TaskResponse >> taskResponsesByIndex = new TreeMap <>();
65
- for (final TransportCcrStatsAction . TaskResponse taskResponse : taskResponses ) {
66
+ final Map <String , Map <Integer , TaskResponse >> taskResponsesByIndex = new TreeMap <>();
67
+ for (final TaskResponse taskResponse : taskResponses ) {
66
68
taskResponsesByIndex .computeIfAbsent (
67
69
taskResponse .followerShardId ().getIndexName (),
68
70
k -> new TreeMap <>()).put (taskResponse .followerShardId ().getId (), taskResponse );
69
71
}
70
72
builder .startObject ();
71
73
{
72
- for (final Map .Entry <String , Map <Integer , TransportCcrStatsAction . TaskResponse >> index : taskResponsesByIndex .entrySet ()) {
74
+ for (final Map .Entry <String , Map <Integer , TaskResponse >> index : taskResponsesByIndex .entrySet ()) {
73
75
builder .startObject (index .getKey ());
74
76
{
75
- for (final Map .Entry <Integer , TransportCcrStatsAction . TaskResponse > shard : index .getValue ().entrySet ()) {
77
+ for (final Map .Entry <Integer , TaskResponse > shard : index .getValue ().entrySet ()) {
76
78
builder .startObject (Integer .toString (shard .getKey ()));
77
79
{
78
80
final ShardFollowNodeTask .Status status = shard .getValue ().status ();
@@ -153,4 +155,36 @@ public void writeTo(StreamOutput out) throws IOException {
153
155
}
154
156
155
157
158
+ public static class TaskResponse implements Writeable {
159
+
160
+ private final ShardId followerShardId ;
161
+
162
+ ShardId followerShardId () {
163
+ return followerShardId ;
164
+ }
165
+
166
+ private final ShardFollowNodeTask .Status status ;
167
+
168
+ ShardFollowNodeTask .Status status () {
169
+ return status ;
170
+ }
171
+
172
+ TaskResponse (final ShardId followerShardId , final ShardFollowNodeTask .Status status ) {
173
+ this .followerShardId = followerShardId ;
174
+ this .status = status ;
175
+ }
176
+
177
+ TaskResponse (final StreamInput in ) throws IOException {
178
+ this .followerShardId = ShardId .readShardId (in );
179
+ this .status = new ShardFollowNodeTask .Status (in );
180
+ }
181
+
182
+ @ Override
183
+ public void writeTo (final StreamOutput out ) throws IOException {
184
+ followerShardId .writeTo (out );
185
+ status .writeTo (out );
186
+ }
187
+
188
+ }
189
+
156
190
}
0 commit comments