@Override public CompletableFuture<List<SnapshotDescription>> listSnapshots() { return CompletableFuture.supplyAsync(() -> { try { return ListSnapshotsRequest.newBuilder() .setParent(getSnapshotClusterName().toString()) .build(); } catch (IOException e) { throw new CompletionException(e); } }).thenCompose(request -> bigtableTableAdminClient.listSnapshotsAsync(request) .thenApply(r -> r.getSnapshotsList() .stream() .map(BigtableAsyncAdmin::toSnapshotDescription) .collect(Collectors.toList()) ) ); }
@Override public CompletableFuture<List<SnapshotDescription>> listSnapshots() { return CompletableFuture.supplyAsync(() -> { try { return ListSnapshotsRequest.newBuilder() .setParent(getSnapshotClusterName().toString()) .build(); } catch (IOException e) { throw new CompletionException(e); } }).thenCompose(request -> bigtableTableAdminClient.listSnapshotsAsync(request) .thenApply(r -> r.getSnapshotsList() .stream() .map(BigtableAsyncAdmin::toSnapshotDescription) .collect(Collectors.toList()) ) ); }
@Override public CompletableFuture<Void> snapshot(String snapshotName, TableName tableName) { return CompletableFuture.supplyAsync(() -> { try { return SnapshotTableRequest.newBuilder() .setCluster(getSnapshotClusterName().toString()) .setSnapshotId(snapshotName) .setName(options.getInstanceName().toTableNameStr(tableName.getNameAsString())).build(); } catch (IOException e) { throw new CompletionException(e); } }).thenCompose( c -> bigtableTableAdminClient.snapshotTableAsync(c).thenApply(r -> null)); }
@Override public CompletableFuture<Void> snapshot(String snapshotName, TableName tableName) { return CompletableFuture.supplyAsync(() -> { try { return SnapshotTableRequest.newBuilder() .setCluster(getSnapshotClusterName().toString()) .setSnapshotId(snapshotName) .setName(options.getInstanceName().toTableNameStr(tableName.getNameAsString())).build(); } catch (IOException e) { throw new CompletionException(e); } }).thenCompose( c -> bigtableTableAdminClient.snapshotTableAsync(c).thenApply(r -> null)); }
@Override public List<SnapshotDescription> listSnapshots() throws IOException { ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder() .setParent(getSnapshotClusterName().toString()) .build(); ListSnapshotsResponse snapshotList = Futures.getChecked(bigtableTableAdminClient .listSnapshotsAsync(request), IOException.class); List<SnapshotDescription> response = new ArrayList<>(); for (Snapshot snapshot : snapshotList.getSnapshotsList()) { response.add(new SnapshotDescription( snapshot.getName(), TableName.valueOf(snapshot.getSourceTable().getName()))); } return response; }
@Override public List<SnapshotDescription> listSnapshots() throws IOException { ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder() .setParent(getSnapshotClusterName().toString()) .build(); ListSnapshotsResponse snapshotList = Futures.getChecked(bigtableTableAdminClient .listSnapshotsAsync(request), IOException.class); List<SnapshotDescription> response = new ArrayList<>(); for (Snapshot snapshot : snapshotList.getSnapshotsList()) { response.add(new SnapshotDescription( snapshot.getName(), TableName.valueOf(snapshot.getSourceTable().getName()))); } return response; }
/** {@inheritDoc} */ @Override public List<HBaseProtos.SnapshotDescription> listSnapshots() throws IOException { ListSnapshotsRequest request = ListSnapshotsRequest.newBuilder() .setParent(getSnapshotClusterName().toString()) .build(); ListSnapshotsResponse snapshotList = Futures.getChecked( bigtableTableAdminClient.listSnapshotsAsync(request), IOException.class ); List<HBaseProtos.SnapshotDescription> response = new ArrayList<>(); for (Snapshot snapshot : snapshotList.getSnapshotsList()) { BigtableSnapshotName snapshotName = new BigtableSnapshotName(snapshot.getName()); BigtableTableName tableName = new BigtableTableName(snapshot.getSourceTable().getName()); response.add(HBaseProtos.SnapshotDescription.newBuilder() .setName(snapshotName.getSnapshotId()) .setTable(tableName.getTableId()) .setCreationTime(TimeUnit.SECONDS.toMillis(snapshot.getCreateTime().getSeconds())) .build()); } return response; }
/** * Creates a snapshot from an existing table. NOTE: Cloud Bigtable has a cleanup policy * * @param snapshotName * @param tableName * @return * @throws IOException */ protected Operation snapshotTable(String snapshotName, TableName tableName) throws IOException { SnapshotTableRequest.Builder requestBuilder = SnapshotTableRequest.newBuilder() .setCluster(getSnapshotClusterName().toString()) .setSnapshotId(snapshotName) .setName(options.getInstanceName().toTableNameStr(tableName.getNameAsString())); int ttlSecs = configuration.getInt(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_DEFAULT_TTL_SECS_KEY, -1); if (ttlSecs > 0) { requestBuilder.setTtl( Duration.newBuilder().setSeconds(ttlSecs).build() ); } ListenableFuture<Operation> future = bigtableTableAdminClient .snapshotTableAsync(requestBuilder.build()); return Futures.getChecked(future, IOException.class); }
/** * Creates a snapshot from an existing table. NOTE: Cloud Bigtable has a cleanup policy * * @param snapshotName * @param tableName * @return * @throws IOException */ protected Operation snapshotTable(String snapshotName, TableName tableName) throws IOException { SnapshotTableRequest.Builder requestBuilder = SnapshotTableRequest.newBuilder() .setCluster(getSnapshotClusterName().toString()) .setSnapshotId(snapshotName) .setName(options.getInstanceName().toTableNameStr(tableName.getNameAsString())); int ttlSecs = configuration.getInt(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_DEFAULT_TTL_SECS_KEY, -1); if (ttlSecs > 0) { requestBuilder.setTtl( Duration.newBuilder().setSeconds(ttlSecs).build() ); } ListenableFuture<Operation> future = bigtableTableAdminClient .snapshotTableAsync(requestBuilder.build()); return Futures.getChecked(future, IOException.class); }