8
8
9
9
import org .elasticsearch .Version ;
10
10
import org .elasticsearch .common .ParseField ;
11
+ import org .elasticsearch .common .Strings ;
11
12
import org .elasticsearch .common .io .stream .StreamInput ;
12
13
import org .elasticsearch .common .io .stream .StreamOutput ;
13
14
import org .elasticsearch .common .xcontent .ConstructingObjectParser ;
@@ -36,23 +37,34 @@ public class TransformIndexerStats extends IndexerJobStats {
36
37
public static ParseField SEARCH_TOTAL = new ParseField ("search_total" );
37
38
public static ParseField SEARCH_FAILURES = new ParseField ("search_failures" );
38
39
public static ParseField INDEX_FAILURES = new ParseField ("index_failures" );
39
- public static ParseField EXPONENTIAL_AVG_CHECKPOINT_DURATION_MS =
40
- new ParseField ("exponential_avg_checkpoint_duration_ms" );
41
- public static ParseField EXPONENTIAL_AVG_DOCUMENTS_INDEXED =
42
- new ParseField ("exponential_avg_documents_indexed" );
43
- public static ParseField EXPONENTIAL_AVG_DOCUMENTS_PROCESSED =
44
- new ParseField ("exponential_avg_documents_processed" );
40
+ public static ParseField EXPONENTIAL_AVG_CHECKPOINT_DURATION_MS = new ParseField ("exponential_avg_checkpoint_duration_ms" );
41
+ public static ParseField EXPONENTIAL_AVG_DOCUMENTS_INDEXED = new ParseField ("exponential_avg_documents_indexed" );
42
+ public static ParseField EXPONENTIAL_AVG_DOCUMENTS_PROCESSED = new ParseField ("exponential_avg_documents_processed" );
45
43
46
44
// This changes how much "weight" past calculations have.
47
45
// The shorter the window, the less "smoothing" will occur.
48
46
private static final int EXP_AVG_WINDOW = 10 ;
49
- private static final double ALPHA = 2.0 / (EXP_AVG_WINDOW + 1 );
47
+ private static final double ALPHA = 2.0 / (EXP_AVG_WINDOW + 1 );
50
48
51
49
private static final ConstructingObjectParser <TransformIndexerStats , Void > LENIENT_PARSER = new ConstructingObjectParser <>(
52
- NAME , true ,
53
- args -> new TransformIndexerStats (
54
- (long ) args [0 ], (long ) args [1 ], (long ) args [2 ], (long ) args [3 ], (long ) args [4 ], (long ) args [5 ], (long ) args [6 ],
55
- (long ) args [7 ], (long ) args [8 ], (long ) args [9 ], (Double ) args [10 ], (Double ) args [11 ], (Double ) args [12 ]));
50
+ NAME ,
51
+ true ,
52
+ args -> new TransformIndexerStats (
53
+ (long ) args [0 ],
54
+ (long ) args [1 ],
55
+ (long ) args [2 ],
56
+ (long ) args [3 ],
57
+ (long ) args [4 ],
58
+ (long ) args [5 ],
59
+ (long ) args [6 ],
60
+ (long ) args [7 ],
61
+ (long ) args [8 ],
62
+ (long ) args [9 ],
63
+ (Double ) args [10 ],
64
+ (Double ) args [11 ],
65
+ (Double ) args [12 ]
66
+ )
67
+ );
56
68
57
69
static {
58
70
LENIENT_PARSER .declareLong (constructorArg (), NUM_PAGES );
@@ -73,37 +85,62 @@ public class TransformIndexerStats extends IndexerJobStats {
73
85
private double expAvgCheckpointDurationMs ;
74
86
private double expAvgDocumentsIndexed ;
75
87
private double expAvgDocumentsProcessed ;
88
+
76
89
/**
77
90
* Create with all stats set to zero
78
91
*/
79
92
public TransformIndexerStats () {
80
93
super ();
81
94
}
82
95
83
- public TransformIndexerStats (long numPages , long numInputDocuments , long numOutputDocuments ,
84
- long numInvocations , long indexTime , long searchTime , long indexTotal , long searchTotal ,
85
- long indexFailures , long searchFailures , Double expAvgCheckpointDurationMs ,
86
- Double expAvgDocumentsIndexed , Double expAvgDocumentsProcessed ) {
87
- super (numPages , numInputDocuments , numOutputDocuments , numInvocations , indexTime , searchTime , indexTotal , searchTotal ,
88
- indexFailures , searchFailures );
96
+ public TransformIndexerStats (
97
+ long numPages ,
98
+ long numInputDocuments ,
99
+ long numOutputDocuments ,
100
+ long numInvocations ,
101
+ long indexTime ,
102
+ long searchTime ,
103
+ long indexTotal ,
104
+ long searchTotal ,
105
+ long indexFailures ,
106
+ long searchFailures ,
107
+ Double expAvgCheckpointDurationMs ,
108
+ Double expAvgDocumentsIndexed ,
109
+ Double expAvgDocumentsProcessed
110
+ ) {
111
+ super (
112
+ numPages ,
113
+ numInputDocuments ,
114
+ numOutputDocuments ,
115
+ numInvocations ,
116
+ indexTime ,
117
+ searchTime ,
118
+ indexTotal ,
119
+ searchTotal ,
120
+ indexFailures ,
121
+ searchFailures
122
+ );
89
123
this .expAvgCheckpointDurationMs = expAvgCheckpointDurationMs == null ? 0.0 : expAvgCheckpointDurationMs ;
90
124
this .expAvgDocumentsIndexed = expAvgDocumentsIndexed == null ? 0.0 : expAvgDocumentsIndexed ;
91
125
this .expAvgDocumentsProcessed = expAvgDocumentsProcessed == null ? 0.0 : expAvgDocumentsProcessed ;
92
126
}
93
127
94
- public TransformIndexerStats (long numPages , long numInputDocuments , long numOutputDocuments ,
95
- long numInvocations , long indexTime , long searchTime , long indexTotal , long searchTotal ,
96
- long indexFailures , long searchFailures ) {
97
- this (numPages , numInputDocuments , numOutputDocuments , numInvocations , indexTime , searchTime , indexTotal , searchTotal ,
98
- indexFailures , searchFailures , 0.0 , 0.0 , 0.0 );
99
- }
100
-
101
128
public TransformIndexerStats (TransformIndexerStats other ) {
102
- this (other .numPages , other .numInputDocuments , other .numOuputDocuments , other .numInvocations ,
103
- other .indexTime , other .searchTime , other .indexTotal , other .searchTotal , other .indexFailures , other .searchFailures );
104
- this .expAvgCheckpointDurationMs = other .expAvgCheckpointDurationMs ;
105
- this .expAvgDocumentsIndexed = other .expAvgDocumentsIndexed ;
106
- this .expAvgDocumentsProcessed = other .expAvgDocumentsProcessed ;
129
+ this (
130
+ other .numPages ,
131
+ other .numInputDocuments ,
132
+ other .numOuputDocuments ,
133
+ other .numInvocations ,
134
+ other .indexTime ,
135
+ other .searchTime ,
136
+ other .indexTotal ,
137
+ other .searchTotal ,
138
+ other .indexFailures ,
139
+ other .searchFailures ,
140
+ other .expAvgCheckpointDurationMs ,
141
+ other .expAvgDocumentsIndexed ,
142
+ other .expAvgDocumentsProcessed
143
+ );
107
144
}
108
145
109
146
public TransformIndexerStats (StreamInput in ) throws IOException {
@@ -180,7 +217,7 @@ public void incrementCheckpointExponentialAverages(long checkpointDurationMs, lo
180
217
}
181
218
182
219
private double calculateExpAvg (double previousExpValue , double alpha , long observedValue ) {
183
- return alpha * observedValue + (1 - alpha ) * previousExpValue ;
220
+ return alpha * observedValue + (1 - alpha ) * previousExpValue ;
184
221
}
185
222
186
223
@ Override
@@ -212,9 +249,26 @@ public boolean equals(Object other) {
212
249
213
250
@ Override
214
251
public int hashCode () {
215
- return Objects .hash (numPages , numInputDocuments , numOuputDocuments , numInvocations ,
216
- indexTime , searchTime , indexFailures , searchFailures , indexTotal , searchTotal ,
217
- expAvgCheckpointDurationMs , expAvgDocumentsIndexed , expAvgDocumentsProcessed );
252
+ return Objects .hash (
253
+ numPages ,
254
+ numInputDocuments ,
255
+ numOuputDocuments ,
256
+ numInvocations ,
257
+ indexTime ,
258
+ searchTime ,
259
+ indexFailures ,
260
+ searchFailures ,
261
+ indexTotal ,
262
+ searchTotal ,
263
+ expAvgCheckpointDurationMs ,
264
+ expAvgDocumentsIndexed ,
265
+ expAvgDocumentsProcessed
266
+ );
267
+ }
268
+
269
+ @ Override
270
+ public String toString () {
271
+ return Strings .toString (this );
218
272
}
219
273
220
274
public static TransformIndexerStats fromXContent (XContentParser parser ) {
0 commit comments