当前位置:   article > 正文

python3 调用 yarn-rest-api 样例将相关数据写入到文本_yarn rest api get python

yarn rest api get python

#!/data/anaconda3/bin/python

# coding=utf-8

# author :dyqin

# 通过范文yarn_rest_api 接口获取json报文 ,解析报文获取yarn相关指标

import os

import json

import urllib.request

import urllib.parse

import time

import datetime

#from datetime import datetime

import cx_Oracle

#定义函数用于获取active状态的 resource manager

def getActiveRN(master1, master2):

activemaster = ""

response = urllib.request.urlopen("http://" + master1 + "/ws/v1/cluster/info")

jsonstring = response.read()

#print(jsonstring)

#通过jason 加载

j1 = json.loads(jsonstring)

#print(master1 + " resourcemanager state is :" + j1['clusterInfo']['haState'])

response = urllib.request.urlopen("http://" + master2 + "/ws/v1/cluster/info"

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号