使用适用于 SAP 的软件开发工具包的 Amazon EMR 示例 ABAP - AWS 适用于 SAP 的 SDK ABA

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用适用于 SAP 的软件开发工具包的 Amazon EMR 示例 ABAP

以下代码示例向您展示了如何使用适用于 SAP ABAP 的 AWS 软件开发工具包和 Amazon EMR 来执行操作和实现常见场景。

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以从中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例演示了如何使用 AddJobFlowSteps

适用于 SAP ABAP 的 SDK
注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

TRY. " Build args list for Spark submit DATA lt_args TYPE /aws1/cl_emrxmlstringlist_w=>tt_xmlstringlist. APPEND NEW /aws1/cl_emrxmlstringlist_w( 'spark-submit' ) TO lt_args. APPEND NEW /aws1/cl_emrxmlstringlist_w( '--deploy-mode' ) TO lt_args. APPEND NEW /aws1/cl_emrxmlstringlist_w( 'cluster' ) TO lt_args. APPEND NEW /aws1/cl_emrxmlstringlist_w( iv_script_uri ) TO lt_args. APPEND LINES OF it_script_args TO lt_args. " Create step configuration DATA(lo_hadoop_jar_step) = NEW /aws1/cl_emrhadoopjarstepcfg( iv_jar = 'command-runner.jar' it_args = lt_args ). DATA(lo_step_config) = NEW /aws1/cl_emrstepconfig( iv_name = iv_name iv_actiononfailure = 'CONTINUE' io_hadoopjarstep = lo_hadoop_jar_step ). DATA lt_steps TYPE /aws1/cl_emrstepconfig=>tt_stepconfiglist. APPEND lo_step_config TO lt_steps. DATA(lo_result) = lo_emr->addjobflowsteps( iv_jobflowid = iv_cluster_id it_steps = lt_steps ). " Get first step ID DATA(lt_step_ids) = lo_result->get_stepids( ). READ TABLE lt_step_ids INDEX 1 INTO DATA(lo_step_id_obj). IF sy-subrc = 0. ov_step_id = lo_step_id_obj->get_value( ). MESSAGE |Step added with ID { ov_step_id }| TYPE 'I'. ENDIF. 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 的详细信息,请参阅适用AddJobFlowSteps于 S AP 的AWS SDK ABAP API 参考

以下代码示例演示了如何使用 DescribeCluster

适用于 SAP ABAP 的 SDK
注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

TRY. oo_result = lo_emr->describecluster( iv_clusterid = iv_cluster_id ). DATA(lo_cluster) = oo_result->get_cluster( ). DATA(lv_cluster_name) = lo_cluster->get_name( ). MESSAGE |Retrieved cluster information for { lv_cluster_name }| TYPE 'I'. CATCH /aws1/cx_emrinternalserverex INTO DATA(lo_internal_error). DATA(lv_error) = lo_internal_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. CATCH /aws1/cx_emrinvalidrequestex INTO DATA(lo_invalid_error). lv_error = lo_invalid_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. ENDTRY.
  • 有关 API 的详细信息,请参阅适用DescribeCluster于 S AP 的AWS SDK ABAP API 参考

以下代码示例演示了如何使用 DescribeStep

适用于 SAP ABAP 的 SDK
注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

TRY. oo_result = lo_emr->describestep( iv_clusterid = iv_cluster_id iv_stepid = iv_step_id ). DATA(lo_step) = oo_result->get_step( ). DATA(lv_step_name) = lo_step->get_name( ). MESSAGE |Retrieved step information for { lv_step_name }| TYPE 'I'. CATCH /aws1/cx_emrinternalserverex INTO DATA(lo_internal_error). DATA(lv_error) = lo_internal_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. CATCH /aws1/cx_emrinvalidrequestex INTO DATA(lo_invalid_error). lv_error = lo_invalid_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. ENDTRY.
  • 有关 API 的详细信息,请参阅适用DescribeStep于 S AP 的AWS SDK ABAP API 参考

以下代码示例演示了如何使用 ListSteps

适用于 SAP ABAP 的 SDK
注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

TRY. oo_result = lo_emr->liststeps( iv_clusterid = iv_cluster_id ). DATA(lt_steps) = oo_result->get_steps( ). DATA(lv_step_count) = lines( lt_steps ). MESSAGE |Retrieved { lv_step_count } steps for cluster| TYPE 'I'. CATCH /aws1/cx_emrinternalserverex INTO DATA(lo_internal_error). DATA(lv_error) = lo_internal_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. CATCH /aws1/cx_emrinvalidrequestex INTO DATA(lo_invalid_error). lv_error = lo_invalid_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. ENDTRY.
  • 有关 API 的详细信息,请参阅适用ListSteps于 S AP 的AWS SDK ABAP API 参考

以下代码示例演示了如何使用 RunJobFlow

适用于 SAP ABAP 的 SDK
注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

TRY. " Create instances configuration DATA(lo_instances) = NEW /aws1/cl_emrjobflowinstsconfig( iv_masterinstancetype = 'm5.xlarge' iv_slaveinstancetype = 'm5.xlarge' iv_instancecount = 3 iv_keepjobflowalivewhennos00 = iv_keep_alive iv_emrmanagedmastersecgroup = iv_primary_sec_grp iv_emrmanagedslavesecgroup = iv_secondary_sec_grp ). DATA(lo_result) = lo_emr->runjobflow( iv_name = iv_name iv_loguri = iv_log_uri iv_releaselabel = 'emr-5.30.1' io_instances = lo_instances it_steps = it_steps it_applications = it_applications iv_jobflowrole = iv_job_flow_role iv_servicerole = iv_service_role iv_ebsrootvolumesize = 10 iv_visibletoallusers = abap_true ). ov_cluster_id = lo_result->get_jobflowid( ). MESSAGE 'EMR cluster created 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'. CATCH /aws1/cx_emrclientexc INTO DATA(lo_client_error). lv_error = lo_client_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. ENDTRY.
  • 有关 API 的详细信息,请参阅适用RunJobFlow于 S AP 的AWS SDK ABAP API 参考

以下代码示例演示了如何使用 TerminateJobFlows

适用于 SAP ABAP 的 SDK
注意

还有更多相关信息 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 的详细信息,请参阅适用TerminateJobFlows于 S AP 的AWS SDK ABAP API 参考