Search in sources :

Example 6 with GcsUtil

use of org.apache.beam.sdk.extensions.gcp.util.GcsUtil in project beam by apache.

the class DataflowPipelineTranslatorTest method buildPipelineOptions.

private static DataflowPipelineOptions buildPipelineOptions() throws IOException {
    GcsUtil mockGcsUtil = mock(GcsUtil.class);
    when(mockGcsUtil.expand(any(GcsPath.class))).then(invocation -> ImmutableList.of((GcsPath) invocation.getArguments()[0]));
    when(mockGcsUtil.bucketAccessible(any(GcsPath.class))).thenReturn(true);
    DataflowPipelineOptions options = PipelineOptionsFactory.as(DataflowPipelineOptions.class);
    options.setRunner(DataflowRunner.class);
    options.setGcpCredential(new TestCredential());
    options.setJobName("some-job-name");
    options.setProject("some-project");
    options.setRegion("some-region");
    options.setTempLocation(GcsPath.fromComponents("somebucket", "some/path").toString());
    options.setFilesToStage(new ArrayList<>());
    options.setDataflowClient(buildMockDataflow(new IsValidCreateRequest()));
    options.setGcsUtil(mockGcsUtil);
    // Enable the FileSystems API to know about gs:// URIs in this test.
    FileSystems.setDefaultPipelineOptions(options);
    return options;
}
Also used : TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) DataflowPipelineOptions(org.apache.beam.runners.dataflow.options.DataflowPipelineOptions) GcsPath(org.apache.beam.sdk.extensions.gcp.util.gcsfs.GcsPath) GcsUtil(org.apache.beam.sdk.extensions.gcp.util.GcsUtil)

Example 7 with GcsUtil

use of org.apache.beam.sdk.extensions.gcp.util.GcsUtil in project beam by apache.

the class BatchStatefulParDoOverridesTest method buildPipelineOptions.

private static DataflowPipelineOptions buildPipelineOptions(String... args) throws IOException {
    GcsUtil mockGcsUtil = mock(GcsUtil.class);
    when(mockGcsUtil.expand(any(GcsPath.class))).then(invocation -> ImmutableList.of((GcsPath) invocation.getArguments()[0]));
    when(mockGcsUtil.bucketAccessible(any(GcsPath.class))).thenReturn(true);
    DataflowPipelineOptions options = PipelineOptionsFactory.fromArgs(args).as(DataflowPipelineOptions.class);
    options.setRunner(DataflowRunner.class);
    options.setGcpCredential(new TestCredential());
    options.setJobName("some-job-name");
    options.setProject("some-project");
    options.setRegion("some-region");
    options.setTempLocation(GcsPath.fromComponents("somebucket", "some/path").toString());
    options.setFilesToStage(new ArrayList<>());
    options.setGcsUtil(mockGcsUtil);
    // Enable the FileSystems API to know about gs:// URIs in this test.
    FileSystems.setDefaultPipelineOptions(options);
    return options;
}
Also used : TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) DataflowPipelineOptions(org.apache.beam.runners.dataflow.options.DataflowPipelineOptions) GcsPath(org.apache.beam.sdk.extensions.gcp.util.gcsfs.GcsPath) GcsUtil(org.apache.beam.sdk.extensions.gcp.util.GcsUtil)

Aggregations

GcsUtil (org.apache.beam.sdk.extensions.gcp.util.GcsUtil)7 GcsPath (org.apache.beam.sdk.extensions.gcp.util.gcsfs.GcsPath)6 ArrayList (java.util.ArrayList)2 List (java.util.List)2 DataflowPipelineOptions (org.apache.beam.runners.dataflow.options.DataflowPipelineOptions)2 TestCredential (org.apache.beam.sdk.extensions.gcp.auth.TestCredential)2 ImmutableList (org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList)2 StorageObject (com.google.api.services.storage.model.StorageObject)1 File (java.io.File)1 IOException (java.io.IOException)1 URI (java.net.URI)1 SeekableByteChannel (java.nio.channels.SeekableByteChannel)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Pipeline (org.apache.beam.sdk.Pipeline)1 PipelineResult (org.apache.beam.sdk.PipelineResult)1 State (org.apache.beam.sdk.PipelineResult.State)1 GcsOptions (org.apache.beam.sdk.extensions.gcp.options.GcsOptions)1 MatchResult (org.apache.beam.sdk.io.fs.MatchResult)1 Metadata (org.apache.beam.sdk.io.fs.MatchResult.Metadata)1