|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 |
| -# [START composer_quickstart] |
| 15 | +# [START composer_hadoop_tutorial] |
16 | 16 | """Example Airflow DAG that creates a Cloud Dataproc cluster, runs the Hadoop
|
17 | 17 | wordcount example, and deletes the cluster.
|
18 | 18 |
|
|
62 | 62 | 'project_id': models.Variable.get('gcp_project')
|
63 | 63 | }
|
64 | 64 |
|
65 |
| -# [START composer_quickstart_schedule] |
| 65 | +# [START composer_hadoop_schedule] |
66 | 66 | with models.DAG(
|
67 |
| - 'composer_sample_quickstart', |
| 67 | + 'composer_hadoop_tutorial', |
68 | 68 | # Continue to run DAG once per day
|
69 | 69 | schedule_interval=datetime.timedelta(days=1),
|
70 | 70 | default_args=default_dag_args) as dag:
|
71 |
| - # [END composer_quickstart_schedule] |
| 71 | + # [END composer_hadoop_schedule] |
72 | 72 |
|
73 | 73 | # Create a Cloud Dataproc cluster.
|
74 | 74 | create_dataproc_cluster = dataproc_operator.DataprocClusterCreateOperator(
|
75 | 75 | task_id='create_dataproc_cluster',
|
76 | 76 | # Give the cluster a unique name by appending the date scheduled.
|
77 | 77 | # See https://airflow.apache.org/code.html#default-variables
|
78 |
| - cluster_name='quickstart-cluster-{{ ds_nodash }}', |
| 78 | + cluster_name='composer-hadoop-tutorial-cluster-{{ ds_nodash }}', |
79 | 79 | num_workers=2,
|
80 | 80 | zone=models.Variable.get('gce_zone'),
|
81 | 81 | master_machine_type='n1-standard-1',
|
|
86 | 86 | run_dataproc_hadoop = dataproc_operator.DataProcHadoopOperator(
|
87 | 87 | task_id='run_dataproc_hadoop',
|
88 | 88 | main_jar=WORDCOUNT_JAR,
|
89 |
| - cluster_name='quickstart-cluster-{{ ds_nodash }}', |
| 89 | + cluster_name='composer-hadoop-tutorial-cluster-{{ ds_nodash }}', |
90 | 90 | arguments=wordcount_args)
|
91 | 91 |
|
92 | 92 | # Delete Cloud Dataproc cluster.
|
93 | 93 | delete_dataproc_cluster = dataproc_operator.DataprocClusterDeleteOperator(
|
94 | 94 | task_id='delete_dataproc_cluster',
|
95 |
| - cluster_name='quickstart-cluster-{{ ds_nodash }}', |
| 95 | + cluster_name='composer-hadoop-tutorial-cluster-{{ ds_nodash }}', |
96 | 96 | # Setting trigger_rule to ALL_DONE causes the cluster to be deleted
|
97 | 97 | # even if the Dataproc job fails.
|
98 | 98 | trigger_rule=trigger_rule.TriggerRule.ALL_DONE)
|
99 | 99 |
|
100 |
| - # [START composer_quickstart_steps] |
| 100 | + # [START composer_hadoop_steps] |
101 | 101 | # Define DAG dependencies.
|
102 | 102 | create_dataproc_cluster >> run_dataproc_hadoop >> delete_dataproc_cluster
|
103 |
| - # [END composer_quickstart_steps] |
| 103 | + # [END composer_hadoop_steps] |
104 | 104 |
|
105 |
| -# [END composer_quickstart] |
| 105 | +# [END composer_hadoop] |
0 commit comments