Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa7fee1

Browse files
authored
[automatic failover] Fix misleading timing information for AA scenario test (#4303)
1 parent840eb9e commitaa7fee1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎src/test/java/redis/clients/jedis/scenario/ActiveActiveFailoverIT.java‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public void accept(DatabaseSwitchEvent e) {
120120
AtomicLongretryingThreadsCounter =newAtomicLong(0);
121121
AtomicLongfailedCommandsAfterFailover =newAtomicLong(0);
122122
AtomicReference<Instant>lastFailedCommandAt =newAtomicReference<>();
123+
EndpointprimaryEndpoint =client.getActiveDatabaseEndpoint();
123124

124125
// Start thread that imitates an application that uses the client
125126
MultiThreadedFakeAppfakeApp =newMultiThreadedFakeApp(client, (UnifiedJedisc) -> {
@@ -130,13 +131,15 @@ public void accept(DatabaseSwitchEvent e) {
130131
intmaxTries =500;
131132
intretryingDelay =5;
132133
while (true) {
134+
booleanattemptToExecuteOnFailedCluster =true;
133135
try {
134136
Map<String,String>executionInfo =newHashMap<String,String>() {
135137
{
136138
put("threadId",String.valueOf(threadId));
137139
put("cluster",reporter.getCurrentClusterName());
138140
}
139141
};
142+
attemptToExecuteOnFailedCluster =client.getActiveDatabaseEndpoint() ==primaryEndpoint;
140143
client.xadd("execution_log",StreamEntryID.NEW_ENTRY,executionInfo);
141144
executedCommands.incrementAndGet();
142145

@@ -148,7 +151,8 @@ public void accept(DatabaseSwitchEvent e) {
148151
break;
149152
}catch (JedisConnectionExceptione) {
150153

151-
if (reporter.failoverHappened) {
154+
if (reporter.failoverHappened && !reporter.failbackHappened
155+
&&attemptToExecuteOnFailedCluster) {
152156
failedCommandsAfterFailover.incrementAndGet();
153157
lastFailedCommandAt.set(Instant.now());
154158
}
@@ -219,9 +223,12 @@ public void accept(DatabaseSwitchEvent e) {
219223
log.info("Failback happened at: {}",reporter.failbackAt);
220224
log.info("Last failed command at: {}",lastFailedCommandAt.get());
221225
log.info("Failed commands after failover: {}",failedCommandsAfterFailover.get());
222-
DurationfullFailoverTime =Duration.between(reporter.failoverAt,lastFailedCommandAt.get());
223-
log.info("Full failover time: {} s",fullFailoverTime.getSeconds());
224-
226+
if (lastFailedCommandAt.get() ==null) {
227+
log.info("No failed commands after failover!");
228+
}else {
229+
DurationfullFailoverTime =Duration.between(reporter.failoverAt,lastFailedCommandAt.get());
230+
log.info("Full failover time: {} s",fullFailoverTime.getSeconds());
231+
}
225232
assertEquals(0,pool1.getNumActive());
226233
assertTrue(fakeApp.capturedExceptions().isEmpty());
227234
assertTrue(reporter.failoverHappened);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp