/** {@inheritDoc} */ @Override public ListenableFuture<List<String>> listTablesAsync() { ListTablesRequest request = ListTablesRequest.newBuilder() .setParent(instanceName.toString()) .build(); ListenableFuture<ListTablesResponse> response = adminClient.listTablesAsync(request); return Futures.transform(response, new Function<ListTablesResponse, List<String>>() { @Override public List<String> apply(ListTablesResponse input) { ImmutableList.Builder<String> tableIdsBuilder = ImmutableList.builder(); for(com.google.bigtable.admin.v2.Table tableProto : input.getTablesList()){ tableIdsBuilder.add(instanceName.toTableId(tableProto.getName())); } return tableIdsBuilder.build(); } }, MoreExecutors.directExecutor()); }
/** * Request a list of Tables for the cluster. The {@link Table}s in the response will only * contain fully qualified Bigtable table names, and not column family information. */ private ListTablesResponse requestTableList() throws IOException { try { ListTablesRequest.Builder builder = ListTablesRequest.newBuilder(); builder.setParent(bigtableInstanceName.toString()); return bigtableTableAdminClient.listTables(builder.build()); } catch (Throwable throwable) { throw new IOException("Failed to listTables", throwable); } }
private CompletableFuture<List<Table>> requestTableList() { ListTablesRequest request = ListTablesRequest.newBuilder().setParent(bigtableInstanceName.toString()).build(); return bigtableTableAdminClient.listTablesAsync(request) .thenApply(r -> r.getTablesList()); }
private CompletableFuture<List<Table>> requestTableList() { ListTablesRequest request = ListTablesRequest.newBuilder().setParent(bigtableInstanceName.toString()).build(); return bigtableTableAdminClient.listTablesAsync(request) .thenApply(r -> r.getTablesList()); }
/** {@inheritDoc} */ @Override public List<String> listTables() { ListTablesRequest requestProto = ListTablesRequest.newBuilder() .setParent(instanceName.toString()) .build(); ListTablesResponse response = adminClient.listTables(requestProto); ImmutableList.Builder<String> tableIdsBuilder = ImmutableList.builder(); for(com.google.bigtable.admin.v2.Table tableProto : response.getTablesList()){ tableIdsBuilder.add(instanceName.toTableId(tableProto.getName())); } return tableIdsBuilder.build(); }
.add(new GoogleCloudResourcePrefixInterceptor(options.getInstanceName().toString()));
@Override public CompletableFuture<Void> cloneSnapshot(String snapshotName, TableName tableName) { return CompletableFuture.supplyAsync(() -> { try { return CreateTableFromSnapshotRequest.newBuilder() .setParent(options.getInstanceName().toString()) .setTableId(tableName.getNameAsString()) .setSourceSnapshot(getClusterName().toSnapshotName(snapshotName)).build(); } catch (IOException e) { throw new CompletionException(e); } }).thenCompose( c -> bigtableTableAdminClient.createTableFromSnapshotAsync(c).thenApply(r -> null)); }
@Override public CompletableFuture<Void> cloneSnapshot(String snapshotName, TableName tableName) { return CompletableFuture.supplyAsync(() -> { try { return CreateTableFromSnapshotRequest.newBuilder() .setParent(options.getInstanceName().toString()) .setTableId(tableName.getNameAsString()) .setSourceSnapshot(getClusterName().toSnapshotName(snapshotName)).build(); } catch (IOException e) { throw new CompletionException(e); } }).thenCompose( c -> bigtableTableAdminClient.createTableFromSnapshotAsync(c).thenApply(r -> null)); }
private synchronized static ResourceLimiter initializeResourceLimiter(BigtableOptions options) { BigtableInstanceName instanceName = options.getInstanceName(); String key = instanceName.toString(); ResourceLimiter resourceLimiter = resourceLimiterMap.get(key); if (resourceLimiter == null) { int maxInflightRpcs = options.getBulkOptions().getMaxInflightRpcs(); long maxMemory = options.getBulkOptions().getMaxMemory(); ResourceLimiterStats stats = ResourceLimiterStats.getInstance(instanceName); resourceLimiter = new ResourceLimiter(stats, maxMemory, maxInflightRpcs); BulkOptions bulkOptions = options.getBulkOptions(); if (bulkOptions.isEnableBulkMutationThrottling()) { resourceLimiter.throttle(bulkOptions.getBulkMutationRpcTargetMs()); } resourceLimiterMap.put(key, resourceLimiter); } return resourceLimiter; }
/** {@inheritDoc} */ @Override public void cloneSnapshot(String snapshotName, TableName tableName) throws IOException, TableExistsException, RestoreSnapshotException { CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder() .setParent(options.getInstanceName().toString()) .setTableId(tableName.getNameAsString()) .setSourceSnapshot(getClusterName().toSnapshotName(snapshotName)) .build(); Operation operation = Futures .getChecked(bigtableTableAdminClient.createTableFromSnapshotAsync(request), IOException.class); try { connection.getSession().getInstanceAdminClient(). waitForOperation(operation); } catch (TimeoutException e) { throw new IOException("Timed out waiting for cloneSnapshot operation to finish", e); } }
/** {@inheritDoc} */ @Override public void cloneSnapshot(String snapshotName, TableName tableName) throws IOException, TableExistsException, RestoreSnapshotException { CreateTableFromSnapshotRequest request = CreateTableFromSnapshotRequest.newBuilder() .setParent(options.getInstanceName().toString()) .setTableId(tableName.getNameAsString()) .setSourceSnapshot(getClusterName().toSnapshotName(snapshotName)) .build(); Operation operation = Futures .getChecked(bigtableTableAdminClient.createTableFromSnapshotAsync(request), IOException.class); try { connection.getSession().getInstanceAdminClient(). waitForOperation(operation); } catch (TimeoutException e) { throw new IOException("Timed out waiting for cloneSnapshot operation to finish", e); } }
.add(new GoogleCloudResourcePrefixInterceptor(options.getInstanceName().toString()));
@Test public void testE2EBigtableWrite() throws Exception { final String tableName = bigtableOptions.getInstanceName().toTableNameStr(tableId); final String instanceName = bigtableOptions.getInstanceName().toString(); final int numRows = 1000; final List<KV<ByteString, ByteString>> testData = generateTableData(numRows);