FabricServicePartitionResolver Class

public class FabricServicePartitionResolver implements ServicePartitionResolver

Implements the class that helps in determining the endpoint of a service. This class wraps the FabricClient's system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(java.net.URI) method, and implements a back-off/retry mechanism on errors from that method.

Field Summary

Modifier and Type Field and Description
final Duration defaultMaxRetryBackoffInterval

This is the default max retry backoff interval used by ServicePartitionResolver's ResolveAsync method when it is invoked without explicitly specifying the maxRetryBackoffInterval argument.

final Duration defaultResolveTimeout

This is the default resolve timeout per try used by the ResolveAsync method of ServicePartitionResolver when it is invoked without explicitly specifying the resolveTimeoutPerTry argument.

Constructor Summary

Constructor Description
FabricServicePartitionResolver(FabricClientSettings settings, String... connectionEndpoints)

Instantiates a ServicePartitionResolver, uses the given FabricClient Settings and the connectionEndpoints to create a new instance of FabricClient.

FabricServicePartitionResolver(String... connectionEndpoints)

Instantiates a ServicePartitionResolver, uses the given connectionEndpoints to create a new instance of FabricClient.

FabricServicePartitionResolver(Supplier<FabricClient> createFabricClient)

Instantiates a ServicePartitionResolver, invoking the given delegate to instantiate FabricClient.

FabricServicePartitionResolver(Supplier<FabricClient> createFabricClient, Supplier<FabricClient> recreateFabricClient)

Instantiates a ServicePartionResolver, invoking the first delegate to instantiate FabricClient. During partition resolution if FabricClient object gets disposed and second delegate is provided, it uses the second delegate to re-create the FabricClient. The second delegate provides a way to specify an alternate way to create FabricClient if FabricClient created with first delegates get disposed.

Method Summary

Modifier and Type Method and Description
ServicePartitionResolver getDefault()

Gets the default ServicePartitionResolver

Duration getResolveTimeout()
Duration getRetryBackoffInterval()
CompletableFuture<ResolvedServicePartition> resolveAsync(ResolvedServicePartition previousRsp)

Resolves a partition of the specified service by invoking FabricClient's system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI) method with back-off/retry on retriable errors. This takes in the resolved service partition that was got via an earlier invocation of the ResolveAsync() method. This api-overload is used in cases where the client knows that the resolved service partition that it has is no longer valid.

CompletableFuture<ResolvedServicePartition> resolveAsync(ResolvedServicePartition previousRsp, Duration resolveTimeoutPerTry, Duration maxRetryBackoffInterval)

Resolves a partition of the specified service with backoff/ retry on retriable errors. This takes in the resolved service partition that was got via an earlier invocation of the ResolveAsync() method. This api-overload is used in cases where the client knows that the resolved service partition that it has is no longer valid.

CompletableFuture<ResolvedServicePartition> resolveAsync(URI serviceUri, ServicePartitionKey partitionKey)

Resolves a partition of the specified service by invoking FabricClient's system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI)method with back-off/retry on retriable errors.

CompletableFuture<ResolvedServicePartition> resolveAsync(URI serviceUri, ServicePartitionKey partitionKey, Duration resolveTimeoutPerTry, Duration maxRetryBackoffInterval)

Resolves a partition of the specified service by invoking system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI) method with back-off/retry on retriable errors.

void setDefault(ServicePartitionResolver defaultServiceResolver)

Updates the default ServicePartitionResolver

void setResolveTimeout(Duration resolveTimeout)
void setRetryBackoffInterval(Duration retryBackoffInterval)

Field Details

defaultMaxRetryBackoffInterval

public static final Duration defaultMaxRetryBackoffInterval= Duration.ofSeconds(5)

This is the default max retry backoff interval used by ServicePartitionResolver's ResolveAsync method when it is invoked without explicitly specifying the maxRetryBackoffInterval argument.

defaultResolveTimeout

public static final Duration defaultResolveTimeout= Duration.ofSeconds(30)

This is the default resolve timeout per try used by the ResolveAsync method of ServicePartitionResolver when it is invoked without explicitly specifying the resolveTimeoutPerTry argument.

Constructor Details

FabricServicePartitionResolver

public FabricServicePartitionResolver(FabricClientSettings settings, String... connectionEndpoints)

Instantiates a ServicePartitionResolver, uses the given FabricClient Settings and the connectionEndpoints to create a new instance of FabricClient.

Parameters:

settings - Fabric client Settings
connectionEndpoints - Array of management endpoints of the cluster

FabricServicePartitionResolver

public FabricServicePartitionResolver(String... connectionEndpoints)

Instantiates a ServicePartitionResolver, uses the given connectionEndpoints to create a new instance of FabricClient.

