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


Java Transport类代码示例

本文整理汇总了Java中org.apache.beam.sdk.util.Transport的典型用法代码示例。如果您正苦于以下问题:Java Transport类的具体用法?Java Transport怎么用?Java Transport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Transport类属于org.apache.beam.sdk.util包,在下文中一共展示了Transport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processElement

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
  Entity entity = c.element();
  EntityBQTransform ebt = EntityBQTransform.newBuilder()
      .setRowSchema(tableSchema().getFields())
      .setStrictCast(strictCast().get())
      .build();

  TableRow row = ebt.toTableRow(entity);

  if (jsTransform().hasTransform()) {
    String rowJson = jsTransform().invoke(
        Transport.getJsonFactory().toString(entity),
        Transport.getJsonFactory().toString(row));
    row = Transport.getJsonFactory().fromString(rowJson, TableRow.class);
  }

  c.output(row);
}
 
开发者ID:cobookman,项目名称:teleport,代码行数:20,代码来源:DatastoreToBq.java

示例2: newCloudResourceManagerClient

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
/**
 * Returns a CloudResourceManager client builder using the specified
 * {@link CloudResourceManagerOptions}.
 */
@VisibleForTesting
static CloudResourceManager.Builder newCloudResourceManagerClient(
    CloudResourceManagerOptions options) {
  Credentials credentials = options.getGcpCredential();
  if (credentials == null) {
    NullCredentialInitializer.throwNullCredentialException();
  }
  return new CloudResourceManager.Builder(Transport.getTransport(), Transport.getJsonFactory(),
      chainHttpRequestInitializer(
          credentials,
          // Do not log 404. It clutters the output and is possibly even required by the caller.
          new RetryHttpRequestInitializer(ImmutableList.of(404))))
      .setApplicationName(options.getAppName())
      .setGoogleClientRequestInitializer(options.getGoogleApiTrace());
}
 
开发者ID:apache,项目名称:beam,代码行数:20,代码来源:GcpOptions.java

示例3: testWithMultipleTraces

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@Test
public void testWithMultipleTraces() throws Exception {
  String[] args = new String[] {STORAGE_GET_AND_LIST_TRACE};
  GcsOptions options = PipelineOptionsFactory.fromArgs(args).as(GcsOptions.class);
  options.setGcpCredential(new TestCredential());

  assertNotNull(options.getGoogleApiTrace());

  Storage.Objects.Get getRequest =
      Transport.newStorageClient(options).build().objects().get("testBucketId", "testObjectId");
  assertEquals("GetTraceDestination", getRequest.get("$trace"));

  Storage.Objects.List listRequest =
      Transport.newStorageClient(options).build().objects().list("testProjectId");
  assertEquals("ListTraceDestination", listRequest.get("$trace"));
}
 
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:GoogleApiDebugOptionsTest.java

示例4: testMatchingAllCalls

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@Test
public void testMatchingAllCalls() throws Exception {
  String[] args = new String[] {STORAGE_TRACE};
  GcsOptions options =
      PipelineOptionsFactory.fromArgs(args).as(GcsOptions.class);
  options.setGcpCredential(new TestCredential());

  assertNotNull(options.getGoogleApiTrace());

  Storage.Objects.Get getRequest =
      Transport.newStorageClient(options).build().objects().get("testBucketId", "testObjectId");
  assertEquals("TraceDestination", getRequest.get("$trace"));

  Storage.Objects.List listRequest =
      Transport.newStorageClient(options).build().objects().list("testProjectId");
  assertEquals("TraceDestination", listRequest.get("$trace"));
}
 
开发者ID:apache,项目名称:beam,代码行数:18,代码来源:GoogleApiDebugOptionsTest.java

