Skip to content
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 @@ -45,13 +45,15 @@ 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;

public BrokerAdminApiApplication(BrokerRoutingManager routingManager, BrokerRequestHandler brokerRequestHandler,
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);
}
Expand Down Expand Up @@ -89,7 +91,11 @@ private void setupSwagger() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -58,7 +59,8 @@ public ControllerAdminApiApplication(ControllerConf conf) {
_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);
}
Expand Down Expand Up @@ -109,7 +111,11 @@ private void setupSwagger(HttpServer httpServer) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -84,7 +85,11 @@ private void setupSwagger() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
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);
Expand Down Expand Up @@ -101,23 +98,28 @@ public boolean start(List<ListenerConfig> listenerConfigs) {
// 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public static class Broker {
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.
Expand Down Expand Up @@ -317,6 +318,7 @@ public static class Server {
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;

Expand Down Expand Up @@ -495,6 +497,7 @@ public static class Minion {
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";
Expand Down