private static List < String > getNodeIds ( StatefulRedisClusterConnection < ? , ? > connection ) { List < String > nodeIds = new ArrayList <> ( ) ; PartitionAccessor partitionAccessor = new PartitionAccessor ( connection . getPartitions ( ) ) ; for ( RedisClusterNode redisClusterNode : partitionAccessor . getMasters ( ) ) { if ( connection . getReadFrom ( ) != null ) { List < RedisNodeDescription > readCandidates = ( List ) partitionAccessor . getReadCandidates ( redisClusterNode ) ; List < RedisNodeDescription > selection = connection . getReadFrom ( ) . select ( new ReadFrom . Nodes ( ) { @ Override public List < RedisNodeDescription > getNodes ( ) { return readCandidates ; } @ Override public Iterator < RedisNodeDescription > iterator ( ) { return readCandidates . iterator ( ) ; } } ) ; if ( ! selection . isEmpty ( ) ) { RedisClusterNode selectedNode = ( RedisClusterNode ) selection . get ( 0 ) ; nodeIds . add ( selectedNode . getNodeId ( ) ) ; continue ; } } nodeIds . add ( redisClusterNode . getNodeId ( ) ) ; } return nodeIds ; }
Retrieve a list of node Ids to use for the SCAN operation .