Parameters:

connectionEndpoints - Array of management endpoints of the cluster

FabricServicePartitionResolver

public FabricServicePartitionResolver(Supplier createFabricClient)

Instantiates a ServicePartitionResolver, invoking the given delegate to instantiate FabricClient.

Parameters:

createFabricClient - Delegate to create fabric client

FabricServicePartitionResolver

public FabricServicePartitionResolver(Supplier createFabricClient, Supplier recreateFabricClient)

Instantiates a ServicePartionResolver, invoking the first delegate to instantiate FabricClient. During partition resolution if FabricClient object gets disposed and second delegate is provided, it uses the second delegate to re-create the FabricClient. The second delegate provides a way to specify an alternate way to create FabricClient if FabricClient created with first delegates get disposed.

Parameters:

createFabricClient - Delegate to create fabric client
recreateFabricClient - Delegate to create fabric client

Method Details

getDefault

public static ServicePartitionResolver getDefault()

Gets the default ServicePartitionResolver

Returns:

getResolveTimeout

public Duration getResolveTimeout()

getRetryBackoffInterval

public Duration getRetryBackoffInterval()

resolveAsync

public CompletableFuture resolveAsync(ResolvedServicePartition previousRsp)

Resolves a partition of the specified service by invoking FabricClient's system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI) method with back-off/retry on retriable errors. This takes in the resolved service partition that was got via an earlier invocation of the ResolveAsync() method. This api-overload is used in cases where the client knows that the resolved service partition that it has is no longer valid.

Parameters:

previousRsp - Previous resolved service partition

Returns:

A CompletableFuture that represents outstanding operation. The result from the Task is the ResolvedServicePartition object, that contains the information about the resolved service partition including the service endpoints.

resolveAsync

public CompletableFuture resolveAsync(ResolvedServicePartition previousRsp, Duration resolveTimeoutPerTry, Duration maxRetryBackoffInterval)

Resolves a partition of the specified service with backoff/ retry on retriable errors. This takes in the resolved service partition that was got via an earlier invocation of the ResolveAsync() method. This api-overload is used in cases where the client knows that the resolved service partition that it has is no longer valid.

Overrides:

FabricServicePartitionResolver.resolveAsync(ResolvedServicePartition previousRsp, Duration resolveTimeoutPerTry, Duration maxRetryBackoffInterval)

Parameters:

previousRsp - Previous resolved service partition
resolveTimeoutPerTry - The timeout passed to ServiceManagementClient::resolveServicePartitionAsync(URI) method
maxRetryBackoffInterval - The interval to back-off before retrying when resolve service partition fails with a retriable exception.

Returns:

A CompletableFuture that represents outstanding operation. The result from the Task is the ResolvedServicePartition object, that contains the information about the resolved service partition including the service endpoints.

resolveAsync

public CompletableFuture resolveAsync(URI serviceUri, ServicePartitionKey partitionKey)

Resolves a partition of the specified service by invoking FabricClient's system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI)method with back-off/retry on retriable errors.

Parameters:

serviceUri - Uri of the service to resolve
partitionKey - Key that identifies the partition to resolve

Returns:

A CompletableFuture that represents outstanding operation. The result from the Task is the ResolvedServicePartition object, that contains the information about the resolved service partition including the service endpoints.

resolveAsync

public CompletableFuture resolveAsync(URI serviceUri, ServicePartitionKey partitionKey, Duration resolveTimeoutPerTry, Duration maxRetryBackoffInterval)

Resolves a partition of the specified service by invoking system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI) method with back-off/retry on retriable errors.

Overrides:

FabricServicePartitionResolver.resolveAsync(URI serviceUri, ServicePartitionKey partitionKey, Duration resolveTimeoutPerTry, Duration maxRetryBackoffInterval)

Parameters:

serviceUri - Uri of the service to resolve
partitionKey - Key that identifies the partition to resolve
resolveTimeoutPerTry - The timeout passed to system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI) method
maxRetryBackoffInterval - The interval to back-off before retrying when system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI)method fails with a retriable exception.

Returns:

A CompletableFuture that represents outstanding operation. The result from the Task is the ResolvedServicePartition object, that contains the information about the resolved service partition including the service endpoints.

setDefault

public static void setDefault(ServicePartitionResolver defaultServiceResolver)

Updates the default ServicePartitionResolver

Parameters:

defaultServiceResolver - The new default value

setResolveTimeout

public void setResolveTimeout(Duration resolveTimeout)

Parameters:

resolveTimeout

setRetryBackoffInterval

public void setRetryBackoffInterval(Duration retryBackoffInterval)

Parameters:

retryBackoffInterval

Applies to