You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/08/06 08:44:41 UTC

[GitHub] [phoenix-connectors] stoty commented on a change in pull request #25: PHOENIX-6057 Create phoenix-connector for spark, kafka, pig, flume ...

stoty commented on a change in pull request #25:
URL: https://github.com/apache/phoenix-connectors/pull/25#discussion_r466221043



##########
File path: phoenix4-compat/src/main/java/org/apache/phoenix/compat/CompatUtil.java
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.phoenix.compat;
+
+import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.RegionLocator;
+import org.apache.hadoop.hbase.util.RegionSizeCalculator;
+import jline.internal.Preconditions;

Review comment:
       Connectors shouldn't have jline dependencies. 
   I'm going to  look into removing this dependency in Phoenix-core in 4.x as well.

##########
File path: phoenix5-compat/pom.xml
##########
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>phoenix-connectors</artifactId>
+        <groupId>org.apache.phoenix</groupId>
+        <version>6.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <version>6.0.0-SNAPSHOT</version>
+
+    <groupId>org.apache.phoenix</groupId>
+    <artifactId>Phoenix5-compat</artifactId>
+
+    <properties>
+        <phoenix.version>5.1.0-SNAPSHOT</phoenix.version>
+        <hbase.version>2.2.4</hbase.version>
+    </properties>
+
+    <build>
+        <plugins>
+            <!-- Setup eclipse -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-eclipse-plugin</artifactId>
+                <version>2.9</version>
+                <configuration>
+                    <buildcommands>
+                        <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+                    </buildcommands>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>

Review comment:
       The 4.x comments apply here as well.

