你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

FabricServicePartitionResolver 类

public class FabricServicePartitionResolver implements ServicePartitionResolver

实现有助于确定服务终结点的 类。 此类包装 FabricClient 的 system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(java.net.URI) 方法,并针对该方法的错误实现退让/重试机制。

字段摘要

修饰符和类型 字段和描述
final Duration defaultMaxRetryBackoffInterval

这是 ServicePartitionResolver 的 ResolveAsync 方法在未显式指定 maxRetryBackoffInterval 参数的情况下调用它时使用的默认最大重试回退间隔。

final Duration defaultResolveTimeout

这是在未显式指定 resolveTimeoutPerTry 参数的情况下调用的 ResolveAsync 方法 ServicePartitionResolver 每次尝试使用的默认解析超时。

构造函数摘要

构造函数 说明
FabricServicePartitionResolver(FabricClientSettings settings, String... connectionEndpoints)

实例化 ServicePartitionResolver,使用给定的 FabricClient 设置和 connectionEndpoints 创建 FabricClient 的新实例。

FabricServicePartitionResolver(String... connectionEndpoints)

实例化 ServicePartitionResolver,使用给定的 connectionEndpoint 创建 FabricClient 的新实例。

FabricServicePartitionResolver(Supplier<FabricClient> createFabricClient)

实例化 ServicePartitionResolver,调用给定的委托来实例化 FabricClient。

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

实例化 ServicePartionResolver,调用第一个委托来实例化 FabricClient。 在分区解析期间,如果释放 FabricClient 对象并提供第二个委托,它将使用第二个委托重新创建 FabricClient。 如果释放了使用第一个委托创建的 FabricClient,则第二个委托提供了一种指定创建 FabricClient 的另一种方法。

方法摘要

修饰符和类型 方法和描述
ServicePartitionResolver getDefault()

获取默认的 ServicePartitionResolver

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

通过在可重试错误时回退/重试调用 FabricClient 的 system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI) 方法,解析指定服务的分区。 这会采用通过早期调用 ResolveAsync () 方法获取的已解析服务分区。 如果客户端知道其已解析的服务分区不再有效,则使用此 api 重载。

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

解析指定服务的分区,并针对可重试的错误进行回退/重试。 这会采用通过早期调用 ResolveAsync () 方法获取的已解析服务分区。 如果客户端知道其已解析的服务分区不再有效,则使用此 api 重载。

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

通过在可重试错误时回退/重试调用 FabricClient 的 system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI)方法,解析指定服务的分区。

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

通过调用 system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI) 方法解决指定服务的分区,并在可重试错误时返回/重试。

void setDefault(ServicePartitionResolver defaultServiceResolver)

汇报默认 ServicePartitionResolver

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

字段详细信息

defaultMaxRetryBackoffInterval

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

这是 ServicePartitionResolver 的 ResolveAsync 方法在未显式指定 maxRetryBackoffInterval 参数的情况下调用它时使用的默认最大重试回退间隔。

defaultResolveTimeout

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

这是在未显式指定 resolveTimeoutPerTry 参数的情况下调用的 ResolveAsync 方法 ServicePartitionResolver 每次尝试使用的默认解析超时。

构造函数详细信息

FabricServicePartitionResolver

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

实例化 ServicePartitionResolver,使用给定的 FabricClient 设置和 connectionEndpoints 创建 FabricClient 的新实例。

Parameters:

settings - Fabric 客户端设置
connectionEndpoints - 群集的管理终结点数组

FabricServicePartitionResolver

public FabricServicePartitionResolver(String... connectionEndpoints)

实例化 ServicePartitionResolver,使用给定的 connectionEndpoint 创建 FabricClient 的新实例。

Parameters:

connectionEndpoints - 群集的管理终结点数组

FabricServicePartitionResolver

public FabricServicePartitionResolver(Supplier createFabricClient)

实例化 ServicePartitionResolver,调用给定的委托来实例化 FabricClient。

Parameters:

