public ScanStatus toScanStatus ( ) { List < ScanRangeStatus > pendingRangeStatuses = Lists . newArrayList ( ) ; // Unique identifier for each scan task int taskId = 0 ; // Unique identifier for each batch int batchId = 0 ; // Unique identifier which identifies all tasks which affect the same resources in the ring int concurrencyId = 0 ; for ( PlanBatch batch : _clusterHeads . values ( ) ) { // Within a single Cassandra ring each batch runs serially. This is enforced by blocking on the prior batch // from the same cluster. Integer lastBatchId = null ; while ( batch != null ) { List < PlanItem > items = batch . getItems ( ) ; if ( ! items . isEmpty ( ) ) { Optional < Integer > blockingBatch = Optional . fromNullable ( lastBatchId ) ; for ( PlanItem item : items ) { String placement = item . getPlacement ( ) ; // If the token range is subdivided into more than one scan range then mark all sub-ranges with // the same unique concurrency ID. Optional < Integer > concurrency = item . getScanRanges ( ) . size ( ) > 1 ? Optional . of ( concurrencyId ++ ) : Optional . < Integer > absent ( ) ; for ( ScanRange scanRange : item . getScanRanges ( ) ) { pendingRangeStatuses . add ( new ScanRangeStatus ( taskId ++ , placement , scanRange , batchId , blockingBatch , concurrency ) ) ; } } lastBatchId = batchId ; batchId ++ ; } batch = batch . getNextBatch ( ) ; } } return new ScanStatus ( _scanId , _options , false , false , new Date ( ) , pendingRangeStatuses , ImmutableList . < ScanRangeStatus > of ( ) , ImmutableList . < ScanRangeStatus > of ( ) ) ; }
Creates a ScanStatus based on the current state of the plan . All scan ranges are added as pending tasks .