Search in sources :

Example 6 with JobControllerClient

use of com.google.cloud.dataproc.v1.JobControllerClient in project java-pubsublite-spark by googleapis.

the class SampleTestBase method runDataprocJob.

protected Job runDataprocJob(SparkJob.Builder sparkJobBuilder) throws Exception {
    String myEndpoint = String.format("%s-dataproc.googleapis.com:443", cloudRegion.value());
    JobControllerSettings jobControllerSettings = JobControllerSettings.newBuilder().setEndpoint(myEndpoint).build();
    try (JobControllerClient jobControllerClient = JobControllerClient.create(jobControllerSettings)) {
        JobPlacement jobPlacement = JobPlacement.newBuilder().setClusterName(clusterName).build();
        sparkJobBuilder.addJarFileUris(String.format("gs://%s/%s", bucketName, sampleJarNameInGCS)).addJarFileUris(String.format("gs://%s/%s", bucketName, connectorJarNameInGCS));
        Job job = Job.newBuilder().setPlacement(jobPlacement).setSparkJob(sparkJobBuilder.build()).build();
        OperationFuture<Job, JobMetadata> submitJobAsOperationAsyncRequest = jobControllerClient.submitJobAsOperationAsync(projectId.value(), cloudRegion.value(), job);
        return submitJobAsOperationAsyncRequest.get();
    }
}
Also used : JobControllerSettings(com.google.cloud.dataproc.v1.JobControllerSettings) JobMetadata(com.google.cloud.dataproc.v1.JobMetadata) JobPlacement(com.google.cloud.dataproc.v1.JobPlacement) JobControllerClient(com.google.cloud.dataproc.v1.JobControllerClient) SparkJob(com.google.cloud.dataproc.v1.SparkJob) Job(com.google.cloud.dataproc.v1.Job)

Aggregations

Job (com.google.cloud.dataproc.v1.Job)4 JobControllerClient (com.google.cloud.dataproc.v1.JobControllerClient)4 JobControllerSettings (com.google.cloud.dataproc.v1.JobControllerSettings)4 JobMetadata (com.google.cloud.dataproc.v1.JobMetadata)4 JobPlacement (com.google.cloud.dataproc.v1.JobPlacement)4 Blob (com.google.cloud.storage.Blob)3 Storage (com.google.cloud.storage.Storage)3 ExecutionException (java.util.concurrent.ExecutionException)3 Matcher (java.util.regex.Matcher)3 CredentialsProvider (com.google.api.gax.core.CredentialsProvider)2 FixedCredentialsProvider (com.google.api.gax.core.FixedCredentialsProvider)2 SparkJob (com.google.cloud.dataproc.v1.SparkJob)2 JobControllerClient (com.google.cloud.dataproc.v1beta2.JobControllerClient)2 Cluster (com.google.cloud.dataproc.v1.Cluster)1 ClusterConfig (com.google.cloud.dataproc.v1.ClusterConfig)1 ClusterControllerClient (com.google.cloud.dataproc.v1.ClusterControllerClient)1 ClusterControllerSettings (com.google.cloud.dataproc.v1.ClusterControllerSettings)1 ClusterOperationMetadata (com.google.cloud.dataproc.v1.ClusterOperationMetadata)1 HadoopJob (com.google.cloud.dataproc.v1.HadoopJob)1 InstanceGroupConfig (com.google.cloud.dataproc.v1.InstanceGroupConfig)1