@tornado.gen.coroutine<EOL><INDENT>def getComponentMetrics(self,<EOL>tmaster,<EOL>componentName,<EOL>metricNames,<EOL>instances,<EOL>interval,<EOL>callback=None):<DEDENT>
if not tmaster or not tmaster.host or not tmaster.stats_port:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>host = tmaster.host<EOL>port = tmaster.stats_port<EOL>metricRequest = tmaster_pb2.MetricRequest()<EOL>metricRequest.component_name = componentName<EOL>if len(instances) > <NUM_LIT:0>:<EOL><INDENT>for instance in instances:<EOL><INDENT>metricRequest.instance_id.append(instance)<EOL><DEDENT><DEDENT>for metricName in metricNames:<EOL><INDENT>metricRequest.metric.append(metricName)<EOL><DEDENT>metricRequest.interval = interval<EOL>metricRequestString = metricRequest.SerializeToString()<EOL>url = "<STR_LIT>".format(host, port)<EOL>request = tornado.httpclient.HTTPRequest(url,<EOL>body=metricRequestString,<EOL>method='<STR_LIT:POST>',<EOL>request_timeout=<NUM_LIT:5>)<EOL>Log.debug("<STR_LIT>")<EOL>Log.debug("<STR_LIT>" + url)<EOL>try:<EOL><INDENT>client = tornado.httpclient.AsyncHTTPClient()<EOL>result = yield client.fetch(request)<EOL>Log.debug("<STR_LIT>")<EOL><DEDENT>except tornado.httpclient.HTTPError as e:<EOL><INDENT>raise Exception(str(e))<EOL><DEDENT>responseCode = result.code<EOL>if responseCode >= <NUM_LIT>:<EOL><INDENT>message = "<STR_LIT>" + responseCode<EOL>Log.error(message)<EOL>raise Exception(message)<EOL><DEDENT>metricResponse = tmaster_pb2.MetricResponse()<EOL>metricResponse.ParseFromString(result.body)<EOL>if metricResponse.status.status == common_pb2.NOTOK:<EOL><INDENT>if metricResponse.status.HasField("<STR_LIT:message>"):<EOL><INDENT>Log.warn("<STR_LIT>", metricResponse.status.message)<EOL><DEDENT><DEDENT>ret = {}<EOL>ret["<STR_LIT>"] = metricResponse.interval<EOL>ret["<STR_LIT>"] = componentName<EOL>ret["<STR_LIT>"] = {}<EOL>for metric in metricResponse.metric:<EOL><INDENT>instance = metric.instance_id<EOL>for im in metric.metric:<EOL><INDENT>metricname = im.name<EOL>value = im.value<EOL>if metricname not in ret["<STR_LIT>"]:<EOL><INDENT>ret["<STR_LIT>"][metricname] = {}<EOL><DEDENT>ret["<STR_LIT>"][metricname][instance] = value<EOL><DEDENT><DEDENT>raise tornado.gen.Return(ret)<EOL>
Get the specified metrics for the given component name of this topology.
Returns the following dict on success:
{
  "metrics": {
    <metricname>: {
      <instance>: <numeric value>,
      <instance>: <numeric value>,
      ...
    }, ...
  },
  "interval": <numeric value>,
  "component": "..."
}

Raises exception on failure.