##########
File path: phoenix5-compat/src/main/java/org/apache/phoenix/compat/CompatUtil.java
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.phoenix.compat;
+
+import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.RegionLocator;
+import org.apache.hadoop.hbase.mapreduce.RegionSizeCalculator;
+import org.junit.Assert;
+
+import java.io.IOException;
+
+public class CompatUtil {
+
+    private CompatUtil() {
+        // Not to be instantiated
+    }
+
+    public static void assertTableExists(Admin admin, String fullTableName)
+            throws IOException {
+        try {
+            boolean exists = admin.tableExists(TableName.valueOf(fullTableName));
+            Assert.assertTrue(exists);
+        } finally {
+            admin.close();
+        }
+    }
+
+    public static boolean isEmpty(String text) {

Review comment:
       This doesn't really belong in a compat module.
   If you cannot find an suitable isEmpty implementation that is present in both versions of the hbase transitive dependencies, it'd be better to just replace it with standard Java code in the drivers.

##########
File path: phoenix4-compat/pom.xml
##########
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>phoenix-connectors</artifactId>
+        <groupId>org.apache.phoenix</groupId>
+        <version>6.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <version>6.0.0-SNAPSHOT</version>
+
+    <groupId>org.apache.phoenix</groupId>
+    <artifactId>Phoenix4-compat</artifactId>
+
+
+    <build>
+        <plugins>
+            <!-- Setup eclipse -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-eclipse-plugin</artifactId>
+                <version>2.9</version>
+                <configuration>
+                    <buildcommands>
+                        <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+                    </buildcommands>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <!-- Phoenix dependencies -->
+        <dependency>
+            <groupId>org.apache.phoenix</groupId>
+            <artifactId>phoenix-core</artifactId>
+            <version>${phoenix.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.phoenix</groupId>
+            <artifactId>phoenix-core</artifactId>
+            <version>${phoenix.version}</version>
+        </dependency>
+
+        <!-- HBase dependencies -->

Review comment:
       hbase-server also seems to be needed for RegionSizeCalculator

##########
File path: pom.xml
##########
@@ -317,7 +320,7 @@
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-shade-plugin</artifactId>
-          <version>2.4.3</version>
+          <version>${maven-shade-plugin.version}</version>

Review comment:
       Most of these module versions are definied in the ASF parent POM.
   Eventually, we'll want to do the same cleanup that we've done in core (update the asf parent pom version, and remove the plugin version overrides, but that can be handled in a follow-up ticket)

##########
File path: phoenix-flume-base/phoenix5-flume/pom.xml
##########
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>phoenix-flume-base</artifactId>
+        <groupId>org.apache.phoenix</groupId>
+        <version>6.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>phoenix5-flume</artifactId>
+    <name>Phoenix5 - Flume</name>
+
+    <properties>
+        <top.dir>${project.basedir}/..</top.dir>
+        <phoenix.version>5.1.0-SNAPSHOT</phoenix.version>
+        <hbase.version>2.2.4</hbase.version>

Review comment:
       This version handling is messy.
   
   I think that the best option would be  defining hadoop-two, hadoop-three, hbase-one, hbase-two in the top level pom, and using those in the modules (i.e. <hadoop.version>${hadoop-three.version}</hadoop.version>) That way both versions can be overriden at build time.
   
   In fact the same could be done for phoenix5.version and phoenix4.version.

##########
File path: phoenix-kafka-base/phoenix5-kafka/pom.xml
##########
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>phoenix-kafka-base</artifactId>
+        <groupId>org.apache.phoenix</groupId>
+        <version>6.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>phoenix5-kafka</artifactId>
+    <name>Phoenix5 - Kafka</name>
+
+    <properties>
+        <top.dir>${project.basedir}/..</top.dir>
+        <phoenix.version>5.1.0-SNAPSHOT</phoenix.version>
+        <hbase.version>2.2.4</hbase.version>
+        <hadoop.version>3.0.3</hadoop.version>
+        <hadoop-two.version>3.0.3</hadoop-two.version>
+        <phoenix.compat.version>5</phoenix.compat.version>
+        <curator.version>4.0.0</curator.version>
+        <jdk.version>1.8</jdk.version>
+        <maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>
+        <jetty.version>9.3.19.v20170502</jetty.version>
+    </properties>
+
+
+    <dependencies>

Review comment:
       These are additional dependencies that are not needed for 4.x ?

##########
File path: phoenix4-compat/pom.xml
##########
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>phoenix-connectors</artifactId>
+        <groupId>org.apache.phoenix</groupId>
+        <version>6.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <version>6.0.0-SNAPSHOT</version>
+
+    <groupId>org.apache.phoenix</groupId>
+    <artifactId>Phoenix4-compat</artifactId>
+
+
+    <build>
+        <plugins>
+            <!-- Setup eclipse -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-eclipse-plugin</artifactId>
+                <version>2.9</version>
+                <configuration>
+                    <buildcommands>
+                        <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+                    </buildcommands>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <!-- Phoenix dependencies -->
+        <dependency>

Review comment:
       I don't think that either compat module should depend on Phoenix itself. They are meant to isolate the connectors from the HBase incompatibilities

##########
File path: phoenix4-compat/pom.xml
##########
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>phoenix-connectors</artifactId>

Review comment:
       You may want to consider using apache-parent as default, I don't think we need anything from the connectors parent pom.

##########
File path: phoenix-flume-base/phoenix-flume/pom.xml
##########
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>phoenix-flume-base</artifactId>
+        <groupId>org.apache.phoenix</groupId>
+        <version>6.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>phoenix-flume</artifactId>

Review comment:
       I am not sure about calling the 4.x version phoenix-whatever.
   We may want to rename them to phoenix4-whatever.
   Should try to get a third opinion on what would be the least distruptive.

##########
File path: phoenix5-compat/src/main/java/org/apache/phoenix/compat/CompatUtil.java
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.phoenix.compat;
+
+import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.RegionLocator;
+import org.apache.hadoop.hbase.mapreduce.RegionSizeCalculator;
+import org.junit.Assert;
+
+import java.io.IOException;
+
+public class CompatUtil {
+
+    private CompatUtil() {
+        // Not to be instantiated
+    }
+
+    public static void assertTableExists(Admin admin, String fullTableName)
+            throws IOException {
+        try {
+            boolean exists = admin.tableExists(TableName.valueOf(fullTableName));
+            Assert.assertTrue(exists);
+        } finally {
+            admin.close();
+        }
+    }
+
+    public static boolean isEmpty(String text) {
+        return org.apache.commons.lang3.StringUtils.isEmpty(text);
+    }
+
+
+    public static long getSize(RegionLocator regionLocator, Admin admin,
+                               HRegionLocation location) throws IOException {
+        RegionSizeCalculator sizeCalculator = new RegionSizeCalculator(regionLocator, admin);
+        return sizeCalculator.getRegionSize(location.getRegionInfo().getRegionName());
+    }
+
+    public static TableName getTableName(byte[] tableNameBytes) {
+        return TableName.valueOf(tableNameBytes);
+    }
+
+    public static void checkNotNull(Object o) {

Review comment:
       This should also be replaced in the connectors with equivalent java code.

##########
File path: phoenix-pig-base/phoenix5-pig/pom.xml
##########
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>phoenix-pig-base</artifactId>
+        <groupId>org.apache.phoenix</groupId>
+        <version>6.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>phoenix5-pig</artifactId>
+    <name>Phoenix5 - Pig</name>
+
+    <properties>
+        <top.dir>${project.basedir}/..</top.dir>
+        <shaded.package>org.apache.phoenix.shaded</shaded.package>

Review comment:
       I think this belong is the parent pom.

##########
File path: phoenix-spark-base/src/main/java/org/apache/phoenix/spark/datasource/v2/writer/PhoenixDataSourceWriteOptions.java
##########
@@ -36,10 +36,10 @@
     private PhoenixDataSourceWriteOptions(String tableName, String zkUrl, String scn,
             String tenantId, StructType schema, boolean skipNormalizingIdentifier,
             Properties overriddenProps) {
-        Preconditions.checkNotNull(tableName);
-        Preconditions.checkNotNull(zkUrl);
-        Preconditions.checkNotNull(schema);
-        Preconditions.checkNotNull(overriddenProps);
+        CompatUtil.checkNotNull(tableName);

Review comment:
       Again, just replace with plain java code.

##########
File path: phoenix-pig-base/src/main/java/org/apache/phoenix/pig/PhoenixHBaseLoader.java
##########
@@ -149,11 +149,11 @@ private void initializePhoenixPigConfiguration(final String location, final Conf
             this.tableName = pair.getFirst();
             final String selectedColumns = pair.getSecond();
             
-            if(isEmpty(this.tableName) && isEmpty(this.selectQuery)) {
+            if(CompatUtil.isEmpty(this.tableName) && CompatUtil.isEmpty(this.selectQuery)) {

Review comment:
       Again, better to replace with plain Java.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org