@ SuppressWarnings ( "WeakerAccess" ) public ApiFuture < List < Cluster > > listClustersAsync ( String instanceId ) { String name = NameUtil . formatInstanceName ( projectId , instanceId ) ; com . google . bigtable . admin . v2 . ListClustersRequest request = com . google . bigtable . admin . v2 . ListClustersRequest . newBuilder ( ) . setParent ( name ) . build ( ) ; return ApiFutures . transform ( stub . listClustersCallable ( ) . futureCall ( request ) , new ApiFunction < com . google . bigtable . admin . v2 . ListClustersResponse , List < Cluster > > ( ) { @ Override public List < Cluster > apply ( com . google . bigtable . admin . v2 . ListClustersResponse proto ) { // NOTE: serverside pagination is not and will not be implemented, so remaining pages // are not fetched. However, if that assumption turns out to be wrong, fail fast to // avoid returning partial data. Verify . verify ( proto . getNextPageToken ( ) . isEmpty ( ) , "Server returned an unexpected paginated response" ) ; ImmutableList . Builder < Cluster > clusters = ImmutableList . builder ( ) ; for ( com . google . bigtable . admin . v2 . Cluster cluster : proto . getClustersList ( ) ) { clusters . add ( Cluster . fromProto ( cluster ) ) ; } ImmutableList . Builder < String > failedZones = ImmutableList . builder ( ) ; for ( String locationStr : proto . getFailedLocationsList ( ) ) { failedZones . add ( NameUtil . extractZoneIdFromLocationName ( locationStr ) ) ; } if ( ! failedZones . build ( ) . isEmpty ( ) ) { throw new PartialListClustersException ( failedZones . build ( ) , clusters . build ( ) ) ; } return clusters . build ( ) ; } } , MoreExecutors . directExecutor ( ) ) ; }
Asynchronously lists all clusters in the specified instance .