use of com.google.cloud.bigtable.admin.v2.models.Table in project java-bigtable-hbase by googleapis.
the class TestTableAdapter method testAdaptForTable.
@Test
public void testAdaptForTable() {
// If no GcRule passed to ColumnFamily, then ColumnDescriptorAdapter#buildGarbageCollectionRule
// updates maxVersion to Integer.MAX_VALUE
GCRule gcRule = GCRULES.maxVersions(1);
ColumnFamily columnFamily = ColumnFamily.newBuilder().setGcRule(gcRule.toProto()).build();
Table table = Table.newBuilder().setName(TABLE_NAME).putColumnFamilies(COLUMN_FAMILY, columnFamily).build();
HTableDescriptor actualTableDesc = TableAdapter.adapt(com.google.cloud.bigtable.admin.v2.models.Table.fromProto(table));
HTableDescriptor expected = new HTableDescriptor(TableName.valueOf(TABLE_ID));
expected.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
Assert.assertEquals(expected, actualTableDesc);
}
use of com.google.cloud.bigtable.admin.v2.models.Table in project java-bigtable-hbase by googleapis.
the class TestAdminClientVeneerApi method testCreateTableAsync.
@Test
public void testCreateTableAsync() throws Exception {
CreateTableRequest req = CreateTableRequest.of(TABLE_ID_1);
Future<Table> response = adminClientWrapper.createTableAsync(req);
assertEquals(TABLE_ID_1, response.get().getId());
}
use of com.google.cloud.bigtable.admin.v2.models.Table in project java-bigtable-hbase by googleapis.
the class TestAdminClientVeneerApi method testModifyFamilyAsync.
@Test
public void testModifyFamilyAsync() throws Exception {
ModifyColumnFamiliesRequest request = ModifyColumnFamiliesRequest.of(TABLE_ID_1).addFamily("first-family").addFamily("another-family");
Future<Table> response = adminClientWrapper.modifyFamiliesAsync(request);
assertEquals(TABLE_ID_1, response.get().getId());
}
use of com.google.cloud.bigtable.admin.v2.models.Table in project java-bigtable-hbase by googleapis.
the class TestTableAdapter2x method testAdaptWithTable.
@Test
public void testAdaptWithTable() {
// If no GcRule passed to ColumnFamily, then ColumnDescriptorAdapter#buildGarbageCollectionRule
// updates maxVersion to Integer.MAX_VALUE
int maxVersion = 1;
GCRules.GCRule gcRule = GCRULES.maxVersions(maxVersion);
ColumnFamily columnFamily = ColumnFamily.newBuilder().setGcRule(gcRule.toProto()).build();
Table table = Table.newBuilder().setName(TABLE_NAME).putColumnFamilies(COLUMN_FAMILY, columnFamily).build();
TableDescriptor actualTableDesc = TableAdapter2x.adapt(com.google.cloud.bigtable.admin.v2.models.Table.fromProto(table));
TableDescriptor expected = new HTableDescriptor(TableName.valueOf(TABLE_ID)).addFamily(new HColumnDescriptor(COLUMN_FAMILY));
Assert.assertEquals(expected, actualTableDesc);
}
use of com.google.cloud.bigtable.admin.v2.models.Table in project java-bigtable by googleapis.
the class NativeImageBigtableSample method main.
/**
* Entrypoint to the BigTable sample application.
*/
public static void main(String[] args) throws IOException {
String projectId = ServiceOptions.getDefaultProjectId();
BigtableTableAdminSettings adminClientSettings = BigtableTableAdminSettings.newBuilder().setInstanceId(INSTANCE_NAME).setProjectId(projectId).build();
BigtableDataSettings clientSettings = BigtableDataSettings.newBuilder().setInstanceId(INSTANCE_NAME).setProjectId(projectId).build();
BigtableInstanceAdminSettings instanceAdminSettings = BigtableInstanceAdminSettings.newBuilder().setProjectId(projectId).build();
BigtableTableAdminClient adminClient = BigtableTableAdminClient.create(adminClientSettings);
BigtableDataClient standardClient = BigtableDataClient.create(clientSettings);
BigtableInstanceAdminClient instanceAdminClient = BigtableInstanceAdminClient.create(instanceAdminSettings);
if (!instanceAdminClient.exists(INSTANCE_NAME)) {
instanceAdminClient.createInstance(CreateInstanceRequest.of(INSTANCE_NAME).addCluster("cluster", "us-central1-f", 3, StorageType.SSD).setType(Instance.Type.PRODUCTION).addLabel("example", "instance_admin"));
}
String tableName = TABLE_NAME + UUID.randomUUID().toString().replace("-", "");
createTable(adminClient, tableName);
// Add data into table
ImmutableMap<String, Long> dataWithLong = ImmutableMap.of("connected_cell", 1L, "connected_wifi", 1L);
ImmutableMap<String, String> dataWithStrings = ImmutableMap.of("os_build", "PQ2A.190405.003");
long timestamp = System.currentTimeMillis() * 1000;
insertData(standardClient, tableName, timestamp, dataWithLong, dataWithStrings);
readData(standardClient, tableName);
// Clean up
deleteTable(adminClient, tableName);
}
Aggregations