0

我正在尝试使用 cm_api/get_yarn_applications 获取正在运行的 YARN 应用程序列表。我在 cm-api (9.0.0) & CM 5.3.2

我正在关注这个https://github.com/cloudera/cm_api/blob/master/python/src/cm_api/endpoints/services.py

lastHourDateTime = datetime.datetime.now() - datetime.timedelta(hours = 1)

nowDateTime = datetime.datetime.now()

yarn_applications = cm.get_service().get_yarn_applications(lastHourDateTime, nowDateTime)

但我得到以下异常

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/cm_api/endpoints/services.py", line 418, in get_yarn_applications
params=params, api_version=6)
  File "/usr/lib/python2.6/site-packages/cm_api/endpoints/types.py", line 357, in _get
api_version)
  File "/usr/lib/python2.6/site-packages/cm_api/endpoints/types.py", line 380, in _call
api_version)
  File "/usr/lib/python2.6/site-packages/cm_api/endpoints/types.py", line 139, in call
ret = method(path, params=params)
  File "/usr/lib/python2.6/site-packages/cm_api/resource.py", line 100, in get
return self.invoke("GET", relpath, params)
  File "/usr/lib/python2.6/site-packages/cm_api/resource.py", line 63, in invoke
headers=headers)
  File "/usr/lib/python2.6/site-packages/cm_api/http_client.py", line 161, in execute
raise self._exc_class(ex)
cm_api.api_client.ApiException:  (error 404)

如何使用filter_str获取正在运行的纱线应用程序列表

4

1 回答 1

2

您需要在调用时指定 YARN 服务get_service(),并且只获取您需要的正在运行的应用filter_str程序state=RUNNING

如果您的 YARN 服务被命名yarn,那么您的get_yarn_applications()调用将如下所示:

yarn_applications = cm.get_service("yarn").get_yarn_applications(lastHourDateTime, nowDateTime, filter_str = "state=RUNNING")
于 2015-03-21T21:58:21.533 回答