Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiyv-improving committed May 2, 2023
1 parent c2f12f5 commit c67c028
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public <T, E extends Exception> T execute(final Class<T> resultClass, final Clas
final Object methodInvokeOn, final String methodName, final JdbcCallable<T, E> jdbcMethodFunc,
final Object[] jdbcMethodArgs) throws E {
final HostSpec originalHost = this.pluginService.getCurrentHostSpec();
LOGGER.finest(() -> "Original host: " + originalHost);
try {
final T result = jdbcMethodFunc.call();
if ((methodName.equals(METHOD_CLOSE) || methodName.equals(METHOD_ABORT))) {
Expand All @@ -137,6 +138,7 @@ public <T, E extends Exception> T execute(final Class<T> resultClass, final Clas
return result;
} catch (final Exception e) {
if (e instanceof FailoverSQLException) {
LOGGER.finest(() -> "Original host: " + originalHost);
tracker.invalidateAllConnections(originalHost);
tracker.logOpenedConnections();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ private void invalidateConnections(final Queue<WeakReference<Connection>> connec
});
}

public static void clearCache() {
openedConnections.clear();
}

public static void logOpenedConnections() {
LOGGER.finest(() -> {
final StringBuilder builder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import integration.refactored.container.condition.EnableBasedOnTestDriverExtension;
import integration.refactored.container.condition.MakeSureFirstInstanceWriter;
import integration.util.AuroraTestUtility;
import java.net.InetAddress;
import software.amazon.jdbc.plugin.OpenedConnectionTracker;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -170,6 +170,7 @@ public void beforeEach(ExtensionContext context) throws Exception {
auroraUtil.makeSureInstancesUp(instanceIDs);
TestAuroraHostListProvider.clearCache();
TestPluginServiceImpl.clearHostAvailabilityCache();
OpenedConnectionTracker.clearCache();
}
}
});
Expand Down

0 comments on commit c67c028

Please sign in to comment.