Class JdbcHazelcastConfigurer
- All Implemented Interfaces:
HazelcastConfigurer
HazelcastConfigurer implementation that builds the Hazelcast
configuration programmatically using a JDBC data source for persistence.
Standalone mode (default, clustered = false):
An embedded H2 file-based database stored in the crawler's work directory is
used automatically — no external configuration is required.
Clustered mode (clustered = true):
An external database must be supplied via setJdbcUrl(String) (plus
optionally setJdbcUsername(String), setJdbcPassword(String)
, setJdbcDriver(String)). The default SQL merge statement uses
PostgreSQL INSERT ... ON CONFLICT syntax; set
setSqlMerge(String) to target a different database dialect.
| Setting | Standalone | Clustered |
|---|---|---|
| backupCount | 0 | 1 |
| maxPoolSize | 10 | 20 |
| jdbcUrl | H2 file in workDir | must be set |
| sqlMerge | H2 MERGE syntax | PostgreSQL INSERT … ON CONFLICT |
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.hazelcast.config.ConfigBuilds a HazelcastConfigfor the given context.protected booleanbooleanintHazelcast backup count.SQL column type for map/queue keys.SQL column type for map values.Additional Hazelcast system properties set on the config (e.g.com.hazelcast.config.MapStoreConfig.InitialLoadModeHazelcast map-store initial load mode.JDBC driver class name.JDBC password.JDBC URL for the data source.JDBC username.Whether Hazelcast Jet engine should be enabled.intMaximum JDBC connection pool size.SQL merge/upsert template used for map stores.TCP/IP member list for clustered discovery, as a comma-separated list ofhost:portaddresses (e.g.,"192.168.1.10:5701,192.168.1.11:5701").intMaximum number of entries per write-behind batch.intWrite-behind delay in seconds for data maps (ledger, session, etc.).inthashCode()booleanWhether to use Hazelcast auto-discovery in clustered mode.booleanWhether queue-store persistence should be enabled for Hazelcast queues.booleanWhether to coalesce write-behind updates so that only the latest value for each key is persisted per batch.setAutoDiscoveryEnabled(boolean autoDiscoveryEnabled) Whether to use Hazelcast auto-discovery in clustered mode.setBackupCount(int backupCount) Hazelcast backup count.setColumnKeyType(String columnKeyType) SQL column type for map/queue keys.setColumnValueType(String columnValueType) SQL column type for map values.setHazelcastProperties(Map<String, String> hazelcastProperties) Additional Hazelcast system properties set on the config (e.g.setInitialLoadMode(com.hazelcast.config.MapStoreConfig.InitialLoadMode initialLoadMode) Hazelcast map-store initial load mode.setJdbcDriver(String jdbcDriver) JDBC driver class name.setJdbcPassword(String jdbcPassword) JDBC password.setJdbcUrl(String jdbcUrl) JDBC URL for the data source.setJdbcUsername(String jdbcUsername) JDBC username.setJetEnabled(Boolean jetEnabled) Whether Hazelcast Jet engine should be enabled.setMaxPoolSize(int maxPoolSize) Maximum JDBC connection pool size.setQueueStoreEnabled(boolean queueStoreEnabled) Whether queue-store persistence should be enabled for Hazelcast queues.setSqlMerge(String sqlMerge) SQL merge/upsert template used for map stores.setTcpMembers(String tcpMembers) TCP/IP member list for clustered discovery, as a comma-separated list ofhost:portaddresses (e.g.,"192.168.1.10:5701,192.168.1.11:5701").setWriteBatchSize(int writeBatchSize) Maximum number of entries per write-behind batch.setWriteCoalescing(boolean writeCoalescing) Whether to coalesce write-behind updates so that only the latest value for each key is persisted per batch.setWriteDelaySeconds(int writeDelaySeconds) Write-behind delay in seconds for data maps (ledger, session, etc.).toString()
-
Field Details
-
MAP_STORE_FACTORY_CLASS
Factory class for JDBC-backed map stores. -
QUEUE_STORE_FACTORY_CLASS
Factory class for JDBC-backed queue stores. -
DATA_CONNECTION_REF
Name of the shared JDBC data-connection referenced by store configs.- See Also:
-
-
Constructor Details
-
JdbcHazelcastConfigurer
public JdbcHazelcastConfigurer()
-
-
Method Details
-
buildConfig
Description copied from interface:HazelcastConfigurerBuilds a HazelcastConfigfor the given context. The returned config must not yet have aHazelcastInstancestarted against it.- Specified by:
buildConfigin interfaceHazelcastConfigurer- Parameters:
ctx- context carrying work directory, clustering mode, and cluster name- Returns:
- a fully-configured (but not yet started) Hazelcast
Config
-
getJdbcUrl
JDBC URL for the data source. In standalone mode, defaults to an H2 file database stored inside the crawler work directory. In clustered mode this must be set explicitly. -
getJdbcUsername
JDBC username. Defaults to"sa"(H2 default). -
getJdbcPassword
JDBC password. Defaults to empty string. -
getJdbcDriver
JDBC driver class name. Optional; HikariCP auto-detects the driver from the URL when this is not set. -
getMaxPoolSize
public int getMaxPoolSize()Maximum JDBC connection pool size.0(default) means automatic: 10 for standalone, 20 for clustered. -
getWriteDelaySeconds
public int getWriteDelaySeconds()Write-behind delay in seconds for data maps (ledger, session, etc.).0makes writes synchronous (write-through). Default is5, which batches writes for significantly better throughput. Pipeline coordination maps always use write-through regardless of this setting. -
getWriteBatchSize
public int getWriteBatchSize()Maximum number of entries per write-behind batch. Only effective whenwriteDelaySeconds> 0. Default is100. -
isWriteCoalescing
public boolean isWriteCoalescing()Whether to coalesce write-behind updates so that only the latest value for each key is persisted per batch. Only effective whenwriteDelaySeconds> 0. Default istrue. -
getColumnKeyType
SQL column type for map/queue keys. Defaults to"VARCHAR(4096)". -
getColumnValueType
SQL column type for map values. Defaults to"TEXT". -
getSqlMerge
SQL merge/upsert template used for map stores. The token{tableName}is replaced at runtime with the actual table name.Defaults to H2
MERGE … KEY …syntax for standalone and PostgreSQLINSERT … ON CONFLICT …syntax for clustered. Override this when targeting a different database dialect. -
getInitialLoadMode
public com.hazelcast.config.MapStoreConfig.InitialLoadMode getInitialLoadMode()Hazelcast map-store initial load mode.MapStoreConfig.InitialLoadMode.LAZY(default) defers loading until an entry is accessed, which speeds up startup. Critical maps such as the crawl ledger callloadAll()explicitly when they are first used so that operations likesize()and iteration return correct results.MapStoreConfig.InitialLoadMode.EAGERloads all entries as soon as the cluster member starts. -
getBackupCount
public int getBackupCount()Hazelcast backup count.-1(default) means automatic: 0 for standalone, 1 for clustered. -
getTcpMembers
TCP/IP member list for clustered discovery, as a comma-separated list ofhost:portaddresses (e.g.,"192.168.1.10:5701,192.168.1.11:5701"). Defaults to"127.0.0.1:5701,127.0.0.1:5702,127.0.0.1:5703"when in clustered mode and not otherwise specified. -
isAutoDiscoveryEnabled
public boolean isAutoDiscoveryEnabled()Whether to use Hazelcast auto-discovery in clustered mode.Default is
falseto keep deterministic TCP member discovery. When set totrue, auto-detection is enabled and explicit TCP-member discovery is disabled. -
getJetEnabled
Whether Hazelcast Jet engine should be enabled.null(default) means enabled for backward compatibility. Set tofalsewhen Jet is not used and a leaner cluster runtime is preferred (e.g., deterministic integration tests). -
isQueueStoreEnabled
public boolean isQueueStoreEnabled()Whether queue-store persistence should be enabled for Hazelcast queues.Defaults to
true. Set tofalsefor tests that do not require persistent queue recovery and prioritize startup/runtime speed. -
getHazelcastProperties
Additional Hazelcast system properties set on the config (e.g."hazelcast.partition.count"→"17"). Applied after all other settings are built. -
setJdbcUrl
JDBC URL for the data source. In standalone mode, defaults to an H2 file database stored inside the crawler work directory. In clustered mode this must be set explicitly.- Returns:
this.
-
setJdbcUsername
JDBC username. Defaults to"sa"(H2 default).- Returns:
this.
-
setJdbcPassword
JDBC password. Defaults to empty string.- Returns:
this.
-
setJdbcDriver
JDBC driver class name. Optional; HikariCP auto-detects the driver from the URL when this is not set.- Returns:
this.
-
setMaxPoolSize
Maximum JDBC connection pool size.0(default) means automatic: 10 for standalone, 20 for clustered.- Returns:
this.
-
setWriteDelaySeconds
Write-behind delay in seconds for data maps (ledger, session, etc.).0makes writes synchronous (write-through). Default is5, which batches writes for significantly better throughput. Pipeline coordination maps always use write-through regardless of this setting.- Returns:
this.
-
setWriteBatchSize
Maximum number of entries per write-behind batch. Only effective whenwriteDelaySeconds> 0. Default is100.- Returns:
this.
-
setWriteCoalescing
Whether to coalesce write-behind updates so that only the latest value for each key is persisted per batch. Only effective whenwriteDelaySeconds> 0. Default istrue.- Returns:
this.
-
setColumnKeyType
SQL column type for map/queue keys. Defaults to"VARCHAR(4096)".- Returns:
this.
-
setColumnValueType
SQL column type for map values. Defaults to"TEXT".- Returns:
this.
-
setSqlMerge
SQL merge/upsert template used for map stores. The token{tableName}is replaced at runtime with the actual table name.Defaults to H2
MERGE … KEY …syntax for standalone and PostgreSQLINSERT … ON CONFLICT …syntax for clustered. Override this when targeting a different database dialect.- Returns:
this.
-
setInitialLoadMode
public JdbcHazelcastConfigurer setInitialLoadMode(com.hazelcast.config.MapStoreConfig.InitialLoadMode initialLoadMode) Hazelcast map-store initial load mode.MapStoreConfig.InitialLoadMode.LAZY(default) defers loading until an entry is accessed, which speeds up startup. Critical maps such as the crawl ledger callloadAll()explicitly when they are first used so that operations likesize()and iteration return correct results.MapStoreConfig.InitialLoadMode.EAGERloads all entries as soon as the cluster member starts.- Returns:
this.
-
setBackupCount
Hazelcast backup count.-1(default) means automatic: 0 for standalone, 1 for clustered.- Returns:
this.
-
setTcpMembers
TCP/IP member list for clustered discovery, as a comma-separated list ofhost:portaddresses (e.g.,"192.168.1.10:5701,192.168.1.11:5701"). Defaults to"127.0.0.1:5701,127.0.0.1:5702,127.0.0.1:5703"when in clustered mode and not otherwise specified.- Returns:
this.
-
setAutoDiscoveryEnabled
Whether to use Hazelcast auto-discovery in clustered mode.Default is
falseto keep deterministic TCP member discovery. When set totrue, auto-detection is enabled and explicit TCP-member discovery is disabled.- Returns:
this.
-
setJetEnabled
Whether Hazelcast Jet engine should be enabled.null(default) means enabled for backward compatibility. Set tofalsewhen Jet is not used and a leaner cluster runtime is preferred (e.g., deterministic integration tests).- Returns:
this.
-
setQueueStoreEnabled
Whether queue-store persistence should be enabled for Hazelcast queues.Defaults to
true. Set tofalsefor tests that do not require persistent queue recovery and prioritize startup/runtime speed.- Returns:
this.
-
setHazelcastProperties
Additional Hazelcast system properties set on the config (e.g."hazelcast.partition.count"→"17"). Applied after all other settings are built.- Returns:
this.
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-