@@ -128,9 +128,21 @@ public void testMaxLastIndexRequestTimestampAggregation() throws Exception {
128128 long ts1 = randomLongBetween (0 , 1000000 );
129129 long ts2 = randomLongBetween (0 , 1000000 );
130130 long ts3 = randomLongBetween (0 , 1000000 );
131- IndexingStats .Stats stats1 = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , ts1 );
132- IndexingStats .Stats stats2 = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , ts2 );
133- IndexingStats .Stats stats3 = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , ts3 );
131+ IndexingStats .Stats .Builder defaultStats = new IndexingStats .Stats .Builder ()
132+ .indexCount (1 )
133+ .indexTimeInMillis (2 )
134+ .indexCurrent (3 )
135+ .indexFailedCount (4 )
136+ .deleteCount (5 )
137+ .deleteTimeInMillis (6 )
138+ .deleteCurrent (7 )
139+ .noopUpdateCount (8 )
140+ .isThrottled (false )
141+ .throttleTimeInMillis (9 )
142+ .docStatusStats (docStatusStats );
143+ IndexingStats .Stats stats1 = defaultStats .maxLastIndexRequestTimestamp (ts1 ).build ();
144+ IndexingStats .Stats stats2 = defaultStats .maxLastIndexRequestTimestamp (ts2 ).build ();
145+ IndexingStats .Stats stats3 = defaultStats .maxLastIndexRequestTimestamp (ts3 ).build ();
134146
135147 // Aggregate stats1 + stats2
136148 stats1 .add (stats2 );
@@ -141,20 +153,34 @@ public void testMaxLastIndexRequestTimestampAggregation() throws Exception {
141153 assertEquals (Math .max (Math .max (ts1 , ts2 ), ts3 ), stats1 .getMaxLastIndexRequestTimestamp ());
142154
143155 // Test with zero and negative values
144- IndexingStats .Stats statsZero = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , 0L );
145- IndexingStats .Stats statsNeg = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , -100L );
156+ IndexingStats .Stats statsZero = defaultStats .maxLastIndexRequestTimestamp (0L ).build ();
157+ IndexingStats .Stats statsNeg = defaultStats .maxLastIndexRequestTimestamp (-100L ).build ();
158+
146159 statsZero .add (statsNeg );
147160 assertEquals (0L , statsZero .getMaxLastIndexRequestTimestamp ());
148161
149- IndexingStats .Stats statsNeg2 = new IndexingStats . Stats ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , -50L );
162+ IndexingStats .Stats statsNeg2 = defaultStats . maxLastIndexRequestTimestamp ( -50L ). build ( );
150163 statsNeg .add (statsNeg2 );
151164 assertEquals (-50L , statsNeg .getMaxLastIndexRequestTimestamp ());
152165 }
153166
154167 public void testMaxLastIndexRequestTimestampBackwardCompatibility () throws IOException {
155168 IndexingStats .Stats .DocStatusStats docStatusStats = new IndexingStats .Stats .DocStatusStats ();
156169 long ts = randomLongBetween (0 , 1000000 );
157- IndexingStats .Stats stats = new IndexingStats .Stats (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , false , 9 , docStatusStats , ts );
170+ IndexingStats .Stats stats = new IndexingStats .Stats .Builder ()
171+ .indexCount (1 )
172+ .indexTimeInMillis (2 )
173+ .indexCurrent (3 )
174+ .indexFailedCount (4 )
175+ .deleteCount (5 )
176+ .deleteTimeInMillis (6 )
177+ .deleteCurrent (7 )
178+ .noopUpdateCount (8 )
179+ .isThrottled (false )
180+ .throttleTimeInMillis (9 )
181+ .docStatusStats (docStatusStats )
182+ .maxLastIndexRequestTimestamp (ts )
183+ .build ();
158184
159185 // Serialize with V_3_1_0 (should include the field)
160186 BytesStreamOutput outNew = new BytesStreamOutput ();
@@ -181,20 +207,20 @@ private IndexingStats createTestInstance() {
181207 docStatusStats .add (RestStatus .fromCode (i * 100 ), randomNonNegativeLong ());
182208 }
183209
184- IndexingStats .Stats stats = new IndexingStats .Stats (
185- randomNonNegativeLong (),
186- randomNonNegativeLong (),
187- randomNonNegativeLong (),
188- randomNonNegativeLong (),
189- randomNonNegativeLong (),
190- randomNonNegativeLong (),
191- randomNonNegativeLong (),
192- randomNonNegativeLong (),
193- randomBoolean (),
194- randomNonNegativeLong (),
195- docStatusStats ,
196- randomLong ()
197- );
210+ IndexingStats .Stats stats = new IndexingStats .Stats . Builder ()
211+ . indexCount ( randomNonNegativeLong ())
212+ . indexTimeInMillis ( randomNonNegativeLong ())
213+ . indexCurrent ( randomNonNegativeLong ())
214+ . indexFailedCount ( randomNonNegativeLong ())
215+ . deleteCount ( randomNonNegativeLong ())
216+ . deleteTimeInMillis ( randomNonNegativeLong ())
217+ . deleteCurrent ( randomNonNegativeLong ())
218+ . noopUpdateCount ( randomNonNegativeLong ())
219+ . isThrottled ( randomBoolean ())
220+ . throttleTimeInMillis ( randomNonNegativeLong ())
221+ . docStatusStats ( docStatusStats )
222+ . maxLastIndexRequestTimestamp ( randomLong () )
223+ . build ( );
198224
199225 return new IndexingStats (stats );
200226 }
0 commit comments