다음을 통해 공유


CommunicationClientFactoryBase<T> Class

Type Parameters

T

The type of communication client

public class CommunicationClientFactoryBase implements CommunicationClientFactory

Provides the base implementation of CommunicationClientFactory for creating communication clients to talk to service fabric services. Extend the CommunicationClientFactoryBase class to create communication clients for custom transport implementations. This class maintains a cache of communication clients and attempts to reuse the clients for requests to the same service endpoint.

Constructor Summary

Constructor Description
CommunicationClientFactoryBase()

Initializes a new instance of the communication client factory.

CommunicationClientFactoryBase(ServicePartitionResolver servicePartitionResolver, List<ExceptionHandler> exceptionHandlers)

Initializes a new instance of the communication client factory.

CommunicationClientFactoryBase(ServicePartitionResolver servicePartitionResolver, List<ExceptionHandler> exceptionHandlers, String traceId)

Initializes a new instance of the communication client factory.

Method Summary

Modifier and Type Method and Description
abstract void abortClient(T client)

Aborts the given client

abstract CompletableFuture<T> createClientAsync(String endpoint)
CompletableFuture<T> getClientAsync(ResolvedServicePartition previousRsp, TargetReplicaSelector targetReplicaSelector, String listenerName, OperationRetrySettings retrySettings)

Resolves a partition of the specified service containing one or more communication listeners and returns a client to communicate to the endpoint corresponding to the given listenerName. The endpoint of the service is of the form - {"Endpoints":{"Listener1":"Endpoint1","Listener2":"Endpoint2" ...}}

CompletableFuture<T> getClientAsync(URI serviceUri, ServicePartitionKey partitionKey, TargetReplicaSelector targetReplicaSelector, String listenerName, OperationRetrySettings retrySettings)

Resolves a partition of the specified service containing one or more communication listeners and returns a client to communicate to the endpoint corresponding to the given listenerName. The endpoint of the service is of the form - {"Endpoints":{"Listener1":"Endpoint1","Listener2":"Endpoint2" ...}}

List<ExceptionHandler> getExceptionHandlers()

Gets the custom exception handlers for handling exceptions on the client to service communication channel.

ServicePartitionResolver getServiceResolver()

Gets the ServicePartitionResolver used by the client factory for resolving the service endpoint.

String getTraceId()

Gets the trace identifier that is used to identify an instance of the CommunicationClientFactory. This is used as a correlation identifier for tracing/logging.

CompletableFuture<OperationRetryControl> reportOperationExceptionAsync(T client, ExceptionInformation exceptionInformation, OperationRetrySettings retrySettings)

Handles the exceptions that occur in the CommunicationClient when sending a message to the Service

abstract boolean validateClient(String endpoint, T client)

Returns true if the client is still valid and connected to the endpoint specified in the parameter.

abstract boolean validateClient(T client)

Returns true if the client is still valid. Connection oriented transports can use this method to indicate that the client is no longer connected to the service.

Inherited Members

Constructor Details

CommunicationClientFactoryBase

protected CommunicationClientFactoryBase()

Initializes a new instance of the communication client factory.

CommunicationClientFactoryBase

protected CommunicationClientFactoryBase(ServicePartitionResolver servicePartitionResolver, List exceptionHandlers)

Initializes a new instance of the communication client factory.

Parameters:

servicePartitionResolver - Optional ServicePartitionResolver
exceptionHandlers - Optional Custom exception handlers for the exceptions on the Client to Service communication channel

CommunicationClientFactoryBase

protected CommunicationClientFactoryBase(ServicePartitionResolver servicePartitionResolver, List exceptionHandlers, String traceId)

Initializes a new instance of the communication client factory.

Parameters:

servicePartitionResolver - Optional ServicePartitionResolver
exceptionHandlers - Optional Custom exception handlers for the exceptions on the Client to Service communication channel
traceId - Id to use in diagnostics traces from this component.

Method Details

abortClient

protected abstract void abortClient(T client)

Aborts the given client

Parameters:

client - Communication client

createClientAsync

protected abstract CompletableFuture createClientAsync(String endpoint)

Parameters:

endpoint

getClientAsync

public CompletableFuture getClientAsync(ResolvedServicePartition previousRsp, TargetReplicaSelector targetReplicaSelector, String listenerName, OperationRetrySettings retrySettings)

Resolves a partition of the specified service containing one or more communication listeners and returns a client to communicate to the endpoint corresponding to the given listenerName. The endpoint of the service is of the form - {"Endpoints":{"Listener1":"Endpoint1","Listener2":"Endpoint2" ...}}

Parameters:

previousRsp - previous ResolvedServicePartition
targetReplicaSelector -

TargetReplicaSelector

listenerName - Listener name
retrySettings - retry settings

Returns:

A CompletableFuture that represents outstanding operation. The result of the Task is the CommunicationClient(CommunicationClient) object.

getClientAsync

public CompletableFuture getClientAsync(URI serviceUri, ServicePartitionKey partitionKey, TargetReplicaSelector targetReplicaSelector, String listenerName, OperationRetrySettings retrySettings)

Resolves a partition of the specified service containing one or more communication listeners and returns a client to communicate to the endpoint corresponding to the given listenerName. The endpoint of the service is of the form - {"Endpoints":{"Listener1":"Endpoint1","Listener2":"Endpoint2" ...}}

Parameters:

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

TargetReplicaSelector

listenerName - Listener name
retrySettings - retry settings

Returns:

A CompletableFuture that represents outstanding operation. The result of the Task is the CommunicationClient(CommunicationClient) object.

getExceptionHandlers

public List getExceptionHandlers()

Gets the custom exception handlers for handling exceptions on the client to service communication channel.

Returns:

List of Exception handlers

getServiceResolver

public ServicePartitionResolver getServiceResolver()

Gets the ServicePartitionResolver used by the client factory for resolving the service endpoint.

Returns:

ServicePartitionResolver

getTraceId

protected String getTraceId()

Gets the trace identifier that is used to identify an instance of the CommunicationClientFactory. This is used as a correlation identifier for tracing/logging.

Returns:

Trace identifier

reportOperationExceptionAsync

public CompletableFuture reportOperationExceptionAsync(T client, ExceptionInformation exceptionInformation, OperationRetrySettings retrySettings)

Handles the exceptions that occur in the CommunicationClient when sending a message to the Service

Parameters:

client - Communication client
exceptionInformation - exception info
retrySettings - retry settings

Returns:

A CompletableFuture that represents outstanding operation. The result of the Task is a OperationRetryControl object that determines how the retry policy for this exception.

validateClient

protected abstract boolean validateClient(String endpoint, T client)

Returns true if the client is still valid and connected to the endpoint specified in the parameter.

Parameters:

endpoint - the endpoint
client - the communication client

Returns:

true if the client is valid, false otherwise

validateClient

protected abstract boolean validateClient(T client)

Returns true if the client is still valid. Connection oriented transports can use this method to indicate that the client is no longer connected to the service.

Parameters:

client - the communication client

Returns:

true if the client is valid, false otherwise

Applies to