2

I have to Trigger a Template of dataflow Job from App Engine in Fixed Interval of Time to Make Fix Interval I Have used cron job but do not have any Idea how to trigger a Template in Java Language I Need the Below Code in Form of Java.

import datetime
import logging
import os

from google.appengine.ext import ndb
import webapp2

    from googleapiclient.discovery import build
    from oauth2client.client import GoogleCredentials



    class LaunchJob(webapp2.RequestHandler):

        credentials = GoogleCredentials.get_application_default()
        service = build('dataflow', 'v1b3', credentials=credentials)

        # Set the following variables to your values.
        JOBNAME = 'kiss-fn-dataflow-job'
        PROJECT = 'testing1-18001111'
        BUCKET = 'kiss-bucket'
        TEMPLATE = 'Test1'

        GCSPATH="gs://{bucket}/templates/{template}".format(bucket=BUCKET, template=TEMPLATE),
        BODY = {
            "jobName": "{jobname}".format(jobname=JOBNAME),
            "parameters": {
                "inputFile" : "gs://{bucket}/input/my_input.txt",
                "outputFile": "gs://{bucket}/output/my_output".format(bucket=BUCKET)
             },
             "environment": {
                "tempLocation": "gs://{bucket}/temp".format(bucket=BUCKET),
                "zone": "us-central1-f"
             }
        }

        request = service.projects().templates().launch(projectId=PROJECT, gcsPath=GCSPATH, body=BODY)
        response = request.execute()


    app = webapp2.WSGIApplication([
        ('/', LaunchJob),
    ], debug=True)

The Above Program Runs Perfectly But to Deploy a Single application Many Dependency in Python is Done and Some Functionality is Not Available as Per Requirement to I need to Change my App Engine Program in Java. So I Can Usee Apache beam in My App.

BackBenChers
  • 304
  • 2
  • 15

0 Answers0