private GetOperationResult checkOperation ( String operationId ) { String result = "" ; GetOperationResult opResult = null ; try { while ( ! result . equals ( "SUCCESS" ) && ! result . equals ( "FAIL" ) ) { opResult = getDiscoveryClient ( ) . getOperation ( new GetOperationRequest ( ) . withOperationId ( operationId ) ) ; result = opResult . getOperation ( ) . getStatus ( ) ; if ( opResult . getOperation ( ) . getStatus ( ) . equals ( "SUCCESS" ) ) { LOG . info ( "Successfully get operation id " + operationId ) ; return opResult ; } else { if ( opResult . getOperation ( ) . getStatus ( ) . equals ( "FAIL" ) ) { LOG . error ( "Error calling aws service for operationId:" + operationId + " error code:" + opResult . getOperation ( ) . getErrorCode ( ) + " error message:" + opResult . getOperation ( ) . getErrorMessage ( ) ) ; return opResult ; } } //TODO make this configurable Thread . currentThread ( ) . sleep ( 5000 ) ; // if you call this to much amazon will rate limit you } } catch ( InterruptedException e ) { LOG . error ( "Error polling for aws response operation:" , e ) ; } return opResult ; }
Loop for checking of the call to aws is complete or not . This is the non - async version used for testing