zoukankan      html  css  js  c++  java
  • 使用Python脚本提交Spark任务到Yarn

    背景:使用脚本管理Spark任务,正处于RUNNING状态的任务跳过,不提交

    一、涉及到的知识点:

    脚本不重要,重要的是知识点

    1.查询yarn处于RUNNING状态的任务列表

    yarn application -list -appStates RUNNING
    

    2.在Python中使用Linux命令

    import os
    os.system('ll /')
    os.popen("ll /")
    

    二、完整脚本

    import os
    file = open(r'./bash.txt', 'r')
    
    name_bash_dict = {}
    
    for line in file.readlines():
        words = line.split(':')
        name_bash_dict[words[0]] = words[1]
    file.close()
    
    running_job_lines = os.popen("yarn application -list -appStates RUNNING")
    line_num = 0
    for line in running_job_lines.readlines():
        line_num += 1
        if line_num == 3:
            column = line.split('	')
            if len(column) == 9 and column[5].strip() == 'RUNNING':
                jobName = column[1].strip()
                del name_bash_dict[jobName]
    
    for v in name_bash_dict.values():
        os.system(v)
    
  • 相关阅读:
    c++ bitset 10进制转二进制
    PIVOT
    西渡
    check all tables rows

    View Triggers Function Procedure
    ORA-01400: cannot insert NULL into
    中东
    力的合成
    正弦、余弦和正切
  • 原文地址:https://www.cnblogs.com/yangyh11/p/14059124.html
Copyright © 2011-2022 走看看