josephxsxn

Spark Dynamic Allocation Detector

Jun 27th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. #!/bin/python
  2. import urllib, sys, json
  3.  
  4. data = json.loads(urllib.urlopen("http://"+sys.argv[1]+":18080/api/v1/applications?status=running").read())
  5.  
  6. dyna = []
  7. nondyna = []
  8.  
  9. #The History REST API for environments is not until Spark 2. So mining the html pages.
  10. #Is not HA Safe, is not YARN App restart safe will only mine the first app attempts
  11. for app in data:
  12.     env = urllib.urlopen("http://"+sys.argv[1]+":18080/history/"+app['id']+"/1/environment").read()
  13.     if "spark.executor.instances" not in env:
  14.         dyna.append(app['id'])
  15.     else:
  16.         nondyna.append(app['id'])
  17.  
  18. print dyna
  19. print nondyna
Advertisement
Add Comment
Please, Sign In to add comment