本文整理汇总了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);
}
示例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());
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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());
}
示例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());
}
示例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"));
}