Skip to content

Commit 51659d2

Browse files
chore: add additional logging for efm
1 parent 987fd41 commit 51659d2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

wrapper/src/main/java/software/amazon/jdbc/plugin/efm/MonitorImpl.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ public MonitorImpl(
9494

9595
@Override
9696
public void startMonitoring(final MonitorConnectionContext context) {
97+
if (this.stopped) {
98+
LOGGER.warning(() -> Messages.get("MonitorImpl.monitorIsStopped"));
99+
}
97100
final long currentTimeNano = this.getCurrentTimeNano();
98101
context.setStartMonitorTimeNano(currentTimeNano);
99102
this.contextLastUsedTimestampNano = currentTimeNano;
@@ -222,12 +225,24 @@ public void run() {
222225
}
223226
} catch (final InterruptedException intEx) {
224227
// do nothing; exit thread
228+
LOGGER.warning(
229+
() -> Messages.get(
230+
"MonitorImpl.interruptedExceptionDuringMonitoring",
231+
new Object[] {this.hostSpec.getHost(), intEx.getMessage()}));
232+
} catch (final Exception ex) {
233+
// do nothing; exit thread
234+
LOGGER.warning(
235+
() -> Messages.get(
236+
"MonitorImpl.exceptionDuringMonitoring",
237+
new Object[] {this.hostSpec.getHost(), ex.getMessage()}));
225238
} finally {
226239
if (this.monitoringConn != null) {
227240
try {
228241
this.monitoringConn.close();
229242
} catch (final SQLException ex) {
230243
// ignore
244+
LOGGER.warning(
245+
() -> Messages.get("MonitorImpl.exceptionClosingMonitoringConn", new Object[] {ex.getMessage()}));
231246
}
232247
}
233248
this.stopped = true;

wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ MonitorThreadContainer.emptyNodeKeys=Provided node keys are empty.
188188

189189
# Monitor Impl
190190
MonitorImpl.contextNullWarning=Parameter 'context' should not be null.
191+
MonitorImpl.exceptionClosingMonitoringConn=An exception was thrown when trying to close the monitoring connection: {0}
192+
MonitorImpl.interruptedExceptionDuringMonitoring=Monitoring thread for node {0} was interrupted: {1}
193+
MonitorImpl.exceptionDuringMonitoring=Unhandled exception in monitoring thread for node {0}: {1}
194+
MonitorImpl.monitorIsStopped=Monitor has already stopped.
191195

192196
# Monitor Service Impl
193197
MonitorServiceImpl.nullMonitorParam=Parameter 'monitor' should not be null.

0 commit comments

Comments
 (0)