Open
Description
Create documentation on how to connect to the Java Wrapped Emulator using the HBase API
I would like to use the HBase API to connect to BigTable
https://cloud.google.com/bigtable/docs/samples-hbase-java-hello#connect
https://github.com/GoogleCloudPlatform/cloud-bigtable-examples/blob/main/java/quickstart/src/main/java/com/example/cloud/bigtable/quickstart/Quickstart.java#L45
// ...
import com.google.cloud.bigtable.hbase.BigtableConfiguration;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
// ...
try (Connection connection = BigtableConfiguration.connect(projectId, instanceId)) {
HTableDescriptor descriptor = new HTableDescriptor(TableName.valueOf(tableId));
descriptor.addFamily(new HColumnDescriptor(columnFamilyName));
try (Admin admin = connection.getAdmin()) {
admin.createTable(descriptor);
// Retrieve the table we just created so we can do some reads and writes
try (Table table = connection.getTable(TableName.valueOf(tableId))) {
String rowKey = "r1";
Put put = new Put(Bytes.toBytes(rowKey));
put.addColumn(Bytes.toBytes(columnFamilyName), Bytes.toBytes(columnName),
Bytes.toBytes(data));
table.put(put);
}
}
}
But I also want to run my tests using the emulator via Java wrapper.
https://cloud.google.com/bigtable/docs/emulator#java_wrapper_for_the_emulator
https://github.com/googleapis/java-bigtable/tree/main/google-cloud-bigtable-emulator
BigtableTableAdminSettings.Builder tableAdminSettings = BigtableTableAdminSettings.newBuilderForEmulator(bigtableEmulator.getPort());
tableAdminClient = BigtableTableAdminClient.create(tableAdminSettings.build());
BigtableDataSettings.Builder dataSettings = BigtableDataSettings.newBuilderForEmulator(bigtableEmulator.getPort());
dataClient = BigtableDataClient.create(dataSettings.build());
// Create a test table that can be used in tests
tableAdminClient.createTable(
CreateTableRequest.of("fake-table")
.addFamily("cf")
);
However there is no documentation how to use the HBase API with the Java wrapped emulator.
Describe the solution you'd like
- Documentation and working example on how to connect to the emulator Java wrapper, using the HBase API, ... or
- Documentation on how to create org.apache.hadoop.hbase.client.Connection object from the emulator Java wrapper, or
- Documentation on how to create com.google.cloud.bigtable.hbase.BigtableConfiguration object from the Emulator Java Wrapper (assuming it is possible to do this:
Connection connection = BigtableConfiguration.connect(projectId, instanceId)
)
Describe alternatives you've considered
- Using the native Go or docker emulator, but my environment does not have docker, or Go
- Using
hbase-site.xml
, when using this setting:but I get the following error:<property> <name>hbase.client.connection.impl</name> <value>com.google.cloud.bigtable.hbase2_x.BigtableConnection</value> </property>
Caused by: java.io.IOException: java.lang.NoSuchMethodException: com.google.cloud.bigtable.hbase2_x.BigtableConnection.<init>(org.apache.hadoop.conf.Configuration,java.util.concurrent.ExecutorService,org.apache.hadoop.hbase.security.User,java.util.Map)