示例5: testMatchingAgainstClient

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@Test
public void testMatchingAgainstClient() throws Exception {
  GcsOptions options = PipelineOptionsFactory.as(GcsOptions.class);
  options.setGcpCredential(new TestCredential());
  options.setGoogleApiTrace(new GoogleApiTracer().addTraceFor(
      Transport.newStorageClient(options).build(), "TraceDestination"));

  Storage.Objects.Get getRequest =
      Transport.newStorageClient(options).build().objects().get("testBucketId", "testObjectId");
  assertEquals("TraceDestination", getRequest.get("$trace"));

  Delete deleteRequest = GcpOptions.GcpTempLocationFactory.newCloudResourceManagerClient(
      options.as(CloudResourceManagerOptions.class))
      .build().projects().delete("testProjectId");
  assertNull(deleteRequest.get("$trace"));
}
 
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:GoogleApiDebugOptionsTest.java

示例6: testMatchingAgainstRequestType

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@Test
public void testMatchingAgainstRequestType() throws Exception {
  GcsOptions options = PipelineOptionsFactory.as(GcsOptions.class);
  options.setGcpCredential(new TestCredential());
  options.setGoogleApiTrace(new GoogleApiTracer().addTraceFor(
      Transport.newStorageClient(options).build().objects()
          .get("aProjectId", "aObjectId"), "TraceDestination"));

  Storage.Objects.Get getRequest =
      Transport.newStorageClient(options).build().objects().get("testBucketId", "testObjectId");
  assertEquals("TraceDestination", getRequest.get("$trace"));

  Storage.Objects.List listRequest =
      Transport.newStorageClient(options).build().objects().list("testProjectId");
  assertNull(listRequest.get("$trace"));
}
 
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:GoogleApiDebugOptionsTest.java

示例7: newClient

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@Override
public PubsubClient newClient(
    @Nullable String timestampAttribute, @Nullable String idAttribute, PubsubOptions options)
    throws IOException {
  Pubsub pubsub = new Builder(
      Transport.getTransport(),
      Transport.getJsonFactory(),
      chainHttpRequestInitializer(
          options.getGcpCredential(),
          // Do not log 404. It clutters the output and is possibly even required by the caller.
          new RetryHttpRequestInitializer(ImmutableList.of(404))))
      .setRootUrl(options.getPubsubRootUrl())
      .setApplicationName(options.getAppName())
      .setGoogleClientRequestInitializer(options.getGoogleApiTrace())
      .build();
  return new PubsubJsonClient(timestampAttribute, idAttribute, pubsub);
}
 
开发者ID:apache,项目名称:beam,代码行数:18,代码来源:PubsubJsonClient.java

示例8: setUp

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);

  // A mock transport that lets us mock the API responses.
  MockHttpTransport transport =
      new MockHttpTransport.Builder()
          .setLowLevelHttpRequest(
              new MockLowLevelHttpRequest() {
                @Override
                public LowLevelHttpResponse execute() throws IOException {
                  return response;
                }
              })
          .build();

  // A sample BigQuery API client that uses default JsonFactory and RetryHttpInitializer.
  bigquery =
      new Bigquery.Builder(
              transport, Transport.getJsonFactory(), new RetryHttpRequestInitializer())
          .build();
}
 
开发者ID:apache,项目名称:beam,代码行数:23,代码来源:BigQueryServicesImplTest.java

示例9: PubSubClient

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
public PubSubClient(PubSubDatastoreProperties datastore) {

        Credentials credentials = null;
        if (datastore.serviceAccountFile.getValue() == null) {
            try {
                credentials = GoogleCredentials.getApplicationDefault().createScoped(PubsubScopes.all());
            } catch (IOException e) {
                throw TalendRuntimeException.createUnexpectedException(e);
            }
        } else {
            credentials = createCredentials(datastore);
        }
        this.PROJECT_NAME = datastore.projectName.getValue();
        this.client = new Pubsub.Builder(Transport.getTransport(), Transport.getJsonFactory(),
                chainHttpRequestInitializer(credentials,
                        // Do not log 404. It clutters the output and is possibly even required by the caller.
                        new RetryHttpRequestInitializer(ImmutableList.of(404)))).build();
    }
 
