Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(schema-registry): exclude schema reg onboot check from schema re… #10349

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
@Slf4j
@Component
public class OnBootApplicationListener {

public static final String SCHEMA_REGISTRY_SERVLET_NAME = "dispatcher-schema-registry";

private static final Set<Integer> ACCEPTED_HTTP_CODES =
Set.of(
HttpStatus.SC_OK,
Expand Down Expand Up @@ -58,6 +61,12 @@ public class OnBootApplicationListener {

@EventListener(ContextRefreshedEvent.class)
public void onApplicationEvent(@Nonnull ContextRefreshedEvent event) {

if (SCHEMA_REGISTRY_SERVLET_NAME.equals(event.getApplicationContext().getId())) {
log.info("Loading servlet {} without interruption.", SCHEMA_REGISTRY_SERVLET_NAME);
return;
}

log.warn(
"OnBootApplicationListener context refreshed! {} event: {}",
ROOT_WEB_APPLICATION_CONTEXT_ID.equals(event.getApplicationContext().getId()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.linkedin.gms;

import static com.linkedin.metadata.boot.OnBootApplicationListener.SCHEMA_REGISTRY_SERVLET_NAME;

import com.datahub.auth.authentication.filter.AuthenticationFilter;
import com.datahub.gms.servlet.Config;
import com.datahub.gms.servlet.ConfigSearchExport;
Expand Down Expand Up @@ -35,6 +37,7 @@ public void onStartup(ServletContext container) {
"contextInitializerClasses", "com.linkedin.gms.SpringApplicationInitializer");

// Auth filter
List<String> servletNames = new ArrayList<>();

// Independent dispatcher
schemaRegistryServlet(container);
Expand All @@ -43,8 +46,6 @@ public void onStartup(ServletContext container) {
healthCheckServlet(container);
configServlet(container);

List<String> servletNames = new ArrayList<>();

// Restli non-Dispatcher
servletNames.add(restliServlet(rootContext, container));

Expand All @@ -69,11 +70,12 @@ public void onStartup(ServletContext container) {
*/
private void schemaRegistryServlet(ServletContext container) {
AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext();
webContext.setId(SCHEMA_REGISTRY_SERVLET_NAME);
webContext.register(SchemaRegistryServletConfig.class);

DispatcherServlet dispatcherServlet = new DispatcherServlet(webContext);
ServletRegistration.Dynamic registration =
container.addServlet("dispatcher-schema-registry", dispatcherServlet);
container.addServlet(SCHEMA_REGISTRY_SERVLET_NAME, dispatcherServlet);
registration.addMapping("/schema-registry/*");
registration.setLoadOnStartup(1);
registration.setAsyncSupported(true);
Expand Down
Loading