This is an automated email from the ASF dual-hosted git repository. jackie 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 1c3a215750 allow to set https as the default scheme (#8729) 1c3a215750 is described below commit 1c3a2157505568415e0a32c6499493604ef303f9 Author: Xiaobing <61892277+klsi...@users.noreply.github.com> AuthorDate: Tue May 24 09:55:55 2022 -0700 allow to set https as the default scheme (#8729) --- .../pinot/broker/broker/BrokerAdminApiApplication.java | 8 +++++++- .../java/org/apache/pinot/controller/ControllerConf.java | 1 + .../controller/api/ControllerAdminApiApplication.java | 10 ++++++++-- .../apache/pinot/minion/MinionAdminApiApplication.java | 9 +++++++-- .../pinot/server/starter/helix/AdminApiApplication.java | 16 +++++++++------- .../java/org/apache/pinot/spi/utils/CommonConstants.java | 3 +++ 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/pinot-broker/src/main/java/org/apache/pinot/broker/broker/BrokerAdminApiApplication.java b/pinot-broker/src/main/java/org/apache/pinot/broker/broker/BrokerAdminApiApplication.java index fdb701b9f2..cfc5d55928 100644 --- a/pinot-broker/src/main/java/org/apache/pinot/broker/broker/BrokerAdminApiApplication.java +++ b/pinot-broker/src/main/java/org/apache/pinot/broker/broker/BrokerAdminApiApplication.java @@ -45,6 +45,7 @@ public class BrokerAdminApiApplication extends ResourceConfig { private static final String RESOURCE_PACKAGE = "org.apache.pinot.broker.api.resources"; public static final String PINOT_CONFIGURATION = "pinotConfiguration"; public static final String BROKER_INSTANCE_ID = "brokerInstanceId"; + private final boolean _useHttps; private HttpServer _httpServer; @@ -52,6 +53,7 @@ public class BrokerAdminApiApplication extends ResourceConfig { BrokerMetrics brokerMetrics, PinotConfiguration brokerConf, SqlQueryExecutor sqlQueryExecutor) { packages(RESOURCE_PACKAGE); property(PINOT_CONFIGURATION, brokerConf); + _useHttps = Boolean.parseBoolean(brokerConf.getProperty(CommonConstants.Broker.CONFIG_OF_SWAGGER_USE_HTTPS)); if (brokerConf.getProperty(CommonConstants.Broker.BROKER_SERVICE_AUTO_DISCOVERY, false)) { register(ServiceAutoDiscoveryFeature.class); } @@ -89,7 +91,11 @@ public class BrokerAdminApiApplication extends ResourceConfig { beanConfig.setDescription("APIs for accessing Pinot broker information"); beanConfig.setContact("https://github.com/apache/pinot"); beanConfig.setVersion("1.0"); - beanConfig.setSchemes(new String[]{CommonConstants.HTTP_PROTOCOL, CommonConstants.HTTPS_PROTOCOL}); + if (_useHttps) { + beanConfig.setSchemes(new String[]{CommonConstants.HTTPS_PROTOCOL}); + } else { + beanConfig.setSchemes(new String[]{CommonConstants.HTTP_PROTOCOL, CommonConstants.HTTPS_PROTOCOL}); + } beanConfig.setBasePath("/"); beanConfig.setResourcePackage(RESOURCE_PACKAGE); beanConfig.setScan(true); diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java b/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java index f23e7e6ae2..ff7a987d57 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java @@ -63,6 +63,7 @@ public class ControllerConf extends PinotConfiguration { public static final String HELIX_CLUSTER_NAME = "controller.helix.cluster.name"; public static final String CLUSTER_TENANT_ISOLATION_ENABLE = "cluster.tenant.isolation.enable"; public static final String CONSOLE_WEBAPP_ROOT_PATH = "controller.query.console"; + public static final String CONSOLE_SWAGGER_USE_HTTPS = "controller.swagger.use.https"; public static final String CONTROLLER_MODE = "controller.mode"; public static final String LEAD_CONTROLLER_RESOURCE_REBALANCE_STRATEGY = "controller.resource.rebalance.strategy"; diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/ControllerAdminApiApplication.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/ControllerAdminApiApplication.java index de74d90304..fa95790ad9 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/ControllerAdminApiApplication.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/ControllerAdminApiApplication.java @@ -49,6 +49,7 @@ public class ControllerAdminApiApplication extends ResourceConfig { public static final String PINOT_CONFIGURATION = "pinotConfiguration"; private final String _controllerResourcePackages; + private final boolean _useHttps; private HttpServer _httpServer; public ControllerAdminApiApplication(ControllerConf conf) { @@ -58,7 +59,8 @@ public class ControllerAdminApiApplication extends ResourceConfig { _controllerResourcePackages = conf.getControllerResourcePackages(); packages(_controllerResourcePackages); // TODO See ControllerResponseFilter -// register(new LoggingFeature()); + // register(new LoggingFeature()); + _useHttps = Boolean.parseBoolean(conf.getProperty(ControllerConf.CONSOLE_SWAGGER_USE_HTTPS)); if (conf.getProperty(CommonConstants.Controller.CONTROLLER_SERVICE_AUTO_DISCOVERY, false)) { register(ServiceAutoDiscoveryFeature.class); } @@ -109,7 +111,11 @@ public class ControllerAdminApiApplication extends ResourceConfig { beanConfig.setDescription("APIs for accessing Pinot Controller information"); beanConfig.setContact("https://github.com/apache/pinot"); beanConfig.setVersion("1.0"); - beanConfig.setSchemes(new String[]{CommonConstants.HTTP_PROTOCOL, CommonConstants.HTTPS_PROTOCOL}); + if (_useHttps) { + beanConfig.setSchemes(new String[]{CommonConstants.HTTPS_PROTOCOL}); + } else { + beanConfig.setSchemes(new String[]{CommonConstants.HTTP_PROTOCOL, CommonConstants.HTTPS_PROTOCOL}); + } beanConfig.setBasePath("/"); beanConfig.setResourcePackage(_controllerResourcePackages); beanConfig.setScan(true); diff --git a/pinot-minion/src/main/java/org/apache/pinot/minion/MinionAdminApiApplication.java b/pinot-minion/src/main/java/org/apache/pinot/minion/MinionAdminApiApplication.java index 6164b4cebd..71f1ee6320 100644 --- a/pinot-minion/src/main/java/org/apache/pinot/minion/MinionAdminApiApplication.java +++ b/pinot-minion/src/main/java/org/apache/pinot/minion/MinionAdminApiApplication.java @@ -48,11 +48,12 @@ public class MinionAdminApiApplication extends ResourceConfig { public static final String MINION_INSTANCE_ID = "minionInstanceId"; private HttpServer _httpServer; + private final boolean _useHttps; public MinionAdminApiApplication(String instanceId, PinotConfiguration minionConf) { packages(RESOURCE_PACKAGE); property(PINOT_CONFIGURATION, minionConf); - + _useHttps = Boolean.parseBoolean(minionConf.getProperty(CommonConstants.Minion.CONFIG_OF_SWAGGER_USE_HTTPS)); register(new AbstractBinder() { @Override protected void configure() { @@ -84,7 +85,11 @@ public class MinionAdminApiApplication extends ResourceConfig { beanConfig.setDescription("APIs for accessing Pinot Minion information"); beanConfig.setContact("https://github.com/apache/pinot"); beanConfig.setVersion("1.0"); - beanConfig.setSchemes(new String[]{CommonConstants.HTTP_PROTOCOL, CommonConstants.HTTPS_PROTOCOL}); + if (_useHttps) { + beanConfig.setSchemes(new String[]{CommonConstants.HTTPS_PROTOCOL}); + } else { + beanConfig.setSchemes(new String[]{CommonConstants.HTTP_PROTOCOL, CommonConstants.HTTPS_PROTOCOL}); + } beanConfig.setBasePath("/"); beanConfig.setResourcePackage(RESOURCE_PACKAGE); beanConfig.setScan(true); 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 a45ba47940..edcd944c0c 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,9 +43,6 @@ 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); @@ -101,23 +98,28 @@ public class AdminApiApplication extends ResourceConfig { // 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)) { + if (pinotConfiguration.getProperty(CommonConstants.Server.CONFIG_OF_SWAGGER_SERVER_ENABLED, + CommonConstants.Server.DEFAULT_SWAGGER_SERVER_ENABLED)) { LOGGER.info("Starting swagger for the Pinot server."); synchronized (PinotReflectionUtils.getReflectionLock()) { - setupSwagger(_httpServer); + setupSwagger(_httpServer, pinotConfiguration); } } _started = true; return true; } - private void setupSwagger(HttpServer httpServer) { + private void setupSwagger(HttpServer httpServer, PinotConfiguration pinotConfiguration) { BeanConfig beanConfig = new BeanConfig(); beanConfig.setTitle("Pinot Server API"); beanConfig.setDescription("APIs for accessing Pinot server information"); beanConfig.setContact("https://github.com/apache/pinot"); beanConfig.setVersion("1.0"); - beanConfig.setSchemes(new String[]{CommonConstants.HTTP_PROTOCOL, CommonConstants.HTTPS_PROTOCOL}); + if (Boolean.parseBoolean(pinotConfiguration.getProperty(CommonConstants.Server.CONFIG_OF_SWAGGER_USE_HTTPS))) { + beanConfig.setSchemes(new String[]{CommonConstants.HTTPS_PROTOCOL}); + } else { + beanConfig.setSchemes(new String[]{CommonConstants.HTTP_PROTOCOL, CommonConstants.HTTPS_PROTOCOL}); + } beanConfig.setBasePath("/"); beanConfig.setResourcePackage(RESOURCE_PACKAGE); beanConfig.setScan(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 eeb83a6349..0f197aebbd 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 @@ -200,6 +200,7 @@ public class CommonConstants { public static final long DEFAULT_BROKER_TIMEOUT_MS = 10_000L; public static final String CONFIG_OF_BROKER_ID = "pinot.broker.id"; public static final String CONFIG_OF_BROKER_HOSTNAME = "pinot.broker.hostname"; + public static final String CONFIG_OF_SWAGGER_USE_HTTPS = "pinot.broker.swagger.use.https"; // Configuration to consider the broker ServiceStatus as being STARTED if the percent of resources (tables) that // are ONLINE for this this broker has crossed the threshold percentage of the total number of tables // that it is expected to serve. @@ -319,6 +320,7 @@ public class CommonConstants { 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_SWAGGER_USE_HTTPS = "pinot.server.swagger.use.https"; public static final String CONFIG_OF_ADMIN_API_PORT = "pinot.server.adminapi.port"; public static final int DEFAULT_ADMIN_API_PORT = 8097; @@ -497,6 +499,7 @@ public class CommonConstants { public static final String METADATA_EVENT_OBSERVER_PREFIX = "metadata.event.notifier"; // Config keys + public static final String CONFIG_OF_SWAGGER_USE_HTTPS = "pinot.minion.swagger.use.https"; public static final String CONFIG_OF_METRICS_PREFIX_KEY = "pinot.minion.metrics.prefix"; @Deprecated public static final String DEPRECATED_CONFIG_OF_METRICS_PREFIX_KEY = "metricsPrefix"; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org