# Class ZKClientConfig

java.lang.Object
org.apache.zookeeper.common.ZKConfig
org.apache.zookeeper.client.ZKClientConfig

@Public public class ZKClientConfig extends ZKConfig
Handles client specific properties

Since:
  3.5.2

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`CLIENT_MAX_PACKET_LENGTH_DEFAULT`
`static final String`
`DISABLE_AUTO_WATCH_RESET`
This controls whether automatic watch resetting is enabled.
`static final String`
`ENABLE_CLIENT_SASL_DEFAULT`
`static final String`
`ENABLE_CLIENT_SASL_KEY`
`static final String`
`LOGIN_CONTEXT_NAME_KEY`
`static final String`
`LOGIN_CONTEXT_NAME_KEY_DEFAULT`
`static final String`
`SECURE_CLIENT`
Setting this to "true" will enable encrypted client-server communication.
`static final String`
`ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME`
`static final String`
`ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME_DEFAULT`
`static final String`
`ZK_SASL_CLIENT_USERNAME`
`static final String`
`ZK_SASL_CLIENT_USERNAME_DEFAULT`
`static final String`
`ZOOKEEPER_CLIENT_CNXN_SOCKET`
`static final String`
`ZOOKEEPER_REQUEST_TIMEOUT`
`static final long`
`ZOOKEEPER_REQUEST_TIMEOUT_DEFAULT`
Feature is disabled by default.
`static final String`
`ZOOKEEPER_SERVER_PRINCIPAL`
`static final String`
`ZOOKEEPER_SERVER_REALM`

### Fields inherited from class ZKConfig

`JGSS_NATIVE, JUTE_MAXBUFFER, KINIT_COMMAND`

## Constructor Summary

Constructors
Constructor
Description
`ZKClientConfig()`
`ZKClientConfig(File configFile)`
Deprecated.
`ZKClientConfig(String configPath)`
Deprecated.
`ZKClientConfig(Path configPath)`

## Method Summary

Modifier and Type
Method
Description
`long`
`getLong(String key, long defaultValue)`
Get the value of the `key` property as an `long`.
`protected void`
`handleBackwardCompatibility()`
Now onwards client code will use properties from this class but older clients still be setting properties through system properties.
`boolean`
`isSaslClientEnabled()`
Returns true if the SASL client is enabled.

### Methods inherited from class ZKConfig

`addConfiguration, addConfiguration, addConfiguration, getBoolean, getBoolean, getInt, getJaasConfKey, getProperty, getProperty, setProperty`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### ZK_SASL_CLIENT_USERNAME

public static final String ZK_SASL_CLIENT_USERNAME

See Also:
  - Constant Field Values

### ZK_SASL_CLIENT_USERNAME_DEFAULT

public static final String ZK_SASL_CLIENT_USERNAME_DEFAULT

See Also:
  - Constant Field Values

### ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME

public static final String ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME

See Also:
  - Constant Field Values

### ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME_DEFAULT

public static final String ZK_SASL_CLIENT_CANONICALIZE_HOSTNAME_DEFAULT

See Also:
  - Constant Field Values

### LOGIN_CONTEXT_NAME_KEY

public static final String LOGIN_CONTEXT_NAME_KEY

See Also:
  - Constant Field Values

### LOGIN_CONTEXT_NAME_KEY_DEFAULT

public static final String LOGIN_CONTEXT_NAME_KEY_DEFAULT

See Also:
  - Constant Field Values

### ENABLE_CLIENT_SASL_KEY

public static final String ENABLE_CLIENT_SASL_KEY

See Also:
  - Constant Field Values

### ENABLE_CLIENT_SASL_DEFAULT

public static final String ENABLE_CLIENT_SASL_DEFAULT

See Also:
  - Constant Field Values

### ZOOKEEPER_SERVER_REALM

public static final String ZOOKEEPER_SERVER_REALM

See Also:
  - Constant Field Values

### DISABLE_AUTO_WATCH_RESET

public static final String DISABLE_AUTO_WATCH_RESET
This controls whether automatic watch resetting is enabled. Clients automatically reset watches during session reconnect, this option allows the client to turn off this behavior by setting the property "zookeeper.disableAutoWatchReset" to "true"

See Also:
  - Constant Field Values

### ZOOKEEPER_CLIENT_CNXN_SOCKET

public static final String ZOOKEEPER_CLIENT_CNXN_SOCKET

See Also:
  - Constant Field Values

### SECURE_CLIENT

public static final String SECURE_CLIENT
Setting this to "true" will enable encrypted client-server communication.

See Also:
  - Constant Field Values

### CLIENT_MAX_PACKET_LENGTH_DEFAULT

public static final int CLIENT_MAX_PACKET_LENGTH_DEFAULT

See Also:
  - Constant Field Values

### ZOOKEEPER_REQUEST_TIMEOUT

public static final String ZOOKEEPER_REQUEST_TIMEOUT

See Also:
  - Constant Field Values

### ZOOKEEPER_SERVER_PRINCIPAL

public static final String ZOOKEEPER_SERVER_PRINCIPAL

See Also:
  - Constant Field Values

### ZOOKEEPER_REQUEST_TIMEOUT_DEFAULT

public static final long ZOOKEEPER_REQUEST_TIMEOUT_DEFAULT
Feature is disabled by default.

See Also:
  - Constant Field Values

## Constructor Details

### ZKClientConfig

public ZKClientConfig()

### ZKClientConfig

@Deprecated public ZKClientConfig(File configFile) throws QuorumPeerConfig.ConfigException
Deprecated.

Use `ZKClientConfig(Path configPath)` instead.

The signature of this method will be changed to throw `ConfigException` instead of `QuorumPeerConfig.ConfigException` in future release.

Throws:
  `QuorumPeerConfig.ConfigException`

### ZKClientConfig

@Deprecated public ZKClientConfig(String configPath) throws QuorumPeerConfig.ConfigException
Deprecated.

Use `ZKClientConfig(Path configPath)` instead.

The signature of this method will be changed to throw `ConfigException` instead of `QuorumPeerConfig.ConfigException` in future release.

Throws:
  `QuorumPeerConfig.ConfigException`

### ZKClientConfig

public ZKClientConfig(Path configPath) throws ConfigException

Throws:
  `ConfigException`

## Method Details

### handleBackwardCompatibility

protected void handleBackwardCompatibility()
Description copied from class: `ZKConfig`
Now onwards client code will use properties from this class but older clients still be setting properties through system properties. So to make this change backward compatible we should set old system properties in this configuration.

Overrides:
  `handleBackwardCompatibility` in class `ZKConfig`

### isSaslClientEnabled

public boolean isSaslClientEnabled()
Returns true if the SASL client is enabled. By default, the client is enabled but can be disabled by setting the system property `zookeeper.sasl.client` to `false`. See ZOOKEEPER-1657 for more information.

Returns:
  true if the SASL client is enabled.

### getLong

public long getLong(String key, long defaultValue)
Get the value of the `key` property as an `long`. If property is not set, the provided `defaultValue` is returned

Parameters:
  `key` - property key.
  `defaultValue` - default value.
Returns:
  return property value as an `long`, or `defaultValue`
Throws:
  `NumberFormatException` - when the value is invalid