-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added default cluster client options for refreshing topology
- Loading branch information
1 parent
ca36ba6
commit 18255a5
Showing
6 changed files
with
96 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
exporter/src/main/java/io/zeebe/redis/exporter/ClusterClientSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.zeebe.redis.exporter; | ||
|
||
import io.lettuce.core.cluster.ClusterClientOptions; | ||
import io.lettuce.core.cluster.ClusterTopologyRefreshOptions; | ||
import io.lettuce.core.cluster.models.partitions.RedisClusterNode; | ||
import io.lettuce.core.resource.ClientResources; | ||
|
||
public class ClusterClientSettings { | ||
|
||
public static ClientResources createResourcesFromConfig(ExporterConfiguration config) { | ||
return ClientResources.builder() | ||
.ioThreadPoolSize(config.getIoThreadPoolSize()) | ||
.build(); | ||
} | ||
|
||
public static ClusterClientOptions createStandardOptions() { | ||
return ClusterClientOptions.builder() | ||
.autoReconnect(true) | ||
// dynamic adaptive refresh | ||
.topologyRefreshOptions(dynamicRefreshOptions()) | ||
// filter out failed nodes from the topology | ||
.nodeFilter(it -> | ||
! (it.is(RedisClusterNode.NodeFlag.FAIL) | ||
|| it.is(RedisClusterNode.NodeFlag.EVENTUAL_FAIL) | ||
|| it.is(RedisClusterNode.NodeFlag.HANDSHAKE) | ||
|| it.is(RedisClusterNode.NodeFlag.NOADDR))) | ||
.validateClusterNodeMembership(true) | ||
.build(); | ||
} | ||
|
||
private static ClusterTopologyRefreshOptions dynamicRefreshOptions() { | ||
return ClusterTopologyRefreshOptions.builder() | ||
.enableAllAdaptiveRefreshTriggers() | ||
.enablePeriodicRefresh() | ||
.dynamicRefreshSources(true) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters