Skip to content

Commit ffbc046

Browse files
committed
Replaces slf logger with airlift logger
1 parent 2a3672d commit ffbc046

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

gateway-ha/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,6 @@
278278
<version>2.5.2.Final</version>
279279
</dependency>
280280

281-
<dependency>
282-
<groupId>org.slf4j</groupId>
283-
<artifactId>slf4j-api</artifactId>
284-
</dependency>
285-
286281
<dependency>
287282
<groupId>org.weakref</groupId>
288283
<artifactId>jmxutils</artifactId>

gateway-ha/src/main/java/io/trino/gateway/ha/config/ClusterSchedulerConfiguration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
package io.trino.gateway.ha.config;
1515

1616
import com.google.inject.Inject;
17+
import io.airlift.log.Logger;
1718
import io.trino.gateway.ha.scheduler.ClusterScheduler;
1819
import jakarta.annotation.Nullable;
1920
import jakarta.annotation.PostConstruct;
2021
import jakarta.annotation.PreDestroy;
21-
import org.slf4j.Logger;
22-
import org.slf4j.LoggerFactory;
2322

2423
public class ClusterSchedulerConfiguration
2524
{
26-
private static final Logger log = LoggerFactory.getLogger(ClusterSchedulerConfiguration.class);
25+
private static final Logger log = Logger.get(ClusterSchedulerConfiguration.class);
2726

2827
private final ClusterScheduler scheduler;
2928

@@ -49,7 +48,7 @@ public void stop()
4948
scheduler.close();
5049
}
5150
catch (Exception e) {
52-
log.error("Exception occurred while shutting down ClusterScheduler", e);
51+
log.error(e, "Exception occurred while shutting down ClusterScheduler");
5352
}
5453
}
5554
}

gateway-ha/src/main/java/io/trino/gateway/ha/scheduler/ClusterScheduler.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@
1919
import com.cronutils.model.definition.CronDefinitionBuilder;
2020
import com.cronutils.model.time.ExecutionTime;
2121
import com.cronutils.parser.CronParser;
22+
import io.airlift.log.Logger;
2223
import io.trino.gateway.ha.config.ProxyBackendConfiguration;
2324
import io.trino.gateway.ha.config.ScheduleConfiguration;
2425
import io.trino.gateway.ha.router.GatewayBackendManager;
2526
import jakarta.annotation.PostConstruct;
2627
import jakarta.annotation.PreDestroy;
2728
import jakarta.inject.Inject;
28-
import org.slf4j.Logger;
29-
import org.slf4j.LoggerFactory;
3029

3130
import java.time.ZoneId;
3231
import java.time.ZonedDateTime;
@@ -42,7 +41,7 @@
4241
public class ClusterScheduler
4342
implements AutoCloseable
4443
{
45-
private static final Logger log = LoggerFactory.getLogger(ClusterScheduler.class);
44+
private static final Logger log = Logger.get(ClusterScheduler.class);
4645
private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
4746
private final GatewayBackendManager backendManager;
4847
private final ScheduleConfiguration config;
@@ -68,12 +67,12 @@ public ClusterScheduler(GatewayBackendManager backendManager, ScheduleConfigurat
6867
}
6968
else {
7069
configuredTimezone = ZoneId.of(timezoneStr);
71-
log.info("Using configured timezone: {}", timezoneStr);
70+
log.info("Using configured timezone: %s", timezoneStr);
7271
}
7372
}
7473
catch (Exception e) {
7574
configuredTimezone = ZoneId.of("GMT");
76-
log.warn("Invalid timezone '{}' in configuration, falling back to GMT", config.getTimezone(), e);
75+
log.warn(e, "Invalid timezone '%s' in configuration, falling back to GMT", config.getTimezone());
7776
}
7877
this.timezone = configuredTimezone;
7978
}
@@ -110,15 +109,15 @@ public void start()
110109
0,
111110
config.getCheckInterval().toMillis(),
112111
TimeUnit.MILLISECONDS);
113-
log.info("Started cluster scheduler with check interval: {} (using {} timezone)",
112+
log.info("Started cluster scheduler with check interval: %s (using %s timezone)",
114113
config.getCheckInterval(),
115114
timezone);
116115
}
117116

