synchronized public String getPrettyProgressBar ( ) { StringBuilder sb = new StringBuilder ( ) ; double taskRate = numTasksCompleted / ( double ) totalTaskCount ; double partitionStoreRate = numPartitionStoresMigrated / ( double ) totalPartitionStoreCount ; long deltaTimeMs = System . currentTimeMillis ( ) - startTimeMs ; long taskTimeRemainingMs = Long . MAX_VALUE ; if ( taskRate > 0 ) { taskTimeRemainingMs = ( long ) ( deltaTimeMs * ( ( 1.0 / taskRate ) - 1.0 ) ) ; } long partitionStoreTimeRemainingMs = Long . MAX_VALUE ; if ( partitionStoreRate > 0 ) { partitionStoreTimeRemainingMs = ( long ) ( deltaTimeMs * ( ( 1.0 / partitionStoreRate ) - 1.0 ) ) ; } // Title line sb . append ( "Progress update on rebalancing batch " + batchId ) . append ( Utils . NEWLINE ) ; // Tasks in flight update sb . append ( "There are currently " + tasksInFlight . size ( ) + " rebalance tasks executing: " ) . append ( tasksInFlight ) . append ( "." ) . append ( Utils . NEWLINE ) ; // Tasks completed update sb . append ( "\t" + numTasksCompleted + " out of " + totalTaskCount + " rebalance tasks complete." ) . append ( Utils . NEWLINE ) . append ( "\t" ) . append ( decimalFormatter . format ( taskRate * 100.0 ) ) . append ( "% done, estimate " ) . append ( taskTimeRemainingMs ) . append ( " ms (" ) . append ( TimeUnit . MILLISECONDS . toMinutes ( taskTimeRemainingMs ) ) . append ( " minutes) remaining." ) . append ( Utils . NEWLINE ) ; // Partition-stores migrated update sb . append ( "\t" + numPartitionStoresMigrated + " out of " + totalPartitionStoreCount + " partition-stores migrated." ) . append ( Utils . NEWLINE ) . append ( "\t" ) . append ( decimalFormatter . format ( partitionStoreRate * 100.0 ) ) . append ( "% done, estimate " ) . append ( partitionStoreTimeRemainingMs ) . append ( " ms (" ) . append ( TimeUnit . MILLISECONDS . toMinutes ( partitionStoreTimeRemainingMs ) ) . append ( " minutes) remaining." ) . append ( Utils . NEWLINE ) ; return sb . toString ( ) ; }
Construct a pretty string documenting progress for this batch plan thus far .