How to connect to a working bigtable emulator from java

I am trying to use the bigtable emulator from gcloud beta emulators. I run the emulator, grab the hostname (localhost) and port (in this case 8885)

gcloud beta emulators bigtable start

Execution: / usr / local / Caskroom / google-cloud-sdk / latest / google-cloud-sdk / platform / bigtable-emulator / cbtemulator --host = localhost -port = 8885

I am trying to connect to an emulator from a Java test client, here is what I provide:

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

if(!Strings.isNullOrEmpty(host)){
    conf.set(BigtableOptionsFactory.BIGTABLE_HOST_KEY, host);
    conf.set(BigtableOptionsFactory.BIGTABLE_PORT_KEY, Integer.toString(port));
}
connection = BigtableConfiguration.connect(configuration);
try (Table table = connection.getTable("tName")){
    table.put(<Put instance>);
} 

When I execute the test code, I get:

16:36:37.369 [bigtable-batch-pool-1] INFO com.google.cloud.bigtable.grpc.async.AbstractRetryingRpcListener - Retrying failed call. Failure #1, got: Status{code=UNAVAILABLE, description=null, cause=java.net.ConnectException: Connection refused: localhost/0:0:0:0:0:0:0:1:8885}
java.net.ConnectException: Connection refused: localhost/0:0:0:0:0:0:0:1:8885

I am using the library: com.google.cloud.bigtable:bigtable-hbase-1.2:0.9.1

Any idea what I'm doing wrong?

Thank!

+4
source share
1 answer

You need to set another configuration property:

conf.set(BigtableOptionsFactory.BIGTABLE_USE_PLAINTEXT_NEGOTIATION, true);

, , IPv6-, , , . , host IPv4.

java .

+3

Source: https://habr.com/ru/post/1649081/


All Articles