Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import redis.clients.jedis.exceptions.JedisConnectionException;
import redis.clients.jedis.mcf.ClusterSwitchEventArgs;
import redis.clients.jedis.mcf.MultiClusterPooledConnectionProvider;
import redis.clients.jedis.mcf.MultiClusterPooledConnectionProvider.Cluster;

import java.io.IOException;
import java.time.Duration;
Expand Down Expand Up @@ -119,6 +120,7 @@ public void accept(ClusterSwitchEventArgs e) {
FailoverReporter reporter = new FailoverReporter();
provider.setClusterSwitchListener(reporter);
provider.setActiveCluster(endpoint.getHostAndPort(0));
Cluster cluster1 = provider.getCluster();

UnifiedJedis client = new UnifiedJedis(provider);

Expand All @@ -136,13 +138,15 @@ public void accept(ClusterSwitchEventArgs e) {
int maxTries = 500;
int retryingDelay = 5;
while (true) {
boolean attempToExecuteOnFailedCluster = false;
Copy link
Preview

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'attemp' to 'attempt'.

Copilot uses AI. Check for mistakes.

try {
Map<String, String> executionInfo = new HashMap<String, String>() {
{
put("threadId", String.valueOf(threadId));
put("cluster", reporter.getCurrentClusterName());
}
};
attempToExecuteOnFailedCluster = provider.getCluster() == cluster1;
client.xadd("execution_log", StreamEntryID.NEW_ENTRY, executionInfo);
executedCommands.incrementAndGet();

Expand All @@ -154,7 +158,7 @@ public void accept(ClusterSwitchEventArgs e) {
break;
} catch (JedisConnectionException e) {

if (reporter.failoverHappened) {
if (reporter.failoverHappened && attempToExecuteOnFailedCluster) {
failedCommandsAfterFailover.incrementAndGet();
lastFailedCommandAt.set(Instant.now());
}
Expand Down