当前位置: 首页>>代码示例>>Python>>正文


Python SparkSubmitHook._process_log方法代码示例

本文整理汇总了Python中airflow.contrib.hooks.spark_submit_hook.SparkSubmitHook._process_log方法的典型用法代码示例。如果您正苦于以下问题:Python SparkSubmitHook._process_log方法的具体用法?Python SparkSubmitHook._process_log怎么用?Python SparkSubmitHook._process_log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在airflow.contrib.hooks.spark_submit_hook.SparkSubmitHook的用法示例。


在下文中一共展示了SparkSubmitHook._process_log方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_process_log

# 需要导入模块: from airflow.contrib.hooks.spark_submit_hook import SparkSubmitHook [as 别名]
# 或者: from airflow.contrib.hooks.spark_submit_hook.SparkSubmitHook import _process_log [as 别名]
    def test_process_log(self):
        # Must select yarn connection
        hook = SparkSubmitHook(conn_id='spark_yarn_cluster')

        log_lines = [
            'SPARK_MAJOR_VERSION is set to 2, using Spark2',
            'WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable',
            'WARN DomainSocketFactory: The short-circuit local reads feature cannot be used because libhadoop cannot be loaded.',
            'INFO Client: Requesting a new application from cluster with 10 NodeManagers',
            'INFO Client: Submitting application application_1486558679801_1820 to ResourceManager'
        ]

        hook._process_log(log_lines)

        assert hook._yarn_application_id == 'application_1486558679801_1820'
开发者ID:ludovicc,项目名称:airflow,代码行数:17,代码来源:test_spark_submit_hook.py

示例2: test_spark_process_on_kill

# 需要导入模块: from airflow.contrib.hooks.spark_submit_hook import SparkSubmitHook [as 别名]
# 或者: from airflow.contrib.hooks.spark_submit_hook.SparkSubmitHook import _process_log [as 别名]
    def test_spark_process_on_kill(self, mock_popen):
        # Given
        mock_popen.return_value.stdout = StringIO(u'stdout')
        mock_popen.return_value.stderr = StringIO(u'stderr')
        mock_popen.return_value.poll.return_value = None
        mock_popen.return_value.wait.return_value = 0
        log_lines = [
            'SPARK_MAJOR_VERSION is set to 2, using Spark2',
            'WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable',
            'WARN DomainSocketFactory: The short-circuit local reads feature cannot be used because libhadoop cannot be loaded.',
            'INFO Client: Requesting a new application from cluster with 10 NodeManagerapplication_1486558679801_1820s',
            'INFO Client: Submitting application application_1486558679801_1820 to ResourceManager'
        ]
        hook = SparkSubmitHook(conn_id='spark_yarn_cluster')
        hook._process_log(log_lines)
        hook.submit()

        # When
        hook.on_kill()

        # Then
        self.assertIn(call(['yarn', 'application', '-kill', 'application_1486558679801_1820'], stderr=-1, stdout=-1), mock_popen.mock_calls)
开发者ID:SivaPandeti,项目名称:airflow,代码行数:24,代码来源:test_spark_submit_hook.py


注:本文中的airflow.contrib.hooks.spark_submit_hook.SparkSubmitHook._process_log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。