当前位置: 首页>>代码示例>>Java>>正文


Java CredentialOptions类代码示例

本文整理汇总了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());
}
 
开发者ID:apache,项目名称:beam,代码行数:31,代码来源:BigtableConfig.java

示例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();
}
 
开发者ID:apache,项目名称:beam,代码行数:23,代码来源:BigtableWriteIT.java

示例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());
}
 
开发者ID:apache,项目名称:beam,代码行数:24,代码来源:BigtableIOTest.java

示例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());
}
 
开发者ID:apache,项目名称:beam,代码行数:24,代码来源:BigtableIOTest.java

示例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);
}
 
开发者ID:spotify,项目名称:heroic,代码行数:39,代码来源:BigtableConnectionBuilder.java

示例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));
}
 
开发者ID:spotify,项目名称:heroic,代码行数:8,代码来源:JsonCredentialsBuilder.java

示例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));
}
 
开发者ID:spotify,项目名称:heroic,代码行数:8,代码来源:DefaultCredentialsBuilderTest.java

示例8: build

import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
@Override
public CredentialOptions build() {
    return CredentialOptions.credential(new ComputeEngineCredentials());
}
 
开发者ID:spotify,项目名称:heroic,代码行数:5,代码来源:ComputeEngineCredentialsBuilder.java

示例9: build

import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
@Override
public CredentialOptions build() {
    return CredentialOptions.p12Credential(serviceAccount, keyFile);
}
 
开发者ID:spotify,项目名称:heroic,代码行数:5,代码来源:ServiceAccountCredentialsBuilder.java

示例10: build

import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
@Override
public CredentialOptions build() {
  return CredentialOptions.defaultCredentials();
}
 
开发者ID:spotify,项目名称:heroic,代码行数:5,代码来源:DefaultCredentialsBuilder.java

示例11: build

import com.google.cloud.bigtable.config.CredentialOptions; //导入依赖的package包/类
public CredentialOptions build() throws Exception; 
开发者ID:spotify,项目名称:heroic,代码行数:2,代码来源:CredentialsBuilder.java


注:本文中的com.google.cloud.bigtable.config.CredentialOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。