@@ -60,31 +60,39 @@ public enum Stage {
60
60
private final AtomicReference <Stage > stage ;
61
61
private long startTime ;
62
62
private long totalTime ;
63
- private int numberOfFiles ;
63
+ private int differenceOfNumberOfFiles ;
64
+ private int totalNumberOfFiles ;
64
65
private int processedFiles ;
65
66
private long totalSize ;
67
+ private long differenceOfSize ;
66
68
private long processedSize ;
67
69
private long indexVersion ;
68
70
private String failure ;
69
71
70
72
private IndexShardSnapshotStatus (final Stage stage , final long startTime , final long totalTime ,
71
- final int numberOfFiles , final int processedFiles , final long totalSize , final long processedSize ,
73
+ final int differenceOfNumberOfFiles , final int totalNumberOfFiles , final int processedFiles ,
74
+ final long differenceOfSize , final long totalSize , final long processedSize ,
72
75
final long indexVersion , final String failure ) {
73
76
this .stage = new AtomicReference <>(Objects .requireNonNull (stage ));
74
77
this .startTime = startTime ;
75
78
this .totalTime = totalTime ;
76
- this .numberOfFiles = numberOfFiles ;
79
+ this .differenceOfNumberOfFiles = differenceOfNumberOfFiles ;
80
+ this .totalNumberOfFiles = totalNumberOfFiles ;
77
81
this .processedFiles = processedFiles ;
78
82
this .totalSize = totalSize ;
79
83
this .processedSize = processedSize ;
84
+ this .differenceOfSize = differenceOfSize ;
80
85
this .indexVersion = indexVersion ;
81
86
this .failure = failure ;
82
87
}
83
88
84
- public synchronized Copy moveToStarted (final long startTime , final int numberOfFiles , final long totalSize ) {
89
+ public synchronized Copy moveToStarted (final long startTime , final int differenceOfNumberOfFiles , final int numberOfFiles ,
90
+ final long diffSize , final long totalSize ) {
85
91
if (stage .compareAndSet (Stage .INIT , Stage .STARTED )) {
86
92
this .startTime = startTime ;
87
- this .numberOfFiles = numberOfFiles ;
93
+ this .differenceOfNumberOfFiles = differenceOfNumberOfFiles ;
94
+ this .totalNumberOfFiles = numberOfFiles ;
95
+ this .differenceOfSize = diffSize ;
88
96
this .totalSize = totalSize ;
89
97
} else {
90
98
throw new IllegalStateException ("Unable to move the shard snapshot status to [STARTED]: " +
@@ -146,25 +154,30 @@ public synchronized void addProcessedFile(long size) {
146
154
* @return a {@link IndexShardSnapshotStatus.Copy}
147
155
*/
148
156
public synchronized IndexShardSnapshotStatus .Copy asCopy () {
149
- return new IndexShardSnapshotStatus .Copy (stage .get (), startTime , totalTime , numberOfFiles , processedFiles , totalSize , processedSize ,
150
- indexVersion , failure );
157
+ return new IndexShardSnapshotStatus .Copy (stage .get (), startTime , totalTime ,
158
+ differenceOfNumberOfFiles , totalNumberOfFiles , processedFiles ,
159
+ differenceOfSize , totalSize , processedSize ,
160
+ indexVersion , failure );
151
161
}
152
162
153
163
public static IndexShardSnapshotStatus newInitializing () {
154
- return new IndexShardSnapshotStatus (Stage .INIT , 0L , 0L , 0 , 0 , 0 , 0 , 0 , null );
164
+ return new IndexShardSnapshotStatus (Stage .INIT , 0L , 0L , 0 , 0 , 0 , 0 , 0 , 0 , 0 , null );
155
165
}
156
166
157
167
public static IndexShardSnapshotStatus newFailed (final String failure ) {
158
168
assert failure != null : "expecting non null failure for a failed IndexShardSnapshotStatus" ;
159
169
if (failure == null ) {
160
170
throw new IllegalArgumentException ("A failure description is required for a failed IndexShardSnapshotStatus" );
161
171
}
162
- return new IndexShardSnapshotStatus (Stage .FAILURE , 0L , 0L , 0 , 0 , 0 , 0 , 0 , failure );
172
+ return new IndexShardSnapshotStatus (Stage .FAILURE , 0L , 0L , 0 , 0 , 0 , 0 , 0 , 0 , 0 , failure );
163
173
}
164
174
165
- public static IndexShardSnapshotStatus newDone (final long startTime , final long totalTime , final int files , final long size ) {
175
+ public static IndexShardSnapshotStatus newDone (final long startTime , final long totalTime ,
176
+ final int differenceOfNumberOfFiles , final int files ,
177
+ final long differenceOfSize , final long size ) {
166
178
// The snapshot is done which means the number of processed files is the same as total
167
- return new IndexShardSnapshotStatus (Stage .DONE , startTime , totalTime , files , files , size , size , 0 , null );
179
+ return new IndexShardSnapshotStatus (Stage .DONE , startTime , totalTime , differenceOfNumberOfFiles , files , differenceOfNumberOfFiles ,
180
+ differenceOfSize , size , differenceOfSize , 0 , null );
168
181
}
169
182
170
183
/**
@@ -175,23 +188,28 @@ public static class Copy {
175
188
private final Stage stage ;
176
189
private final long startTime ;
177
190
private final long totalTime ;
178
- private final int numberOfFiles ;
191
+ private final int differenceOfNumberOfFiles ;
192
+ private final int totalNumberOfFiles ;
179
193
private final int processedFiles ;
180
194
private final long totalSize ;
181
195
private final long processedSize ;
196
+ private final long differenceOfSize ;
182
197
private final long indexVersion ;
183
198
private final String failure ;
184
199
185
200
public Copy (final Stage stage , final long startTime , final long totalTime ,
186
- final int numberOfFiles , final int processedFiles , final long totalSize , final long processedSize ,
201
+ final int differenceOfNumberOfFiles , final int totalNumberOfFiles , final int processedFiles ,
202
+ final long differenceOfSize , final long totalSize , final long processedSize ,
187
203
final long indexVersion , final String failure ) {
188
204
this .stage = stage ;
189
205
this .startTime = startTime ;
190
206
this .totalTime = totalTime ;
191
- this .numberOfFiles = numberOfFiles ;
207
+ this .differenceOfNumberOfFiles = differenceOfNumberOfFiles ;
208
+ this .totalNumberOfFiles = totalNumberOfFiles ;
192
209
this .processedFiles = processedFiles ;
193
210
this .totalSize = totalSize ;
194
211
this .processedSize = processedSize ;
212
+ this .differenceOfSize = differenceOfSize ;
195
213
this .indexVersion = indexVersion ;
196
214
this .failure = failure ;
197
215
}
@@ -208,14 +226,22 @@ public long getTotalTime() {
208
226
return totalTime ;
209
227
}
210
228
211
- public int getNumberOfFiles () {
212
- return numberOfFiles ;
229
+ public int getDifferenceOfNumberOfFiles () {
230
+ return differenceOfNumberOfFiles ;
231
+ }
232
+
233
+ public int getTotalNumberOfFiles () {
234
+ return totalNumberOfFiles ;
213
235
}
214
236
215
237
public int getProcessedFiles () {
216
238
return processedFiles ;
217
239
}
218
240
241
+ public long getDifferenceOfSize () {
242
+ return differenceOfSize ;
243
+ }
244
+
219
245
public long getTotalSize () {
220
246
return totalSize ;
221
247
}
@@ -238,8 +264,10 @@ public String toString() {
238
264
"stage=" + stage +
239
265
", startTime=" + startTime +
240
266
", totalTime=" + totalTime +
241
- ", numberOfFiles=" + numberOfFiles +
267
+ ", differenceOfNumberOfFiles=" + differenceOfNumberOfFiles +
268
+ ", totalNumberOfFiles=" + totalNumberOfFiles +
242
269
", processedFiles=" + processedFiles +
270
+ ", differenceOfSize=" + differenceOfSize +
243
271
", totalSize=" + totalSize +
244
272
", processedSize=" + processedSize +
245
273
", indexVersion=" + indexVersion +
0 commit comments