private Map < String , String [ ] > getShards ( DBCollection collection ) { DB config = collection . getDB ( ) . getSisterDB ( "config" ) ; DBCollection configShards = config . getCollection ( "shards" ) ; DBCursor cursorShards = configShards . find ( ) ; Map < String , String [ ] > map = new HashMap <> ( ) ; while ( cursorShards . hasNext ( ) ) { DBObject currentShard = cursorShards . next ( ) ; String currentHost = ( String ) currentShard . get ( "host" ) ; int slashIndex = currentHost . indexOf ( "/" ) ; if ( slashIndex > 0 ) { map . put ( ( String ) currentShard . get ( MONGO_DEFAULT_ID ) , currentHost . substring ( slashIndex + 1 ) . split ( "," ) ) ; } } return map ; }
Gets shards .