This is an automated email from the ASF dual-hosted git repository. tingchen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push: new 612803e Add an optional flag to disable swagger in Pinot servers. (#7341) 612803e is described below commit 612803e06471b51784edf42cdd0a3db68b9c25a5 Author: Ting Chen <tingc...@uber.com> AuthorDate: Fri Aug 20 08:53:40 2021 -0700 Add an optional flag to disable swagger in Pinot servers. (#7341) * Add an optional flag to disable swagger in Pinot servers. * Replace with single instance class importa --- .../java/org/apache/pinot/server/conf/ServerConf.java | 6 ++++++ .../pinot/server/starter/helix/AdminApiApplication.java | 15 +++++++++++++-- .../java/org/apache/pinot/spi/utils/CommonConstants.java | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pinot-server/src/main/java/org/apache/pinot/server/conf/ServerConf.java b/pinot-server/src/main/java/org/apache/pinot/server/conf/ServerConf.java index a9058a6..f6151fb 100644 --- a/pinot-server/src/main/java/org/apache/pinot/server/conf/ServerConf.java +++ b/pinot-server/src/main/java/org/apache/pinot/server/conf/ServerConf.java @@ -28,7 +28,9 @@ import org.apache.pinot.spi.utils.CommonConstants.Server; import static org.apache.pinot.spi.utils.CommonConstants.Server.CONFIG_OF_ALLOWED_TABLES_FOR_EMITTING_METRICS; import static org.apache.pinot.spi.utils.CommonConstants.Server.CONFIG_OF_ENABLE_TABLE_LEVEL_METRICS; +import static org.apache.pinot.spi.utils.CommonConstants.Server.CONFIG_OF_SWAGGER_SERVER_ENABLED; import static org.apache.pinot.spi.utils.CommonConstants.Server.DEFAULT_ENABLE_TABLE_LEVEL_METRICS; +import static org.apache.pinot.spi.utils.CommonConstants.Server.DEFAULT_SWAGGER_SERVER_ENABLED; /** @@ -94,6 +96,10 @@ public class ServerConf { return _serverConf.getProperty(Server.CONFIG_OF_ENABLE_GRPC_SERVER, Server.DEFAULT_ENABLE_GRPC_SERVER); } + public boolean isEnableSwagger() { + return _serverConf.getProperty(CONFIG_OF_SWAGGER_SERVER_ENABLED, DEFAULT_SWAGGER_SERVER_ENABLED); + } + public int getGrpcPort() { return _serverConf.getProperty(Server.CONFIG_OF_GRPC_PORT, Server.DEFAULT_GRPC_PORT); } diff --git a/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/AdminApiApplication.java b/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/AdminApiApplication.java index 34b83a4..8a1d6c0 100644 --- a/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/AdminApiApplication.java +++ b/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/AdminApiApplication.java @@ -43,6 +43,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.pinot.spi.utils.CommonConstants.Server.CONFIG_OF_SWAGGER_SERVER_ENABLED; +import static org.apache.pinot.spi.utils.CommonConstants.Server.DEFAULT_SWAGGER_SERVER_ENABLED; + public class AdminApiApplication extends ResourceConfig { private static final Logger LOGGER = LoggerFactory.getLogger(AdminApiApplication.class); @@ -92,8 +95,16 @@ public class AdminApiApplication extends ResourceConfig { throw new RuntimeException("Failed to start http server", e); } - synchronized (PinotReflectionUtils.getReflectionLock()) { - setupSwagger(httpServer); + PinotConfiguration pinotConfiguration = + (PinotConfiguration) getProperties().get(PINOT_CONFIGURATION); + // Allow optional start of the swagger as the Reflection lib has multi-thread access bug (issues/7271). It is not + // always possible to pin the Reflection lib on 0.9.9. So this optional setting will disable the swagger because it + // is NOT an essential part of Pinot servers. + if (pinotConfiguration.getProperty(CONFIG_OF_SWAGGER_SERVER_ENABLED, DEFAULT_SWAGGER_SERVER_ENABLED)) { + LOGGER.info("Starting swagger for the Pinot server."); + synchronized (PinotReflectionUtils.getReflectionLock()) { + setupSwagger(httpServer); + } } started = true; return true; diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java index 83c0a42..6d0e91c 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java @@ -252,6 +252,8 @@ public class CommonConstants { public static final int DEFAULT_GRPC_PORT = 8090; public static final String CONFIG_OF_NETTYTLS_SERVER_ENABLED = "pinot.server.nettytls.enabled"; public static final boolean DEFAULT_NETTYTLS_SERVER_ENABLED = false; + public static final String CONFIG_OF_SWAGGER_SERVER_ENABLED = "pinot.server.swagger.enabled"; + public static final boolean DEFAULT_SWAGGER_SERVER_ENABLED = true; public static final String CONFIG_OF_ADMIN_API_PORT = "pinot.server.adminapi.port"; public static final int DEFAULT_ADMIN_API_PORT = 8097; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org