@Deprecated public Builder() { options = new BigtableOptions(); options.appProfileId = BIGTABLE_APP_PROFILE_DEFAULT; // Optional configuration for hosts - useful for the Bigtable team, more than anything else. options.dataHost = BIGTABLE_DATA_HOST_DEFAULT; options.adminHost = BIGTABLE_ADMIN_HOST_DEFAULT; options.port = BIGTABLE_PORT_DEFAULT; options.dataChannelCount = BIGTABLE_DATA_CHANNEL_COUNT_DEFAULT; options.usePlaintextNegotiation = false; options.useCachedDataPool = false; options.retryOptions = new RetryOptions.Builder().build(); options.callOptionsConfig = new CallOptionsConfig.Builder().build(); // CredentialOptions.defaultCredentials() gets credentials from well known locations, such as // the Google Compute Engine metadata service or gcloud configuration in other environments. A // user can also override the default behavior with P12 or JSON configuration. options.credentialOptions = CredentialOptions.defaultCredentials(); options.useBatch = false; }
LOG.debug("Using default credentials."); builder.setCredentialOptions( CredentialOptions.defaultCredentials());
LOG.debug("Using default credentials."); builder.setCredentialOptions( CredentialOptions.defaultCredentials());
/** Tests that credentials are used from PipelineOptions if not supplied by BigtableOptions. */ @Test public void testUsePipelineOptionsCredentialsIfNotSpecifiedInBigtableOptions() throws Exception { BigtableOptions options = BIGTABLE_OPTIONS .toBuilder() .setCredentialOptions(CredentialOptions.defaultCredentials()) .build(); GcpOptions pipelineOptions = PipelineOptionsFactory.as(GcpOptions.class); pipelineOptions.setGcpCredential(new TestCredential()); BigtableService readService = BigtableIO.read() .withBigtableOptions(options) .withTableId("TEST-TABLE") .getBigtableConfig() .getBigtableService(pipelineOptions); BigtableService writeService = BigtableIO.write() .withBigtableOptions(options) .withTableId("TEST-TABLE") .getBigtableConfig() .getBigtableService(pipelineOptions); assertEquals( CredentialType.SuppliedCredentials, readService.getBigtableOptions().getCredentialOptions().getCredentialType()); assertEquals( CredentialType.SuppliedCredentials, writeService.getBigtableOptions().getCredentialOptions().getCredentialType()); }