Skip to content

Commit

Permalink
Envoy announcer should only start from coordinators
Browse files Browse the repository at this point in the history
  • Loading branch information
prabodhtr committed Oct 8, 2024
1 parent 0875830 commit f2074ac
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public ListenableFuture<Duration> announce() {

return httpClient.executeAsync(request, new EnvoyResponseHandler<>("envoyAnnouncement", uri) {
@Override
public Duration handle(Request request, Response response) throws RuntimeException {
public Duration handle(Request request, Response response) throws DiscoveryException {
int statusCode = response.getStatusCode();
if (!isSuccess(statusCode)) {
throw new DiscoveryException(String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,9 @@ public class EnvoyAnnouncerModule extends AbstractConfigurationAwareModule {

@Override
protected void setup(Binder binder) {
if (buildConfigObject(ServerConfig.class).isCoordinator() &&
buildConfigObject(CoordinatorAnnouncerConfig.class).isEnabled()) {

ConfigBinder.configBinder(binder).bindConfig(CoordinatorAnnouncerConfig.class);
binder.bind(EnvoyAnnouncementClient.class).in(Scopes.SINGLETON);
HttpClientBinder.httpClientBinder(binder).bindHttpClient("envoy", ForEnvoyAnnouncement.class);
binder.bind(EnvoyAnnouncer.class).in(Scopes.SINGLETON);
}

ConfigBinder.configBinder(binder).bindConfig(CoordinatorAnnouncerConfig.class);
binder.bind(EnvoyAnnouncementClient.class).in(Scopes.SINGLETON);
HttpClientBinder.httpClientBinder(binder).bindHttpClient("envoy", ForEnvoyAnnouncement.class);
binder.bind(EnvoyAnnouncer.class).in(Scopes.SINGLETON);
}
}
3 changes: 1 addition & 2 deletions core/trino-main/src/main/java/io/trino/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,14 @@ private void doStart(String trinoVersion)

if (injector.getInstance(ServerConfig.class).isCoordinator()) {
injector.getInstance(EventListenerManager.class).loadEventListeners();
injector.getInstance(EnvoyAnnouncer.class).start();
}

injector.getInstance(Key.get(new TypeLiteral<Optional<OAuth2Client>>() {}))
.ifPresent(OAuth2Client::load);

injector.getInstance(Announcer.class).start();

injector.getInstance(EnvoyAnnouncer.class).start();

injector.getInstance(StartupStatus.class).startupComplete();
log.info("Server startup completed in %s", Duration.nanosSince(startTime).convertToMostSuccinctTimeUnit());
log.info("======== SERVER STARTED ========");
Expand Down

0 comments on commit f2074ac

Please sign in to comment.