[
https://issues.apache.org/jira/browse/DRILL-8279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17579670#comment-17579670
]
ASF GitHub Bot commented on DRILL-8279:
---------------------------------------
jnturton commented on code in PR #2622:
URL: https://github.com/apache/drill/pull/2622#discussion_r945557835
##########
contrib/storage-phoenix/README.md:
##########
@@ -83,11 +83,11 @@ Tips :
Configurations :
1. Enable [Drill User
Impersonation](https://drill.apache.org/docs/configuring-user-impersonation/)
2. Enable [PQS
Impersonation](https://phoenix.apache.org/server.html#Impersonation)
-3. PQS URL:
- 1. Provide `host` and `port` and Drill will generate the PQS URL with a doAs
parameter of current session user
- 2. Provide the `jdbcURL` with a `doAs` url param and `$user` placeholder as
a value, for instance:
- `jdbc:phoenix:thin:url=http://localhost:8765?doAs=$user`. In case Drill
Impersonation is enabled, but `doAs=$user`
- is missing the User Exception is thrown.
+3. Phoenix URL:
+ 1. Provide `zkQUorum` and `port` and Drill will create a connection to
Phoenix with a doAs of current
Review Comment:
```suggestion
1. Provide `zkQuorum` and `port` and Drill will create a connection to
Phoenix with a doAs of current
```
##########
contrib/storage-phoenix/pom.xml:
##########
@@ -353,6 +381,9 @@
<profiles>
<profile>
<id>hadoop-2</id>
+ <properties>
+ <phoenix.skip.tests>true</phoenix.skip.tests>
Review Comment:
Is the Phoenix thick driver only compatible with Hadoop 3?
##########
contrib/storage-phoenix/src/main/java/org/apache/drill/exec/store/phoenix/PhoenixDataSource.java:
##########
@@ -18,40 +18,42 @@
package org.apache.drill.exec.store.phoenix;
import java.io.PrintWriter;
+import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Map;
+import java.util.Optional;
import java.util.Properties;
+import java.util.function.Supplier;
import java.util.logging.Logger;
import javax.sql.DataSource;
-import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.common.exceptions.DrillRuntimeException;
+import org.apache.drill.common.util.function.CheckedSupplier;
+import org.apache.drill.exec.util.ImpersonationUtil;
import org.apache.drill.shaded.guava.com.google.common.base.Preconditions;
+import org.apache.hadoop.security.UserGroupInformation;
import org.slf4j.LoggerFactory;
/**
* Phoenix’s Connection objects are different from most other JDBC Connections
* due to the underlying HBase connection. The Phoenix Connection object
* is designed to be a thin object that is inexpensive to create.
- *
+ * <p>
* If Phoenix Connections are reused, it is possible that the underlying HBase
connection
* is not always left in a healthy state by the previous user. It is better to
* create new Phoenix Connections to ensure that you avoid any potential
issues.
Review Comment:
Reviewer's note: I checked the Phoenix FAQ and believe that these comments
remain true of the thick driver.
##########
contrib/storage-phoenix/src/main/java/org/apache/drill/exec/store/phoenix/PhoenixDataSource.java:
##########
@@ -138,30 +137,37 @@ public boolean isWrapperFor(Class<?> iface) {
@Override
public Connection getConnection() throws SQLException {
- useDriverClass();
+ loadDriverClass();
return getConnection(this.user, null);
}
@Override
public Connection getConnection(String userName, String password) throws
SQLException {
- useDriverClass();
+ loadDriverClass();
logger.debug("Drill/Phoenix connection url: {}", url);
- return DriverManager.getConnection(url, useConfProperties());
+ CheckedSupplier<Connection, SQLException> action =
+ () -> DriverManager.getConnection(url, useConfProperties());
+ if (impersonationEnabled) {
+ return doAsRemoteUser(userName, action);
+ }
+ return action.getAndThrow();
+ }
+
+ private <T> T doAsRemoteUser(String remoteUserName, final Supplier<T>
action) {
+ try {
+ UserGroupInformation proxyUser =
ImpersonationUtil.createProxyUgi(remoteUserName);
+ return proxyUser.doAs((PrivilegedExceptionAction<T>) action::get);
+ } catch (Exception e) {
+ throw new DrillRuntimeException(e);
+ }
}
/**
- * The thin-client is lightweight and better compatibility.
- * Only thin-client is currently supported.
- *
- * @throws SQLException
+ * Only thick-client is currently supported doe to shaded Avatica issues
with thin client.
Review Comment:
```suggestion
* Only thick-client is currently supported due to a shaded Avatica
conflict created by the thin client.
```
> Use thick Phoenix driver
> ------------------------
>
> Key: DRILL-8279
> URL: https://issues.apache.org/jira/browse/DRILL-8279
> Project: Apache Drill
> Issue Type: Bug
> Reporter: Vova Vysotskyi
> Assignee: Vova Vysotskyi
> Priority: Blocker
>
> phoenix-queryserver-client shades Avatica classes, so it causes issues when
> starting Drill and shaded class from phoenix jars is loaded before, so Drill
> wouldn't be able to start correctly.
> To avoid that, phoenix thick client can be used, it also will improve query
> performance.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)