本文整理汇总了Java中com.google.cloud.bigtable.config.CredentialOptions类的典型用法代码示例。如果您正苦于以下问题:Java CredentialOptions类的具体用法?Java CredentialOptions怎么用?Java CredentialOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CredentialOptions类属于com.google.cloud.bigtable.config包,在下文中一共展示了CredentialOptions类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBigtableService
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
/**
* Helper function that either returns the mock Bigtable service supplied by
* {@link #withBigtableService} or creates and returns an implementation that talks to
* {@code Cloud Bigtable}.
*
* <p>Also populate the credentials option from {@link GcpOptions#getGcpCredential()} if the
* default credentials are being used on {@link BigtableOptions}.
*/
@VisibleForTesting
BigtableService getBigtableService(PipelineOptions pipelineOptions) {
if (getBigtableService() != null) {
return getBigtableService();
}
BigtableOptions.Builder bigtableOptions = effectiveUserProvidedBigtableOptions();
bigtableOptions.setUserAgent(pipelineOptions.getUserAgent());
if (bigtableOptions.build().getCredentialOptions().getCredentialType()
== CredentialOptions.CredentialType.DefaultCredentials) {
bigtableOptions.setCredentialOptions(
CredentialOptions.credential(
pipelineOptions.as(GcpOptions.class).getGcpCredential()));
}
// Default option that should be forced
bigtableOptions.setUseCachedDataPool(true);
return new BigtableServiceImpl(bigtableOptions.build());
}
示例2: setup
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
@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();
}
示例3: testUsePipelineOptionsCredentialsIfNotSpecifiedInBigtableOptions
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
/** 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());
}
示例4: testDontUsePipelineOptionsCredentialsIfSpecifiedInBigtableOptions
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
/** Tests that credentials are not used from PipelineOptions if supplied by BigtableOptions. */
@Test
public void testDontUsePipelineOptionsCredentialsIfSpecifiedInBigtableOptions() throws Exception {
BigtableOptions options = BIGTABLE_OPTIONS.toBuilder()
.setCredentialOptions(CredentialOptions.nullCredential())
.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.None,
readService.getBigtableOptions().getCredentialOptions().getCredentialType());
assertEquals(CredentialType.None,
writeService.getBigtableOptions().getCredentialOptions().getCredentialType());
}
示例5: call
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
@Override
public BigtableConnection call() throws Exception {
final CredentialOptions credentials = this.credentials.build();
final RetryOptions retryOptions = new RetryOptions.Builder()
.addStatusToRetryOn(Status.Code.UNKNOWN)
.setAllowRetriesWithoutTimestamp(true)
.build();
final BulkOptions bulkOptions = batchSize
.map(integer -> new BulkOptions.Builder().setBulkMaxRowKeyCount(integer).build())
.orElseGet(() -> new BulkOptions.Builder().build());
final BigtableOptions options = new BigtableOptions.Builder()
.setProjectId(project)
.setInstanceId(instance)
.setUserAgent(USER_AGENT)
.setDataChannelCount(64)
.setCredentialOptions(credentials)
.setRetryOptions(retryOptions)
.setBulkOptions(bulkOptions)
.build();
final BigtableSession session = new BigtableSession(options);
final BigtableTableAdminClient adminClient =
new BigtableTableTableAdminClientImpl(async, session.getTableAdminClient(), project,
instance);
final BigtableMutator mutator =
new BigtableMutatorImpl(async, session, disableBulkMutations, flushIntervalSeconds);
final BigtableDataClient client =
new BigtableDataClientImpl(async, session, mutator, project, instance);
return new GrpcBigtableConnection(async, project, instance, session, mutator, adminClient,
client);
}
示例6: build
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
@Override
public CredentialOptions build() throws Exception {
// XXX: You have to leave the input stream open for BigtableSession to use it.
// This does 'leak' an input stream, but it's only once, so we'll live with it for now.
// Reported here: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/issues/534
return CredentialOptions.jsonCredentials(Files.newInputStream(path));
}
示例7: shouldBuildDefaultOptions
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
@Test
public void shouldBuildDefaultOptions() throws Exception {
final DefaultCredentialsBuilder credentialsBuilder = new DefaultCredentialsBuilder();
final CredentialOptions credentialOptions = credentialsBuilder.build();
final CredentialOptions.CredentialType type = credentialOptions.getCredentialType();
assertThat(type, is(CredentialOptions.CredentialType.DefaultCredentials));
}
示例8: build
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
@Override
public CredentialOptions build() {
return CredentialOptions.credential(new ComputeEngineCredentials());
}
示例9: build
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
@Override
public CredentialOptions build() {
return CredentialOptions.p12Credential(serviceAccount, keyFile);
}
示例10: build
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
@Override
public CredentialOptions build() {
return CredentialOptions.defaultCredentials();
}
示例11: build
import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
public CredentialOptions build() throws Exception;