Package com.azure.core.util.polling
Class DefaultPollingStrategy<T,U>
java.lang.Object
com.azure.core.util.polling.DefaultPollingStrategy<T,U>
- Type Parameters:
T- the type of the response type from a polling call, or BinaryData if raw response body should be keptU- the type of the final result object to deserialize into, or BinaryData if raw response body should be kept
- All Implemented Interfaces:
PollingStrategy<T,U>
The default polling strategy to use with Azure data plane services. The default polling strategy will attempt 3
known strategies,
OperationResourcePollingStrategy, LocationPollingStrategy, and
StatusCheckPollingStrategy, in this order. The first strategy that can poll on the initial response will be
used. The created chained polling strategy is capable of handling most of the polling scenarios in Azure.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPollingStrategy(HttpPipeline httpPipeline) Creates a chained polling strategy with 3 known polling strategies,OperationResourcePollingStrategy,LocationPollingStrategy, andStatusCheckPollingStrategy, in this order, with a JSON serializer.DefaultPollingStrategy(HttpPipeline httpPipeline, JsonSerializer serializer) Creates a chained polling strategy with 3 known polling strategies,OperationResourcePollingStrategy,LocationPollingStrategy, andStatusCheckPollingStrategy, in this order, with a custom serializer.DefaultPollingStrategy(HttpPipeline httpPipeline, JsonSerializer serializer, Context context) Creates a chained polling strategy with 3 known polling strategies,OperationResourcePollingStrategy,LocationPollingStrategy, andStatusCheckPollingStrategy, in this order, with a custom serializer.DefaultPollingStrategy(HttpPipeline httpPipeline, String endpoint, JsonSerializer serializer, Context context) Creates a chained polling strategy with 3 known polling strategies,OperationResourcePollingStrategy,LocationPollingStrategy, andStatusCheckPollingStrategy, in this order, with a custom serializer.DefaultPollingStrategy(PollingStrategyOptions pollingStrategyOptions) Creates a chained polling strategy with 3 known polling strategies,OperationResourcePollingStrategy,LocationPollingStrategy, andStatusCheckPollingStrategy, in this order, with a custom serializer. -
Method Summary
Modifier and TypeMethodDescriptionChecks if this strategy is able to handle polling for this long-running operation based on the information in the initial response.getResult(PollingContext<T> context, TypeReference<U> resultType) Parses the response from the final GET call into the result type of the long-running operation.onInitialResponse(Response<?> response, PollingContext<T> pollingContext, TypeReference<T> pollResponseType) Parses the initial response into aLongRunningOperationStatus, and stores information useful for polling in thePollingContext.poll(PollingContext<T> context, TypeReference<T> pollResponseType) Parses the response from the polling URL into aPollResponse, and stores information useful for further polling and final response in thePollingContext.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.azure.core.util.polling.PollingStrategy
cancel
-
Constructor Details
-
DefaultPollingStrategy
Creates a chained polling strategy with 3 known polling strategies,OperationResourcePollingStrategy,LocationPollingStrategy, andStatusCheckPollingStrategy, in this order, with a JSON serializer.- Parameters:
httpPipeline- an instance ofHttpPipelineto send requests with- Throws:
NullPointerException- IfhttpPipelineis null.
-
DefaultPollingStrategy
Creates a chained polling strategy with 3 known polling strategies,OperationResourcePollingStrategy,LocationPollingStrategy, andStatusCheckPollingStrategy, in this order, with a custom serializer.- Parameters:
httpPipeline- an instance ofHttpPipelineto send requests withserializer- a custom serializer for serializing and deserializing polling responses- Throws:
NullPointerException- IfhttpPipelineis null.
-
DefaultPollingStrategy
public DefaultPollingStrategy(HttpPipeline httpPipeline, JsonSerializer serializer, Context context) Creates a chained polling strategy with 3 known polling strategies,OperationResourcePollingStrategy,LocationPollingStrategy, andStatusCheckPollingStrategy, in this order, with a custom serializer.- Parameters:
httpPipeline- an instance ofHttpPipelineto send requests withserializer- a custom serializer for serializing and deserializing polling responsescontext- an instance ofContext- Throws:
NullPointerException- IfhttpPipelineis null.
-
DefaultPollingStrategy
public DefaultPollingStrategy(HttpPipeline httpPipeline, String endpoint, JsonSerializer serializer, Context context) Creates a chained polling strategy with 3 known polling strategies,OperationResourcePollingStrategy,LocationPollingStrategy, andStatusCheckPollingStrategy, in this order, with a custom serializer.- Parameters:
httpPipeline- an instance ofHttpPipelineto send requests with.endpoint- an endpoint for creating an absolute path when the path itself is relative.serializer- a custom serializer for serializing and deserializing polling responses.context- an instance ofContext.- Throws:
NullPointerException- IfhttpPipelineis null.
-
DefaultPollingStrategy
Creates a chained polling strategy with 3 known polling strategies,OperationResourcePollingStrategy,LocationPollingStrategy, andStatusCheckPollingStrategy, in this order, with a custom serializer.- Parameters:
pollingStrategyOptions- options to configure this polling strategy.- Throws:
NullPointerException- IfpollingStrategyOptionsis null.
-
-
Method Details
-
getResult
Description copied from interface:PollingStrategyParses the response from the final GET call into the result type of the long-running operation.- Specified by:
getResultin interfacePollingStrategy<T,U> - Parameters:
context- thePollingContextfor the current polling operationresultType- theTypeReferenceof the final result object to deserialize into, or BinaryData if raw response body should be kept.- Returns:
- a publisher emitting the final result
-
canPoll
Description copied from interface:PollingStrategyChecks if this strategy is able to handle polling for this long-running operation based on the information in the initial response.- Specified by:
canPollin interfacePollingStrategy<T,U> - Parameters:
initialResponse- the response from the initial method call to activate the long-running operation- Returns:
- true if this polling strategy can handle the initial response, false if not
-
onInitialResponse
public Mono<PollResponse<T>> onInitialResponse(Response<?> response, PollingContext<T> pollingContext, TypeReference<T> pollResponseType) Description copied from interface:PollingStrategyParses the initial response into aLongRunningOperationStatus, and stores information useful for polling in thePollingContext. If the result is anything other thanLongRunningOperationStatus.IN_PROGRESS, the long-running operation will be terminated and none of the other methods will be invoked.- Specified by:
onInitialResponsein interfacePollingStrategy<T,U> - Parameters:
response- the response from the initial method call to activate the long-running operationpollingContext- thePollingContextfor the current polling operationpollResponseType- theTypeReferenceof the response type from a polling call, or BinaryData if raw response body should be kept. This should match the generic parameterPollingStrategy.- Returns:
- a publisher emitting the poll response containing the status and the response content
-
poll
Description copied from interface:PollingStrategyParses the response from the polling URL into aPollResponse, and stores information useful for further polling and final response in thePollingContext. The result must have theLongRunningOperationStatusspecified, and the entire polling response content as aBinaryData.- Specified by:
pollin interfacePollingStrategy<T,U> - Parameters:
context- thePollingContextfor the current polling operationpollResponseType- theTypeReferenceof the response type from a polling call, or BinaryData if raw response body should be kept. This should match the generic parameterPollingStrategy.- Returns:
- a publisher emitting the poll response containing the status and the response content
-