TerminateJobFlows 搭配 AWS SDK 使用 - AWS SDK 程式碼範例

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

TerminateJobFlows 搭配 AWS SDK 使用

下列程式碼範例示範如何使用 TerminateJobFlows

Python
適用於 Python 的 SDK (Boto3)
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

def terminate_cluster(cluster_id, emr_client): """ Terminates a cluster. This terminates all instances in the cluster and cannot be undone. Any data not saved elsewhere, such as in an Amazon S3 bucket, is lost. :param cluster_id: The ID of the cluster to terminate. :param emr_client: The Boto3 EMR client object. """ try: emr_client.terminate_job_flows(JobFlowIds=[cluster_id]) logger.info("Terminated cluster %s.", cluster_id) except ClientError: logger.exception("Couldn't terminate cluster %s.", cluster_id) raise
  • 如需 API 詳細資訊,請參閱《AWS SDK for Python (Boto3) API 參考》中的 TerminateJobFlows

SAP ABAP
適用於 SAP ABAP 的開發套件
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

TRY. DATA lt_cluster_ids TYPE /aws1/cl_emrxmlstringlist_w=>tt_xmlstringlist. APPEND NEW /aws1/cl_emrxmlstringlist_w( iv_cluster_id ) TO lt_cluster_ids. lo_emr->terminatejobflows( it_jobflowids = lt_cluster_ids ). MESSAGE 'EMR cluster terminated successfully.' TYPE 'I'. CATCH /aws1/cx_emrinternalservererr INTO DATA(lo_internal_error). DATA(lv_error) = lo_internal_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. ENDTRY.
  • 如需 API 詳細資訊,請參閱《適用於 AWS SAP ABAP 的 SDK API 參考》中的 TerminateJobFlows