/** {@inheritDoc} */ @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .add("project", options.getProjectId()) .add("instance", options.getInstanceId()) .add("adminHost", options.getAdminHost()) .toString(); }
/** {@inheritDoc} */ @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .add("project", options.getProjectId()) .add("instance", options.getInstanceId()) .add("adminHost", options.getAdminHost()) .toString(); }
/** {@inheritDoc} */ @Override public String toString() { return MoreObjects.toStringHelper(AbstractBigtableTable.class) .add("hashCode", "0x" + Integer.toHexString(hashCode())) .add("project", options.getProjectId()) .add("instance", options.getInstanceId()) .add("table", tableName.getNameAsString()) .add("host", options.getDataHost()) .toString(); }
/** {@inheritDoc} */ @Override public String toString() { return MoreObjects.toStringHelper(AbstractBigtableTable.class) .add("hashCode", "0x" + Integer.toHexString(hashCode())) .add("project", options.getProjectId()) .add("instance", options.getInstanceId()) .add("table", tableName.getNameAsString()) .add("host", options.getDataHost()) .toString(); }
/** {@inheritDoc} */ @Override public String toString() { return MoreObjects.toStringHelper(AbstractBigtableConnection.class) .add("project", options.getProjectId()) .add("instance", options.getInstanceId()) .add("dataHost", options.getDataHost()) .add("tableAdminHost", options.getAdminHost()) .toString(); }
/** {@inheritDoc} */ @Override public String toString() { return MoreObjects.toStringHelper(AbstractBigtableConnection.class) .add("project", options.getProjectId()) .add("instance", options.getInstanceId()) .add("dataHost", options.getDataHost()) .add("tableAdminHost", options.getAdminHost()) .toString(); }
public BigtableDataClientWrapper(BigtableDataClient bigtableDataClient, BigtableOptions options) { this.delegate = bigtableDataClient; this.requestContext = RequestContext.create(options.getProjectId(), options.getInstanceId(), options.getAppProfileId()); }
/** * <p>modifyColumns.</p> * * @param tableName a {@link org.apache.hadoop.hbase.TableName} object. * @param modifications a {@link ModifyTableBuilder} object. */ private CompletableFuture<Void> modifyColumns(TableName tableName, ModifyTableBuilder modifications) { ModifyColumnFamiliesRequest request = modifications.build(); return bigtableTableAdminClient .modifyColumnFamilyAsync(request.toProto(options.getProjectId(), options.getInstanceId())) .thenApply(r -> null); }
private IOException logAndCreateIOException(String type, byte[] row, Throwable t) { LOG.error("Encountered exception when executing " + type + ".", t); return new DoNotRetryIOException( makeGenericExceptionMessage( type, options.getProjectId(), tableName.getQualifierAsString(), row), t); }
private IOException logAndCreateIOException(String type, byte[] row, Throwable t) { LOG.error("Encountered exception when executing " + type + ".", t); return new DoNotRetryIOException( makeGenericExceptionMessage( type, options.getProjectId(), tableName.getQualifierAsString(), row), t); }
/** * Snapshot operations need various aspects of a {@link BigtableClusterName}. This method gets a * clusterId from either a lookup (projectId and instanceId translate to a single clusterId when * an instance has only one cluster). */ public synchronized BigtableClusterName getClusterName() throws IOException { if (this.clusterName == null) { try (BigtableClusterUtilities util = new BigtableClusterUtilities(options)) { ListClustersResponse clusters = util.getClusters(); Preconditions.checkState(clusters.getClustersCount() == 1, String.format( "Project '%s' / Instance '%s' has %d clusters. There must be exactly 1 for this operation to work.", options.getProjectId(), options.getInstanceId(), clusters.getClustersCount())); clusterName = new BigtableClusterName(clusters.getClusters(0).getName()); } catch (GeneralSecurityException e) { throw new IOException("Could not get cluster Id.", e); } } return clusterName; }
void validate() { checkArgument( getTableId() != null && (!getTableId().isAccessible() || !getTableId().get().isEmpty()), "Could not obtain Bigtable table id"); checkArgument( (getProjectId() != null && (!getProjectId().isAccessible() || !getProjectId().get().isEmpty())) || (getBigtableOptions() != null && getBigtableOptions().getProjectId() != null && !getBigtableOptions().getProjectId().isEmpty()), "Could not obtain Bigtable project id"); checkArgument( (getInstanceId() != null && (!getInstanceId().isAccessible() || !getInstanceId().get().isEmpty())) || (getBigtableOptions() != null && getBigtableOptions().getInstanceId() != null && !getBigtableOptions().getInstanceId().isEmpty()), "Could not obtain Bigtable instance id"); }
/** {@inheritDoc} */ @Override public CompletableFuture<Void> createTable(TableDescriptor desc, byte[][] splitKeys) { // wraps exceptions in a CF (CompletableFuture). No null check here on desc to match Hbase impl if (desc.getTableName() == null) { return failedFuture(new IllegalArgumentException("TableName cannot be null")); } CreateTableRequest request = TableAdapter2x.adapt(desc, splitKeys); return bigtableTableAdminClient.createTableAsync( request.toProto(options.getProjectId(), options.getInstanceId())) .handle((resp, ex) -> { if (ex != null) { throw new CompletionException( AbstractBigtableAdmin.convertToTableExistsException(desc.getTableName(), ex)); } return null; }); }
/** * <p>Constructor for HBaseRequestAdapter.</p> * * @param options a {@link BigtableOptions} object. * @param tableName a {@link TableName} object. * @param mutationAdapters a {@link MutationAdapters} object. */ public HBaseRequestAdapter(BigtableOptions options, TableName tableName, MutationAdapters mutationAdapters) { this(tableName, options.getInstanceName().toTableName(tableName.getQualifierAsString()), mutationAdapters, RequestContext.create( InstanceName.of(options.getProjectId(), options.getInstanceId()), options.getAppProfileId() )); }
/** * <p>Constructor for HBaseRequestAdapter.</p> * * @param options a {@link BigtableOptions} object. * @param tableName a {@link TableName} object. * @param mutationAdapters a {@link MutationAdapters} object. */ public HBaseRequestAdapter(BigtableOptions options, TableName tableName, MutationAdapters mutationAdapters) { this(tableName, options.getInstanceName().toTableName(tableName.getQualifierAsString()), mutationAdapters, RequestContext.create( InstanceName.of(options.getProjectId(), options.getInstanceId()), options.getAppProfileId() )); }
/** * Constructed by BigtableConnection * * @param bigtableConnection a {@link org.apache.hadoop.hbase.client.AbstractBigtableConnection} object. * @param hbaseAdapter a {@link com.google.cloud.bigtable.hbase.adapters.HBaseRequestAdapter} object. */ public AbstractBigtableTable(AbstractBigtableConnection bigtableConnection, HBaseRequestAdapter hbaseAdapter) { this.bigtableConnection = bigtableConnection; BigtableSession session = bigtableConnection.getSession(); this.options = session.getOptions(); this.client = session.getDataClient(); this.clientWrapper = session.getClientWrapper(); this.hbaseAdapter = hbaseAdapter; this.tableName = hbaseAdapter.getTableName(); this.requestContext = RequestContext.create( InstanceName.of(options.getProjectId(), options.getInstanceId()), options.getAppProfileId()); }
/** * Constructed by BigtableConnection * * @param bigtableConnection a {@link org.apache.hadoop.hbase.client.AbstractBigtableConnection} object. * @param hbaseAdapter a {@link com.google.cloud.bigtable.hbase.adapters.HBaseRequestAdapter} object. */ public AbstractBigtableTable(AbstractBigtableConnection bigtableConnection, HBaseRequestAdapter hbaseAdapter) { this.bigtableConnection = bigtableConnection; BigtableSession session = bigtableConnection.getSession(); this.options = session.getOptions(); this.client = session.getDataClient(); this.clientWrapper = session.getClientWrapper(); this.hbaseAdapter = hbaseAdapter; this.tableName = hbaseAdapter.getTableName(); this.requestContext = RequestContext.create( InstanceName.of(options.getProjectId(), options.getInstanceId()), options.getAppProfileId()); }
@Test public void testWriteBuildsCorrectly() { BigtableIO.Write write = BigtableIO.write() .withBigtableOptions(BIGTABLE_OPTIONS) .withTableId("table") .withInstanceId("instance") .withProjectId("project"); assertEquals("table", write.getBigtableConfig().getTableId().get()); assertEquals("options_project", write.getBigtableOptions().getProjectId()); assertEquals("options_instance", write.getBigtableOptions().getInstanceId()); assertEquals("instance", write.getBigtableConfig().getInstanceId().get()); assertEquals("project", write.getBigtableConfig().getProjectId().get()); }
@Test public void testReadBuildsCorrectly() { BigtableIO.Read read = BigtableIO.read() .withBigtableOptions(BIGTABLE_OPTIONS) .withTableId("table") .withInstanceId("instance") .withProjectId("project") .withBigtableOptionsConfigurator(PORT_CONFIGURATOR); assertEquals("options_project", read.getBigtableOptions().getProjectId()); assertEquals("options_instance", read.getBigtableOptions().getInstanceId()); assertEquals("instance", read.getBigtableConfig().getInstanceId().get()); assertEquals("project", read.getBigtableConfig().getProjectId().get()); assertEquals("table", read.getTableId()); assertEquals(PORT_CONFIGURATOR, read.getBigtableConfig().getBigtableOptionsConfigurator()); }
@Test public void testGetBigtableServiceWithConfigurator() { SerializableFunction<BigtableOptions.Builder, BigtableOptions.Builder> configurator = (SerializableFunction<BigtableOptions.Builder, BigtableOptions.Builder>) input -> input .setInstanceId(INSTANCE_ID.get() + INSTANCE_ID.get()) .setProjectId(PROJECT_ID.get() + PROJECT_ID.get()) .setBulkOptions(new BulkOptions.Builder().setUseBulkApi(true).build()); BigtableService service = config .withProjectId(PROJECT_ID) .withInstanceId(INSTANCE_ID) .withBigtableOptionsConfigurator(configurator) .getBigtableService(PipelineOptionsFactory.as(GcpOptions.class)); assertEquals(PROJECT_ID.get(), service.getBigtableOptions().getProjectId()); assertEquals(INSTANCE_ID.get(), service.getBigtableOptions().getInstanceId()); assertEquals(true, service.getBigtableOptions().getBulkOptions().useBulkApi()); }