diff --git a/presto-native-execution/src/test/java/com/facebook/presto/spark/PrestoSparkNativeQueryRunnerUtils.java b/presto-native-execution/src/test/java/com/facebook/presto/spark/PrestoSparkNativeQueryRunnerUtils.java index 56c34b53f6602..c4e4757a66c9e 100644 --- a/presto-native-execution/src/test/java/com/facebook/presto/spark/PrestoSparkNativeQueryRunnerUtils.java +++ b/presto-native-execution/src/test/java/com/facebook/presto/spark/PrestoSparkNativeQueryRunnerUtils.java @@ -21,7 +21,6 @@ import com.facebook.presto.nativeworker.PrestoNativeQueryRunnerUtils; import com.facebook.presto.spark.classloader_interface.PrestoSparkNativeExecutionShuffleManager; import com.facebook.presto.spark.execution.NativeExecutionModule; -import com.facebook.presto.spark.execution.TestNativeExecutionModule; import com.facebook.presto.spi.security.PrincipalType; import com.facebook.presto.testing.QueryRunner; import com.google.common.collect.ImmutableList; @@ -102,7 +101,7 @@ public static PrestoSparkQueryRunner createPrestoSparkNativeQueryRunner() Optional.of(getBaseDataPath()), builder.build(), getNativeExecutionShuffleConfigs(), - getNativeExecutionModules()); + ImmutableList.of(new NativeExecutionModule())); setupJsonFunctionNamespaceManager(queryRunner); // Increases log level to reduce log spamming while running test. @@ -187,19 +186,6 @@ public static void setupJsonFunctionNamespaceManager(QueryRunner queryRunner) "json-based-function-manager.path-to-function-definition", "src/test/resources/external_functions.json")); } - public static ImmutableList getNativeExecutionModules() - { - ImmutableList.Builder moduleBuilder = ImmutableList.builder(); - if (System.getProperty("NATIVE_PORT") != null) { - moduleBuilder.add(new TestNativeExecutionModule()); - } - else { - moduleBuilder.add(new NativeExecutionModule()); - } - - return moduleBuilder.build(); - } - public static synchronized Path getBaseDataPath() { if (dataDirectory.isPresent()) { diff --git a/presto-spark-base/src/test/java/com/facebook/presto/spark/execution/DetachedNativeExecutionProcess.java b/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/DetachedNativeExecutionProcess.java similarity index 100% rename from presto-spark-base/src/test/java/com/facebook/presto/spark/execution/DetachedNativeExecutionProcess.java rename to presto-spark-base/src/main/java/com/facebook/presto/spark/execution/DetachedNativeExecutionProcess.java diff --git a/presto-spark-base/src/test/java/com/facebook/presto/spark/execution/DetachedNativeExecutionProcessFactory.java b/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/DetachedNativeExecutionProcessFactory.java similarity index 100% rename from presto-spark-base/src/test/java/com/facebook/presto/spark/execution/DetachedNativeExecutionProcessFactory.java rename to presto-spark-base/src/main/java/com/facebook/presto/spark/execution/DetachedNativeExecutionProcessFactory.java diff --git a/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/NativeExecutionModule.java b/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/NativeExecutionModule.java index 9c813d6a44e83..660a4f159dd51 100644 --- a/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/NativeExecutionModule.java +++ b/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/NativeExecutionModule.java @@ -44,6 +44,11 @@ public void configure(Binder binder) config.setMaxConnectionsPerServer(250); }); binder.bind(PrestoSparkWorkerProperty.class).in(Scopes.SINGLETON); - binder.bind(NativeExecutionProcessFactory.class).in(Scopes.SINGLETON); + if (System.getProperty("NATIVE_PORT") != null) { + binder.bind(NativeExecutionProcessFactory.class).to(DetachedNativeExecutionProcessFactory.class).in(Scopes.SINGLETON); + } + else { + binder.bind(NativeExecutionProcessFactory.class).in(Scopes.SINGLETON); + } } } diff --git a/presto-spark-base/src/test/java/com/facebook/presto/spark/execution/TestNativeExecutionModule.java b/presto-spark-base/src/test/java/com/facebook/presto/spark/execution/TestNativeExecutionModule.java deleted file mode 100644 index 2c61e30b30237..0000000000000 --- a/presto-spark-base/src/test/java/com/facebook/presto/spark/execution/TestNativeExecutionModule.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed 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 com.facebook.presto.spark.execution; - -import com.facebook.presto.spark.execution.property.PrestoSparkWorkerProperty; -import com.facebook.presto.spark.execution.property.WorkerProperty; -import com.facebook.presto.spark.execution.shuffle.PrestoSparkLocalShuffleInfoTranslator; -import com.facebook.presto.spark.execution.shuffle.PrestoSparkShuffleInfoTranslator; -import com.google.inject.Binder; -import com.google.inject.Module; -import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; -import io.airlift.units.Duration; - -import static com.facebook.airlift.http.client.HttpClientBinder.httpClientBinder; -import static com.google.inject.multibindings.OptionalBinder.newOptionalBinder; -import static java.util.concurrent.TimeUnit.SECONDS; - -public class TestNativeExecutionModule - implements Module -{ - @Override - public void configure(Binder binder) - { - binder.bind(PrestoSparkLocalShuffleInfoTranslator.class).in(Scopes.SINGLETON); - newOptionalBinder(binder, new TypeLiteral>() {}).setDefault().to(PrestoSparkWorkerProperty.class).in(Scopes.SINGLETON); - newOptionalBinder(binder, new TypeLiteral() {}).setDefault().to(PrestoSparkLocalShuffleInfoTranslator.class).in(Scopes.SINGLETON); - binder.bind(NativeExecutionTaskFactory.class).in(Scopes.SINGLETON); - httpClientBinder(binder) - .bindHttpClient("nativeExecution", ForNativeExecutionTask.class) - .withConfigDefaults(config -> { - config.setRequestTimeout(new Duration(10, SECONDS)); - config.setMaxConnectionsPerServer(250); - }); - binder.bind(PrestoSparkWorkerProperty.class).in(Scopes.SINGLETON); - binder.bind(NativeExecutionProcessFactory.class).to(DetachedNativeExecutionProcessFactory.class).in(Scopes.SINGLETON); - } -}