@ThreadSafe public abstract class AbstractMasterClient extends AbstractClient
AbstractClient.RpcCallable<V>
mAlwaysEnableTLS, mChannel, mClosed, mConnected, mContext, mServerAddress, mServiceVersion, mVersionService
Constructor and Description |
---|
AbstractMasterClient(MasterClientContext clientConf)
Creates a new master client base and default the selection policy to primary master.
|
AbstractMasterClient(MasterClientContext clientConf,
MasterSelectionPolicy selectionPolicy)
Creates a new master client base.
|
AbstractMasterClient(MasterClientContext clientConf,
MasterSelectionPolicy selectionPolicy,
java.util.function.Supplier<RetryPolicy> retryPolicySupplier)
Creates a new master client without a specific address.
|
AbstractMasterClient(MasterClientContext clientConf,
java.util.function.Supplier<RetryPolicy> retryPolicySupplier)
Creates a new master client without a specific address.
|
Modifier and Type | Method and Description |
---|---|
protected void |
afterDisconnect()
This method is called after the connection is disconnected.
|
protected void |
beforeConnect()
This method is called before the connection is connected.
|
InetSocketAddress |
getConfAddress()
By default, return the same underlying address as
AbstractClient.getRemoteSockAddress() . |
protected GrpcServerAddress |
queryGrpcServerAddress()
AbstractClient works with Grpc Servers. |
afterConnect, beforeDisconnect, checkVersion, close, connect, connectWithRuntimeException, createChannel, disconnect, getRemoteHostName, getRemoteServiceType, getRemoteServiceVersion, getRemoteSockAddress, getServiceName, getServiceVersion, isClosed, isConnected, retryRPC, retryRPC
public AbstractMasterClient(MasterClientContext clientConf)
clientConf
- master client configurationpublic AbstractMasterClient(MasterClientContext clientConf, MasterSelectionPolicy selectionPolicy)
clientConf
- master client configurationselectionPolicy
- master selection policy: which master the client should connect topublic AbstractMasterClient(MasterClientContext clientConf, java.util.function.Supplier<RetryPolicy> retryPolicySupplier)
clientConf
- master client configurationretryPolicySupplier
- retry policy to usepublic AbstractMasterClient(MasterClientContext clientConf, MasterSelectionPolicy selectionPolicy, java.util.function.Supplier<RetryPolicy> retryPolicySupplier)
clientConf
- master client configurationselectionPolicy
- master selection policy: which master the client should connect toretryPolicySupplier
- retry policy to usepublic InetSocketAddress getConfAddress() throws UnavailableException
AbstractClient
AbstractClient.getRemoteSockAddress()
.
Child classes should override this implementation if they intend to have different
address to fetch configuration.getConfAddress
in interface Client
getConfAddress
in class AbstractClient
UnavailableException
- if address cannot be determinedprotected void beforeConnect() throws IOException
AbstractClient
beforeConnect
in class AbstractClient
IOException
protected void afterDisconnect()
AbstractClient
afterDisconnect
in class AbstractClient
protected GrpcServerAddress queryGrpcServerAddress() throws UnavailableException
AbstractClient
AbstractClient
works with Grpc Servers.
Child classes should only override this method to query the address
of the grpc server they talk to. The conversion from GrpcServerAddress
to more generic SocketAddress
required by Client.getRemoteSockAddress()
is handled by this class.queryGrpcServerAddress
in class AbstractClient
GrpcServerAddress
of the remote serverUnavailableException
- if address can't be determinedCopyright © 2023. All Rights Reserved.