createFabricClient - 委托以创建构造客户端

FabricServicePartitionResolver

public FabricServicePartitionResolver(Supplier createFabricClient, Supplier recreateFabricClient)

实例化 ServicePartionResolver,调用第一个委托来实例化 FabricClient。 在分区解析期间,如果释放 FabricClient 对象并提供第二个委托,它将使用第二个委托重新创建 FabricClient。 如果释放了使用第一个委托创建的 FabricClient,则第二个委托提供了一种指定创建 FabricClient 的另一种方法。

Parameters:

createFabricClient - 委托以创建构造客户端
recreateFabricClient - 委托以创建构造客户端

方法详细信息

getDefault

public static ServicePartitionResolver getDefault()

获取默认的 ServicePartitionResolver

Returns:

getResolveTimeout

public Duration getResolveTimeout()

getRetryBackoffInterval

public Duration getRetryBackoffInterval()

resolveAsync

public CompletableFuture resolveAsync(ResolvedServicePartition previousRsp)

通过在可重试错误时回退/重试调用 FabricClient 的 system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI) 方法,解析指定服务的分区。 这会采用通过早期调用 ResolveAsync () 方法获取的已解析服务分区。 如果客户端知道其已解析的服务分区不再有效,则使用此 api 重载。

Parameters:

previousRsp - 以前解析的服务分区

Returns:

表示 CompletableFuture 未完成的操作的 。 Task 的结果是 ResolvedServicePartition 对象,其中包含有关已解析的服务分区(包括服务终结点)的信息。

resolveAsync

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

解析指定服务的分区,并针对可重试的错误进行回退/重试。 这会采用通过早期调用 ResolveAsync () 方法获取的已解析服务分区。 如果客户端知道其已解析的服务分区不再有效,则使用此 api 重载。

Overrides:

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

Parameters:

previousRsp - 以前解析的服务分区
resolveTimeoutPerTry - 传递给 ServiceManagementClient::resolveServicePartitionAsync (URI) 方法的超时
maxRetryBackoffInterval - 解析服务分区失败并出现可重试异常时重试前的间隔。

Returns:

表示 CompletableFuture 未完成的操作的 。 Task 的结果是 ResolvedServicePartition 对象,其中包含有关已解析的服务分区(包括服务终结点)的信息。

resolveAsync

public CompletableFuture resolveAsync(URI serviceUri, ServicePartitionKey partitionKey)

通过在可重试错误时回退/重试调用 FabricClient 的 system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI)方法,解析指定服务的分区。

Parameters:

serviceUri - 要解析的服务的 URI
partitionKey - 标识要解析的分区的键

Returns:

表示 CompletableFuture 未完成的操作的 。 Task 的结果是 ResolvedServicePartition 对象,其中包含有关已解析的服务分区(包括服务终结点)的信息。

resolveAsync

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

通过调用 system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI) 方法解决指定服务的分区,并在可重试错误时返回/重试。

Overrides:

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

Parameters:

serviceUri - 要解析的服务的 URI
partitionKey - 标识要解析的分区的键
resolveTimeoutPerTry - 传递给方法的 system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI) 超时
maxRetryBackoffInterval - 方法失败并出现可重试异常时重试前 system.fabric.client.ServiceManagementClient#resolveServicePartitionAsync(URI)退的间隔。

Returns:

表示 CompletableFuture 未完成的操作的 。 Task 的结果是 ResolvedServicePartition 对象,其中包含有关已解析的服务分区(包括服务终结点)的信息。

setDefault

public static void setDefault(ServicePartitionResolver defaultServiceResolver)

汇报默认 ServicePartitionResolver

Parameters:

defaultServiceResolver - 新的默认值

setResolveTimeout

public void setResolveTimeout(Duration resolveTimeout)

Parameters:

resolveTimeout

setRetryBackoffInterval

public void setRetryBackoffInterval(Duration retryBackoffInterval)

Parameters:

retryBackoffInterval

适用于