用于hadoop yarn rest api的python包装器

hadoop-yarn-rest-api的Python项目详细描述


这是用于hadoop yarn rest api的python库。

这个项目遵循[hadoop yarn rest api](https://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site/ResourceManagerRest.html)文档。

我们已经实现了以下api。

  • Cluster Information API
  • Cluster Metrics API
  • Cluster Scheduler API
  • Cluster Applications API
  • Cluster Application Statistics API
  • Cluster Application API
  • Cluster Application Attempts API
  • Cluster Nodes API
  • Cluster Node API

用法

安装:

pip install hadoop-yarn-rest-api

用法:

from hadoop.yarn import Yarn
import xml.etree.ElementTree as ET
import json
import xml.dom.minidom

def main():
    yarn = Yarn("http://localhost:8088", 'json')

    response_obj = yarn.cluster_information()
    response_obj = yarn.cluster_metrics()
    response_obj = yarn.cluster_scheduler()
    response_obj = yarn.cluster_applications()
    response_obj = yarn.cluster_applications({"limit":100})
    response_obj = yarn.cluster_appstatistics()
    response_obj = yarn.cluster_appstatistics({"states":"accepted,running,finished","applicationTypes":"mapreduce"})
    response_obj = yarn.cluster_application("job_id")
    response_obj = yarn.cluster_application_attempts("job_id")
    response_obj = yarn.cluster_nodes()
    response_obj = yarn.cluster_nodes({"states":"RUNNING"})  # NEW, RUNNING, UNHEALTHY, DECOMMISSIONING, DECOMMISSIONED, LOST, REBOOTED, SHUTDOWN
    response_obj = yarn.cluster_node("node_id")

    if yarn.response_type == 'json':
        print(json.dumps(response_obj, indent=4, sort_keys=True))
    elif yarn.response_type == 'xml':
        print(xml.dom.minidom.parseString(ET.tostring(response_obj)).toprettyxml())
    else:
        print(response_obj)

if __name__ == '__main__':
    main()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何将java ArrayList对象转换为实际值   web服务如何在JAVA类uisng JAXBElement中解组SOAP UI值   包含无值参数的java HttpClient表单URL   运行简单Camel Restlet演示项目的java问题?   带有自定义图标的java简单SWT警报消息?   java Netbeans 6.8:LibImport可以工作,但编译时“包不存在”   java如何获得绘画完成的通知?   java Hazelcast客户端模式群集故障后如何恢复?   Neo4J中Shapefile的java批插入   为什么ThreadPoolExecutor在Eclipse和从命令行运行Java程序时表现不同?   java在Android中计算两个坐标之间的距离时得到了荒谬的值   java在CardLayout中显示卡本身的下一张卡