Package com.azure.core.util.polling
Interface SyncPoller<T,U>
- Type Parameters:
T- The type of poll response value.U- The type of the final result of long-running operation.
public interface SyncPoller<T,U>
A type that offers API that simplifies the task of executing long-running operations against
an Azure service.
It provides the following functionality:
- Querying the current state of the long-running operation.
- Requesting cancellation of long-running operation, if supported by the service.
- Fetching final result of long-running operation, if supported by the service.
- Wait for long-running operation to complete, with optional timeout.
- Wait for long-running operation to reach a specific state.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancels the remote long-running operation if cancellation is supported by the service.Retrieve the final result of the long running operation.poll()Poll once and return the poll response received.default SyncPoller<T,U> setPollInterval(Duration pollInterval) Sets the poll interval for this poller.Wait for polling to complete.waitForCompletion(Duration timeout) Wait for polling to complete with a timeout.waitUntil(LongRunningOperationStatus statusToWaitFor) Wait for the givenLongRunningOperationStatusto receive.waitUntil(Duration timeout, LongRunningOperationStatus statusToWaitFor) Wait for the givenLongRunningOperationStatus.
-
Method Details
-
poll
PollResponse<T> poll()Poll once and return the poll response received.- Returns:
- the poll response
-
waitForCompletion
PollResponse<T> waitForCompletion()Wait for polling to complete. The polling is considered complete based on status defined inLongRunningOperationStatus.- Returns:
- the final poll response
-
waitForCompletion
Wait for polling to complete with a timeout. The polling is considered complete based on status defined inLongRunningOperationStatus.- Parameters:
timeout- the duration to waits for polling completion.- Returns:
- the final poll response.
-
waitUntil
Wait for the givenLongRunningOperationStatusto receive.- Parameters:
statusToWaitFor- the desiredLongRunningOperationStatusto block for.- Returns:
PollResponsewhosePollResponse.getStatus()matchesstatusToWaitFor.- Throws:
IllegalArgumentException- ifstatusToWaitForisnull.
-
waitUntil
Wait for the givenLongRunningOperationStatus.- Parameters:
timeout- the duration to waits for the polling.statusToWaitFor- the desiredLongRunningOperationStatusto block for.- Returns:
PollResponsewhosePollResponse.getStatus()matchesstatusToWaitFor.- Throws:
IllegalArgumentException- ifstatusToWaitForis ortimeoutnull.
-
getFinalResult
U getFinalResult()Retrieve the final result of the long running operation.- Returns:
- the final result of the long-running operation if there is one.
-
cancelOperation
void cancelOperation()cancels the remote long-running operation if cancellation is supported by the service. -
setPollInterval
Sets the poll interval for this poller. The new interval will be used for all subsequent polling operations including the polling operations that are already in progress.- Parameters:
pollInterval- The new poll interval for this poller.- Returns:
- The updated instance of
SyncPoller. - Throws:
NullPointerException- if thepollIntervalis null.IllegalArgumentException- if thepollIntervalis zero or negative.
-