בניגוד לתהליכי עבודה רגילים שיוצרים מופע של משאב תבנית תהליך עבודה שנוצר קודם, תהליכי עבודה מוטבעים משתמשים בקובץ YAML או בהגדרה מוטמעת של WorkflowTemplate כדי להפעיל תהליך עבודה.
יצירה והרצה של תהליך עבודה מוטבע
gcloud
REST
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- project-id: Google Cloud מזהה הפרויקט
- region: cluster region, כמו us-central1
- zoneUri: מציינים zone בתוך האזור של האשכול, למשל us-central1-b, או משאירים ריק ("") כדי להשתמש בבחירת תחום אוטומטית (Auto Zone) ב-Managed Service for Apache Spark
- clusterName: שם האשכול
ה-method של ה-HTTP וכתובת ה-URL:
POST https://dataproc.googleapis.com/v1/projects/project-id/regions/region/workflowTemplates:instantiateInline
תוכן בקשת JSON:
{
"jobs": [
{
"hadoopJob": {
"mainJarFileUri": "file:///usr/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar",
"args": [
"teragen",
"1000",
"hdfs:///gen/"
]
},
"stepId": "teragen"
},
{
"hadoopJob": {
"mainJarFileUri": "file:///usr/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar",
"args": [
"terasort",
"hdfs:///gen/",
"hdfs:///sort/"
]
},
"stepId": "terasort",
"prerequisiteStepIds": [
"teragen"
]
}
],
"placement": {
"managedCluster": {
"clusterName": "cluster-name",
"config": {
"gceClusterConfig": {
"zoneUri": "zone"
}
}
}
}
}
כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:
אתם אמורים לקבל תגובת JSON שדומה לזו:
{
"name": "projects/project-id/regions/region/operations/2fbd0dad-...",
"metadata": {
"@type": "type.googleapis.com/google.cloud.dataproc.v1.WorkflowMetadata",
"graph": {
"nodes": [
{
"stepId": "teragen",
"state": "RUNNABLE"
},
{
"stepId": "terasort",
"prerequisiteStepIds": [
"teragen"
],
"state": "BLOCKED"
}
]
},
"state": "PENDING",
"startTime": "2020-04-02T22:50:44.826Z"
}
}
המסוף
בשלב הזה, אין תמיכה ביצירת תהליכי עבודה בתוך התוכן במסוף Google Cloud . אפשר לראות את תבניות תהליכי העבודה ואת תהליכי העבודה שנוצרו מהן בדף Workflows (תהליכי עבודה) ב-Managed Service for Apache Spark.
Go
- התקנה של ספריית הלקוח
- הגדרת Application Default Credentials
- מריצים את הקוד
Java
- התקנה של ספריית הלקוח
- הגדרת Application Default Credentials
- מריצים את הקוד.
Node.js
Python
- התקנה של ספריית הלקוח
- הגדרת Application Default Credentials
- מריצים את הקוד