类 ClientConfiguration
java.lang.Object
com.baidu.mochow.client.ClientConfiguration
Basic client configurations for Mochow clients.
-
字段概要
字段修饰符和类型字段说明static final intThe default timeout for creating new connections.static final intThe default max connection pool size.static final intThe default timeout for reading from a connected socket.static ProtocolThe default protocol. -
构造器概要
构造器构造器说明Constructs a new ClientConfiguration instance with default settings.Constructs a new ClientConfiguration instance with the same settings as the specified configuration.ClientConfiguration(ClientConfiguration other, String endpoint) Constructs a new ClientConfiguration instance with the same settings as the specified configuration. -
方法概要
修饰符和类型方法说明Returns the service endpoint URL to which the client will connect.voidsetConnectionTimeoutInMillis(int connectionTimeoutInMillis) Sets the connection timeout in milliseconds.voidsetCredentials(Credentials credentials) Sets the Mochow credentials used by the client to sign HTTP requests.voidsetEndpoint(String endpoint) Sets the service endpoint URL to which the client will connect.voidsetIoThreadCount(int ioThreadCount) Sets the maximum number of open io thread.voidsetMaxConnections(int maxConnections) Sets the maximum number of open HTTP connections.voidsetProtocol(Protocol protocol) Sets the protocol (HTTP/HTTPS) to use when connecting to Mochow services.voidsetRetryPolicy(RetryPolicy retryPolicy) Sets the retry policy for failed requests.voidsetSocketTimeoutInMillis(int socketTimeoutInMillis) Sets the socket timeout (SO_TIMEOUT) in milliseconds, which is a maximum period inactivity between two consecutive data packets.toString()withConnectionTimeoutInMillis(int connectionTimeoutInMillis) Sets the connection timeout in milliseconds, and returns the updated configuration instance.withCredentials(Credentials credentials) Sets the Mochow credentials used by the client to sign HTTP requests, and returns the updated configuration instance.withEndpoint(String endpoint) Sets the service endpoint URL to which the client will connect, and returns the updated configuration instance.withIoThreadCount(int ioThreadCount) Sets the maximum number of io thread, and returns the updated configuration instance.withLocalAddress(InetAddress localAddress) Sets the optional local address to bind when connecting to Mochow services, and returns the updated configuration instance.withMaxConnections(int maxConnections) Sets the maximum number of open HTTP connections, and returns the updated configuration instance.withProtocol(Protocol protocol) Sets the protocol (HTTP/HTTPS) to use when connecting to Mochow services, and returns the updated configuration instance.withRetryPolicy(RetryPolicy retryPolicy) Sets the retry policy for failed requests, and returns the updated configuration instance.withSocketBufferSizeInBytes(int socketBufferSizeInBytes) Sets the optional size (in bytes) for the low level TCP socket buffer, and returns the updated configuration instance.withSocketTimeoutInMillis(int socketTimeoutInMillis) Sets the socket timeout (SO_TIMEOUT) in milliseconds, which is a maximum period inactivity between two consecutive data packets, and returns the updated configuration instance.
-
字段详细资料
-
DEFAULT_CONNECTION_TIMEOUT_IN_MILLIS
public static final int DEFAULT_CONNECTION_TIMEOUT_IN_MILLISThe default timeout for creating new connections.- 另请参阅:
-
DEFAULT_SOCKET_TIMEOUT_IN_MILLIS
public static final int DEFAULT_SOCKET_TIMEOUT_IN_MILLISThe default timeout for reading from a connected socket.- 另请参阅:
-
DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_MAX_CONNECTIONSThe default max connection pool size.- 另请参阅:
-
defaultProtocol
The default protocol.
-
-
构造器详细资料
-
ClientConfiguration
public ClientConfiguration()Constructs a new ClientConfiguration instance with default settings. -
ClientConfiguration
Constructs a new ClientConfiguration instance with the same settings as the specified configuration.- 参数:
other- the configuration to copy settings from.
-
ClientConfiguration
Constructs a new ClientConfiguration instance with the same settings as the specified configuration. This constructor is used to create a client configuration from one SDK to another SDK. e.g. from VOD to BOS. In this case endpoint should be changed while other attributes keep same.- 参数:
other- the configuration to copy settings from.endpoint- the endpoint
-
-
方法详细资料
-
setProtocol
Sets the protocol (HTTP/HTTPS) to use when connecting to Mochow services.- 参数:
protocol- the protocol (HTTP/HTTPS) to use when connecting to Mochow services.
-
withProtocol
Sets the protocol (HTTP/HTTPS) to use when connecting to Mochow services, and returns the updated configuration instance.- 参数:
protocol- the protocol (HTTP/HTTPS) to use when connecting to Mochow services.- 返回:
- the updated configuration instance.
-
setMaxConnections
public void setMaxConnections(int maxConnections) Sets the maximum number of open HTTP connections.- 参数:
maxConnections- the maximum number of open HTTP connections.- 抛出:
IllegalArgumentException- if maxConnections is negative.
-
withMaxConnections
Sets the maximum number of open HTTP connections, and returns the updated configuration instance.- 参数:
maxConnections- the maximum number of open HTTP connections.- 返回:
- the updated configuration instance.
- 抛出:
IllegalArgumentException- if maxConnections is negative.
-
setIoThreadCount
public void setIoThreadCount(int ioThreadCount) Sets the maximum number of open io thread.- 参数:
ioThreadCount- the maximum number of open HTTP connections.- 抛出:
IllegalArgumentException- if ioThreadCount is negative.
-
withIoThreadCount
Sets the maximum number of io thread, and returns the updated configuration instance.- 参数:
ioThreadCount- the maximum number of io thread.- 返回:
- the updated configuration instance.
- 抛出:
IllegalArgumentException- if ioThreadCount is negative.
-
withLocalAddress
Sets the optional local address to bind when connecting to Mochow services, and returns the updated configuration instance.- 参数:
localAddress- the optional local address to bind when connecting to Mochow services.- 返回:
- the updated configuration instance.
-
setRetryPolicy
Sets the retry policy for failed requests.- 参数:
retryPolicy- the retry policy for failed requests.
-
withRetryPolicy
Sets the retry policy for failed requests, and returns the updated configuration instance.- 参数:
retryPolicy- the retry policy for failed requests.- 返回:
- the updated configuration instance.
-
setSocketTimeoutInMillis
public void setSocketTimeoutInMillis(int socketTimeoutInMillis) Sets the socket timeout (SO_TIMEOUT) in milliseconds, which is a maximum period inactivity between two consecutive data packets. A value of 0 means infinity, and is not recommended.- 参数:
socketTimeoutInMillis- the socket timeout (SO_TIMEOUT) in milliseconds.- 抛出:
IllegalArgumentException- if socketTimeoutInMillis is negative.
-
withSocketTimeoutInMillis
Sets the socket timeout (SO_TIMEOUT) in milliseconds, which is a maximum period inactivity between two consecutive data packets, and returns the updated configuration instance. A value of 0 means infinity, and is not recommended.- 参数:
socketTimeoutInMillis- the socket timeout (SO_TIMEOUT) in milliseconds.- 返回:
- the updated configuration instance.
- 抛出:
IllegalArgumentException- if socketTimeoutInMillis is negative.
-
setConnectionTimeoutInMillis
public void setConnectionTimeoutInMillis(int connectionTimeoutInMillis) Sets the connection timeout in milliseconds. A value of 0 means infinity, and is not recommended.- 参数:
connectionTimeoutInMillis- the connection timeout in milliseconds.- 抛出:
IllegalArgumentException- if connectionTimeoutInMillis is negative.
-
withConnectionTimeoutInMillis
Sets the connection timeout in milliseconds, and returns the updated configuration instance. A value of 0 means infinity, and is not recommended.- 参数:
connectionTimeoutInMillis- the connection timeout in milliseconds.- 返回:
- the updated configuration instance.
- 抛出:
IllegalArgumentException- if connectionTimeoutInMillis is negative.
-
withSocketBufferSizeInBytes
Sets the optional size (in bytes) for the low level TCP socket buffer, and returns the updated configuration instance. This is an advanced option for advanced users who want to tune low level TCP parameters to try and squeeze out more performance. Ignored if not positive.- 参数:
socketBufferSizeInBytes- the optional size (in bytes) for the low level TCP socket buffer.- 返回:
- the updated configuration instance.
-
getEndpoint
Returns the service endpoint URL to which the client will connect.- 返回:
- the service endpoint URL to which the client will connect.
-
setEndpoint
Sets the service endpoint URL to which the client will connect.- 参数:
endpoint- the service endpoint URL to which the client will connect.- 抛出:
IllegalArgumentException- if endpoint is not a valid URL.NullPointerException- if endpoint is null.
-
withEndpoint
Sets the service endpoint URL to which the client will connect, and returns the updated configuration instance.- 参数:
endpoint- the service endpoint URL to which the client will connect.- 返回:
- the updated configuration instance.
- 抛出:
IllegalArgumentException- if endpoint is not a valid URL.NullPointerException- if endpoint is null.
-
setCredentials
Sets the Mochow credentials used by the client to sign HTTP requests.- 参数:
credentials- the Mochow credentials used by the client to sign HTTP requests.- 抛出:
NullPointerException- if credentials is null.
-
withCredentials
Sets the Mochow credentials used by the client to sign HTTP requests, and returns the updated configuration instance.- 参数:
credentials- the Mochow credentials used by the client to sign HTTP requests.- 返回:
- the updated configuration instance.
- 抛出:
NullPointerException- if credentials is null.
-
toString
-