程序包 com.baidubce

类 BceClientConfiguration

    • 字段详细资料

      • DEFAULT_CONNECTION_TIMEOUT_IN_MILLIS

        public static final int DEFAULT_CONNECTION_TIMEOUT_IN_MILLIS
        The default timeout for creating new connections.
        另请参阅:
        常量字段值
      • DEFAULT_SOCKET_TIMEOUT_IN_MILLIS

        public static final int DEFAULT_SOCKET_TIMEOUT_IN_MILLIS
        The default timeout for reading from a connected socket.
        另请参阅:
        常量字段值
      • DEFAULT_MAX_CONNECTIONS

        public static final int DEFAULT_MAX_CONNECTIONS
        The default max connection pool size.
        另请参阅:
        常量字段值
      • DEFAULT_USER_AGENT

        public static final String DEFAULT_USER_AGENT
        The default User-Agent header value when sending requests to the target service. Initialized in the static initializer.
      • DEFAULT_REGION

        public static Region DEFAULT_REGION
        The default region.
      • DEFAULT_PROTOCOL

        public static Protocol DEFAULT_PROTOCOL
        The default protocol.
    • 构造器详细资料

      • BceClientConfiguration

        public BceClientConfiguration()
        Constructs a new BceClientConfiguration instance with default settings.
      • BceClientConfiguration

        public BceClientConfiguration​(BceClientConfiguration other)
        Constructs a new BceClientConfiguration instance with the same settings as the specified configuration.
        参数:
        other - the configuration to copy settings from.
      • BceClientConfiguration

        public BceClientConfiguration​(BceClientConfiguration other,
                                      String endpoint)
        Constructs a new BceClientConfiguration 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
    • 方法详细资料

      • getProtocol

        public Protocol getProtocol()
        Returns the protocol (HTTP/HTTPS) to use when connecting to BCE services.
        返回:
        the protocol (HTTP/HTTPS) to use when connecting to BCE services.
      • setProtocol

        public void setProtocol​(Protocol protocol)
        Sets the protocol (HTTP/HTTPS) to use when connecting to BCE services.
        参数:
        protocol - the protocol (HTTP/HTTPS) to use when connecting to BCE services.
      • withProtocol

        public BceClientConfiguration withProtocol​(Protocol protocol)
        Sets the protocol (HTTP/HTTPS) to use when connecting to BCE services, and returns the updated configuration instance.
        参数:
        protocol - the protocol (HTTP/HTTPS) to use when connecting to BCE services.
        返回:
        the updated configuration instance.
      • getMaxConnections

        public int getMaxConnections()
        Returns the maximum number of open HTTP connections.
        返回:
        the maximum number of open HTTP connections.
      • 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

        public BceClientConfiguration withMaxConnections​(int maxConnections)
        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.
      • getUserAgent

        public String getUserAgent()
        Returns the User-Agent header value to use when sending requests to BCE services.
        返回:
        the User-Agent header value to use when sending requests to BCE services.
      • setUserAgent

        public void setUserAgent​(String userAgent)
        Sets the User-Agent header value to use when sending requests to BCE services.

        If the specified value is null, DEFAULT_USER_AGENT is used. If the specified value does not end with DEFAULT_USER_AGENT, DEFAULT_USER_AGENT is appended.

        参数:
        userAgent - the User-Agent header value to use when sending requests to BCE services.
      • withUserAgent

        public BceClientConfiguration withUserAgent​(String userAgent)
        Sets the User-Agent header value to use when sending requests to BCE services, and returns the updated configuration instance.

        If the specified value is null, DEFAULT_USER_AGENT is used. If the specified value does not end with DEFAULT_USER_AGENT, DEFAULT_USER_AGENT is appended.

        参数:
        userAgent - the User-Agent header value to use when sending requests to BCE services.
        返回:
        the updated configuration instance.
      • getLocalAddress

        public InetAddress getLocalAddress()
        Returns the optional local address to bind when connecting to BCE services.
        返回:
        the optional local address to bind when connecting to BCE services.
      • setLocalAddress

        public void setLocalAddress​(InetAddress localAddress)
        Sets the optional local address to bind when connecting to BCE services.
        参数:
        localAddress - the optional local address to bind when connecting to BCE services.
      • withLocalAddress

        public BceClientConfiguration withLocalAddress​(InetAddress localAddress)
        Sets the optional local address to bind when connecting to BCE services, and returns the updated configuration instance.
        参数:
        localAddress - the optional local address to bind when connecting to BCE services.
        返回:
        the updated configuration instance.
      • isRedirectsEnabled

        public boolean isRedirectsEnabled()
        Gets the flag of http redirection
        返回:
      • setRedirectsEnabled

        public void setRedirectsEnabled​(boolean redirectsEnabled)
        Sets the flag of http redirection
        参数:
        redirectsEnabled -
      • withRedirectsEnabled

        public BceClientConfiguration withRedirectsEnabled​(boolean redirectsEnabled)
        Sets the flag of http redirection
        参数:
        redirectsEnabled -
        返回:
        the updated configuration instance.
      • getProxyHost

        public String getProxyHost()
        Returns the optional proxy host the client will connect through.
        返回:
        the optional proxy host the client will connect through.
      • setProxyHost

        public void setProxyHost​(String proxyHost)
        Sets the optional proxy host the client will connect through.

        The client will connect through the proxy only if the host is not null and the port is positive.

        参数:
        proxyHost - the optional proxy host the client will connect through.
      • withProxyHost

        public BceClientConfiguration withProxyHost​(String proxyHost)
        Sets the optional proxy host the client will connect through, and returns the updated configuration instance.

        The client will connect through the proxy only if the host is not null and the port is positive.

        参数:
        proxyHost - the optional proxy host the client will connect through.
        返回:
        the updated configuration instance.
      • getProxyPort

        public int getProxyPort()
        Returns the optional proxy port the client will connect through.
        返回:
        the optional proxy port the client will connect through.
      • setProxyPort

        public void setProxyPort​(int proxyPort)
        Sets the optional proxy port the client will connect through.

        The client will connect through the proxy only if the host is not null and the port is positive.

        参数:
        proxyPort - the optional proxy port the client will connect through.
      • withProxyPort

        public BceClientConfiguration withProxyPort​(int proxyPort)
        Sets the optional proxy port the client will connect through, and returns the updated configuration instance.

        The client will connect through the proxy only if the host is not null and the port is positive.

        参数:
        proxyPort - the optional proxy port the client will connect through.
        返回:
        the updated configuration instance.
      • getProxyUsername

        public String getProxyUsername()
        Returns the optional user name to use when connecting through a proxy.
        返回:
        the optional user name to use when connecting through a proxy.
      • setProxyUsername

        public void setProxyUsername​(String proxyUsername)
        Sets the optional user name to use when connecting through a proxy.
        参数:
        proxyUsername - the optional user name to use when connecting through a proxy.
      • withProxyUsername

        public BceClientConfiguration withProxyUsername​(String proxyUsername)
        Sets the optional user name to use when connecting through a proxy, and returns the updated configuration instance.
        参数:
        proxyUsername - the optional user name to use when connecting through a proxy.
        返回:
        the updated configuration instance.
      • getProxyPassword

        public String getProxyPassword()
        Returns the optional password to use when connecting through a proxy.
        返回:
        the optional password to use when connecting through a proxy.
      • setProxyPassword

        public void setProxyPassword​(String proxyPassword)
        Sets the optional password to use when connecting through a proxy.
        参数:
        proxyPassword - the optional password to use when connecting through a proxy.
      • withProxyPassword

        public BceClientConfiguration withProxyPassword​(String proxyPassword)
        Sets the optional password to use when connecting through a proxy, and returns the updated configuration instance.
        参数:
        proxyPassword - the optional password to use when connecting through a proxy.
        返回:
        the updated configuration instance.
      • getProxyDomain

        public String getProxyDomain()
        Returns the optional Windows domain to use when connecting through a Windows NTLM proxy.
        返回:
        the optional Windows domain to use when connecting through a Windows NTLM proxy.
      • setProxyDomain

        public void setProxyDomain​(String proxyDomain)
        Sets the optional Windows domain to use when connecting through a Windows NTLM proxy.
        参数:
        proxyDomain - the optional Windows domain to use when connecting through a Windows NTLM proxy.
      • withProxyDomain

        public BceClientConfiguration withProxyDomain​(String proxyDomain)
        Sets the optional Windows domain to use when connecting through a Windows NTLM proxy, and returns the updated configuration instance.
        参数:
        proxyDomain - the optional Windows domain to use when connecting through a Windows NTLM proxy.
        返回:
        the updated configuration instance.
      • getProxyWorkstation

        public String getProxyWorkstation()
        Returns the optional Windows workstation to use when connecting through a Windows NTLM proxy.
        返回:
        the optional Windows workstation to use when connecting through a Windows NTLM proxy.
      • setProxyWorkstation

        public void setProxyWorkstation​(String proxyWorkstation)
        Sets the optional Windows workstation to use when connecting through a Windows NTLM proxy.
        参数:
        proxyWorkstation - the optional Windows workstation to use when connecting through a Windows NTLM proxy.
      • withProxyWorkstation

        public BceClientConfiguration withProxyWorkstation​(String proxyWorkstation)
        Sets the optional Windows workstation to use when connecting through a Windows NTLM proxy, and returns the updated configuration instance.
        参数:
        proxyWorkstation - the optional Windows workstation to use when connecting through a Windows NTLM proxy.
        返回:
        the updated configuration instance.
      • isProxyPreemptiveAuthenticationEnabled

        public boolean isProxyPreemptiveAuthenticationEnabled()
        Returns whether to enable proxy preemptive authentication. If it is true, the client will send the basic authentication response even before the proxy server gives an unauthorized response in certain situations, thus reducing the overhead of making the connection.
        返回:
        whether to enable proxy preemptive authentication.
      • setProxyPreemptiveAuthenticationEnabled

        public void setProxyPreemptiveAuthenticationEnabled​(boolean proxyPreemptiveAuthenticationEnabled)
        Sets whether to enable proxy preemptive authentication. If it is true, the client will send the basic authentication response even before the proxy server gives an unauthorized response in certain situations, thus reducing the overhead of making the connection.
        参数:
        proxyPreemptiveAuthenticationEnabled - whether to enable proxy preemptive authentication.
      • withProxyPreemptiveAuthenticationEnabled

        public BceClientConfiguration withProxyPreemptiveAuthenticationEnabled​(boolean proxyPreemptiveAuthenticationEnabled)
        Sets whether to enable proxy preemptive authentication, and returns the updated configuration instance. If it is true, the client will send the basic authentication response even before the proxy server gives an unauthorized response in certain situations, thus reducing the overhead of making the connection.
        参数:
        proxyPreemptiveAuthenticationEnabled - whether to enable proxy preemptive authentication.
        返回:
        the updated configuration instance.
      • getRetryPolicy

        public RetryPolicy getRetryPolicy()
        Returns the retry policy for failed requests.
        返回:
        the retry policy for failed requests.
      • setRetryPolicy

        public void setRetryPolicy​(RetryPolicy retryPolicy)
        Sets the retry policy for failed requests.
        参数:
        retryPolicy - the retry policy for failed requests.
      • withRetryPolicy

        public BceClientConfiguration withRetryPolicy​(RetryPolicy retryPolicy)
        Sets the retry policy for failed requests, and returns the updated configuration instance.
        参数:
        retryPolicy - the retry policy for failed requests.
        返回:
        the updated configuration instance.
      • getSocketTimeoutInMillis

        public int getSocketTimeoutInMillis()
        Returns the socket timeout (SO_TIMEOUT) in milliseconds, which is a maximum period inactivity between two consecutive data packets.
        返回:
        the socket timeout (SO_TIMEOUT) in milliseconds.
      • 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

        public BceClientConfiguration 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. 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.
      • getConnectionTimeoutInMillis

        public int getConnectionTimeoutInMillis()
        Returns the connection timeout in milliseconds.
        返回:
        the connection timeout in milliseconds.
      • 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

        public BceClientConfiguration withConnectionTimeoutInMillis​(int connectionTimeoutInMillis)
        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.
      • getSocketBufferSizeInBytes

        public int getSocketBufferSizeInBytes()
        Returns the optional size (in bytes) for the low level TCP socket buffer. 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.
        返回:
        the optional size (in bytes) for the low level TCP socket buffer.
      • setSocketBufferSizeInBytes

        public void setSocketBufferSizeInBytes​(int socketBufferSizeInBytes)
        Sets the optional size (in bytes) for the low level TCP socket buffer. 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.
      • withSocketBufferSizeInBytes

        public BceClientConfiguration withSocketBufferSizeInBytes​(int socketBufferSizeInBytes)
        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

        public String getEndpoint()
        Returns the service endpoint URL to which the client will connect.
        返回:
        the service endpoint URL to which the client will connect.
      • setEndpoint

        public void setEndpoint​(String endpoint)
        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

        public BceClientConfiguration withEndpoint​(String endpoint)
        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.
      • getRegion

        public Region getRegion()
        Returns the region of service. This value is used by the client to construct the endpoint URL automatically, and is ignored if endpoint is not null.
        返回:
        the region of service.
      • setRegion

        public void setRegion​(Region region)
        Sets the region of service. This value is used by the client to construct the endpoint URL automatically, and is ignored if endpoint is not null.

        If the specified region is null, sets to DEFAULT_REGION.

        参数:
        region - the region of service.
      • withRegion

        public BceClientConfiguration withRegion​(Region region)
        Sets the region of service, and returns the updated configuration instance. This value is used by the client to construct the endpoint URL automatically, and is ignored if endpoint is not null.

        If the specified region is null, sets to DEFAULT_REGION.

        参数:
        region - the region of service.
        返回:
        the updated configuration instance.
      • getCredentials

        public BceCredentials getCredentials()
        Returns the BCE credentials used by the client to sign HTTP requests.
        返回:
        the BCE credentials used by the client to sign HTTP requests.
      • setCredentials

        public void setCredentials​(BceCredentials credentials)
        Sets the BCE credentials used by the client to sign HTTP requests.
        参数:
        credentials - the BCE credentials used by the client to sign HTTP requests.
        抛出:
        NullPointerException - if credentials is null.
      • withCredentials

        public BceClientConfiguration withCredentials​(BceCredentials credentials)
        Sets the BCE credentials used by the client to sign HTTP requests, and returns the updated configuration instance.
        参数:
        credentials - the BCE credentials used by the client to sign HTTP requests.
        返回:
        the updated configuration instance.
        抛出:
        NullPointerException - if credentials is null.