diff --git a/wrapper/src/main/java/software/amazon/jdbc/HostListProvider.java b/wrapper/src/main/java/software/amazon/jdbc/HostListProvider.java index 77ab0ddc4..0aa93714a 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/HostListProvider.java +++ b/wrapper/src/main/java/software/amazon/jdbc/HostListProvider.java @@ -42,5 +42,5 @@ public interface HostListProvider { HostSpec identifyConnection(Connection connection) throws SQLException; - String getClusterId() throws UnsupportedOperationException; + String getClusterId() throws UnsupportedOperationException, SQLException; } diff --git a/wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/RdsHostListProvider.java b/wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/RdsHostListProvider.java index 98482b329..eb677a1c2 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/RdsHostListProvider.java +++ b/wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/RdsHostListProvider.java @@ -694,7 +694,8 @@ public HostSpec identifyConnection(Connection connection) throws SQLException { } @Override - public String getClusterId() throws UnsupportedOperationException { + public String getClusterId() throws UnsupportedOperationException, SQLException { + init(); return this.clusterId; } diff --git a/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java b/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java index 954d98958..2c9d79752 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java +++ b/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java @@ -24,14 +24,18 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; +import java.util.logging.Logger; import org.checkerframework.checker.nullness.qual.NonNull; import software.amazon.jdbc.AwsWrapperProperty; import software.amazon.jdbc.HostSpec; import software.amazon.jdbc.PluginService; +import software.amazon.jdbc.util.Messages; import software.amazon.jdbc.util.SlidingExpirationCacheWithCleanupThread; import software.amazon.jdbc.util.Utils; public class LimitlessRouterServiceImpl implements LimitlessRouterService { + private static final Logger LOGGER = + Logger.getLogger(LimitlessRouterServiceImpl.class.getName()); public static final AwsWrapperProperty MONITOR_DISPOSAL_TIME_MS = new AwsWrapperProperty( "limitlessTransactionRouterMonitorDisposalTimeMs", @@ -143,12 +147,13 @@ public void startMonitoring(final @NonNull HostSpec hostSpec, .createLimitlessRouterMonitor( hostSpec, limitlessRouterCache, - this.pluginService.getHostListProvider().getClusterId(), + limitlessRouterMonitorKey, props, intervalMs), cacheExpirationNano); - } catch (UnsupportedOperationException e) { - throw e; + } catch (SQLException e) { + LOGGER.warning(Messages.get("LimitlessRouterServiceImpl.errorStartingMonitor", new Object[]{e})); + throw new RuntimeException(e); } } } diff --git a/wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties b/wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties index 422ab9972..65c8877ea 100644 --- a/wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties +++ b/wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties @@ -243,6 +243,9 @@ LimitlessRouterMonitor.openedConnection=Opened Limitless Router Monitor connecti LimitlessRouterMonitor.running=Limitless Router Monitor thread running on node {0}. LimitlessRouterMonitor.stopped=Limitless Router Monitor thread stopped on node {0]. +# Limitless Router Service +LimitlessRouterServiceImpl.errorStartingMonitor=An error occurred while starting Limitless Router Monitor. {0} + # Log Query Connection Plugin LogQueryConnectionPlugin.executingQuery=[{0}] Executing query: {1}