From e2986ae6120399e7282a89f9b00666e36367a881 Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Thu, 16 May 2024 12:49:10 +0000 Subject: [PATCH] cleanup --- .../org/apache/druid/quidem/Launcher.java | 49 +++++-- .../druid/guice/http/HttpClientModule.java | 2 +- .../apache/druid/server/StatusResource.java | 5 +- .../calcite/util/CacheTestHelperModule2.java | 121 ------------------ 4 files changed, 40 insertions(+), 137 deletions(-) delete mode 100644 server/src/test/java/org/apache/druid/sql/calcite/util/CacheTestHelperModule2.java diff --git a/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java b/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java index 830f9b919f1..cefff102948 100644 --- a/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java +++ b/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java @@ -90,6 +90,7 @@ import org.apache.druid.server.QueryLifecycleFactory; import org.apache.druid.server.QueryScheduler; import org.apache.druid.server.QuerySchedulerProvider; import org.apache.druid.server.SpecificSegmentsQuerySegmentWalker; +import org.apache.druid.server.initialization.AuthorizerMapperModule; import org.apache.druid.server.initialization.ExternalStorageAccessSecurityModule; import org.apache.druid.server.initialization.jetty.JettyServerModule; import org.apache.druid.server.log.RequestLogger; @@ -607,7 +608,7 @@ public class Launcher binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0); binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1); binder.bind(AuthenticatorMapper.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_MAPPER); - binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER); +// binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER); binder.bind(Escalator.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_ESCALATOR); binder.bind(RequestLogger.class).toInstance(testRequestLogger); binder.bind(String.class) @@ -663,7 +664,7 @@ public class Launcher // new AuthenticatorMapperModule(), // new EscalatorModule(), new AuthorizerModule(), -// new AuthorizerMapperModule(), + new AuthorizerMapperModule(), new StartupLoggingModule(), new ExternalStorageAccessSecurityModule(), new ServiceClientModule(), @@ -750,17 +751,9 @@ public class Launcher if(true) { Lifecycle lifecycle = GuiceRunnable.initLifecycle(framework.injector(), log); - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create("http://localhost:12345/druid/v2/sql")) - .header("Content-Type", "application/json") - .POST(BodyPublishers.ofString("{\"query\":\"Select * from foo\"}")) - .build(); - System.out.println(request); -// request. - HttpClient hc = HttpClient.newHttpClient(); - HttpResponse a = hc.send(request, HttpResponse.BodyHandlers.ofString()); - System.out.println(a); - assertNotEquals(400, a.statusCode()); + chk1(); + chkStatus(); + lifecycle.stop(); }else { @@ -789,5 +782,35 @@ public class Launcher } + private static void chk1() throws IOException, InterruptedException + { + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("http://localhost:12345/druid/v2/sql")) + .header("Content-Type", "application/json") + .POST(BodyPublishers.ofString("{\"query\":\"Select * from foo\"}")) + .build(); + System.out.println(request); +// request. + HttpClient hc = HttpClient.newHttpClient(); + HttpResponse a = hc.send(request, HttpResponse.BodyHandlers.ofString()); + System.out.println(a); + assertNotEquals(400, a.statusCode()); + } + private static void chkStatus() throws IOException, InterruptedException + { + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("http://localhost:12345/status")) + .header("Content-Type", "application/json") + .GET() + .build(); + System.out.println(request); +// request. + HttpClient hc = HttpClient.newHttpClient(); + HttpResponse a = hc.send(request, HttpResponse.BodyHandlers.ofString()); + System.out.println(a); + assertNotEquals(400, a.statusCode()); + + } + } diff --git a/server/src/main/java/org/apache/druid/guice/http/HttpClientModule.java b/server/src/main/java/org/apache/druid/guice/http/HttpClientModule.java index 7c6b4e99d36..2aaf30a469f 100644 --- a/server/src/main/java/org/apache/druid/guice/http/HttpClientModule.java +++ b/server/src/main/java/org/apache/druid/guice/http/HttpClientModule.java @@ -120,7 +120,7 @@ public class HttpClientModule implements Module final Binding sslContextBinding = getSslContextBinding(); if (sslContextBinding != null) { -// builder.withSslContext(sslContextBinding.getProvider().get()); + builder.withSslContext(sslContextBinding.getProvider().get()); } HttpClient client = HttpClientInit.createClient( diff --git a/server/src/main/java/org/apache/druid/server/StatusResource.java b/server/src/main/java/org/apache/druid/server/StatusResource.java index f1680f7503e..cf0ed113c47 100644 --- a/server/src/main/java/org/apache/druid/server/StatusResource.java +++ b/server/src/main/java/org/apache/druid/server/StatusResource.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.Maps; import com.sun.jersey.spi.container.ResourceFilters; import org.apache.druid.client.DruidServerConfig; +import org.apache.druid.common.guava.GuavaUtils; import org.apache.druid.guice.ExtensionsLoader; import org.apache.druid.initialization.DruidModule; import org.apache.druid.java.util.common.StringUtils; @@ -137,14 +138,14 @@ public class StatusResource public Status(Collection modules) { - this.version = "30.0.0-asd1";//getDruidVersion(); + this.version = getDruidVersion(); this.modules = getExtensionVersions(modules); this.memory = new Memory(JvmUtils.getRuntimeInfo()); } private String getDruidVersion() { - return Status.class.getPackage().getImplementationVersion(); + return GuavaUtils.firstNonNull(Status.class.getPackage().getImplementationVersion(), "unknown"); } @JsonProperty diff --git a/server/src/test/java/org/apache/druid/sql/calcite/util/CacheTestHelperModule2.java b/server/src/test/java/org/apache/druid/sql/calcite/util/CacheTestHelperModule2.java deleted file mode 100644 index 0b47e63a6c8..00000000000 --- a/server/src/test/java/org/apache/druid/sql/calcite/util/CacheTestHelperModule2.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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 org.apache.druid.sql.calcite.util; - -import com.google.inject.AbstractModule; -import com.google.inject.Module; -import com.google.inject.Provides; -import org.apache.druid.client.cache.Cache; -import org.apache.druid.client.cache.CacheConfig; -import org.apache.druid.client.cache.MapCache; -import org.apache.druid.server.EtagProvider; - -public class CacheTestHelperModule2 extends AbstractModule -{ - - public enum ResultCacheMode - { - DISABLED, - ENABLED; - - public Module makeModule() - { - return new CacheTestHelperModule2(this); - } - - public boolean isPopulateResultLevelCache() - { - return this != DISABLED; - } - - public boolean isUseResultLevelCache() - { - return this != DISABLED; - } - } - - protected final Cache cache; - private CacheConfig cacheConfig; - private EtagProvider etagProvider; - - static class TestCacheConfig extends CacheConfig - { - private ResultCacheMode resultLevelCache; - - public TestCacheConfig(ResultCacheMode resultCacheMode) - { - this.resultLevelCache = resultCacheMode; - } - - @Override - public boolean isPopulateResultLevelCache() - { - return resultLevelCache.isPopulateResultLevelCache(); - } - - @Override - public boolean isUseResultLevelCache() - { - return resultLevelCache.isUseResultLevelCache(); - } - - } - - public CacheTestHelperModule2(ResultCacheMode resultCacheMode) - { - cacheConfig = new TestCacheConfig(resultCacheMode); - - switch (resultCacheMode) { - case ENABLED: - etagProvider = new EtagProvider.ProvideEtagBasedOnDatasource(); - cache = MapCache.create(1_000_000L); - break; - case DISABLED: - etagProvider = new EtagProvider.EmptyEtagProvider(); - cache = null; - break; - default: - throw new RuntimeException(); - } - } - - @Provides - EtagProvider etagProvider() - { - return etagProvider; - } - - @Provides - CacheConfig getCacheConfig() - { - return cacheConfig; - } - - @Provides - Cache getCache() - { - return cache; - } - - @Override - public void configure() - { - } -}