tencent cloud

Batch Compute

Product Introduction
What's Batch?
Scenarios
Strengths
Glossary
Quota & Limits
Data Security
Purchase Guide
Getting Started
Preparation
Using CLI - Submit a Job
Using CLI - Compute Environment
Configuring a Job
Using Console
Console User Guide
Task Template Management
Job Management
User Guide
How to create images usable by BatchCompute
Windows Custom Images
Environment Variables
Entering COS & CFS Paths
Event Notice & Callback
Cloud Access Management
Command Line Interface
Preparation
Quick Start
Running Remote Package
Mapping Remote Storage
Use Cases
Building Cluster Using Compute Environment
Example: 3ds Max 2018 Rendering
Example: Deep Learning
API Documentation
History
Introduction
API Category
Making API Requests
Compute Environment APIs
Configuration Viewing-related APIs
Task Template-related APIs
Job-related APIs
Data Types
Error Codes
SDK Documentation
Instructions
FAQs
Contact Us
Glossary
문서Batch ComputeUser GuideEvent Notice & Callback

Event Notice & Callback

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2024-01-13 11:19:29

Summary

BatchCompute (Batch) supports throwing of events generated in the jobs and compute environment in the form of Cloud Message Queue (CMQ). For example, when events such as job execution success/failure and compute environment node creation success/failure/exception occur, notifications and callbacks can be made possible through the topic subscription mechanism of CMQ.

How to Use

A compute environment listening event is used as an example below to demonstrate how to register a compute environment-related event in three steps.

1. Create a CMQ topic

Log in to the CMQ Console and create a new topic.




2. Create a compute environment and associate the CMQ topic

Add a notifications field when submitting a job (SubmitJob) or creating a compute environment (Create) and specify the event_name of the event to be listened to. Multiple events can be specified.
"notifications": [
{
"event_configs": [
{
"event_name": "JobFailed" // Event name
},
{
"event_name": "JobSucceed",
"event_vars": [ // Custom event parameter
{
"name": "jobSucceed",
"value": "Success"
}
]
}
],
"topic_name": "job-message" // CMQ topic name
}
],
Currently, it is only supported to associate CMQ topics when creating a compute environment via API or CLI. Doing so in the console will be supported in the future.
event_vars: In addition to the fixed message generated by the event, custom parameters can be added.
topic_name: Name of the associated CMQ topic (Note: This is not the ID). All event messages will be delivered to this topic which will then forward the messages to all subscribers.

3. Set up a subscriber and test

Add a subscriber to the newly created topic in the CMQ Console. For quick and easy viewing, you can specify an existing message queue.


The message structure is as follows. If a message queue is specified as the subscriber, you can quickly view the messages sent to the topic by Batch in CMQ Console > Message Receiving where the message content requires Base64 processing.
{
"Events": [{
"EventVersion": "1.0",
"EventTime": "2018-06-15T14:43:17Z",
"Region": "ap-guangzhou",
"Batch": {
"ComputeNodeId": "node-0iy7wxyo",
"EnvId": "env-ptoxdb1t",
"ComputeNodeState": "CREATED",
"Mem": 8,
"ResourceCreatedTime": "2018-06-15T14:43:18Z",
"EnvName": "batch-env",
"ComputeNodeInstanceId": "ins-9rikj9kw",
"Cpu": 4
},
"EventName": "COMPUTE_NODE_CREATED",
"EventVars": []
}]
}

Job-related Events

Type
Description
JOB_RUNNING
Job is running
JOB_SUCCEED
Job succeeded
JOB_FAILED
Job failed
JOB_FAILED_INTERRUPTED
Job is interrupted due to failure
TASK_RUNNING
Task is running
TASK_SUCCEED
Task succeeded
TASK_FAILED
Task failed
TASK_FAILED_INTERRUPTED
Task is interrupted due to failure
TASK_INSTANCE_RUNNING
Task instance is running
TASK_INSTANCE_SUCCEED
Task instance succeeded
TASK_INSTANCE_FAILED
Task instance failed
TASK_INSTANCE_FAILED_INTERRUPTED
Task instance is interrupted due to failure
For more information, see SubmitJob.

Compute Environment-related Events

Type
Description
COMPUTE_ENV_CREATED
Compute environment created
COMPUTE_ENV_DELETED
Compute environment deleted
COMPUTE_NODE_CREATED
Compute node successfully created
COMPUTE_NODE_CREATION_FAILED
Compute node creation failed
COMPUTE_NODE_RUNNING
Compute node is running
COMPUTE_NODE_ABNORMAL
Compute node is abnormal
COMPUTE_NODE_DELETING
Deleting compute node
For more information, see CreateComputeEnv.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백