从云数据流连接到bigtable

时间:2018-07-06 18:09:25

标签: google-cloud-platform apache-beam google-cloud-bigtable

我正在尝试从Beam API连接到BigTable。我经常遇到错误:

Exception in thread "BigtableSession-startup-1" 
java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been 
properly configured.

这里是我正在使用的POM:    http://maven.apache.org/xsd/maven-4.0.0.xsd“>     4.0.0

<groupId>com.dataflow.example</groupId>
<artifactId>dataflowTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>dataflowTest</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven-compiler-plugin.version>3.6.2</maven-compiler-plugin.version>
    <maven-exec-plugin.version>1.6.0</maven-exec-plugin.version>
    <beam.version>2.1.0</beam.version>
    <bigtable.version>1.0.0</bigtable.version>
    <slf4j.version>1.7.21</slf4j.version>
    <bigtable.table>Dataflow_test</bigtable.table>
    <pubsubTopic>projects/${bigtable.projectID}/topics/shakes</pubsubTopic>
    <bigtable.hbase.version>${bigtable.version}</bigtable.hbase.version>
</properties>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    <extensions>
        <!-- Use os-maven-plugin to initialize the "os.detected" properties -->
        <extension>
            <groupId>kr.motd.maven</groupId>
            <artifactId>os-maven-plugin</artifactId>
            <version>1.4.0.Final</version>
        </extension>
    </extensions>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
                <execution>
                    <id>bundle-and-repackage</id>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <filters>
                            <filter>
                                <artifact>*:*</artifact>
                                <excludes>
                                    <exclude>META-INF/*.SF</exclude>
                                    <exclude>META-INF/*.DSA</exclude>
                                    <exclude>META-INF/*.RSA</exclude>
                                </excludes>
                            </filter>
                        </filters>
                        <transformers>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>


<dependencies>
    <dependency>
        <groupId>org.apache.beam</groupId>
        <artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
        <version>2.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.beam</groupId>
        <artifactId>beam-sdks-java-extensions-google-cloud-platform-core</artifactId>
        <version>2.2.0</version>
        <exclusions>
            <exclusion>
                <groupId>io.netty</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.mortbay.jetty.alpn/alpn-boot -->
    <!-- https://mvnrepository.com/artifact/io.netty/netty-tcnative-boringssl-static -->
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-tcnative-boringssl-static</artifactId>
        <version>2.0.7.Final</version>
    </dependency>

    <dependency>
        <groupId>com.google.cloud.bigtable</groupId>
        <artifactId>bigtable-hbase-beam</artifactId>
        <version>${bigtable.version}</version>
        <exclusions>
            <exclusion>
                <groupId>io.netty</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.google.cloud.dataflow</groupId>
        <artifactId>google-cloud-dataflow-java-sdk-all</artifactId>
        <version>2.2.0</version>
        <exclusions>
            <exclusion>
                <groupId>io.netty</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.6</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

以及出现此错误的代码库:

try (BigtableSession session = new BigtableSession(optionsBuilder
        .setCredentialOptions(CredentialOptions.credential(options.as(GcpOptions.class).getGcpCredential())).build())) {

      BigtableTableAdminClient tableAdminClient = session.getTableAdminClient();

我尝试过fork26,fork13、2.0.7.Final和其他各种版本的netty。

2 个答案:

答案 0 :(得分:1)

尝试使用此链接-https://github.com/grpc/grpc-java/blob/master/SECURITY.md#troubleshooting。您可能需要从每个依赖项中排除所有netty依赖项,并分别添加netty作为依赖项以避免冲突。一起使用Spark和Big Table时,我遇到了类似的问题。

答案 1 :(得分:0)

您所使用的netty版本之间似乎存在冲突。您可以使用诸如“缺陷管理”之类的方法来解决此问题吗?

enter image description here

在其他一些依赖项中可能会使用其他版本的netty,请尝试删除其他版本。