Skip to content

Commit

Permalink
test: close topology monitors before each test
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-congo committed Jan 16, 2025
1 parent db91c85 commit 6f31328
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
1 change: 1 addition & 0 deletions wrapper/src/main/java/software/amazon/jdbc/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ public static void releaseResources() {
CustomEndpointPlugin.closeMonitors();
HikariPoolsHolder.closeAllPools();
HostResponseTimeServiceImpl.closeAllMonitors();
MonitoringRdsHostListProvider.closeAllMonitors();
clearCaches();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ protected List<HostSpec> waitTillTopologyGetsUpdated(final long timeoutMs) throw
@Override
public void close() throws Exception {
this.stop.set(true);
this.nodeThreadsStop.set(true);

// It breaks a waiting/sleeping cycles in monitoring thread
synchronized (this.requestToUpdateTopology) {
Expand All @@ -276,6 +277,8 @@ public void close() throws Exception {
if (!this.monitorExecutor.awaitTermination(30, TimeUnit.SECONDS)) {
this.monitorExecutor.shutdownNow();
}

this.nodeThreads.clear();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,8 @@ public MonitoringRdsHostListProvider(
CLUSTER_TOPOLOGY_HIGH_REFRESH_RATE_MS.getLong(this.properties));
}

/**
* Clear topology cache for the current cluster.
*/
public void clear() {
topologyCache.remove(this.clusterId);
}

public static void clearCache() {
topologyCache.clear();
primaryClusterIdCache.clear();
suggestedPrimaryClusterIdCache.clear();
clearAll();
}

public static void closeAllMonitors() {
Expand Down

0 comments on commit 6f31328

Please sign in to comment.