Class GridClientConfiguration


  • public class GridClientConfiguration
    extends Object
    Java client configuration.
    • Field Detail

      • DFLT_CLIENT_PROTOCOL

        public static final GridClientProtocol DFLT_CLIENT_PROTOCOL
        Default client protocol.
      • DFLT_TOP_REFRESH_FREQ

        public static final int DFLT_TOP_REFRESH_FREQ
        Default topology refresh frequency is 2 sec.
        See Also:
        Constant Field Values
      • DFLT_MAX_CONN_IDLE_TIME

        public static final long DFLT_MAX_CONN_IDLE_TIME
        Default maximum time connection can be idle.
        See Also:
        Constant Field Values
      • DFLT_PING_INTERVAL

        public static final long DFLT_PING_INTERVAL
        Default ping interval in milliseconds.
        See Also:
        Constant Field Values
      • DFLT_PING_TIMEOUT

        public static final long DFLT_PING_TIMEOUT
        Default ping timeout in milliseconds.
        See Also:
        Constant Field Values
      • DFLT_CONNECT_TIMEOUT

        public static final int DFLT_CONNECT_TIMEOUT
        Default connect timeout in milliseconds.
        See Also:
        Constant Field Values
      • DFLT_TCP_NODELAY

        public static final boolean DFLT_TCP_NODELAY
        Default flag setting for TCP_NODELAY option.
        See Also:
        Constant Field Values
    • Constructor Detail

      • GridClientConfiguration

        public GridClientConfiguration()
        Creates default configuration.
      • GridClientConfiguration

        public GridClientConfiguration​(GridClientConfiguration cfg)
        Copy constructor.
        Parameters:
        cfg - Configuration to be copied.
      • GridClientConfiguration

        public GridClientConfiguration​(Properties in)
                                throws GridClientException
        Creates properties-based configuration based on passed in properties.
        Parameters:
        in - Client configuration in properties format.
        Throws:
        GridClientException - If parsing configuration failed.
      • GridClientConfiguration

        public GridClientConfiguration​(String prefix,
                                       Properties in)
                                throws GridClientException
        Creates properties-based configuration.
        Parameters:
        prefix - Prefix for the client properties.
        in - Properties map to load configuration from.
        Throws:
        GridClientException - If parsing configuration failed.
    • Method Detail

      • getServers

        public Collection<String> getServers()
        Collection of 'host:port' pairs representing remote grid servers used to establish initial connection to the grid. Once connection is established, Ignite will get a full view on grid topology and will be able to connect to any available remote node.

        Note that only these addresses are used to perform topology updates in background and to detect Grid connectivity status.

        Returns:
        Collection of 'host:port' pairs representing remote grid servers.
        See Also:
        GridClient.connected()
      • getRouters

        public Collection<String> getRouters()
        Collection of 'host:port' pairs representing grid routers used to establish connection to the grid.

        Addresses here could be owned by Routers as well as by individual Grid nodes. No additional connections will be made even if other Grid nodes are available.

        This configuration mode is designated for cases when some Grid nodes are unavailable (due to security restrictions for example). So only few nodes acting as routers or dedicated router components used to access entire Grid.

        This configuration parameter will not be used and direct connections to all grid nodes will be established if getServers() return non-empty collection value.

        Note that only these addresses are used to perform topology updates in background and to detect Grid connectivity status.

        Returns:
        Collection of 'host:port' pairs representing routers.
        See Also:
        GridClient.connected()
      • setServers

        public GridClientConfiguration setServers​(Collection<String> srvs)
        Sets list of servers this client should connect to.
        Parameters:
        srvs - List of servers.
        Returns:
        this for chaining.
      • setRouters

        public GridClientConfiguration setRouters​(Collection<String> routers)
        Sets list of routers this client should connect to.
        Parameters:
        routers - List of routers.
        Returns:
        this for chaining.
      • getProtocol

        public GridClientProtocol getProtocol()
        Gets protocol for communication between client and remote grid. Default is defined by DFLT_CLIENT_PROTOCOL constant.
        Returns:
        Protocol for communication between client and remote grid.
      • getConnectTimeout

        public int getConnectTimeout()
        Gets timeout for socket connect operation in milliseconds. If 0 - then wait infinitely. Default is defined by DFLT_CONNECT_TIMEOUT constant.
        Returns:
        Connect timeout in milliseconds.
      • isTcpNoDelay

        public boolean isTcpNoDelay()
        Gets flag indicating whether TCP_NODELAY flag should be enabled for outgoing connections. This flag reduces communication latency and in the majority of cases should be set to true. For more information, see Socket.setTcpNoDelay(boolean)

        If not set, default value is DFLT_TCP_NODELAY

        Returns:
        If TCP_NODELAY should be set on underlying sockets.
      • setTcpNoDelay

        public GridClientConfiguration setTcpNoDelay​(boolean tcpNoDelay)
        Sets whether TCP_NODELAY flag should be set on underlying socket connections.
        Parameters:
        tcpNoDelay - True if flag should be set.
        Returns:
        this for chaining.
      • setConnectTimeout

        public GridClientConfiguration setConnectTimeout​(int connectTimeout)
        Sets timeout for socket connect operation.
        Parameters:
        connectTimeout - Connect timeout in milliseconds.
        Returns:
        this for chaining.
      • getSslContextFactory

        public javax.cache.configuration.Factory<SSLContext> getSslContextFactory()
        Gets a factory that should be used for SSL context creation. If it returns null then SSL is considered disabled.
        Returns:
        Factory instance.
      • setSslContextFactory

        public GridClientConfiguration setSslContextFactory​(javax.cache.configuration.Factory<SSLContext> sslCtxFactory)
        Sets SSL context factory that will be used for creation of secure connections.
        Parameters:
        sslCtxFactory - Context factory.
        Returns:
        this for chaining.
      • getBalancer

        public GridClientLoadBalancer getBalancer()
        Default balancer to be used for computational client. It can be overridden for different compute instances. By default GridClientRandomBalancer is used.
        Returns:
        Default balancer to be used for computational client.
      • getSecurityCredentialsProvider

        public SecurityCredentialsProvider getSecurityCredentialsProvider()
        Gets client credentials provider to authenticate with.
        Returns:
        Credentials provider.
      • setSecurityCredentialsProvider

        public GridClientConfiguration setSecurityCredentialsProvider​(SecurityCredentialsProvider credProvider)
        Sets client credentials provider used in authentication process.
        Parameters:
        credProvider - Client credentials provider.
        Returns:
        this for chaining.
      • getDataConfigurations

        public Collection<GridClientDataConfiguration> getDataConfigurations()
        Gets a collection of data configurations specified by user.
        Returns:
        Collection of data configurations (possibly empty).
      • getDataConfiguration

        public GridClientDataConfiguration getDataConfiguration​(@Nullable
                                                                @Nullable String name)
        Gets data configuration for a cache with specified name.
        Parameters:
        name - Name of grid cache.
        Returns:
        Configuration or null if there is not configuration for specified name.
      • setEnableMetricsCache

        public GridClientConfiguration setEnableMetricsCache​(boolean enableMetricsCache)
        Sets flag indicating whether node and cache metrics should be cached by client.
        Parameters:
        enableMetricsCache - True if cache should be enabled.
        Returns:
        this for chaining.
      • isEnableMetricsCache

        public boolean isEnableMetricsCache()
        Enables client to cache per-node and per-cache metrics internally. In memory sensitive environments, such as mobile platforms, caching metrics may be expensive and, hence, this parameter should be set to false.

        Note that topology is refreshed automatically every getTopologyRefreshFrequency() interval, and if isAutoFetchMetrics() enabled then metrics will be updated with that frequency.

        By default this value is true which means that metrics will be cached on the client side.

        Returns:
        True if metrics cache is enabled, false otherwise.
      • setEnableAttributesCache

        public GridClientConfiguration setEnableAttributesCache​(boolean enableAttrsCache)
        Sets flag indicating whether node attributes should be cached by client.
        Parameters:
        enableAttrsCache - True if cache should be enabled.
        Returns:
        this for chaining.
      • isEnableAttributesCache

        public boolean isEnableAttributesCache()
        Enables client to cache per-node attributes internally. In memory sensitive environments, such as mobile platforms, caching node attributes may be expensive and, hence, this parameter should be set to false.

        Note that node attributes are static and, if cached, there is no need to refresh them again. If isAutoFetchAttributes() is enabled then attributes will be cached during client initialization.

        By default this value is true which means that node attributes will be cached on the client side.

        Returns:
        True if attributes cache is enabled, false otherwise.
      • setAutoFetchMetrics

        public GridClientConfiguration setAutoFetchMetrics​(boolean autoFetchMetrics)
        Sets flag indicating whether node metrics should be fetched by client automatically.
        Parameters:
        autoFetchMetrics - True if metrics should be fetched.
        Returns:
        this for chaining.
      • isAutoFetchMetrics

        public boolean isAutoFetchMetrics()
        Allows client to fetch node metrics automatically with background topology refresh.

        Note that this parameter will only affect auto-fetching of node metrics. Cache metrics still need to be fetched explicitly via GridClientData.metrics() or GridClientData.metricsAsync() methods.

        By default this value is true which means that metrics will be fetched automatically.

        Returns:
        true if client should fetch metrics on topology refresh, false otherwise.
      • setAutoFetchAttributes

        public GridClientConfiguration setAutoFetchAttributes​(boolean autoFetchAttrs)
        Sets flag indicating whether node attributes should be fetched by client automatically.
        Parameters:
        autoFetchAttrs - True if attributes should be fetched.
        Returns:
        this for chaining.
      • isAutoFetchAttributes

        public boolean isAutoFetchAttributes()
        Allows client to fetch node attributes automatically with background topology refresh.

        By default this value is true which means that attributes will be fetched automatically.

        Returns:
        True if client should fetch attributes once on topology refresh, false otherwise.
      • getTopologyRefreshFrequency

        public long getTopologyRefreshFrequency()
        Gets topology refresh frequency. Default is defined by DFLT_TOP_REFRESH_FREQ constant.
        Returns:
        Topology refresh frequency.
      • setTopologyRefreshFrequency

        public GridClientConfiguration setTopologyRefreshFrequency​(long topRefreshFreq)
        Sets topology refresh frequency. If topology cache is enabled, grid topology will be refreshed every topRefreshFreq milliseconds.
        Parameters:
        topRefreshFreq - Topology refresh frequency in milliseconds.
        Returns:
        this for chaining.
      • getMaxConnectionIdleTime

        public long getMaxConnectionIdleTime()
        Gets maximum amount of time that client connection can be idle before it is closed. Default is defined by DFLT_MAX_CONN_IDLE_TIME constant.
        Returns:
        Maximum idle time in milliseconds.
      • setMaxConnectionIdleTime

        public GridClientConfiguration setMaxConnectionIdleTime​(long maxConnIdleTime)
        Sets maximum time in milliseconds which connection can be idle before it is closed by client.
        Parameters:
        maxConnIdleTime - Maximum time of connection idleness in milliseconds.
        Returns:
        this for chaining.
      • getPingInterval

        public long getPingInterval()
        Gets time interval in milliseconds between ping requests. Default is defined by DFLT_PING_INTERVAL constant.

        Ping requests used by GridClientProtocol.TCP protocol to detect network failures and half-opened sockets.

        Returns:
        Ping interval.
      • setPingInterval

        public GridClientConfiguration setPingInterval​(long pingInterval)
        Sets ping interval in milliseconds.
        Parameters:
        pingInterval - Ping interval in milliseconds.
        Returns:
        this for chaining.
      • getPingTimeout

        public long getPingTimeout()
        Gets ping timeout. Default is defined by DFLT_PING_TIMEOUT constant.

        Ping requests used by GridClientProtocol.TCP protocol to detect network failures and half-opened sockets. If no response received in period equal to this timeout than connection considered broken and closed.

        Returns:
        Ping timeout.
      • setPingTimeout

        public GridClientConfiguration setPingTimeout​(long pingTimeout)
        Sets ping timeout in milliseconds.
        Parameters:
        pingTimeout - Ping interval in milliseconds.
        Returns:
        this for chaining.
      • getExecutorService

        public ExecutorService getExecutorService()
        Gets ExecutorService where client could run asynchronous operations.

        When using GridClientProtocol.TCP this executor should be able to serve at least Runtime.getRuntime().availableProcessors() parallel tasks.

        Note that this executor will be automatically shut down when client get closed.

        Returns:
        ExecutorService instance to use.
      • setExecutorService

        public GridClientConfiguration setExecutorService​(ExecutorService executor)
        Sets executor service.
        Parameters:
        executor - Executor service to use in client.
        Returns:
        this for chaining.
      • getMarshaller

        public GridClientMarshaller getMarshaller()
        Gets the marshaller, that is used to communicate between client and server.

        Options, that can be used out-of-the-box:

        Returns:
        A marshaller to use.
      • setMarshaller

        public GridClientConfiguration setMarshaller​(GridClientMarshaller marshaller)
        Sets the marshaller to use for communication.
        Parameters:
        marshaller - A marshaller to use.
        Returns:
        this for chaining.
      • load

        public void load​(String prefix,
                         Properties in)
                  throws GridClientException
        Load client configuration from the properties map.
        Parameters:
        prefix - Prefix for the client properties.
        in - Properties map to load configuration from.
        Throws:
        GridClientException - If parsing configuration failed.
      • setDaemon

        public GridClientConfiguration setDaemon​(boolean daemon)
        Set the daemon flag value. Communication threads will be created as daemons if this flag is set.
        Parameters:
        daemon - Daemon flag.
        Returns:
        this for chaining.
      • isDaemon

        public boolean isDaemon()
        Get the daemon flag.
        Returns:
        Daemon flag.
      • getUserAttributes

        public Map<String,​String> getUserAttributes()
        Returns user attributes which can be used on server node.
        Returns:
        User attributes.