How to Start a Job in Google Dataflow

Java Client Library

package com.wordpress.simplesassim.gcp;

import com.google.dataflow.v1beta3.Job;
import com.google.dataflow.v1beta3.JobState;
import com.google.dataflow.v1beta3.JobsV1Beta3Client;
import com.google.dataflow.v1beta3.UpdateJobRequest;

public class GcpSample {

  public static void main(String... args) throws Exception {
    JobsV1Beta3Client client = JobsV1Beta3Client.create();

    Job job = Job.newBuilder().setRequestedState(JobState.JOB_STATE_RUNNING).build(); // for FlexRS jobs only

    UpdateJobRequest req = UpdateJobRequest.newBuilder().setProjectId("sampleproject").setJobId("samplejobid").setJob(job).build(); // location defaults to "us-central1"

    client.updateJob(req);

    client.close();
  }

}

Python Client Library

from google.cloud import dataflow_v1beta3

client = dataflow_v1beta3.JobsV1Beta3Client()

job = {
  'requested_state': 'JOB_STATE_RUNNING' # for FlexRS jobs only
}

req = dataflow_v1beta3.UpdateJobRequest(project_id = 'sampleproject', job_id = 'samplejobid', job = job) # 'location' defaults to 'us-central1'

client.update_job(req)

CLI

N/A.

Terraform Provider

N/A.

Published by:

Fernando Ribeiro

Experienced tech executive with a 24-year track record in enterprise computing. Leading AWS's professional services application modernization division in Brazil. He's held diverse roles including management, solutions architecture, sales consultancy, and full-stack development at major players like Oracle, Red Hat, and IBM. Fernando also contributes to open source and writes about emerging technologies. The views expressed here are his own and do not necessarily reflect the views of AWS.

Categories SoftwareTags , , , , , , Leave a comment

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.