Skip to content

Commit

Permalink
feat(schema-registry): exclude schema reg onboot check from schema re… (
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker authored Apr 22, 2024
1 parent 3668a56 commit 8d90c21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 8d90c21

Please sign in to comment.