/** * <p>getBigtableTableAdminClient.</p> * * @return a {@link com.google.cloud.bigtable.grpc.BigtableTableAdminClient} object. * @throws java.io.IOException if any. */ protected BigtableTableAdminClient getBigtableTableAdminClient() throws IOException { return session.getTableAdminClient(); }
/** * <p> * Constructor for AbstractBigtableAdmin. * </p> * @param connection a {@link CommonConnection} object. * @throws IOException */ public AbstractBigtableAdmin(CommonConnection connection) throws IOException { LOG.debug("Creating BigtableAdmin"); configuration = connection.getConfiguration(); options = connection.getOptions(); this.connection = connection; bigtableTableAdminClient = connection.getSession().getTableAdminClient(); disabledTables = connection.getDisabledTables(); bigtableInstanceName = options.getInstanceName(); tableAdapter = new TableAdapter(bigtableInstanceName); tableAdminClientWrapper = connection.getSession().getTableAdminClientWrapper(); String clusterId = configuration.get(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_CLUSTER_ID_KEY, null); if (clusterId != null) { bigtableSnapshotClusterName = bigtableInstanceName.toClusterName(clusterId); } }
/** * <p>getBigtableTableAdminClient.</p> * * @return a {@link com.google.cloud.bigtable.grpc.BigtableTableAdminClient} object. * @throws java.io.IOException if any. */ protected BigtableTableAdminClient getBigtableTableAdminClient() throws IOException { return session.getTableAdminClient(); }
/** * <p>Getter for the field <code>adminClientWrapper</code>.</p> * * @return a {@link BigtableTableAdminClientWrapper} object. * @throws java.io.IOException if any. */ public synchronized IBigtableTableAdminClient getTableAdminClientWrapper() throws IOException { if (adminClientWrapper == null) { adminClientWrapper = new BigtableTableAdminClientWrapper(getTableAdminClient(), options); } return adminClientWrapper; }
@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); } }
public BigtableAsyncAdmin(CommonConnection asyncConnection) throws IOException { LOG.debug("Creating BigtableAsyncAdmin"); this.options = asyncConnection.getOptions(); this.bigtableTableAdminClient = new BigtableTableAdminClient( asyncConnection.getSession().getTableAdminClient()); this.disabledTables = asyncConnection.getDisabledTables(); this.bigtableInstanceName = options.getInstanceName(); this.tableAdapter2x = new TableAdapter2x(options); this.asyncConnection = asyncConnection; this.configuration = asyncConnection.getConfiguration(); String clusterId = configuration.get(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_CLUSTER_ID_KEY, null); if (clusterId != null) { bigtableSnapshotClusterName = bigtableInstanceName.toClusterName(clusterId); } }
public BigtableAsyncAdmin(CommonConnection asyncConnection) throws IOException { LOG.debug("Creating BigtableAsyncAdmin"); this.options = asyncConnection.getOptions(); this.bigtableTableAdminClient = new BigtableTableAdminClient( asyncConnection.getSession().getTableAdminClient()); this.disabledTables = asyncConnection.getDisabledTables(); this.bigtableInstanceName = options.getInstanceName(); this.tableAdapter2x = new TableAdapter2x(options); this.asyncConnection = asyncConnection; this.configuration = asyncConnection.getConfiguration(); String clusterId = configuration.get(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_CLUSTER_ID_KEY, null); if (clusterId != null) { bigtableSnapshotClusterName = bigtableInstanceName.toClusterName(clusterId); } }
/** * <p> * Constructor for AbstractBigtableAdmin. * </p> * @param connection a {@link CommonConnection} object. * @throws IOException */ public AbstractBigtableAdmin(CommonConnection connection) throws IOException { LOG.debug("Creating BigtableAdmin"); configuration = connection.getConfiguration(); options = connection.getOptions(); this.connection = connection; bigtableTableAdminClient = connection.getSession().getTableAdminClient(); disabledTables = connection.getDisabledTables(); bigtableInstanceName = options.getInstanceName(); tableAdapter = new TableAdapter(bigtableInstanceName); String clusterId = configuration.get(BigtableOptionsFactory.BIGTABLE_SNAPSHOT_CLUSTER_ID_KEY, null); if (clusterId != null) { bigtableSnapshotClusterName = bigtableInstanceName.toClusterName(clusterId); } }
@Before public void setup() throws Exception { PipelineOptionsFactory.register(BigtableTestOptions.class); options = TestPipeline.testingPipelineOptions().as(BigtableTestOptions.class); project = options.as(GcpOptions.class).getProject(); bigtableOptions = new Builder() .setProjectId(project) .setInstanceId(options.getInstanceId()) .setUserAgent("apache-beam-test") .build(); session = new BigtableSession( bigtableOptions .toBuilder() .setCredentialOptions( CredentialOptions.credential(options.as(GcpOptions.class).getGcpCredential())) .build()); tableAdminClient = session.getTableAdminClient(); }