בניגוד לתהליכי עבודה רגילים שיוצרים מופע של משאב תבנית של תהליך עבודה שנוצר בעבר, תהליכי עבודה מוטבעים משתמשים בקובץ YAML או בהגדרה מוטמעת של WorkflowTemplate כדי להריץ תהליך עבודה.
.יצירה והפעלה של תהליך עבודה מוטמע
gcloud
REST
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- project-id: מזהה הפרויקט ב- Google Cloud
- 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
- התקנה של ספריית הלקוח
- הגדרת Application Default Credentials
- מריצים את הקוד
Python
- התקנה של ספריית הלקוח
- הגדרת Application Default Credentials
- מריצים את הקוד