118117
public void checkAndUpdateClusterStatus(ZonedDateTime currentTime)
119118
{
120119
try {
121-
log.debug("Checking cluster status at: {} ({})", currentTime, timezone);
120+
log.debug("Checking cluster status at: %s (%s)", currentTime, timezone);
122121

123122
for (Map.Entry<String, ExecutionTime> entry : executionTimes.entrySet()) {
124123
String clusterName = entry.getKey();
@@ -130,15 +129,15 @@ public void checkAndUpdateClusterStatus(ZonedDateTime currentTime)
130129
.findFirst();
131130

132131
if (scheduleOpt.isEmpty()) {
133-
log.warn("No schedule configuration found for cluster: {}", clusterName);
132+
log.warn("No schedule configuration found for cluster: %s", clusterName);
134133
continue;
135134
}
136135

137136
ScheduleConfiguration.ClusterSchedule schedule = scheduleOpt.get();
138137
boolean cronMatches = executionTime.isMatch(currentTime);
139138
boolean shouldBeActive = cronMatches == schedule.isActiveDuringCron();
140139

141-
log.info("Cluster: {}, cronMatches: {}, activeDuringCron: {}, shouldBeActive: {}",
140+
log.info("Cluster: %s, cronMatches: %s, activeDuringCron: %s, shouldBeActive: %s",
142141
clusterName,
143142
cronMatches,
144143
schedule.isActiveDuringCron(),
@@ -150,38 +149,38 @@ public void checkAndUpdateClusterStatus(ZonedDateTime currentTime)
150149
ProxyBackendConfiguration cluster = clusterOpt.get();
151150
boolean currentlyActive = cluster.isActive();
152151

153-
log.debug("Cluster: {}, currentlyActive: {}, shouldBeActive: {}",
152+
log.debug("Cluster: %s, currentlyActive: %s, shouldBeActive: %s",
154153
clusterName,
155154
currentlyActive,
156155
shouldBeActive);
157156

158157
if (currentlyActive != shouldBeActive) {
159158
if (shouldBeActive) {
160159
backendManager.activateBackend(clusterName);
161-
log.info("Activated cluster {} based on schedule (cron match: {}, activeDuringCron: {})",
160+
log.info("Activated cluster %s based on schedule (cron match: %s, activeDuringCron: %s)",
162161
clusterName,
163162
cronMatches,
164163
schedule.isActiveDuringCron());
165164
}
166165
else {
167166
backendManager.deactivateBackend(clusterName);
168-
log.info("Deactivated cluster {} based on schedule (cron match: {}, activeDuringCron: {})",
167+
log.info("Deactivated cluster %s based on schedule (cron match: %s, activeDuringCron: %s)",
169168
clusterName,
170169
cronMatches,
171170
schedule.isActiveDuringCron());
172171
}
173172
}
174173
else {
175-
log.debug("Cluster {} status unchanged: active={}", clusterName, currentlyActive);
174+
log.debug("Cluster %s status unchanged: active=%s", clusterName, currentlyActive);
176175
}
177176
}
178177
else {
179-
log.warn("Cluster {} not found in backend manager", clusterName);
178+
log.warn("Cluster %s not found in backend manager", clusterName);
180179
}
181180
}
182181
}
183182
catch (Exception e) {
184-
log.error("Error in cluster scheduler task", e);
183+
log.error(e, "Error in cluster scheduler task");
185184
}
186185
}
187186

@@ -197,7 +196,7 @@ public void close()
197196
}
198197
catch (InterruptedException e) {
199198
Thread.currentThread().interrupt();
200-
log.warn("Interrupted while waiting for scheduler to terminate", e);
199+
log.warn(e, "Interrupted while waiting for scheduler to terminate");
201200
}
202201
}
203202
}

0 commit comments

Comments
 (0)