@@ -411,6 +411,8 @@ private void reindex(ReindexConfig indexState) throws Throwable {
411
411
boolean reindexTaskCompleted = false ;
412
412
Pair <Long , Long > documentCounts = getDocumentCounts (indexState .name (), tempIndexName );
413
413
long documentCountsLastUpdated = System .currentTimeMillis ();
414
+ long previousDocCount = documentCounts .getSecond ();
415
+ long estimatedMinutesRemaining = 0 ;
414
416
415
417
while (System .currentTimeMillis () < timeoutAt ) {
416
418
log .info (
@@ -421,8 +423,22 @@ private void reindex(ReindexConfig indexState) throws Throwable {
421
423
422
424
Pair <Long , Long > tempDocumentsCount = getDocumentCounts (indexState .name (), tempIndexName );
423
425
if (!tempDocumentsCount .equals (documentCounts )) {
424
- documentCountsLastUpdated = System .currentTimeMillis ();
426
+ long currentTime = System .currentTimeMillis ();
427
+ long timeElapsed = currentTime - documentCountsLastUpdated ;
428
+ long docsIndexed = tempDocumentsCount .getSecond () - previousDocCount ;
429
+
430
+ // Calculate indexing rate (docs per millisecond)
431
+ double indexingRate = timeElapsed > 0 ? (double ) docsIndexed / timeElapsed : 0 ;
432
+
433
+ // Calculate remaining docs and estimated time
434
+ long remainingDocs = tempDocumentsCount .getFirst () - tempDocumentsCount .getSecond ();
435
+ long estimatedMillisRemaining =
436
+ indexingRate > 0 ? (long ) (remainingDocs / indexingRate ) : 0 ;
437
+ estimatedMinutesRemaining = estimatedMillisRemaining / (1000 * 60 );
438
+
439
+ documentCountsLastUpdated = currentTime ;
425
440
documentCounts = tempDocumentsCount ;
441
+ previousDocCount = documentCounts .getSecond ();
426
442
}
427
443
428
444
if (documentCounts .getFirst ().equals (documentCounts .getSecond ())) {
@@ -435,12 +451,15 @@ private void reindex(ReindexConfig indexState) throws Throwable {
435
451
break ;
436
452
437
453
} else {
454
+ float progressPercentage =
455
+ 100 * (1.0f * documentCounts .getSecond ()) / documentCounts .getFirst ();
438
456
log .warn (
439
- "Task: {} - Document counts do not match {} != {}. Complete: {}%" ,
457
+ "Task: {} - Document counts do not match {} != {}. Complete: {}%. Estimated time remaining: {} minutes " ,
440
458
parentTaskId ,
441
459
documentCounts .getFirst (),
442
460
documentCounts .getSecond (),
443
- 100 * (1.0f * documentCounts .getSecond ()) / documentCounts .getFirst ());
461
+ progressPercentage ,
462
+ estimatedMinutesRemaining );
444
463
445
464
long lastUpdateDelta = System .currentTimeMillis () - documentCountsLastUpdated ;
446
465
if (lastUpdateDelta > (300 * 1000 )) {
0 commit comments