googleapis / googleapis/google-cloud-java

[java-bigtable] Create documentation on how to connect to the Java Wrapped Emulator using the HBase API

Abierto
#13,064 0 comentarios 0 reacciones 0 asignados Ver en GitHub
api: bigtable
Lenguaje dominante
Java
Estrellas
2.1k
Forks
1.2k
Merge medio
1 d 23 h
PR fusionados (30 d)
154

Descripción

## 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
```java
// ...
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
```java
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:
```xml

hbase.client.connection.impl
com.google.cloud.bigtable.hbase2_x.BigtableConnection

```
but I get the following error:
```sh
Caused by: java.io.IOException: java.lang.NoSuchMethodException: com.google.cloud.bigtable.hbase2_x.BigtableConnection.(org.apache.hadoop.conf.Configuration,java.util.concurrent.ExecutorService,org.apache.hadoop.hbase.security.User,java.util.Map)
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.