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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidcancelOperation()cancels the remote long-running operation if cancellation is supported by the service.UgetFinalResult()Retrieve the final result of the long running operation.PollResponse<T>poll()Poll once and return the poll response received.default SyncPoller<T,U>setPollInterval(Duration pollInterval)Sets the poll interval for this poller.PollResponse<T>waitForCompletion()Wait for polling to complete.PollResponse<T>waitForCompletion(Duration timeout)Wait for polling to complete with a timeout.PollResponse<T>waitUntil(LongRunningOperationStatus statusToWaitFor)Wait for the givenLongRunningOperationStatusto receive.PollResponse<T>waitUntil(Duration timeout, LongRunningOperationStatus statusToWaitFor)Wait for the givenLongRunningOperationStatus.
-
-
-
Method Detail
-
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
PollResponse<T> waitForCompletion(Duration timeout)
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
PollResponse<T> waitUntil(LongRunningOperationStatus statusToWaitFor)
Wait for the givenLongRunningOperationStatusto receive.- Parameters:
statusToWaitFor- the desiredLongRunningOperationStatusto block for.- Returns:
PollResponsewhosePollResponse.getStatus()matchesstatusToWaitFor.- Throws:
IllegalArgumentException- ifstatusToWaitForisnull.
-
waitUntil
PollResponse<T> waitUntil(Duration timeout, LongRunningOperationStatus statusToWaitFor)
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
default SyncPoller<T,U> setPollInterval(Duration pollInterval)
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.
-
-