Class Ignite3Client.Builder
- Enclosing interface:
- Ignite3Client
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the addresses of Ignite server nodes within a cluster.backgroundReconnectInterval(long backgroundReconnectInterval) Sets the background reconnect interval, in milliseconds.backgroundReResolveAddressesInterval(long backgroundReResolveAddressesInterval) Sets how long the resolved addresses will be considered valid, in milliseconds.org.gridgain.ignite.migrationtools.adapter.ignite3.proxies.IgniteProxybuild()Builds the client.connectTimeout(long connectTimeout) Sets the socket connection timeout, in milliseconds.heartbeatInterval(long heartbeatInterval) Sets the heartbeat message interval, in milliseconds.heartbeatTimeout(long heartbeatTimeout) Sets the heartbeat message timeout, in milliseconds.metricsEnabled(boolean metricsEnabled) Enables or disables JMX metrics.Sets the client name.operationTimeout(long operationTimeout) Sets the operation timeout, in milliseconds.sqlPartitionAwarenessMetadataCacheSize(int size) Sets the size of cache to store partition awareness metadata of sql queries, in number of entries.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
addresses
Sets the addresses of Ignite server nodes within a cluster. An address can be an IP address or a hostname, with or without port. If port is not set then Ignite will use the default one - see org.apache.ignite.client.IgniteClientConfiguration#DFLT_PORT.- Parameters:
addrs- Addresses.- Returns:
- This instance.
-
connectTimeout
Sets the socket connection timeout, in milliseconds.Default is org.apache.ignite.client.IgniteClientConfiguration#DFLT_CONNECT_TIMEOUT.
- Parameters:
connectTimeout- Socket connection timeout, in milliseconds.- Returns:
- This instance.
- Throws:
IllegalArgumentException- When value is less than zero.
-
backgroundReconnectInterval
Sets the background reconnect interval, in milliseconds. Set to0to disable background reconnect.Ignite balances requests across all healthy connections (when multiple endpoints are configured). Ignite also repairs connections on demand (when a request is made). However, "secondary" connections can be lost (due to network issues, or node restarts). This property controls how ofter Ignite client will check all configured endpoints and try to reconnect them in case of failure.
- Parameters:
backgroundReconnectInterval- Reconnect interval, in milliseconds.- Returns:
- This instance.
- Throws:
IllegalArgumentException- When value is less than zero.
-
heartbeatInterval
Sets the heartbeat message interval, in milliseconds. Default is30_000.When server-side idle timeout is not zero, effective heartbeat interval is set to
min(heartbeatInterval, idleTimeout / 3).When thin client connection is idle (no operations are performed), heartbeat messages are sent periodically to keep the connection alive and detect potential half-open state.
- Parameters:
heartbeatInterval- Heartbeat interval.- Returns:
- This instance.
-
heartbeatTimeout
Sets the heartbeat message timeout, in milliseconds. Default is5000.When a server does not respond to a heartbeat within the specified timeout, client will close the connection.
- Parameters:
heartbeatTimeout- Heartbeat timeout.- Returns:
- This instance.
-
metricsEnabled
Enables or disables JMX metrics.When enabled, Ignite client will expose JMX metrics via the platform MBean server with bean name "org.apache.ignite:group=metrics,name=client".
Use
jconsoleor any other JMX client to view the metrics.To get metrics programmatically:
MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), new ObjectName("org.apache.ignite:group=metrics,name=client"), DynamicMBean.class, false).getAttribute("ConnectionsActive")See Java Management Extensions (JMX) for more information.
- Parameters:
metricsEnabled- Metrics enabled flag.- Returns:
- This instance.
-
operationTimeout
Sets the operation timeout, in milliseconds. Default is0(no timeout).An "operation" is a single client request to the server. Some public API calls may involve multiple operations, in which case the operation timeout is applied to each individual network call.
- Parameters:
operationTimeout- Operation timeout, in milliseconds.- Returns:
- This instance.
- Throws:
IllegalArgumentException- When value is less than zero.
-
sqlPartitionAwarenessMetadataCacheSize
Sets the size of cache to store partition awareness metadata of sql queries, in number of entries. Default is org.apache.ignite.client.IgniteClientConfiguration#DFLT_SQL_PARTITION_AWARENESS_METADATA_CACHE_SIZE.SQL partition awareness feature improves query performance by directing queries to the specific server nodes that hold the relevant data, minimizing network overhead. Ignite client builds the metadata cache during the initial query execution and leverages this cache to speed up subsequent queries.
Every instance of org.apache.ignite.sql.IgniteSql has its own cache. Every unique pair of (defaultSchema, queryString) reserve its own place in metadata cache, if metadata is available for this particular query. In general, metadata is available for queries which have equality predicate over all colocation columns, or which inserts the whole tuple. Let's consider the following example:
// Creates reservations table. Please mind theCOLOCATE BY (floor_no): all reservations are colocated by //floor_no. CREATE TABLE RoomsReservations (room_no INT, floor_no INT, PRIMARY_KEY (room_no, floor_no)) COLOCATE BY (floor_no); // Here, we are selecting all reserved rooms on a particular floor. All reservation are colocated byfloor_no, // therefore having predicate likefloor_no = ?make it possible to compute a partition which keeps the data of // interest. Which in turn makes it possible to send the query directly to the node that hold the relevant data. SELECT room_no FROM RoomsReservations WHERE floor_no = ?; // Similar with INSERT: since values of dynamic parameters are known on a client, it makes it possible to route the // query directly to the node that hold the relevant data. INSERT INTO RoomsReservations(room_no, floor_no) VALUES(?, ?);- Parameters:
size- Cache size, in number of entries.- Returns:
- This instance.
- Throws:
IllegalArgumentException- When value is less than zero.
-
name
Sets the client name. Default isnull, which means that Ignite will generate a unique name automatically.Client name is used for identifying clients in JMX metrics. The name is only used locally and is not sent to the server.
If multiple clients with the same exist in the same JVM, JMX metrics will be exposed only for one of them. Others will log an error.
- Parameters:
name- Client name.- Returns:
- This instance.
-
backgroundReResolveAddressesInterval
public Ignite3Client.Builder backgroundReResolveAddressesInterval(long backgroundReResolveAddressesInterval) Sets how long the resolved addresses will be considered valid, in milliseconds. Set to0for infinite validity.Ignite client resolve the provided hostnames into multiple IP addresses, each corresponds to an active cluster node. However, additional IP addresses can be collected after updating the DNS records. This property controls how often Ignite client will try to re-resolve provided hostnames and connect to newly discovered addresses.
- Parameters:
backgroundReResolveAddressesInterval- Background re-resolve interval, in milliseconds.- Returns:
- This instance.
- Throws:
IllegalArgumentException- When value is less than zero.
-
build
public org.gridgain.ignite.migrationtools.adapter.ignite3.proxies.IgniteProxy build()Builds the client.- Returns:
- Ignite client.
-