你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
SyncPoller<T,U> Interface
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
Method Details
<T,U>createPoller
public static SyncPoller
Creates default SyncPoller.
Parameters:
Returns:
<T,U>createPoller
public static SyncPoller
Creates PollerFlux.
This method uses a SyncPollingStrategy<T,U> to poll the status of a long-running operation after the activation operation is invoked. See SyncPollingStrategy<T,U> for more details of known polling strategies and how to create a custom strategy.
Parameters:
Returns:
cancelOperation
public abstract void cancelOperation()
Cancels the remote long-running operation if cancellation is supported by the service.
If cancellation isn't supported by the service this will throw an exception.
getFinalResult
public abstract U getFinalResult()
Retrieve the final result of the long-running operation.
If polling hasn't completed this will wait indefinitely until polling completes.
Returns:
getFinalResult
public default U getFinalResult(Duration timeout)
Retrieve the final result of the long-running operation.
If polling hasn't completed this will wait for the timeout
for polling to complete. In this case this API is effectively equivalent to waitForCompletion(Duration timeout) + getFinalResult().
Polling will continue until a completed LongRunningOperationStatus is received or the timeout expires.
The timeout
is applied in two ways, first it's used during each poll operation to time it out if the polling operation takes too long. Second, it's used to determine when the wait for should stop. If polling doesn't reach a completion state before the timeout
elapses a RuntimeException wrapping a TimeoutException will be thrown.
If this method isn't overridden by the implementation then this method is effectively equivalent to calling waitForCompletion(Duration timeout) then getFinalResult().
Parameters:
Returns:
poll
public abstract PollResponse
Poll once and return the poll response received.
Returns:
setPollInterval
public default SyncPoller
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:
Returns:
waitForCompletion
public abstract PollResponse
Wait for polling to complete. The polling is considered complete based on status defined in LongRunningOperationStatus.
This operation will wait indefinitely until a completed LongRunningOperationStatus is received.
Returns:
waitForCompletion
public abstract PollResponse
Wait for polling to complete with a timeout. The polling is considered complete based on status defined in LongRunningOperationStatus or if the timeout expires.
Polling will continue until a completed LongRunningOperationStatus is received or the timeout expires.
The timeout
is applied in two ways, first it's used during each poll operation to time it out if the polling operation takes too long. Second, it's used to determine when the wait for should stop. If polling doesn't reach a completion state before the timeout
elapses a RuntimeException wrapping a TimeoutException will be thrown.
Parameters:
Returns:
waitUntil
public abstract PollResponse
Wait for the given LongRunningOperationStatus to receive.
This operation will wait indefinitely until the statusToWaitFor
is received or a isComplete() state is reached.
Parameters:
Returns:
waitUntil
public abstract PollResponse
Wait for the given LongRunningOperationStatus with a timeout.
Polling will continue until a response is returned with a LongRunningOperationStatus matching statusToWaitFor
, a isComplete() state is reached, or the timeout expires.
Unlike waitForCompletion(Duration timeout) or getFinalResult(Duration timeout), when the timeout elapses a RuntimeException wrapping a TimeoutException will not be thrown. Instead, the last poll response will be returned. This is because unlike a completion state, a wait for state may be skipped if the state is reached and completed before a poll operation is executed. For example, if a long-running operation has the flow A -> B -> C -> D
and the statusToWaitFor
is B
and the first poll request returns state A
but in the time between polls state B
completes, then the next poll request will return state C
and the statusToWaitFor
will never be returned.
This may return null if no poll operation completes within the timeout.
Parameters:
Returns:
statusToWaitFor
, or null if
no response was returned within the timeout.