Skip to content

Instantly share code, notes, and snippets.

@isaacmg
Created January 29, 2017 08:56
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save isaacmg/c1942b1d43ccabe6a8259b9786dff076 to your computer and use it in GitHub Desktop.
Save isaacmg/c1942b1d43ccabe6a8259b9786dff076 to your computer and use it in GitHub Desktop.
A simple example of using a DAG to run a jar file.
from airflow import DAG
from airflow.operators import BashOperator
from datetime import datetime
import os
import sys
args = {
'owner': 'airflow'
, 'start_date': datetime(2017, 1, 27)
, 'provide_context': True
}
d = datetime(2017, 1, 17, 3, 15,00)
dag = DAG('usgs', start_date = d, schedule_interval = '16 * * * *', default_args = args)
t_main = BashOperator(
task_id = 'usgs_fetch'
, dag = dag
, bash_command = 'java -cp /mnt/c/Users/img/Documents/GitHub/backbone/target/kafkaUSGS-1.0-SNAPSHOT.jar KafkaUSGS'
#params = {'class': 'FetchJSON', 'path': 'jars/kafkaUSGS.jar'}
)
@snsinghies
Copy link

I am getting error, java command not found using docker and in local system I am getting bash command can not create the java virtual machine

@ftiryaki
Copy link

ftiryaki commented Jun 4, 2021

I am getting error, java command not found using docker and in local system I am getting bash command can not create the java virtual machine

Hi, were you able to run this from docker image?

@pganjhu
Copy link

pganjhu commented Feb 18, 2022

what is KafkaUSGS in line 20, java_class name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment