|
16 | 16 | import java.util.HashMap;
|
17 | 17 | import java.util.List;
|
18 | 18 | import java.util.Map;
|
| 19 | +import java.util.Queue; |
| 20 | +import java.util.concurrent.atomic.AtomicInteger; |
| 21 | +import java.util.stream.Collectors; |
19 | 22 | import java.util.stream.Stream;
|
20 | 23 | import org.apache.commons.lang3.StringUtils;
|
| 24 | +import org.apache.commons.lang3.exception.ExceptionUtils; |
21 | 25 | import org.jooq.SQLDialect;
|
22 | 26 | import org.slf4j.Logger;
|
23 | 27 | import org.slf4j.LoggerFactory;
|
@@ -105,39 +109,39 @@ public MsSQLTestDatabase withShortenedCapturePollingInterval() {
|
105 | 109 |
|
106 | 110 | private void waitForAgentState(final boolean running) {
|
107 | 111 | final String expectedValue = running ? "Running." : "Stopped.";
|
108 |
| - LOGGER.debug("Waiting for SQLServerAgent state to change to '{}'.", expectedValue); |
| 112 | + LOGGER.info(formatLogLine("Waiting for SQLServerAgent state to change to '{}'."), expectedValue); |
109 | 113 | for (int i = 0; i < MAX_RETRIES; i++) {
|
110 | 114 | try {
|
111 | 115 | final var r = query(ctx -> ctx.fetch("EXEC master.dbo.xp_servicecontrol 'QueryState', N'SQLServerAGENT';").get(0));
|
112 | 116 | if (expectedValue.equalsIgnoreCase(r.getValue(0).toString())) {
|
113 |
| - LOGGER.debug("SQLServerAgent state is '{}', as expected.", expectedValue); |
| 117 | + LOGGER.info(formatLogLine("SQLServerAgent state is '{}', as expected."), expectedValue); |
114 | 118 | return;
|
115 | 119 | }
|
116 |
| - LOGGER.debug("Retrying, SQLServerAgent state {} does not match expected '{}'.", r, expectedValue); |
| 120 | + LOGGER.info(formatLogLine("Retrying, SQLServerAgent state {} does not match expected '{}'."), r, expectedValue); |
117 | 121 | } catch (final SQLException e) {
|
118 |
| - LOGGER.debug("Retrying agent state query after catching exception {}.", e.getMessage()); |
| 122 | + LOGGER.info(formatLogLine("Retrying agent state query after catching exception {}."), e.getMessage()); |
119 | 123 | }
|
120 | 124 | try {
|
121 | 125 | Thread.sleep(1_000); // Wait one second between retries.
|
122 | 126 | } catch (final InterruptedException e) {
|
123 | 127 | throw new RuntimeException(e);
|
124 | 128 | }
|
125 | 129 | }
|
126 |
| - throw new RuntimeException("Exhausted retry attempts while polling for agent state"); |
| 130 | + throw new RuntimeException(formatLogLine("Exhausted retry attempts while polling for agent state")); |
127 | 131 | }
|
128 | 132 |
|
129 | 133 | public MsSQLTestDatabase withWaitUntilMaxLsnAvailable() {
|
130 |
| - LOGGER.debug("Waiting for max LSN to become available for database {}.", getDatabaseName()); |
| 134 | + LOGGER.info(formatLogLine("Waiting for max LSN to become available for database {}."), getDatabaseName()); |
131 | 135 | for (int i = 0; i < MAX_RETRIES; i++) {
|
132 | 136 | try {
|
133 | 137 | final var maxLSN = query(ctx -> ctx.fetch("SELECT sys.fn_cdc_get_max_lsn();").get(0).get(0, byte[].class));
|
134 | 138 | if (maxLSN != null) {
|
135 |
| - LOGGER.debug("Max LSN available for database {}: {}", getDatabaseName(), Lsn.valueOf(maxLSN)); |
| 139 | + LOGGER.info(formatLogLine("Max LSN available for database {}: {}"), getDatabaseName(), Lsn.valueOf(maxLSN)); |
136 | 140 | return self();
|
137 | 141 | }
|
138 |
| - LOGGER.debug("Retrying, max LSN still not available for database {}.", getDatabaseName()); |
| 142 | + LOGGER.info(formatLogLine("Retrying, max LSN still not available for database {}."), getDatabaseName()); |
139 | 143 | } catch (final SQLException e) {
|
140 |
| - LOGGER.warn("Retrying max LSN query after catching exception {}", e.getMessage()); |
| 144 | + LOGGER.info(formatLogLine("Retrying max LSN query after catching exception {}"), e.getMessage()); |
141 | 145 | }
|
142 | 146 | try {
|
143 | 147 | Thread.sleep(1_000); // Wait one second between retries.
|
|
0 commit comments