Connect from Java app to Google Cloud Bigtable which running on Docker

巧了我就是萌 提交于 2021-02-07 10:17:28

问题


I want to connect to Google Cloud Bigtable which running on Docker:

docker run --rm -it -p 8086:8086 -v ~/.config/:/root/.config \
bigtruedata/gcloud-bigtable-emulator

It starts without any problems:

[bigtable] Cloud Bigtable emulator running on 127.0.0.1:8086

~/.config it is my default credentials that I configured in this way:

gcloud auth application-default login

I used Java-code from official sample HelloWorld. Also, I changed connection configuration like this:

Configuration conf = BigtableConfiguration.configure("projectId", "instanceId");

conf.set(BigtableOptionsFactory.BIGTABLE_HOST_KEY, "127.0.0.1");
conf.set(BigtableOptionsFactory.BIGTABLE_PORT_KEY, "8086");
conf.set(BigtableOptionsFactory.BIGTABLE_USE_PLAINTEXT_NEGOTIATION, "true");

try (Connection connection = BigtableConfiguration.connect(conf)) {
    ...

And I set BIGTABLE_EMULATOR_HOST=127.0.0.1:8086 environment variable in a configuration for my app in IntelliJ Idea.

But when I run my Java app, it gets stuck on admin.createTable(descriptor); and shows this log:

... 16:42:44.697 [grpc-default-executor-0] DEBUG com.google.bigtable.repackaged.io.grpc.netty.shaded.io.netty.util.Recycler - -Dio.netty.recycler.ratio: 8

After some time it shows log about BigtableClientMetrics and then throws an exception:

java.net.NoRouteToHostException: No route to host

I get the same problem when trying to run Google Cloud Bigtable with my own Dockerfile.


When I run Google Cloud Bigtable with this command:

gcloud beta emulators bigtable start

my app completed successfully.

So, how to solve this problem?

UPDATE:

Now I have this exception:

io.grpc.StatusRuntimeException: UNAVAILABLE: Network closed for unknown reason

and before this another exception is thrown:

java.io.IOException: Connection reset by peer

来源:https://stackoverflow.com/questions/50839322/connect-from-java-app-to-google-cloud-bigtable-which-running-on-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!