Skip to content

Commit 26dc2fe

Browse files
committed
Add checks to prevent loading default modules in config
1 parent 0231bcb commit 26dc2fe

File tree

1 file changed

+20
-0
lines changed
  • gateway-ha/src/main/java/io/trino/gateway/baseapp

1 file changed

+20
-0
lines changed

gateway-ha/src/main/java/io/trino/gateway/baseapp/BaseApp.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
package io.trino.gateway.baseapp;
1515

16+
import com.google.common.collect.ImmutableList;
1617
import com.google.inject.Binder;
1718
import com.google.inject.Module;
1819
import com.google.inject.Scopes;
@@ -107,6 +108,7 @@ public static List<Module> addModules(HaGatewayConfiguration configuration)
107108
}
108109
else {
109110
for (String clazz : configuration.getModules()) {
111+
warnLoadingDefaultModules(clazz);
110112
modules.add(newModule(clazz, configuration));
111113
}
112114
}
@@ -115,6 +117,19 @@ public static List<Module> addModules(HaGatewayConfiguration configuration)
115117
return modules;
116118
}
117119

120+
private static void warnLoadingDefaultModules(String clazz)
121+
{
122+
// Remove this check when user finished the migration
123+
List<String> defaultModules = ImmutableList.of(
124+
"io.trino.gateway.ha.module.HaGatewayProviderModule",
125+
"io.trino.gateway.ha.module.ClusterStateListenerModule",
126+
"io.trino.gateway.ha.module.ClusterStatsMonitorModule");
127+
if (defaultModules.contains(clazz)) {
128+
logger.error("Default module [%s] is already being loaded. Please remove it from the config file", clazz);
129+
System.exit(1);
130+
}
131+
}
132+
118133
@Override
119134
public void configure(Binder binder)
120135
{
@@ -138,6 +153,11 @@ private static void addManagedApps(HaGatewayConfiguration configuration, Binder
138153
}
139154
configuration.getManagedApps().forEach(
140155
clazz -> {
156+
// Remove this check when user finished the migration
157+
if (clazz.equals("io.trino.gateway.ha.clustermonitor.ActiveClusterMonitor")) {
158+
logger.error("Default class ActiveClusterMonitor is already being loaded. Please remove it from the config file");
159+
System.exit(1);
160+
}
141161
try {
142162
Class<?> c = Class.forName(clazz);
143163
binder.bind(c).in(Scopes.SINGLETON);

0 commit comments

Comments
 (0)