简体   繁体   English

无法连接到Google Cloud Bigtable实例

[英]Unable to connect to Google Cloud Bigtable instance

I am trying to connect to a Google Cloud Bigtable instance using HBase APIs. 我正在尝试使用HBase API连接到Google Cloud Bigtable实例。 I am using Java 1.8. 我正在使用Java 1.8。 I followed the below tutorials: 我遵循以下教程:

https://cloud.google.com/bigtable/docs/samples-java-hello https://cloud.google.com/bigtable/docs/using-maven https://cloud.google.com/bigtable/docs/samples-java-hello https://cloud.google.com/bigtable/docs/using-maven

But for some reason I am unable to connect to this Bigtable instance. 但是由于某种原因,我无法连接到此Bigtable实例。 I am using valid ProjectID and InstanceID but still I am unable to connect. 我正在使用有效的ProjectID和InstanceID,但仍然无法连接。 Please find the exception below: 请在下面找到例外:

java.lang.IllegalStateException: Could not find an appropriate constructor for com.google.cloud.bigtable.hbase1_2.BigtableConnection
    at com.google.cloud.bigtable.hbase.BigtableConfiguration.connect(BigtableConfiguration.java:88)
    at com.google.cloud.bigtable.hbase.BigtableConfiguration.connect(BigtableConfiguration.java:72)
    at com.kp.sensor.iot.IOTSensorPull.makeConnection(IOTSensorPull.java:149)
    at com.kp.sensor.iot.IOTSensorPull.populateTemperature(IOTSensorPull.java:159)
    at com.kp.sensor.iot.IOTSensorPull.readMessagesFromRFIDSub(IOTSensorPull.java:126)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    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)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.google.cloud.bigtable.hbase.BigtableConfiguration.connect(BigtableConfiguration.java:85)
    ... 18 more
Caused by: java.lang.NoSuchMethodError: com.google.cloud.bigtable.config.BigtableOptions$Builder.setInstanceId(Ljava/lang/String;)Lcom/google/cloud/bigtable/config/BigtableOptions$Builder;
    at com.google.cloud.bigtable.hbase.BigtableOptionsFactory.fromConfiguration(BigtableOptionsFactory.java:244)
    at org.apache.hadoop.hbase.client.AbstractBigtableConnection.<init>(AbstractBigtableConnection.java:129)
    at org.apache.hadoop.hbase.client.AbstractBigtableConnection.<init>(AbstractBigtableConnection.java:104)
    at com.google.cloud.bigtable.hbase1_2.BigtableConnection.<init>(BigtableConnection.java:50)

Below are my maven dependencies: 以下是我的Maven依赖项:

<dependency>
    <groupId>com.google.cloud.bigtable</groupId>
    <artifactId>bigtable-hbase-1.2</artifactId>
    <version>0.9.4</version>
</dependency>

<dependency>
    <groupId>org.apache.hbase</groupId>
    <artifactId>hbase-client</artifactId>
    <version>1.1.5</version>
</dependency>

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-tcnative-boringssl-static</artifactId>
    <version>1.1.33.Fork19</version>
</dependency>

There are other dependencies as well since this is a Spring-boot application. 由于这是一个Spring-boot应用程序,因此还存在其他依赖项。

Also, in this case the ProjectID and InstanceID have the same value. 同样,在这种情况下,ProjectID和InstanceID具有相同的值。

Can someone please let me know what could be the issue here? 有人可以让我知道这里可能是什么问题吗?

For what it's worth, my version for org.apache.hbase is 1.2.4 Also I suspect that since your project ID equals Instance ID, you are referring to the ProjectID alias, rather than the actual underlying name, since I think that one is auto-assigned? 对于它的价值,我的org.apache.hbase版本是1.2.4。我还怀疑由于您的项目ID等于实例ID,因此您指的是ProjectID别名,而不是实际的基础名称,因为我认为这是自动分配? I've had issues elsewhere where using the Project alias, wile google seems to expect the underlying ID. 我在使用Project别名的其他地方遇到了问题,而Google似乎希望底层ID。 But looking at the exceptions seems the problem is not with that... 但是查看异常似乎不是问题所在...

Actually I think I found another reason behind this, which is probably more relevant: i noticed that when bigtable-hbase-1.2-0.9.4.jar is not located precisely in the original path of '/com/google/cloud/bigtable/bigtable-hbase-1.2/0.9.4/bigtable-hbase-1.2-0.9.4.jar' this problem will occur, as the code seems to check the version number of 1.2 (based on the parent folder?) 实际上,我认为我发现了这背后的另一个原因,它可能更相关:我注意到,当bigtable-hbase-1.2-0.9.4.jar不在精确的位置'/ com / google / cloud / bigtable / bigtable-hbase-1.2 / 0.9.4 / bigtable-hbase-1.2-0.9.4.jar'会出现此问题,因为代码似乎检查版本号1.2(基于父文件夹?)

In my case, this seems to be related specifically to Bigtable-Dataflow portion of the API, and NOT to the general Bigtable API (ie bigtable-hbase-dataflow in POM.xml). 就我而言,这似乎与该API的Bigtable-Dataflow部分有关,而与一般的Bigtable API(即POM.xml中的bigtable-hbase-dataflow)无关。 The generic part of Bigtable API seems not to care where the JAR is located. Bigtable API的通用部分似乎并不在乎JAR的位置。

I came across this while testing on Google's VMs, where I was dumping all JARs just into one directory for simplicity. 我在Google的VM上进行测试时碰到了这一点,为了简化起见,我将所有JAR都转储到一个目录中。 It worked well for the generic Bigtable functionality, but NOT for the Bigtable-Dataflow functionality, even though it worked on my local machine, where Eclipse built all dependency paths properly before launching the code. 尽管它适用于我的本地机器,但Eclipse在启动代码之前正确地构建了所有依赖关系路径,因此它对于通用的Bigtable功能很好地起作用,但是对于Bigtable-Dataflow功能却不能起作用。 As soon as I put that .JAR in the proper path, the problem was gone. 我将.JAR放在正确的路径上后,问题就消失了。

I'm guessing the complication is coming from somewhere here? 我猜错是从这里来的吗?
https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/master/bigtable-hbase-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/BigtableConfiguration.java#L43 https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/master/bigtable-hbase-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/BigtableConfiguration.java# L43

cc: @solomon-duskis 抄送:@ solomon-duskis

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM