Permalink
Browse files

Properly respect the enableAvatica and enableJsonOverHttp options. (#…

  • Loading branch information...
1 parent d80bec8 commit 76620615a1af511d83ed9898dc22c781abbde72d @gianm gianm committed with himanshug Jan 11, 2017
@@ -92,7 +92,7 @@ The broker's [built-in SQL server](../querying/sql.html) can be configured throu
|Property|Description|Default|
|--------|-----------|-------|
|`druid.sql.enable`|Whether to enable SQL at all, including background metadata fetching. If false, this overrides all other SQL-related properties and disables SQL metadata, serving, and planning completely.|false|
-|`druid.sql.server.enableAvatica`|Whether to enable an Avatica server at `/druid/v2/sql/avatica/`.|false|
+|`druid.sql.server.enableAvatica`|Whether to enable an Avatica server at `/druid/v2/sql/avatica/`.|true|
|`druid.sql.server.enableJsonOverHttp`|Whether to enable a simple JSON over HTTP route at `/druid/v2/sql/`.|true|
#### SQL Planner Configuration
@@ -40,22 +40,18 @@
{
static final String AVATICA_PATH = "/druid/v2/sql/avatica/";
- private final ServerConfig config;
-
@Inject
public DruidAvaticaHandler(
final CalciteConnection connection,
@Self final DruidNode druidNode,
- final AvaticaMonitor avaticaMonitor,
- final ServerConfig config
+ final AvaticaMonitor avaticaMonitor
) throws InstantiationException, IllegalAccessException, InvocationTargetException
{
super(
new LocalService((Meta) CalciteMetaImpl.class.getConstructors()[0].newInstance(connection), avaticaMonitor),
avaticaMonitor
);
- this.config = config;
setServerRpcMetadata(new Service.RpcMetadataResponse(druidNode.getHostAndPort()));
}
@@ -70,7 +66,7 @@ public void handle(
// This is not integrated with the experimental authorization framework.
// (Non-trivial since we don't know the dataSources up-front)
- if (config.isEnableAvatica() && request.getRequestURI().equals(AVATICA_PATH)) {
+ if (request.getRequestURI().equals(AVATICA_PATH)) {
super.handle(target, baseRequest, request, response);
}
}
@@ -1,41 +0,0 @@
-/*
- * Licensed to Metamarkets Group Inc. (Metamarkets) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Metamarkets licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package io.druid.sql.avatica;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ServerConfig
-{
- @JsonProperty
- private boolean enableAvatica = false;
-
- @JsonProperty
- private boolean enableJsonOverHttp = true;
-
- public boolean isEnableAvatica()
- {
- return enableAvatica;
- }
-
- public boolean isEnableJsonOverHttp()
- {
- return enableJsonOverHttp;
- }
-}
@@ -32,7 +32,6 @@
import io.druid.server.metrics.MetricsModule;
import io.druid.sql.avatica.AvaticaMonitor;
import io.druid.sql.avatica.DruidAvaticaHandler;
-import io.druid.sql.avatica.ServerConfig;
import io.druid.sql.calcite.DruidSchema;
import io.druid.sql.calcite.planner.Calcites;
import io.druid.sql.calcite.planner.PlannerConfig;
@@ -45,6 +44,8 @@
public class SqlModule implements Module
{
private static final String PROPERTY_SQL_ENABLE = "druid.sql.enable";
+ private static final String PROPERTY_SQL_ENABLE_JSON_OVER_HTTP = "druid.sql.server.enableJsonOverHttp";
+ private static final String PROPERTY_SQL_ENABLE_AVATICA = "druid.sql.server.enableAvatica";
@Inject
private Properties props;
@@ -57,13 +58,18 @@ public SqlModule()
public void configure(Binder binder)
{
if (isEnabled()) {
- JsonConfigProvider.bind(binder, "druid.sql.server", ServerConfig.class);
JsonConfigProvider.bind(binder, "druid.sql.planner", PlannerConfig.class);
- Jerseys.addResource(binder, SqlResource.class);
- binder.bind(AvaticaMonitor.class).in(LazySingleton.class);
- JettyBindings.addHandler(binder, DruidAvaticaHandler.class);
- MetricsModule.register(binder, AvaticaMonitor.class);
LifecycleModule.register(binder, DruidSchema.class);
+
+ if (isJsonOverHttpEnabled()) {
+ Jerseys.addResource(binder, SqlResource.class);
+ }
+
+ if (isAvaticaEnabled()) {
+ binder.bind(AvaticaMonitor.class).in(LazySingleton.class);
+ JettyBindings.addHandler(binder, DruidAvaticaHandler.class);
+ MetricsModule.register(binder, AvaticaMonitor.class);
+ }
}
}
@@ -85,4 +91,16 @@ private boolean isEnabled()
Preconditions.checkNotNull(props, "props");
return Boolean.valueOf(props.getProperty(PROPERTY_SQL_ENABLE, "false"));
}
+
+ private boolean isJsonOverHttpEnabled()
+ {
+ Preconditions.checkNotNull(props, "props");
+ return Boolean.valueOf(props.getProperty(PROPERTY_SQL_ENABLE_JSON_OVER_HTTP, "true"));
+ }
+
+ private boolean isAvaticaEnabled()
+ {
+ Preconditions.checkNotNull(props, "props");
+ return Boolean.valueOf(props.getProperty(PROPERTY_SQL_ENABLE_AVATICA, "true"));
+ }
}
@@ -74,19 +74,10 @@ public void setUp() throws Exception
),
plannerConfig
);
- final ServerConfig serverConfig = new ServerConfig()
- {
- @Override
- public boolean isEnableAvatica()
- {
- return true;
- }
- };
final DruidAvaticaHandler handler = new DruidAvaticaHandler(
serverConnection,
new DruidNode("dummy", "dummy", 1),
- new AvaticaMonitor(),
- serverConfig
+ new AvaticaMonitor()
);
final int port = new Random().nextInt(9999) + 10000;
server = new Server(new InetSocketAddress("127.0.0.1", port));

0 comments on commit 7662061

Please sign in to comment.