diff --git a/docs/src/main/sphinx/connector/phoenix.md b/docs/src/main/sphinx/connector/phoenix.md index af26ce92644e..bd355e6458e4 100644 --- a/docs/src/main/sphinx/connector/phoenix.md +++ b/docs/src/main/sphinx/connector/phoenix.md @@ -20,7 +20,7 @@ To query HBase data through Phoenix, you need: - Network access from the Trino coordinator and workers to the ZooKeeper servers. The default port is 2181. -- A compatible version of Phoenix: all 5.x versions starting from 5.1.0 are supported. +- A compatible version of Phoenix: all 5.x versions starting from 5.2.0 are supported. ## Configuration diff --git a/lib/trino-phoenix5-patched/pom.xml b/lib/trino-phoenix5-patched/pom.xml deleted file mode 100644 index 842320ab6ce3..000000000000 --- a/lib/trino-phoenix5-patched/pom.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - 4.0.0 - - - io.trino - trino-root - 447-SNAPSHOT - ../../pom.xml - - - trino-phoenix5-patched - Trino - patched Phoenix5 client to work with JDK17 - - - ${project.parent.basedir} - - - - - org.apache.phoenix - phoenix-client-embedded-hbase-2.2 - 5.1.3 - - - - io.airlift - junit-extensions - test - - - - org.junit.jupiter - junit-jupiter-api - test - - - - - - - org.apache.maven.plugins - maven-shade-plugin - - - - shade - - package - - false - false - false - - - org.apache.zookeeper - org.apache.phoenix.shaded.org.apache.zookeeper - - - - - org.apache.phoenix:phoenix-client-embedded-hbase-2.2 - - org/apache/phoenix/shaded/org/apache/zookeeper/client/StaticHostProvider.class - org/apache/phoenix/shaded/org/apache/zookeeper/client/StaticHostProvider$*.class - - javax/xml/bind/** - META-INF/services/javax.xml.bind.JAXBContext - org/apache/phoenix/shaded/com/sun/xml/bind/** - - - - - - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - - org.apache.phoenix - phoenix-client-embedded-hbase-2.2 - - - - - - - diff --git a/lib/trino-phoenix5-patched/src/main/java/org/apache/phoenix/shaded/org/apache/zookeeper/client/StaticHostProvider.java b/lib/trino-phoenix5-patched/src/main/java/org/apache/phoenix/shaded/org/apache/zookeeper/client/StaticHostProvider.java deleted file mode 100644 index 3b475118fa30..000000000000 --- a/lib/trino-phoenix5-patched/src/main/java/org/apache/phoenix/shaded/org/apache/zookeeper/client/StaticHostProvider.java +++ /dev/null @@ -1,165 +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 org.apache.phoenix.shaded.org.apache.zookeeper.client; - -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -// TODO(https://github.com/trinodb/trino/issues/13051): Remove when Phoenix 5.2 is release -public final class StaticHostProvider - implements HostProvider -{ - public interface Resolver - { - InetAddress[] getAllByName(String name) - throws UnknownHostException; - } - - private final List serverAddresses = new ArrayList(5); - private final Resolver resolver; - - private int lastIndex = -1; - private int currentIndex = -1; - - /** - * Constructs a SimpleHostSet. - * - * @param serverAddresses - * possibly unresolved ZooKeeper server addresses - * @throws IllegalArgumentException - * if serverAddresses is empty or resolves to an empty list - */ - public StaticHostProvider(Collection serverAddresses) - { - this.resolver = InetAddress::getAllByName; - init(serverAddresses); - } - - /** - * Introduced for testing purposes. getAllByName() is a static method of InetAddress, therefore cannot be easily mocked. - * By abstraction of Resolver interface we can easily inject a mocked implementation in tests. - * - * @param serverAddresses - * possibly unresolved ZooKeeper server addresses - * @param resolver - * custom resolver implementation - * @throws IllegalArgumentException - * if serverAddresses is empty or resolves to an empty list - */ - public StaticHostProvider(Collection serverAddresses, Resolver resolver) - { - this.resolver = resolver; - init(serverAddresses); - } - - /** - * Common init method for all constructors. - * Resolve all unresolved server addresses, put them in a list and shuffle. - */ - private void init(Collection serverAddresses) - { - if (serverAddresses.isEmpty()) { - throw new IllegalArgumentException( - "A HostProvider may not be empty!"); - } - - this.serverAddresses.addAll(serverAddresses); - Collections.shuffle(this.serverAddresses); - } - - /** - * Evaluate to a hostname if one is available and otherwise it returns the - * string representation of the IP address. - * - * In Java 7, we have a method getHostString, but earlier versions do not support it. - * This method is to provide a replacement for InetSocketAddress.getHostString(). - * - * @return Hostname string of address parameter - */ - private String getHostString(InetSocketAddress addr) - { - String hostString = ""; - - if (addr == null) { - return hostString; - } - if (!addr.isUnresolved()) { - InetAddress ia = addr.getAddress(); - - // If the string starts with '/', then it has no hostname - // and we want to avoid the reverse lookup, so we return - // the string representation of the address. - if (ia.toString().startsWith("/")) { - hostString = ia.getHostAddress(); - } - else { - hostString = addr.getHostName(); - } - } - else { - hostString = addr.getHostString(); - } - - return hostString; - } - - @Override - public int size() - { - return serverAddresses.size(); - } - - @Override - public InetSocketAddress next(long spinDelay) - { - currentIndex = ++currentIndex % serverAddresses.size(); - if (currentIndex == lastIndex && spinDelay > 0) { - try { - Thread.sleep(spinDelay); - } - catch (InterruptedException e) { - } - } - else if (lastIndex == -1) { - // We don't want to sleep on the first ever connect attempt. - lastIndex = 0; - } - - InetSocketAddress curAddr = serverAddresses.get(currentIndex); - try { - String curHostString = getHostString(curAddr); - List resolvedAddresses = new ArrayList(Arrays.asList(this.resolver.getAllByName(curHostString))); - if (resolvedAddresses.isEmpty()) { - return curAddr; - } - Collections.shuffle(resolvedAddresses); - return new InetSocketAddress(resolvedAddresses.get(0), curAddr.getPort()); - } - catch (UnknownHostException e) { - return curAddr; - } - } - - @Override - public void onConnected() - { - lastIndex = currentIndex; - } -} diff --git a/lib/trino-phoenix5-patched/src/test/java/org/apache/phoenix/TestDummy.java b/lib/trino-phoenix5-patched/src/test/java/org/apache/phoenix/TestDummy.java deleted file mode 100644 index 5a6de3fbedc3..000000000000 --- a/lib/trino-phoenix5-patched/src/test/java/org/apache/phoenix/TestDummy.java +++ /dev/null @@ -1,22 +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 org.apache.phoenix; - -import org.junit.jupiter.api.Test; - -public class TestDummy -{ - @Test - public void buildRequiresTestToExist() {} -} diff --git a/plugin/trino-phoenix5/pom.xml b/plugin/trino-phoenix5/pom.xml index 4c9c83e10798..42292248e0fb 100644 --- a/plugin/trino-phoenix5/pom.xml +++ b/plugin/trino-phoenix5/pom.xml @@ -15,7 +15,8 @@ ${project.parent.basedir} - 2.2.7 + 2.5.8-hadoop3 + 5.2.0 ${air.test.jvm.additional-arguments.default} --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED @@ -57,23 +58,17 @@ trino-base-jdbc - io.trino - trino-phoenix5-patched + trino-plugin-toolkit - org.apache.phoenix - * + org.slf4j + slf4j-api - - io.trino - trino-plugin-toolkit - - jakarta.annotation jakarta.annotation-api @@ -89,6 +84,12 @@ joda-time + + org.apache.phoenix + phoenix-client-embedded-hbase-2.5.0 + ${dep.phoenix5.version} + + org.weakref jmxutils @@ -130,16 +131,6 @@ provided - - - - ch.qos.reload4j - reload4j - 1.2.25 - runtime - - com.fasterxml.jackson.core jackson-databind @@ -162,10 +153,6 @@ org.slf4j jcl-over-slf4j - - org.slf4j - log4j-over-slf4j - org.slf4j slf4j-api @@ -252,17 +239,10 @@ - org.apache.hadoop - hadoop-hdfs - 3.1.4 - test-jar + javax.servlet + javax.servlet-api + 4.0.1 test - - - * - * - - @@ -340,14 +320,6 @@ zookeeper test - - com.github.spotbugs - spotbugs-annotations - - - org.apache.yetus - audience-annotations - org.slf4j slf4j-api @@ -386,47 +358,25 @@ org.basepom.maven duplicate-finder-maven-plugin - + mrapp-generated-classpath - - assets/org/apache/commons/math3/exception/util/LocalizedFormats_fr.properties - - tables/.*\.bin - jetty-dir.css - - - com.clearspring.analytics - stream - - + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + + + + javax.servlet:javax.servlet-api + + + - - - - - lib/tools.jar - - - idea.maven.embedder.version - - - - - org.apache.phoenix - phoenix-client-embedded-hbase-2.2 - 5.1.3 - provided - true - - - - diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java index 0f7b55cffc22..068447e6e0a1 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java @@ -209,7 +209,7 @@ import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toSet; import static org.apache.hadoop.hbase.HConstants.FOREVER; -import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.SKIP_REGION_BOUNDARY_CHECK; +import static org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants.SKIP_REGION_BOUNDARY_CHECK; import static org.apache.phoenix.util.PhoenixRuntime.getTable; import static org.apache.phoenix.util.SchemaUtil.ESCAPE_CHARACTER; import static org.apache.phoenix.util.SchemaUtil.getEscapedArgument; diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java index 2164885a16af..6639b6f87899 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClientModule.java @@ -62,8 +62,8 @@ import io.trino.spi.connector.ConnectorSplitManager; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; +import org.apache.phoenix.jdbc.ConnectionInfo; import org.apache.phoenix.jdbc.PhoenixDriver; -import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver; import java.sql.SQLException; import java.util.Map; @@ -82,6 +82,7 @@ import static io.trino.plugin.phoenix5.PhoenixClient.DEFAULT_DOMAIN_COMPACTION_THRESHOLD; import static io.trino.plugin.phoenix5.PhoenixErrorCode.PHOENIX_CONFIG_ERROR; import static java.util.Objects.requireNonNull; +import static org.apache.phoenix.util.ReadOnlyProps.EMPTY_PROPS; import static org.weakref.jmx.guice.ExportBinder.newExporter; public class PhoenixClientModule @@ -195,7 +196,7 @@ public static Properties getConnectionProperties(PhoenixConfig config) connectionProperties.setProperty(entry.getKey(), entry.getValue()); } - PhoenixEmbeddedDriver.ConnectionInfo connectionInfo = PhoenixEmbeddedDriver.ConnectionInfo.create(config.getConnectionUrl()); + ConnectionInfo connectionInfo = ConnectionInfo.create(config.getConnectionUrl(), EMPTY_PROPS, new Properties()); connectionInfo.asProps().asMap().forEach(connectionProperties::setProperty); return connectionProperties; } diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixSplitManager.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixSplitManager.java index c4049636b315..a4f45eea650b 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixSplitManager.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixSplitManager.java @@ -53,7 +53,7 @@ import static io.trino.plugin.phoenix5.PhoenixErrorCode.PHOENIX_SPLIT_ERROR; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toList; -import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.EXPECTED_UPPER_REGION_KEY; +import static org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants.EXPECTED_UPPER_REGION_KEY; public class PhoenixSplitManager implements ConnectorSplitManager diff --git a/pom.xml b/pom.xml index 4cd51fca617a..8d8558fe3fbd 100644 --- a/pom.xml +++ b/pom.xml @@ -54,8 +54,6 @@ lib/trino-memory-context lib/trino-orc lib/trino-parquet - - lib/trino-phoenix5-patched lib/trino-plugin-toolkit lib/trino-record-decoder plugin/trino-accumulo @@ -188,7 +186,7 @@ 1.12.715 4.17.0 7.5.1 - 93 + 94 1.21 2.27.1 10.12.0 @@ -1286,13 +1284,6 @@ ${project.version} - - - io.trino - trino-phoenix5-patched - ${project.version} - - io.trino trino-pinot diff --git a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/environment/EnvMultinodePhoenix5.java b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/environment/EnvMultinodePhoenix5.java index 00b4cd4566b3..55db61282c00 100644 --- a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/environment/EnvMultinodePhoenix5.java +++ b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/environment/EnvMultinodePhoenix5.java @@ -24,10 +24,10 @@ import io.trino.tests.product.launcher.env.common.TestsEnvironment; import io.trino.tests.product.launcher.testcontainers.PortBinder; import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy; +import org.testcontainers.containers.wait.strategy.ShellStrategy; import java.time.Duration; -import static io.trino.tests.product.launcher.docker.ContainerUtil.forSelectedPorts; import static io.trino.tests.product.launcher.env.EnvironmentContainers.configureTempto; import static io.trino.tests.product.launcher.env.EnvironmentContainers.isTrinoContainer; import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TRINO_ETC; @@ -57,7 +57,9 @@ public void extendEnvironment(Environment.Builder builder) String dockerImageName = "ghcr.io/trinodb/testing/phoenix5:" + TestingProperties.getDockerImagesVersion(); DockerContainer phoenix = new DockerContainer(dockerImageName, "phoenix") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) - .waitingFor(forSelectedPorts(ZOOKEEPER_PORT)) + .waitingFor(new ShellStrategy() + .withCommand("grep -q 'All Rolling-Upgrade tasks are complete' /usr/local/lib/hbase/logs/*.log") + .withStartupTimeout(Duration.ofMinutes(5))) .withStartupTimeout(Duration.ofMinutes(5)); portBinder.exposePort(phoenix, ZOOKEEPER_PORT); diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/phoenix/TestPhoenix.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/phoenix/TestPhoenix.java index 3d2ca3b1884d..270149f16755 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/phoenix/TestPhoenix.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/phoenix/TestPhoenix.java @@ -17,6 +17,8 @@ import io.trino.tempto.query.QueryResult; import org.testng.annotations.Test; +import java.util.UUID; + import static io.trino.tempto.assertions.QueryAssert.Row.row; import static io.trino.tests.product.TestGroups.PHOENIX; import static io.trino.tests.product.TestGroups.PROFILE_SPECIFIC_TESTS; @@ -26,17 +28,19 @@ public class TestPhoenix extends ProductTest { - @Test(groups = {PHOENIX, PROFILE_SPECIFIC_TESTS}) + // TODO: https://github.com/trinodb/trino/issues/21824 + @Test(groups = {PHOENIX, PROFILE_SPECIFIC_TESTS}, timeOut = 30_000L, enabled = false) public void testCreateTableAsSelect() { - QueryResult result = onTrino().executeQuery("CREATE TABLE nation AS SELECT * FROM tpch.tiny.nation"); + String tableName = "nation_" + UUID.randomUUID().toString().replace("-", ""); + QueryResult result = onTrino().executeQuery("CREATE TABLE %s AS SELECT * FROM tpch.tiny.nation".formatted(tableName)); try { assertThat(result).updatedRowsCountIsEqualTo(25); - assertThat(onTrino().executeQuery("SELECT COUNT(*) FROM nation")) + assertThat(onTrino().executeQuery("SELECT COUNT(*) FROM " + tableName)) .containsOnly(row(25)); } finally { - onTrino().executeQuery("DROP TABLE nation"); + onTrino().executeQuery("DROP TABLE " + tableName); } } }