/** * Creates a new table asynchronously. The table can be created with a full set of initial column * families, specified in the request. * * @param request a {@link CreateTableRequest} object. */ public CompletableFuture<Table> createTableAsync(CreateTableRequest request) { return toCompletableFuture(adminClient.createTableAsync(request)); }
/** * Creates a new table from a snapshot. * @param request a {@link CreateTableFromSnapshotRequest} object. * @return The long running {@link Operation} for the request. */ public CompletableFuture<Operation> createTableFromSnapshotAsync(CreateTableFromSnapshotRequest request) { return toCompletableFuture(adminClient.createTableFromSnapshotAsync(request)); } }
/** * Permanently deletes the specified snapshot. * @param request a {@link DeleteSnapshotRequest} object. */ public CompletableFuture<Empty> deleteSnapshotAsync(DeleteSnapshotRequest request) { return toCompletableFuture(adminClient.deleteSnapshotAsync(request)); }
/** {@inheritDoc} */ @Override public Table getTable(String tableId) { GetTableRequest requestProto = GetTableRequest.newBuilder() .setName(instanceName.toTableNameStr(tableId)) .build(); return Table.fromProto(adminClient.getTable(requestProto)); }
/** * @param request a {@link CreateTableRequest} object to send. * @throws java.io.IOException if any. */ protected void createTable(TableName tableName, CreateTableRequest request) throws IOException { try { bigtableTableAdminClient.createTable( request.toProto(bigtableInstanceName.toAdminInstanceName())); } catch (Throwable throwable) { throw convertToTableExistsException(tableName, throwable); } }
/** {@inheritDoc} */ @Override public void deleteTable(TableName tableName) throws IOException { Builder deleteBuilder = DeleteTableRequest.newBuilder(); deleteBuilder.setName(toBigtableName(tableName)); try { bigtableTableAdminClient.deleteTable(deleteBuilder.build()); } catch (Throwable throwable) { throw new IOException( String.format( "Failed to delete table '%s'", tableName.getNameAsString()), throwable); } disabledTables.remove(tableName); }
/** * Permanently deletes a specified table and all of its data. * * @param request a {@link DeleteTableRequest} object. * @return a {@link CompletableFuture} that returns {@link Empty} object. */ public CompletableFuture<Empty> deleteTableAsync(DeleteTableRequest request){ return toCompletableFuture(adminClient.deleteTableAsync(request)); }
/** * Permanently deletes all rows in a range. * * @param request a {@link DropRowRangeRequest} object. * @return a {@link CompletableFuture} that returns {@link Empty} object. */ public CompletableFuture<Empty> dropRowRangeAsync(DropRowRangeRequest request) { return toCompletableFuture(adminClient.dropRowRangeAsync(request)); }
/** * Gets the details of a table asynchronously. * * @param request a {@link GetTableRequest} object. * @return a {@link CompletableFuture} that returns a {@link Table} object. */ public CompletableFuture<Table> getTableAsync(GetTableRequest request) { return toCompletableFuture(adminClient.getTableAsync(request)); }
/** {@inheritDoc} */ @Override public void dropRowRange(String tableId, String rowKeyPrefix) { adminClient.dropRowRange(buildDropRowRangeRequest(tableId, rowKeyPrefix)); }
@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); } }
/** {@inheritDoc} */ @Override public Table createTable(CreateTableRequest request) { com.google.bigtable.admin.v2.CreateTableRequest requestProto = request.toProto(instanceName.getProjectId(), instanceName.getInstanceId()); adminClient.createTable(requestProto); return getTable(requestProto.getTableId()); }
/** {@inheritDoc} */ @Override public void deleteTable(String tableId) { DeleteTableRequest request = DeleteTableRequest.newBuilder() .setName(instanceName.toTableNameStr(tableId)) .build(); adminClient.deleteTable(request); }
/** * Permanently deletes a specified table and all of its data. * * @param request a {@link DeleteTableRequest} object. * @return a {@link CompletableFuture} that returns {@link Empty} object. */ public CompletableFuture<Empty> deleteTableAsync(DeleteTableRequest request){ return toCompletableFuture(adminClient.deleteTableAsync(request)); }
/** {@inheritDoc} */ @Override public ListenableFuture<Void> dropRowRangeAsync(String tableId, String rowKeyPrefix) { return Futures.transform( adminClient.dropRowRangeAsync(buildDropRowRangeRequest(tableId, rowKeyPrefix)), new Function<Empty, Void>() { @Override public Void apply(Empty empty) { return null; } }, MoreExecutors.directExecutor()); }
/** * Gets the details of a table asynchronously. * * @param request a {@link GetTableRequest} object. * @return a {@link CompletableFuture} that returns a {@link Table} object. */ public CompletableFuture<Table> getTableAsync(GetTableRequest request) { return toCompletableFuture(adminClient.getTableAsync(request)); }
private void issueBulkDelete(TableName tableName, DropRowRangeRequest.Builder deleteRequest) throws IOException { try { bigtableTableAdminClient .dropRowRange(deleteRequest.setName(toBigtableName(tableName)).build()); } catch (Throwable throwable) { throw new IOException( String.format("Failed to truncate table '%s'", tableName.getNameAsString()), throwable); } }
/** {@inheritDoc} */ @Override public HTableDescriptor getTableDescriptor(TableName tableName) throws IOException { if (tableName == null) { return null; } String bigtableTableName = toBigtableName(tableName); GetTableRequest request = GetTableRequest.newBuilder().setName(bigtableTableName).build(); try { return tableAdapter.adapt(bigtableTableAdminClient.getTable(request)); } catch (Throwable throwable) { if (Status.fromThrowable(throwable).getCode() == Status.Code.NOT_FOUND) { throw new TableNotFoundException(tableName); } throw new IOException("Failed to getTableDescriptor() on " + tableName, throwable); } }
/** * Creates a new table asynchronously. The table can be created with a full set of initial column * families, specified in the request. * * @param request a {@link CreateTableRequest} object. */ public CompletableFuture<Table> createTableAsync(CreateTableRequest request) { return toCompletableFuture(adminClient.createTableAsync(request)); }
/** Helper function to create an empty table. */ private void createEmptyTable(String instanceName, String tableId) { Table.Builder tableBuilder = Table.newBuilder(); tableBuilder.putColumnFamilies(COLUMN_FAMILY_NAME, ColumnFamily.newBuilder().build()); CreateTableRequest.Builder createTableRequestBuilder = CreateTableRequest.newBuilder() .setParent(instanceName) .setTableId(tableId) .setTable(tableBuilder.build()); tableAdminClient.createTable(createTableRequestBuilder.build()); }