private static void initialize ( Storage storage , String counterId ) { LOG . debug ( "Initializing counter shards for resource {}" , counterId ) ; for ( int startIndex = 0 ; startIndex < NUM_SHARDS ; startIndex += TRANSACTION_GROUP_SIZE ) { initShardRange ( storage , counterId , startIndex , Math . min ( NUM_SHARDS , startIndex + TRANSACTION_GROUP_SIZE ) ) ; } }
Idempotent initialization so that we don t reset an existing shard to zero - counterId may have already been initialized and incremented by another process .