【问题标题】:NoSuchMethodError occurs while trying to connect to Cloud Bigtable from a Cloud Dataflow worker尝试从 Cloud Dataflow 工作器连接到 Cloud Bigtable 时发生 NoSuchMethodError
【发布时间】:2015-12-28 14:19:43
【问题描述】:

我按照这篇文章搭建了一个Cloud Dataflow Pipeline:https://cloud.google.com/bigtable/docs/dataflow-hbase

当我将其提交到 Cloud Dataflow 托管服务时,我在 Cloud Dataflow 工作人员处收到以下错误:

Uncaught exception in main thread. Exiting with status code 1.
java.lang.NoSuchMethodError: io.grpc.netty.GrpcSslContexts.forClient()Lcom/google/bigtable/repackaged/io/netty/handler/ssl/SslContextBuilder;
at com.google.cloud.bigtable.grpc.BigtableSession.createSslContext(BigtableSession.java:98)
at com.google.cloud.bigtable.grpc.BigtableSession.access$000(BigtableSession.java:82)
at com.google.cloud.bigtable.grpc.BigtableSession$1.run(BigtableSession.java:151)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

我应该如何处理这个问题?

我的 Cloud Dataflow Pipeline 源代码如下:

package mypackage

import com.google.cloud.bigtable.dataflow.CloudBigtableIO;
import com.google.cloud.bigtable.dataflow.CloudBigtableOptions;
import com.google.cloud.bigtable.dataflow.CloudBigtableTableConfiguration;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.transforms.DoFn;
import com.google.cloud.dataflow.sdk.transforms.ParDo;
import org.apache.hadoop.hbase.client.Mutation;
import org.apache.hadoop.hbase.client.Put;

public class Main {
    // Create a DoFn that creates a Put or Delete.  MUTATION_TRANSFORM is a simplistic example.
    static final DoFn<String, Mutation> MUTATION_TRANSFORM = new DoFn<String, Mutation>() {
        @Override
        public void processElement(DoFn<String, Mutation>.ProcessContext c) throws Exception {
            c.output(new Put(c.element().getBytes()).addColumn("v".getBytes(), "v".getBytes(), "value".getBytes()));
        }
    };

    public static void main(String[] args) {
        // CloudBigtableOptions is one way to retrieve the options.  It's not required to use this
        // specific PipelineOptions extension; CloudBigtableOptions is there as a convenience.
        CloudBigtableOptions options =
                PipelineOptionsFactory.fromArgs(args).withValidation().as(CloudBigtableOptions.class);

        // CloudBigtableTableConfiguration contains the project, zone, cluster and table to connect to
        CloudBigtableTableConfiguration config = CloudBigtableTableConfiguration.fromCBTOptions(options);

        Pipeline p = Pipeline.create(options);
        // This sets up serialization for Puts and Deletes so that Dataflow can potentially move them through
        // the network
        CloudBigtableIO.initializeForWrite(p);

        p
                .apply(Create.of("Hello", "World"))
                .apply(ParDo.of(MUTATION_TRANSFORM))
                .apply(CloudBigtableIO.writeToTable(config));

        p.run();
    }
}

【问题讨论】:

    标签: google-cloud-dataflow


    【解决方案1】:

    这个问题同:https://github.com/GoogleCloudPlatform/cloud-bigtable-client/issues/613

    我认为这里的问题是 Dataflow 和 Bigtable 都包含 io.grpc。 Bigtable 使用着色插件并更改包名称,但没有更改 io.grpc 包名称,如下所述:https://github.com/GoogleCloudPlatform/cloud-bigtable-client/issues/582

    解决此问题的最佳方法是使用 0.2.3-SNAPSHOT 版本的 bigtable-hbase。您必须在 pom.xml 中添加以下内容才能使用 SNAPSHOT:

      <repositories>
        <repository>
          <id>snapshots-repo</id>
          <url>https://oss.sonatype.org/content/repositories/snapshots</url>
          <releases><enabled>false</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
    

    我们将在新的一年尽快发布正式版本。

    【讨论】:

    • 非常感谢!我可以使用 0.2.3-SNAPSHOT 版本的 bigtable-hbase-dataflow 成功地将记录放入 Cloud Bigtable。期待正式版。
    【解决方案2】:

    听起来适当的 jar 文件在工作人员上不可用。它在你的本地类路径上吗?

    默认情况下,Dataflow 会先将主程序中的类路径内容复制到 Google Cloud Storage,然后再在 Dataflow 服务上启动作业。然后工人们从谷歌云存储中抓取罐子。您可以在主程序的日志中看到这种情况:

    INFO: PipelineOptions.filesToStage was not specified. Defaulting to files from the classpath: will stage XX files. Enable logging at DEBUG level to see which files will be staged.
    ...
    INFO: Uploading XX files from PipelineOptions.filesToStage to staging location to prepare for execution.
    INFO: Uploading PipelineOptions.filesToStage complete: YY files newly uploaded, ZZ files cached
    ...
    Submitted job: 2015-12-28_07_22_37-8675309
    

    【讨论】:

    • 当我在 pom.xml 中导入了不同版本的 netty 时发生在我身上。这可以通过排除有问题的版本或 hbase-bigtable 客户端库提供的版本来解决。
    猜你喜欢
    • 1970-01-01
    • 2017-11-25
    • 2015-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-16
    • 1970-01-01
    相关资源
    最近更新 更多