@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
/** * Gets metadata information about the specified table. * * <p>Sample code: * * <pre><code> * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) { * TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); * Table response = baseBigtableTableAdminClient.getTable(name.toString()); * } * </code></pre> * * @param name The unique name of the requested table. Values are of the form * `projects/<project>/instances/<instance>/tables/<table>`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Table getTable(String name) { GetTableRequest request = GetTableRequest.newBuilder().setName(name).build(); return getTable(request); }
/** * Gets metadata information about the specified table. * * <p>Sample code: * * <pre><code> * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) { * TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); * Table response = baseBigtableTableAdminClient.getTable(name); * } * </code></pre> * * @param name The unique name of the requested table. Values are of the form * `projects/<project>/instances/<instance>/tables/<table>`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Table getTable(TableName name) { GetTableRequest request = GetTableRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return getTable(request); }
private ApiFuture<Table> getTableAsync( String tableId, com.google.bigtable.admin.v2.Table.View view) { GetTableRequest request = GetTableRequest.newBuilder().setName(getTableName(tableId)).setView(view).build(); return transformToTableResponse(this.stub.getTableCallable().futureCall(request)); }
@Test public void testGetTable() { // Setup GetTableRequest expectedRequest = GetTableRequest.newBuilder() .setName(TABLE_NAME.toString()) .setView(View.SCHEMA_VIEW) .build(); com.google.bigtable.admin.v2.Table expectedResponse = com.google.bigtable.admin.v2.Table.newBuilder().setName(TABLE_NAME.toString()).build(); Mockito.when(mockGetTableCallable.futureCall(expectedRequest)) .thenReturn(ApiFutures.immediateFuture(expectedResponse)); // Execute Table actualResult = adminClient.getTable(TABLE_ID); // Verify assertThat(actualResult).isEqualTo(Table.fromProto(expectedResponse)); }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
/** {@inheritDoc} */ @Override public ListenableFuture<Table> getTableAsync(String tableId) { GetTableRequest requestProto = GetTableRequest.newBuilder() .setName(instanceName.toTableNameStr(tableId)) .build(); return Futures.transform(adminClient.getTableAsync(requestProto), new Function<com.google.bigtable.admin.v2.Table, Table>() { @Override public Table apply(com.google.bigtable.admin.v2.Table tableProto) { return Table.fromProto(tableProto); } }, MoreExecutors.directExecutor()); }
/** * Gets metadata information about the specified table. * * <p>Sample code: * * <pre><code> * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) { * TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); * Table response = baseBigtableTableAdminClient.getTable(name.toString()); * } * </code></pre> * * @param name The unique name of the requested table. Values are of the form * `projects/<project>/instances/<instance>/tables/<table>`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Table getTable(String name) { GetTableRequest request = GetTableRequest.newBuilder().setName(name).build(); return getTable(request); }
/** {@inheritDoc} */ @Override public Table getTable(String tableId) { GetTableRequest requestProto = GetTableRequest.newBuilder() .setName(instanceName.toTableNameStr(tableId)) .build(); return Table.fromProto(adminClient.getTable(requestProto)); }
/** * Gets metadata information about the specified table. * * <p>Sample code: * * <pre><code> * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) { * TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); * Table response = baseBigtableTableAdminClient.getTable(name); * } * </code></pre> * * @param name The unique name of the requested table. Values are of the form * `projects/<project>/instances/<instance>/tables/<table>`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Table getTable(TableName name) { GetTableRequest request = GetTableRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return getTable(request); }
@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 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); } }
/** {@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); } }
private ApiFuture<Table> getTableAsync( String tableId, com.google.bigtable.admin.v2.Table.View view) { GetTableRequest request = GetTableRequest.newBuilder().setName(getTableName(tableId)).setView(view).build(); return transformToTableResponse(this.stub.getTableCallable().futureCall(request)); }
/** Helper function to get a table. */ private Table getTable(String tableName) { GetTableRequest.Builder getTableRequestBuilder = GetTableRequest.newBuilder().setName(tableName); return tableAdminClient.getTable(getTableRequestBuilder.build()); }
/** {@inheritDoc} */ @Override public CompletableFuture<TableDescriptor> getDescriptor(TableName tableName) { if (tableName == null) { return CompletableFuture.completedFuture(null); } GetTableRequest request = GetTableRequest .newBuilder() .setName(bigtableInstanceName.toTableNameStr(tableName.getNameAsString())) .build(); return bigtableTableAdminClient.getTableAsync(request).handle((resp, ex) -> { if (ex != null) { if (Status.fromThrowable(ex).getCode() == Status.Code.NOT_FOUND) { throw new CompletionException(new TableNotFoundException(tableName)); } else { throw new CompletionException(ex); } } else { return tableAdapter2x.adapt(resp); } }); }
/** {@inheritDoc} */ @Override public CompletableFuture<TableDescriptor> getDescriptor(TableName tableName) { if (tableName == null) { return CompletableFuture.completedFuture(null); } GetTableRequest request = GetTableRequest .newBuilder() .setName(bigtableInstanceName.toTableNameStr(tableName.getNameAsString())) .build(); return bigtableTableAdminClient.getTableAsync(request).handle((resp, ex) -> { if (ex != null) { if (Status.fromThrowable(ex).getCode() == Status.Code.NOT_FOUND) { throw new CompletionException(new TableNotFoundException(tableName)); } else { throw new CompletionException(ex); } } else { return tableAdapter2x.adapt(resp); } }); }