Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow hiding pinot broker swagger UI by config #9343

Merged
merged 2 commits into from
Sep 8, 2022
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 @@ -46,14 +46,18 @@
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class BrokerAdminApiApplication extends ResourceConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(BrokerAdminApiApplication.class);
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 final boolean _swaggerBrokerEnabled;

private HttpServer _httpServer;

Expand All @@ -62,6 +66,8 @@ public BrokerAdminApiApplication(BrokerRoutingManager routingManager, BrokerRequ
packages(RESOURCE_PACKAGE);
property(PINOT_CONFIGURATION, brokerConf);
_useHttps = Boolean.parseBoolean(brokerConf.getProperty(CommonConstants.Broker.CONFIG_OF_SWAGGER_USE_HTTPS));
_swaggerBrokerEnabled = brokerConf.getProperty(CommonConstants.Broker.CONFIG_OF_SWAGGER_BROKER_ENABLED,
CommonConstants.Broker.DEFAULT_SWAGGER_BROKER_ENABLED);
if (brokerConf.getProperty(CommonConstants.Broker.BROKER_SERVICE_AUTO_DISCOVERY, false)) {
register(ServiceAutoDiscoveryFeature.class);
}
Expand Down Expand Up @@ -100,7 +106,12 @@ public void start(List<ListenerConfig> listenerConfigs) {
} catch (IOException e) {
throw new RuntimeException("Failed to start http server", e);
}
PinotReflectionUtils.runWithLock(this::setupSwagger);

if (_swaggerBrokerEnabled) {
PinotReflectionUtils.runWithLock(this::setupSwagger);
} else {
LOGGER.info("Hiding Swagger UI for Broker, by {}", CommonConstants.Broker.CONFIG_OF_SWAGGER_BROKER_ENABLED);
}
}

private void setupSwagger() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ public static class Broker {
public static final boolean DEFAULT_BROKER_REQUEST_CLIENT_IP_LOGGING = false;

public static final String CONFIG_OF_LOGGER_ROOT_DIR = "pinot.broker.logger.root.dir";
public static final String CONFIG_OF_SWAGGER_BROKER_ENABLED = "pinot.broker.swagger.enabled";
public static final boolean DEFAULT_SWAGGER_BROKER_ENABLED = true;

public static class Request {
public static final String SQL = "sql";
Expand Down