public boolean pollResource ( ) throws AmazonServiceException , WaiterTimedOutException , WaiterUnrecoverableException { int retriesAttempted = 0 ; while ( true ) { switch ( getCurrentState ( ) ) { case SUCCESS : return true ; case FAILURE : throw new WaiterUnrecoverableException ( "Resource never entered the desired state as it failed." ) ; case RETRY : PollingStrategyContext pollingStrategyContext = new PollingStrategyContext ( request , retriesAttempted ) ; if ( pollingStrategy . getRetryStrategy ( ) . shouldRetry ( pollingStrategyContext ) ) { safeCustomDelay ( pollingStrategyContext ) ; retriesAttempted ++ ; } else { throw new WaiterTimedOutException ( "Reached maximum attempts without transitioning to the desired state" ) ; } break ; } } }
Polls until a specified resource transitions into either success or failure state or until the specified number of retries has been made .