private static void waitForRecoveriesToFinish ( CloudSolrClient server , String collection ) throws KeeperException , InterruptedException { ZkStateReader zkStateReader = server . getZkStateReader ( ) ; try { boolean cont = true ; while ( cont ) { boolean sawLiveRecovering = false ; zkStateReader . updateClusterState ( true ) ; ClusterState clusterState = zkStateReader . getClusterState ( ) ; Map < String , Slice > slices = clusterState . getSlicesMap ( collection ) ; Preconditions . checkNotNull ( "Could not find collection:" + collection , slices ) ; // change paths for Replica.State per Solr refactoring // remove SYNC state per: http://tinyurl.com/pag6rwt for ( Map . Entry < String , Slice > entry : slices . entrySet ( ) ) { Map < String , Replica > shards = entry . getValue ( ) . getReplicasMap ( ) ; for ( Map . Entry < String , Replica > shard : shards . entrySet ( ) ) { String state = shard . getValue ( ) . getStr ( ZkStateReader . STATE_PROP ) ; if ( ( state . equals ( Replica . State . RECOVERING ) || state . equals ( Replica . State . DOWN ) ) && clusterState . liveNodesContain ( shard . getValue ( ) . getStr ( ZkStateReader . NODE_NAME_PROP ) ) ) { sawLiveRecovering = true ; } } } if ( ! sawLiveRecovering ) { cont = false ; } else { Thread . sleep ( 1000 ) ; } } } finally { logger . info ( "Exiting solr wait" ) ; } }
Wait for all the collection shards to be ready .