diff --git a/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorImpl.java b/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorImpl.java index 326b67de2..e7a83d7e5 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorImpl.java +++ b/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorImpl.java @@ -22,6 +22,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; import java.util.logging.Logger; import org.checkerframework.checker.nullness.qual.NonNull; import software.amazon.jdbc.HostSpec; @@ -63,7 +64,7 @@ static class ConnectionStatus { private final TelemetryFactory telemetryFactory; private final Properties properties; private final HostSpec hostSpec; - private final MonitorService monitorService; + private final MonitorThreadContainer threadContainer; private final long monitorDisposalTimeMillis; private volatile long contextLastUsedTimestampNano; private volatile boolean stopped = false; @@ -85,7 +86,7 @@ static class ConnectionStatus { * @param monitorDisposalTimeMillis Time in milliseconds before stopping the monitoring thread * where there are no active connection to the server this * {@link MonitorImpl} instance is monitoring. - * @param monitorService A reference to the {@link MonitorServiceImpl} implementation + * @param threadContainer A reference to the {@link MonitorThreadContainer} implementation * that initialized this class. */ public MonitorImpl( @@ -93,13 +94,13 @@ public MonitorImpl( @NonNull final HostSpec hostSpec, @NonNull final Properties properties, final long monitorDisposalTimeMillis, - @NonNull final MonitorService monitorService) { + @NonNull final MonitorThreadContainer threadContainer) { this.pluginService = pluginService; this.telemetryFactory = pluginService.getTelemetryFactory(); this.hostSpec = hostSpec; this.properties = properties; this.monitorDisposalTimeMillis = monitorDisposalTimeMillis; - this.monitorService = monitorService; + this.threadContainer = threadContainer; this.contextLastUsedTimestampNano = this.getCurrentTimeNano(); this.contextsSizeGauge = telemetryFactory.createGauge("efm.activeContexts.queue.size", @@ -143,6 +144,7 @@ public void run() { this.telemetryContext = telemetryFactory.openTelemetryContext( "monitoring thread", TelemetryTraceLevel.TOP_LEVEL); telemetryContext.setAttribute("url", hostSpec.getUrl()); + try { this.stopped = false; while (true) { @@ -152,6 +154,7 @@ public void run() { MonitorConnectionContext newMonitorContext; MonitorConnectionContext firstAddedNewMonitorContext = null; final long currentTimeNano = this.getCurrentTimeNano(); + while ((newMonitorContext = this.newContexts.poll()) != null) { if (firstAddedNewMonitorContext == newMonitorContext) { // This context has already been processed. @@ -179,8 +182,7 @@ public void run() { final long statusCheckStartTimeNano = this.getCurrentTimeNano(); this.contextLastUsedTimestampNano = statusCheckStartTimeNano; - final ConnectionStatus status = - checkConnectionStatus(this.nodeCheckTimeoutMillis); + final ConnectionStatus status = checkConnectionStatus(this.nodeCheckTimeoutMillis); long delayMillis = -1; MonitorConnectionContext monitorContext; @@ -240,7 +242,7 @@ public void run() { } else { if ((this.getCurrentTimeNano() - this.contextLastUsedTimestampNano) >= TimeUnit.MILLISECONDS.toNanos(this.monitorDisposalTimeMillis)) { - monitorService.notifyUnused(this); + threadContainer.releaseResource(this); break; } TimeUnit.MILLISECONDS.sleep(THREAD_SLEEP_WHEN_INACTIVE_MILLIS); @@ -250,10 +252,14 @@ public void run() { throw intEx; } catch (final Exception ex) { // log and ignore - LOGGER.warning( - () -> Messages.get( - "MonitorImpl.exceptionDuringMonitoringContinue", - new Object[] {this.hostSpec.getHost(), ex.getMessage()})); + if (LOGGER.isLoggable(Level.WARNING)) { + LOGGER.log( + Level.WARNING, + Messages.get( + "MonitorImpl.exceptionDuringMonitoringContinue", + new Object[]{this.hostSpec.getHost()}), + ex); // We want to print full trace stack of the exception. + } } } } catch (final InterruptedException intEx) { @@ -261,14 +267,19 @@ public void run() { LOGGER.warning( () -> Messages.get( "MonitorImpl.interruptedExceptionDuringMonitoring", - new Object[] {this.hostSpec.getHost(), intEx.getMessage()})); + new Object[] {this.hostSpec.getHost()})); } catch (final Exception ex) { // this should not be reached; log and exit thread - LOGGER.warning( - () -> Messages.get( - "MonitorImpl.exceptionDuringMonitoringStop", - new Object[] {this.hostSpec.getHost(), ex.getMessage()})); + if (LOGGER.isLoggable(Level.WARNING)) { + LOGGER.log( + Level.WARNING, + Messages.get( + "MonitorImpl.exceptionDuringMonitoringStop", + new Object[]{this.hostSpec.getHost()}), + ex); // We want to print full trace stack of the exception. + } } finally { + this.stopped = true; if (this.monitoringConn != null) { try { this.monitoringConn.close(); @@ -279,7 +290,6 @@ public void run() { if (telemetryContext != null) { this.telemetryContext.closeContext(); } - this.stopped = true; } } diff --git a/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorInitializer.java b/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorInitializer.java index eb2b575fc..5e25a66af 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorInitializer.java +++ b/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorInitializer.java @@ -22,5 +22,5 @@ /** Interface for initialize a new {@link MonitorImpl}. */ @FunctionalInterface public interface MonitorInitializer { - Monitor createMonitor(HostSpec hostSpec, Properties properties, MonitorService monitorService); + Monitor createMonitor(HostSpec hostSpec, Properties properties, MonitorThreadContainer threadContainer); } diff --git a/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorService.java b/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorService.java index ed4cf5549..6f034fd75 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorService.java +++ b/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorService.java @@ -52,11 +52,4 @@ MonitorConnectionContext startMonitoring( void stopMonitoringForAllConnections(Set nodeKeys); void releaseResources(); - - /** - * Handle unused {@link Monitor}. - * - * @param monitor The {@link Monitor} in idle. - */ - void notifyUnused(Monitor monitor); } diff --git a/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorServiceImpl.java b/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorServiceImpl.java index 7755af381..2763f8a34 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorServiceImpl.java +++ b/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorServiceImpl.java @@ -16,8 +16,8 @@ package software.amazon.jdbc.plugin.efm; +import java.lang.ref.WeakReference; import java.sql.Connection; -import java.sql.SQLException; import java.util.Collections; import java.util.Properties; import java.util.Set; @@ -42,7 +42,7 @@ public class MonitorServiceImpl implements MonitorService { public static final AwsWrapperProperty MONITOR_DISPOSAL_TIME_MS = new AwsWrapperProperty( "monitorDisposalTime", - "60000", + "600000", // 10min "Interval in milliseconds for a monitor to be considered inactive and to be disposed."); private final PluginService pluginService; @@ -50,7 +50,7 @@ public class MonitorServiceImpl implements MonitorService { final MonitorInitializer monitorInitializer; private Set cachedMonitorNodeKeys = null; - private Monitor cachedMonitor = null; + private WeakReference cachedMonitor = null; final TelemetryFactory telemetryFactory; final TelemetryCounter abortedConnectionsCounter; @@ -100,16 +100,15 @@ public MonitorConnectionContext startMonitoring( new Object[] {hostSpec})); } - final Monitor monitor; - if (this.cachedMonitor == null + Monitor monitor = this.cachedMonitor == null ? null : this.cachedMonitor.get(); + if (monitor == null + || monitor.isStopped() || this.cachedMonitorNodeKeys == null || !this.cachedMonitorNodeKeys.equals(nodeKeys)) { monitor = getMonitor(nodeKeys, hostSpec, properties); - this.cachedMonitor = monitor; + this.cachedMonitor = new WeakReference<>(monitor); this.cachedMonitorNodeKeys = Collections.unmodifiableSet(nodeKeys); - } else { - monitor = this.cachedMonitor; } final MonitorConnectionContext context = @@ -139,7 +138,6 @@ public void stopMonitoringForAllConnections(@NonNull final Set nodeKeys) monitor = this.threadContainer.getMonitor(nodeKey); if (monitor != null) { monitor.clearContexts(); - this.threadContainer.resetResource(monitor); return; } } @@ -148,18 +146,6 @@ public void stopMonitoringForAllConnections(@NonNull final Set nodeKeys) @Override public void releaseResources() { this.threadContainer = null; - MonitorThreadContainer.releaseInstance(); - } - - @Override - public void notifyUnused(final Monitor monitor) { - if (monitor == null) { - LOGGER.warning(() -> Messages.get("MonitorServiceImpl.nullMonitorParam")); - return; - } - - // Remove monitor from the maps - this.threadContainer.releaseResource(monitor); } /** @@ -172,7 +158,7 @@ public void notifyUnused(final Monitor monitor) { */ protected Monitor getMonitor(final Set nodeKeys, final HostSpec hostSpec, final Properties properties) { return this.threadContainer.getOrCreateMonitor( - nodeKeys, () -> monitorInitializer.createMonitor(hostSpec, properties, this)); + nodeKeys, () -> monitorInitializer.createMonitor(hostSpec, properties, this.threadContainer)); } MonitorThreadContainer getThreadContainer() { diff --git a/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorThreadContainer.java b/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorThreadContainer.java index aa526e88d..3dbaea346 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorThreadContainer.java +++ b/wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorThreadContainer.java @@ -19,14 +19,11 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Queue; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Supplier; import software.amazon.jdbc.util.Messages; @@ -36,13 +33,13 @@ * up of each monitoring thread. */ public class MonitorThreadContainer { + private static MonitorThreadContainer singleton = null; - private static final AtomicInteger CLASS_USAGE_COUNT = new AtomicInteger(); private final Map monitorMap = new ConcurrentHashMap<>(); private final Map> tasksMap = new ConcurrentHashMap<>(); - private final Queue availableMonitors = new ConcurrentLinkedDeque<>(); private final ExecutorService threadPool; private static final ReentrantLock LOCK_OBJECT = new ReentrantLock(); + private static final ReentrantLock MONITOR_LOCK_OBJECT = new ReentrantLock(); /** * Create an instance of the {@link MonitorThreadContainer}. @@ -54,15 +51,18 @@ public static MonitorThreadContainer getInstance() { } static MonitorThreadContainer getInstance(final ExecutorServiceInitializer executorServiceInitializer) { - MonitorThreadContainer singletonToReturn; + MonitorThreadContainer singletonToReturn = singleton; + + if (singletonToReturn != null) { + return singletonToReturn; + } + LOCK_OBJECT.lock(); try { if (singleton == null) { singleton = new MonitorThreadContainer(executorServiceInitializer); - CLASS_USAGE_COUNT.set(0); } singletonToReturn = singleton; - CLASS_USAGE_COUNT.getAndIncrement(); } finally { LOCK_OBJECT.unlock(); } @@ -79,10 +79,9 @@ public static void releaseInstance() { } LOCK_OBJECT.lock(); try { - if (singleton != null && CLASS_USAGE_COUNT.decrementAndGet() <= 0) { + if (singleton != null) { singleton.releaseResources(); singleton = null; - CLASS_USAGE_COUNT.set(0); } } finally { LOCK_OBJECT.unlock(); @@ -101,10 +100,6 @@ public Map> getTasksMap() { return tasksMap; } - public ExecutorService getThreadPool() { - return threadPool; - } - Monitor getMonitor(final String node) { return monitorMap.get(node); } @@ -114,42 +109,34 @@ Monitor getOrCreateMonitor(final Set nodeKeys, final Supplier m throw new IllegalArgumentException(Messages.get("MonitorThreadContainer.emptyNodeKeys")); } - Monitor monitor = null; - String anyNodeKey = null; - for (final String nodeKey : nodeKeys) { - monitor = monitorMap.get(nodeKey); - anyNodeKey = nodeKey; - if (monitor != null) { - break; + MONITOR_LOCK_OBJECT.lock(); + try { + + Monitor monitor = null; + String anyNodeKey = null; + for (final String nodeKey : nodeKeys) { + monitor = monitorMap.get(nodeKey); + anyNodeKey = nodeKey; + if (monitor != null) { + break; + } } - } - if (monitor == null) { - monitor = monitorMap.computeIfAbsent( - anyNodeKey, - k -> { - if (!availableMonitors.isEmpty()) { - final Monitor availableMonitor = availableMonitors.remove(); - if (!availableMonitor.isStopped()) { - return availableMonitor; - } - tasksMap.computeIfPresent( - availableMonitor, - (key, v) -> { - v.cancel(true); - return null; - }); - } - - final Monitor newMonitor = monitorSupplier.get(); - addTask(newMonitor); - - return newMonitor; - }); - } + if (monitor == null) { + monitor = monitorMap.computeIfAbsent( + anyNodeKey, + k -> { + final Monitor newMonitor = monitorSupplier.get(); + addTask(newMonitor); + return newMonitor; + }); + } + populateMonitorMap(nodeKeys, monitor); + return monitor; - populateMonitorMap(nodeKeys, monitor); - return monitor; + } finally { + MONITOR_LOCK_OBJECT.unlock(); + } } private void populateMonitorMap(final Set nodeKeys, final Monitor monitor) { @@ -162,21 +149,6 @@ void addTask(final Monitor monitor) { tasksMap.computeIfAbsent(monitor, k -> threadPool.submit(monitor)); } - /** - * Clear all references used by the given monitor. Put the monitor in to a queue waiting to be - * reused. - * - * @param monitor The monitor to reset. - */ - public void resetResource(final Monitor monitor) { - if (monitor == null) { - return; - } - - monitorMap.entrySet().removeIf(e -> e.getValue() == monitor); - availableMonitors.add(monitor); - } - /** * Remove references to the given {@link MonitorImpl} object and stop the background monitoring * thread. @@ -189,23 +161,34 @@ public void releaseResource(final Monitor monitor) { } final List monitorList = Collections.singletonList(monitor); - monitorMap.values().removeAll(monitorList); - tasksMap.computeIfPresent( - monitor, - (k, v) -> { - v.cancel(true); - return null; - }); + + MONITOR_LOCK_OBJECT.lock(); + try { + monitorMap.values().removeAll(monitorList); + tasksMap.computeIfPresent( + monitor, + (k, v) -> { + v.cancel(true); + return null; + }); + } finally { + MONITOR_LOCK_OBJECT.unlock(); + } } - private void releaseResources() { - monitorMap.clear(); - tasksMap.values().stream() - .filter(val -> !val.isDone() && !val.isCancelled()) - .forEach(val -> val.cancel(true)); + public void releaseResources() { + MONITOR_LOCK_OBJECT.lock(); + try { + monitorMap.clear(); + tasksMap.values().stream() + .filter(val -> !val.isDone() && !val.isCancelled()) + .forEach(val -> val.cancel(true)); - if (threadPool != null) { - threadPool.shutdownNow(); + if (threadPool != null) { + threadPool.shutdownNow(); + } + } finally { + MONITOR_LOCK_OBJECT.unlock(); } } } 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 677060f15..627aa1334 100644 --- a/wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties +++ b/wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties @@ -189,13 +189,12 @@ MonitorThreadContainer.emptyNodeKeys=Provided node keys are empty. # Monitor Impl MonitorImpl.contextNullWarning=Parameter 'context' should not be null. -MonitorImpl.interruptedExceptionDuringMonitoring=Monitoring thread for node {0} was interrupted: {1} -MonitorImpl.exceptionDuringMonitoringContinue=Continuing monitoring after unhandled exception was thrown in monitoring thread for node {0}: {1} -MonitorImpl.exceptionDuringMonitoringStop=Stopping monitoring after unhandled exception was thrown in monitoring thread for node {0}: {1} +MonitorImpl.interruptedExceptionDuringMonitoring=Monitoring thread for node {0} was interrupted. +MonitorImpl.exceptionDuringMonitoringContinue=Continuing monitoring after unhandled exception was thrown in monitoring thread for node {0}. +MonitorImpl.exceptionDuringMonitoringStop=Stopping monitoring after unhandled exception was thrown in monitoring thread for node {0}. MonitorImpl.monitorIsStopped=Monitoring was already stopped for node {0}. # Monitor Service Impl -MonitorServiceImpl.nullMonitorParam=Parameter 'monitor' should not be null. MonitorServiceImpl.emptyAliasSet=Empty alias set passed for ''{0}''. Set should not be empty. MonitorServiceImpl.errorPopulatingAliases=Error occurred while populating aliases: ''{0}''. diff --git a/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MonitorImplTest.java b/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MonitorImplTest.java index 76cd16ab1..76107c994 100644 --- a/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MonitorImplTest.java +++ b/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MonitorImplTest.java @@ -24,7 +24,6 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyInt; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; @@ -76,6 +75,7 @@ class MonitorImplTest { private AutoCloseable closeable; private MonitorImpl monitor; + private MonitorThreadContainer threadContainer; @BeforeEach void init() throws SQLException { @@ -93,9 +93,9 @@ void init() throws SQLException { when(telemetryFactory.openTelemetryContext(eq(null), any())).thenReturn(telemetryContext); when(telemetryFactory.createCounter(anyString())).thenReturn(telemetryCounter); when(executorServiceInitializer.createExecutorService()).thenReturn(executorService); - MonitorThreadContainer.getInstance(executorServiceInitializer); + threadContainer = MonitorThreadContainer.getInstance(executorServiceInitializer); - monitor = spy(new MonitorImpl(pluginService, hostSpec, properties, 0L, monitorService)); + monitor = spy(new MonitorImpl(pluginService, hostSpec, properties, 0L, threadContainer)); } @AfterEach @@ -153,18 +153,8 @@ void test_7_isConnectionHealthyWithSQLException() throws SQLException { @Test void test_8_runWithoutContext() { - final MonitorThreadContainer container = - MonitorThreadContainer.getInstance(executorServiceInitializer); - final Map monitorMap = container.getMonitorMap(); - final Map> taskMap = container.getTasksMap(); - - doAnswer( - invocation -> { - container.releaseResource(invocation.getArgument(0)); - return null; - }) - .when(monitorService) - .notifyUnused(any(Monitor.class)); + final Map monitorMap = threadContainer.getMonitorMap(); + final Map> taskMap = threadContainer.getTasksMap(); // Put monitor into container map final String nodeKey = "monitorA"; @@ -185,18 +175,8 @@ void test_8_runWithoutContext() { @RepeatedTest(1000) void test_9_runWithContext() { - final MonitorThreadContainer container = - MonitorThreadContainer.getInstance(executorServiceInitializer); - final Map monitorMap = container.getMonitorMap(); - final Map> taskMap = container.getTasksMap(); - - doAnswer( - invocation -> { - container.releaseResource(invocation.getArgument(0)); - return null; - }) - .when(monitorService) - .notifyUnused(any(Monitor.class)); + final Map monitorMap = threadContainer.getMonitorMap(); + final Map> taskMap = threadContainer.getTasksMap(); // Put monitor into container map final String nodeKey = "monitorA"; diff --git a/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MonitorServiceImplTest.java b/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MonitorServiceImplTest.java index 1b8ada78f..ce70f0f12 100644 --- a/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MonitorServiceImplTest.java +++ b/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MonitorServiceImplTest.java @@ -72,6 +72,7 @@ class MonitorServiceImplTest { private Properties properties; private AutoCloseable closeable; private MonitorServiceImpl monitorService; + private MonitorThreadContainer threadContainer; private ArgumentCaptor contextCaptor; @BeforeEach @@ -83,19 +84,21 @@ void init() { when(pluginService.getTelemetryFactory()).thenReturn(telemetryFactory); when(telemetryFactory.createCounter(anyString())).thenReturn(telemetryCounter); when(monitorInitializer.createMonitor( - any(HostSpec.class), any(Properties.class), any(MonitorService.class))) + any(HostSpec.class), any(Properties.class), any(MonitorThreadContainer.class))) .thenReturn(monitorA, monitorB); when(executorServiceInitializer.createExecutorService()).thenReturn(executorService); doReturn(task).when(executorService).submit(any(Monitor.class)); + threadContainer = MonitorThreadContainer.getInstance(executorServiceInitializer); monitorService = new MonitorServiceImpl(pluginService, monitorInitializer, executorServiceInitializer); } @AfterEach void cleanUp() throws Exception { monitorService.releaseResources(); + threadContainer.releaseResources(); closeable.close(); } @@ -113,7 +116,6 @@ void test_startMonitoringWithNoExecutor() { FAILURE_DETECTION_COUNT); assertNotNull(contextCaptor.getValue()); - verify(executorService).submit(eq(monitorA)); } @Test @@ -134,9 +136,6 @@ void test_startMonitoringCalledMultipleTimes() { } assertNotNull(contextCaptor.getValue()); - - // executorService should only be called once. - verify(executorService).submit(eq(monitorA)); } @Test @@ -223,7 +222,7 @@ void test_getMonitorCalledWithMultipleNodesInKeys() { assertEquals(monitorOne, monitorOneSame); // Make sure createMonitor was called once - verify(monitorInitializer).createMonitor(eq(hostSpec), eq(properties), eq(monitorService)); + verify(monitorInitializer).createMonitor(eq(hostSpec), eq(properties), eq(threadContainer)); } @Test @@ -271,7 +270,7 @@ void test_getMonitorCalledWithSameKeysInDifferentNodeKeys() { assertEquals(monitorOne, monitorOneDupeAgain); // Make sure createMonitor was called once - verify(monitorInitializer).createMonitor(eq(hostSpec), eq(properties), eq(monitorService)); + verify(monitorInitializer).createMonitor(eq(hostSpec), eq(properties), eq(threadContainer)); } @Test diff --git a/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MultiThreadedDefaultMonitorServiceTest.java b/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MultiThreadedDefaultMonitorServiceTest.java index 7d094ff0f..c408d1398 100644 --- a/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MultiThreadedDefaultMonitorServiceTest.java +++ b/wrapper/src/test/java/software/amazon/jdbc/plugin/efm/MultiThreadedDefaultMonitorServiceTest.java @@ -104,7 +104,7 @@ void init(TestInfo testInfo) { CONCURRENT_TEST_MAP.computeIfAbsent(testInfo.getDisplayName(), k -> new AtomicBoolean(false)); when(monitorInitializer.createMonitor( - any(HostSpec.class), any(Properties.class), any(MonitorService.class))) + any(HostSpec.class), any(Properties.class), any(MonitorThreadContainer.class))) .thenReturn(monitor); when(executorServiceInitializer.createExecutorService()).thenReturn(service); doReturn(taskA).when(service).submit(any(Monitor.class)); @@ -158,7 +158,7 @@ void test_1_startMonitoring_multipleConnectionsToDifferentNodes() && contexts.containsAll(capturedContexts) && capturedContexts.containsAll(contexts)); verify(monitorInitializer, times(numConnections)) - .createMonitor(eq(hostSpec), eq(properties), any(MonitorService.class)); + .createMonitor(eq(hostSpec), eq(properties), any(MonitorThreadContainer.class)); } finally { releaseResources(services); } @@ -184,7 +184,7 @@ void test_2_startMonitoring_multipleConnectionsToOneNode() && capturedContexts.containsAll(contexts)); verify(monitorInitializer) - .createMonitor(eq(hostSpec), eq(properties), any(MonitorService.class)); + .createMonitor(eq(hostSpec), eq(properties), any(MonitorThreadContainer.class)); } finally { releaseResources(services); } diff --git a/wrapper/src/test/resources/logging-test.properties b/wrapper/src/test/resources/logging-test.properties index 5f22239d5..3fb02ef01 100644 --- a/wrapper/src/test/resources/logging-test.properties +++ b/wrapper/src/test/resources/logging-test.properties @@ -19,7 +19,7 @@ handlers=java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level=ALL java.util.logging.ConsoleHandler.formatter=software.amazon.logging.ExtendedFormatter -software.amazon.logging.ExtendedFormatter.format=[%1$tF %1$tT.%1$tL] [%4$-7s] [%7$-10s] [%2$s] : %5$s %n +software.amazon.logging.ExtendedFormatter.format=[%1$tF %1$tT.%1$tL] [%4$-7s] [%7$-10s] [%2$s] : %5$s %6$s %n software.amazon.jdbc.level=ALL