googleapis / googleapis/google-cloud-java

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

Đang mở
#13,064 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
api: bigtable
Ngôn ngữ chính
Java
Star
2.1k
Fork
1.2k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
154

Mô tả

## 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)
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.