本文整理汇总了Java中org.apache.beam.sdk.util.Transport类的典型用法代码示例。如果您正苦于以下问题:Java Transport类的具体用法?Java Transport怎么用?Java Transport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transport类属于org.apache.beam.sdk.util包,在下文中一共展示了Transport类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: testWhenTracingDoesNotMatch
import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@Test
public void testWhenTracingDoesNotMatch() 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.List request =
Transport.newStorageClient(options).build().objects().list("testProjectId");
assertNull(request.get("$trace"));
}
开发者ID:apache,项目名称:beam,代码行数:13,代码来源:GoogleApiDebugOptionsTest.java
示例17: newBigqueryClient
import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@VisibleForTesting
Bigquery newBigqueryClient(String applicationName) {
HttpTransport transport = Transport.getTransport();
JsonFactory jsonFactory = Transport.getJsonFactory();
Credentials credential = getDefaultCredential();
return new Bigquery.Builder(transport, jsonFactory, new HttpCredentialsAdapter(credential))
.setApplicationName(applicationName)
.build();
}
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:BigqueryMatcher.java
示例18: buildJobMetrics
import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
private JobMetrics buildJobMetrics(List<MetricUpdate> metricList) {
JobMetrics jobMetrics = new JobMetrics();
jobMetrics.setMetrics(metricList);
// N.B. Setting the factory is necessary in order to get valid JSON.
jobMetrics.setFactory(Transport.getJsonFactory());
return jobMetrics;
}
开发者ID:apache,项目名称:beam,代码行数:8,代码来源:TestDataflowRunnerTest.java
示例19: openBAMTest
import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
@Test
public void openBAMTest() throws IOException {
GCSOptions popts = PipelineOptionsFactory.create().as(GCSOptions.class);
final Storage.Objects storageClient = Transport.newStorageClient(popts).build().objects();
SamReader samReader = BAMIO.openBAM(storageClient, TEST_BAM_FNAME, ValidationStringency.DEFAULT_STRINGENCY);
SAMRecordIterator iterator = samReader.query("1", 550000, 560000, false);
int readCount = 0;
while (iterator.hasNext()) {
iterator.next();
readCount++;
}
Assert.assertEquals("Unexpected count of unmapped reads",
EXPECTED_UNMAPPED_READS_COUNT, readCount);
}
开发者ID:googlegenomics,项目名称:dataflow-java,代码行数:16,代码来源:BAMIOITCase.java
示例20: deleteOutput
import org.apache.beam.sdk.util.Transport; //导入依赖的package包/类
/**
* Delete single file test output.
*
* @param outputPath path to the output file to be deleted.
* @throws Exception
*/
public void deleteOutput(String outputPath) throws Exception {
// boilerplate
GcsPath path = GcsPath.fromUri(outputPath);
GcsOptions gcsOptions = popts.as(GcsOptions.class);
Storage storage = Transport.newStorageClient(gcsOptions).build();
// do the actual work
storage.objects().delete(path.getBucket(), path.getObject()).execute();
}
开发者ID:googlegenomics,项目名称:dataflow-java,代码行数:15,代码来源:IntegrationTestHelper.java
注:本文中的org.apache.beam.sdk.util.Transport类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论