예제 #1
0
async def get_container_heron_pid(
    cluster: str,
    environ: str,
    instance: str,
    topology_name: str = Query(..., alias="topology"),
    role: Optional[str] = None,
):
    """Get the PId of the heron process."""
    topology = state.tracker.get_topology(cluster, role, environ,
                                          topology_name)
    base_url = utils.make_shell_endpoint(topology.info, instance)
    url = f"{base_url}/pid/{instance}"
    async with httpx.AsyncClient() as client:
        return (await client.get(url)).json()
예제 #2
0
def getInstancePid(topology_info, instance_id):
    """
  This method is used by other modules, and so it
  is not a part of the class.
  Fetches Instance pid from heron-shell.
  """
    try:
        http_client = tornado.httpclient.AsyncHTTPClient()
        endpoint = utils.make_shell_endpoint(topology_info, instance_id)
        url = "%s/pid/%s" % (endpoint, instance_id)
        Log.debug("HTTP call for url: %s", url)
        response = yield http_client.fetch(url)
        raise tornado.gen.Return(response.body)
    except tornado.httpclient.HTTPError as e:
        raise Exception(str(e))
예제 #3
0
def getInstancePid(topology_info, instance_id):
  """
  This method is used by other modules, and so it
  is not a part of the class.
  Fetches Instance pid from heron-shell.
  """
  try:
    http_client = tornado.httpclient.AsyncHTTPClient()
    endpoint = utils.make_shell_endpoint(topology_info, instance_id)
    url = "%s/pid/%s" % (endpoint, instance_id)
    Log.debug("HTTP call for url: %s", url)
    response = yield http_client.fetch(url)
    raise tornado.gen.Return(response.body)
  except tornado.httpclient.HTTPError as e:
    raise Exception(str(e))
예제 #4
0
 def getInstanceMemoryHistogram(self, topology_info, instance_id):
   """
   Fetches Instance top memory item as histogram.
   """
   pid_response = yield getInstancePid(topology_info, instance_id)
   try:
     http_client = tornado.httpclient.AsyncHTTPClient()
     pid_json = json.loads(pid_response)
     pid = pid_json['stdout'].strip()
     if pid == '':
       raise Exception('Failed to get pid')
     endpoint = utils.make_shell_endpoint(topology_info, instance_id)
     url = "%s/histo/%s" % (endpoint, pid)
     response = yield http_client.fetch(url)
     Log.debug("HTTP call for url: %s", url)
     raise tornado.gen.Return(response.body)
   except tornado.httpclient.HTTPError as e:
     raise Exception(str(e))
예제 #5
0
 def getInstanceJstack(self, topology_info, instance_id):
     """
 Fetches Instance jstack from heron-shell.
 """
     pid_response = yield getInstancePid(topology_info, instance_id)
     try:
         http_client = tornado.httpclient.AsyncHTTPClient()
         pid_json = json.loads(pid_response)
         pid = pid_json['stdout'].strip()
         if pid == '':
             raise Exception('Failed to get pid')
         endpoint = utils.make_shell_endpoint(topology_info, instance_id)
         url = "%s/jstack/%s" % (endpoint, pid)
         response = yield http_client.fetch(url)
         Log.debug("HTTP call for url: %s", url)
         raise tornado.gen.Return(response.body)
     except tornado.httpclient.HTTPError as e:
         raise Exception(str(e))
예제 #6
0
async def get_container_heron_memory_histogram(
    cluster: str,
    environ: str,
    instance: str,
    topology_name: str = Query(..., alias="topology"),
    role: Optional[str] = None,
):
    """Get memory usage histogram the heron process. This uses the ouput of the last jmap run."""
    topology = state.tracker.get_topology(cluster, role, environ,
                                          topology_name)

    pid_response = await get_container_heron_pid(cluster, environ, instance,
                                                 topology_name, role)
    pid = pid_response["stdout"].strip()

    base_url = utils.make_shell_endpoint(topology.info, instance)
    url = f"{base_url}/histo/{pid}"
    async with httpx.AsyncClient() as client:
        return (await client.get(url)).json()
예제 #7
0
async def get_container_heron_jstack(
    cluster: str,
    environ: str,
    instance: str,
    topology_name: str = Query(..., alias="topology"),
    role: Optional[str] = None,
):
    """Get jstack output for the heron process."""
    topology = state.tracker.get_topology(cluster, role, environ,
                                          topology_name)

    pid_response = await get_container_heron_pid(cluster, environ, instance,
                                                 topology_name, role)
    pid = pid_response["stdout"].strip()

    base_url = utils.make_shell_endpoint(topology.info, instance)
    url = f"{base_url}/jstack/{pid}"
    async with httpx.AsyncClient() as client:
        return (await client.get(url)).json()