开发者ID:Talend,项目名称:components,代码行数:19,代码来源:PubSubClient.java

示例10: startBundle

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@StartBundle
public void startBundle(DoFn<Read, String>.StartBundleContext c) throws IOException {
  LOG.info("Starting bundle ");
  storage = Transport.newStorageClient(c.getPipelineOptions().as(GCSOptions.class)).build().objects();

  Metrics.counter(WriteBAMFn.class, "Initialized Write Shard Count").inc();
  stopWatch = Stopwatch.createStarted();

  options = c.getPipelineOptions().as(Options.class);

  readCount = 0;
  unmappedReadCount = 0;
  headerInfo = null;
  prevRead = null;
  minAlignment = Long.MAX_VALUE;
  maxAlignment = Long.MIN_VALUE;
  hadOutOfOrder = false;
}
 
开发者ID:googlegenomics,项目名称:dataflow-java,代码行数:19,代码来源:WriteBAMFn.java

示例11: tableSchema

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
private TableSchema tableSchema() throws IOException {
  if (mTableSchema == null) {
    mTableSchema = Transport.getJsonFactory().fromString(
        tableSchemaJson().get(), TableSchema.class);
  }
  return mTableSchema;
}
 
开发者ID:cobookman,项目名称:teleport,代码行数:8,代码来源:DatastoreToBq.java

示例12: apply

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@Override
public TableRow apply(String input) {
  try {
    return Transport.getJsonFactory().fromString(input, TableRow.class);
  } catch (IOException e) {
    throw new RuntimeException("Failed parsing table row json", e);
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:9,代码来源:TopWikipediaSessions.java

示例13: newBigQueryClient

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
/**
 * Returns a BigQuery client builder using the specified {@link BigQueryOptions}.
 */
private static Bigquery.Builder newBigQueryClient(BigQueryOptions options) {
  return new Bigquery.Builder(Transport.getTransport(), Transport.getJsonFactory(),
      chainHttpRequestInitializer(
          options.getGcpCredential(),
          // Do not log 404. It clutters the output and is possibly even required by the caller.
          new RetryHttpRequestInitializer(ImmutableList.of(404))))
      .setApplicationName(options.getAppName())
      .setGoogleClientRequestInitializer(options.getGoogleApiTrace());
}
 
开发者ID:apache,项目名称:beam,代码行数:13,代码来源:ExampleUtils.java

示例14: newPubsubClient

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
/**
 * Returns a Pubsub client builder using the specified {@link PubsubOptions}.
 */
private static Pubsub.Builder newPubsubClient(PubsubOptions options) {
  return new Pubsub.Builder(Transport.getTransport(), Transport.getJsonFactory(),
      chainHttpRequestInitializer(
          options.getGcpCredential(),
          // Do not log 404. It clutters the output and is possibly even required by the caller.
          new RetryHttpRequestInitializer(ImmutableList.of(404))))
      .setRootUrl(options.getPubsubRootUrl())
      .setApplicationName(options.getAppName())
      .setGoogleClientRequestInitializer(options.getGoogleApiTrace());
}
 
开发者ID:apache,项目名称:beam,代码行数:14,代码来源:ExampleUtils.java

示例15: testWhenTracingMatches

import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@Test
public void testWhenTracingMatches() throws Exception {
  String[] args = new String[] {STORAGE_GET_TRACE};
  GcsOptions options = PipelineOptionsFactory.fromArgs(args).as(GcsOptions.class);
  options.setGcpCredential(new TestCredential());
  assertNotNull(options.getGoogleApiTrace());

  Storage.Objects.Get request =
      Transport.newStorageClient(options).build().objects().get("testBucketId", "testObjectId");
  assertEquals("GetTraceDestination", request.get("$trace"));
}
 
开发者ID:apache,项目名称:beam,代码行数:12,代码来源:GoogleApiDebugOptionsTest.java


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