Class ClientConfig

    • Constructor Detail

      • ClientConfig

        public ClientConfig()
      • ClientConfig

        public ClientConfig​(ClientConfig config)
    • Method Detail

      • load

        public static ClientConfig load()
        Populates Hazelcast ClientConfig object from an external configuration file.

        It tries to load Hazelcast Client configuration from a list of well-known locations, and then applies overrides found in environment variables/system properties When no location contains Hazelcast Client configuration then it returns default.

        Note that the same mechanism is used when calling HazelcastClient.newHazelcastClient().

        Returns:
        ClientConfig created from a file when exists, otherwise default.
      • setConfigPatternMatcher

        public ClientConfig setConfigPatternMatcher​(ConfigPatternMatcher configPatternMatcher)
        Sets the pattern matcher which is used to match item names to configuration objects. By default the MatchingPointConfigPatternMatcher is used.
        Parameters:
        configPatternMatcher - the pattern matcher
        Returns:
        this configuration
        Throws:
        java.lang.IllegalArgumentException - if the pattern matcher is null
      • getProperty

        public java.lang.String getProperty​(java.lang.String name)
        Gets a named property already set or from system properties if not exists.
        Parameters:
        name - property name
        Returns:
        value of the property
      • setProperty

        public ClientConfig setProperty​(java.lang.String name,
                                        java.lang.String value)
        Sets the value of a named property.
        Parameters:
        name - property name
        value - value of the property
        Returns:
        configured ClientConfig for chaining
      • getProperties

        public java.util.Properties getProperties()
        Gets Properties object
        Returns:
        Properties object
      • setProperties

        public ClientConfig setProperties​(java.util.Properties properties)
        sets all properties
        Parameters:
        properties - Properties object
        Returns:
        configured ClientConfig for chaining
      • setCredentials

        public ClientConfig setCredentials​(Credentials credentials)
        Shortcut for getSecurityConfig().setCredentials()
        Parameters:
        credentials - Credentials instance to be set
        Returns:
        configured ClientConfig for chaining
      • addReliableTopicConfig

        public ClientConfig addReliableTopicConfig​(ClientReliableTopicConfig reliableTopicConfig)
        Adds a ClientReliableTopicConfig.
        Parameters:
        reliableTopicConfig - the ClientReliableTopicConfig to add
        Returns:
        configured ClientConfig for chaining
      • getReliableTopicConfig

        public ClientReliableTopicConfig getReliableTopicConfig​(java.lang.String name)
        Gets the ClientReliableTopicConfig for a given reliable topic name.
        Parameters:
        name - the name of the reliable topic
        Returns:
        the found config. If none is found, a default configured one is returned.
      • getNearCacheConfigMap

        public java.util.Map<java.lang.String,​NearCacheConfig> getNearCacheConfigMap()
        Map of all configured NearCacheConfig's with the name key and configuration as the value
        Returns:
        map of NearCacheConfig
        See Also:
        NearCacheConfig
      • getFlakeIdGeneratorConfigMap

        public java.util.Map<java.lang.String,​ClientFlakeIdGeneratorConfig> getFlakeIdGeneratorConfigMap()
        Returns the map of FlakeIdGenerator configurations, mapped by config name. The config name may be a pattern with which the configuration was initially obtained.
        Returns:
        the map configurations mapped by config name
      • addFlakeIdGeneratorConfig

        public ClientConfig addFlakeIdGeneratorConfig​(ClientFlakeIdGeneratorConfig config)
        Adds a flake ID generator configuration. The configuration is saved under the config name, which may be a pattern with which the configuration will be obtained in the future.
        Parameters:
        config - the flake ID configuration
        Returns:
        this config instance
      • setFlakeIdGeneratorConfigMap

        public ClientConfig setFlakeIdGeneratorConfigMap​(java.util.Map<java.lang.String,​ClientFlakeIdGeneratorConfig> map)
        Sets the map of FlakeIdGenerator configurations, mapped by config name. The config name may be a pattern with which the configuration will be obtained in the future.
        Parameters:
        map - the FlakeIdGenerator configuration map to set
        Returns:
        this config instance
      • setReliableTopicConfigMap

        public ClientConfig setReliableTopicConfigMap​(java.util.Map<java.lang.String,​ClientReliableTopicConfig> map)
        Sets the map of ClientReliableTopicConfig, mapped by config name. The config name may be a pattern with which the configuration will be obtained in the future.
        Parameters:
        map - the FlakeIdGenerator configuration map to set
        Returns:
        this config instance
      • getReliableTopicConfigMap

        public java.util.Map<java.lang.String,​ClientReliableTopicConfig> getReliableTopicConfigMap()
        Returns the map of reliable topic configurations, mapped by config name. The config name may be a pattern with which the configuration was initially obtained.
        Returns:
        the map configurations mapped by config name
      • getLoadBalancer

        public LoadBalancer getLoadBalancer()
        Gets LoadBalancer
        Returns:
        LoadBalancer
        See Also:
        LoadBalancer
      • getLoadBalancerClassName

        public java.lang.String getLoadBalancerClassName()
        Gets load balancer class name
        Returns:
        load balancer class name
        See Also:
        LoadBalancer
      • setLoadBalancerClassName

        public ClientConfig setLoadBalancerClassName​(@Nonnull
                                                     java.lang.String loadBalancerClassName)
        Sets load balancer class name.

        If a load balancer implementation was set, it will be removed.

        Parameters:
        loadBalancerClassName - LoadBalancer
        Returns:
        configured ClientConfig for chaining
        See Also:
        LoadBalancer
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
        Gets the classLoader
        Returns:
        configured classLoader, null if not yet configured
      • setClassLoader

        public ClientConfig setClassLoader​(java.lang.ClassLoader classLoader)
        Sets the classLoader which is used by serialization and listener configuration
        Parameters:
        classLoader - the classLoader
        Returns:
        configured ClientConfig for chaining
      • getQueryCacheConfigs

        public java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​QueryCacheConfig>> getQueryCacheConfigs()
      • setQueryCacheConfigs

        public ClientConfig setQueryCacheConfigs​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​QueryCacheConfig>> queryCacheConfigs)
      • getInstanceName

        public java.lang.String getInstanceName()
      • setInstanceName

        public ClientConfig setInstanceName​(java.lang.String instanceName)
      • getClusterName

        public java.lang.String getClusterName()
        Returns the configured cluster name. The name is sent as part of client authentication message and may be verified on the member.
        Returns:
        the configured cluster name
      • setClusterName

        public ClientConfig setClusterName​(java.lang.String clusterName)
      • getUserCodeDeploymentConfig

        public ClientUserCodeDeploymentConfig getUserCodeDeploymentConfig()
        Get current configuration of User Code Deployment.
        Returns:
        User Code Deployment configuration
        Since:
        3.9
      • setUserCodeDeploymentConfig

        public ClientConfig setUserCodeDeploymentConfig​(ClientUserCodeDeploymentConfig userCodeDeploymentConfig)
        Set User Code Deployment configuration
        Parameters:
        userCodeDeploymentConfig - the configuration of User Code Deployment
        Returns:
        configured ClientConfig for chaining
        Since:
        3.9
      • getOrCreateQueryCacheConfig

        public QueryCacheConfig getOrCreateQueryCacheConfig​(java.lang.String mapName,
                                                            java.lang.String cacheName)
        Parameters:
        mapName - The name of the map for which the query cache config is to be returned.
        cacheName - The name of the query cache.
        Returns:
        The query cache config. If the config does not exist, it is created.
      • getOrNullQueryCacheConfig

        public QueryCacheConfig getOrNullQueryCacheConfig​(java.lang.String mapName,
                                                          java.lang.String cacheName)
        Parameters:
        mapName - The name of the map for which the query cache config is to be returned.
        cacheName - The name of the query cache.
        Returns:
        The query cache config. If no such config exist null is returned.
      • addLabel

        public ClientConfig addLabel​(java.lang.String label)
        Adds a label for this client Client available
        Parameters:
        label - The label to be added.
        Returns:
        configured ClientConfig for chaining
      • getLabels

        public java.util.Set<java.lang.String> getLabels()
        Returns:
        all the labels assigned to this client
      • setLabels

        public ClientConfig setLabels​(java.util.Set<java.lang.String> labels)
        Set labels for the client. Deletes old labels if added earlier.
        Parameters:
        labels - The labels to be set
        Returns:
        configured ClientConfig for chaining
      • setUserContext

        public ClientConfig setUserContext​(java.util.concurrent.ConcurrentMap<java.lang.String,​java.lang.Object> userContext)
      • getUserContext

        public java.util.concurrent.ConcurrentMap<java.lang.String,​java.lang.Object> getUserContext()
      • setBackupAckToClientEnabled

        public ClientConfig setBackupAckToClientEnabled​(boolean backupAckToClientEnabled)
        This feature reduces number of hops and increase performance for smart clients. It is enabled by default for smart clients. This config has no effect for unisocket clients.
        Parameters:
        backupAckToClientEnabled - enables client to get backup acknowledgements directly from the member that backups are applied
        Returns:
        configured ClientConfig for chaining
      • isBackupAckToClientEnabled

        public boolean isBackupAckToClientEnabled()
        Note that backup acks to client can be enabled only for smart client. This config has no effect for unisocket clients.
        Returns:
        true if backup acknowledgements comes to client
      • getMetricsConfig

        @Nonnull
        public ClientMetricsConfig getMetricsConfig()
        Returns the metrics collection config.
      • getInstanceTrackingConfig

        @Nonnull
        public InstanceTrackingConfig getInstanceTrackingConfig()
        Returns the configuration for tracking use of this Hazelcast instance.
      • setInstanceTrackingConfig

        @Nonnull
        public ClientConfig setInstanceTrackingConfig​(@Nonnull
                                                      InstanceTrackingConfig instanceTrackingConfig)
        Returns the configuration for tracking use of this Hazelcast instance.
      • getSqlConfig

        @Nonnull
        public ClientSqlConfig getSqlConfig()
        Returns the configuration for the SQL feature.
        Since:
        5.2
      • setSqlConfig

        @Nonnull
        public ClientConfig setSqlConfig​(ClientSqlConfig sqlConfig)
        Sets the configuration for the SQL feature.
        Since:
        5.2
      • getTpcConfig

        @Beta
        @Nonnull
        public ClientTpcConfig getTpcConfig()
        Returns the ClientTpcConfig
        Returns:
        the ClientTpcConfig
        Since:
        5.3
      • setTpcConfig

        @Beta
        @Nonnull
        public ClientConfig setTpcConfig​(@Nonnull
                                         ClientTpcConfig tpcConfig)
        Sets the TpcConfig
        Parameters:
        tpcConfig - TpcConfig to set
        Returns:
        configured ClientConfig for chaining
        Throws:
        java.lang.IllegalArgumentException - if the tpcConfig is null
        Since:
        5.3
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object