use of com.google.bigtable.admin.v2.GetTableRequest in project beam by apache.
the class BigtableServiceImpl method tableExists.
@Override
public boolean tableExists(String tableId) throws IOException {
try (BigtableSession session = new BigtableSession(options)) {
GetTableRequest getTable = GetTableRequest.newBuilder().setName(options.getInstanceName().toTableNameStr(tableId)).build();
session.getTableAdminClient().getTable(getTable);
return true;
} catch (StatusRuntimeException e) {
if (e.getStatus().getCode() == Code.NOT_FOUND) {
return false;
}
String message = String.format("Error checking whether table %s (BigtableOptions %s) exists", tableId, options);
LOG.error(message, e);
throw new IOException(message, e);
}
}
Aggregations