@WebServlet(name = "dataflowscheduler", value = "/dataflow/schedule") public class DataflowSchedulingServlet extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { ScheduledMinimalWordCount.run(); } }
$ mvn gcloud:deploy
cron: - description: Cron job to schedule Dataflow pipeline url: /dataflow/schedule schedule: every 30 mins login: admin
$ gcloud preview app deploy cron.yaml Beginning deployment... Updating config [cron]...done.
module.exports = { wordcount: function(context, data) { context.success(“Success”); } }
module.exports = { wordcount: function(context, data) { const spawn = require('child_process').spawn; const child = spawn( 'jre1.8.0_77/bin/java', ['-cp', 'WordCount.jar', 'com.google.cloud.dataflow.WordCount', '--jobName=FromACloudFunction', '--project=[YOUR_PROJECT_ID], '--runner=BlockingDataflowPipelineRunner', '--stagingLocation=gs://[YOUR_BUCKET]/staging', '--output=gs://[YOUR_BUCKET]/output' ], { cwd: __dirname }); child.stdout.on('data', function(data) { console.log('stdout: ' + data); context.success("Success: " + data); }); child.stderr.on('data', function(data) { console.error('error: ' + data); context.failure("Error: " + data); }); child.on('close', function(code) { console.log('closing code: ' + code); }); } }
$ gcloud alpha functions deploy wordcount --bucket [BUCKET_NAME] --trigger-http
$ gcloud alpha functions list
$ curl -X POST https://[REGION].[PROJECT_ID].cloudfunctions.net/wordcount --data '{"message":"contents not matter in this example"}'
0 件のコメント :
コメントを投稿