Skip to content

Commit fa4c981

Browse files
david-leifkersleeperdeep
authored andcommitted
feat(schema-registry): exclude schema reg onboot check from schema re… (datahub-project#10349)
1 parent 1999959 commit fa4c981

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

metadata-service/factories/src/main/java/com/linkedin/metadata/boot/OnBootApplicationListener.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
@Slf4j
2727
@Component
2828
public class OnBootApplicationListener {
29+
30+
public static final String SCHEMA_REGISTRY_SERVLET_NAME = "dispatcher-schema-registry";
31+
2932
private static final Set<Integer> ACCEPTED_HTTP_CODES =
3033
Set.of(
3134
HttpStatus.SC_OK,
@@ -58,6 +61,12 @@ public class OnBootApplicationListener {
5861

5962
@EventListener(ContextRefreshedEvent.class)
6063
public void onApplicationEvent(@Nonnull ContextRefreshedEvent event) {
64+
65+
if (SCHEMA_REGISTRY_SERVLET_NAME.equals(event.getApplicationContext().getId())) {
66+
log.info("Loading servlet {} without interruption.", SCHEMA_REGISTRY_SERVLET_NAME);
67+
return;
68+
}
69+
6170
log.warn(
6271
"OnBootApplicationListener context refreshed! {} event: {}",
6372
ROOT_WEB_APPLICATION_CONTEXT_ID.equals(event.getApplicationContext().getId()),

metadata-service/war/src/main/java/com/linkedin/gms/WebApplicationInitializer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.linkedin.gms;
22

3+
import static com.linkedin.metadata.boot.OnBootApplicationListener.SCHEMA_REGISTRY_SERVLET_NAME;
4+
35
import com.datahub.auth.authentication.filter.AuthenticationFilter;
46
import com.datahub.gms.servlet.Config;
57
import com.datahub.gms.servlet.ConfigSearchExport;
@@ -35,6 +37,7 @@ public void onStartup(ServletContext container) {
3537
"contextInitializerClasses", "com.linkedin.gms.SpringApplicationInitializer");
3638

3739
// Auth filter
40+
List<String> servletNames = new ArrayList<>();
3841

3942
// Independent dispatcher
4043
schemaRegistryServlet(container);
@@ -43,8 +46,6 @@ public void onStartup(ServletContext container) {
4346
healthCheckServlet(container);
4447
configServlet(container);
4548

46-
List<String> servletNames = new ArrayList<>();
47-
4849
// Restli non-Dispatcher
4950
servletNames.add(restliServlet(rootContext, container));
5051

@@ -69,11 +70,12 @@ public void onStartup(ServletContext container) {
6970
*/
7071
private void schemaRegistryServlet(ServletContext container) {
7172
AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext();
73+
webContext.setId(SCHEMA_REGISTRY_SERVLET_NAME);
7274
webContext.register(SchemaRegistryServletConfig.class);
7375

7476
DispatcherServlet dispatcherServlet = new DispatcherServlet(webContext);
7577
ServletRegistration.Dynamic registration =
76-
container.addServlet("dispatcher-schema-registry", dispatcherServlet);
78+
container.addServlet(SCHEMA_REGISTRY_SERVLET_NAME, dispatcherServlet);
7779
registration.addMapping("/schema-registry/*");
7880
registration.setLoadOnStartup(1);
7981
registration.setAsyncSupported(true);

0 commit comments

Comments
 (0)