Пример #1
0
  def get(self, cluster, environ, topology):
    '''
    :param cluster:
    :param environ:
    :param topology:
    :return:
    '''

    start_time = time.time()
    lplan = yield access.get_logical_plan(cluster, environ, topology)

    if not lplan:
      self.write(dict())
      return

    if not lplan.has_key('spouts') or not lplan.has_key('bolts'):
      self.write(dict())
      return

    # format the logical plan as required by the web (because of Ambrose)
    # first, spouts followed by bolts
    spouts_map = dict()
    for name, value in lplan['spouts'].items():
      spouts_map[name] = dict(
          outputs=value["outputs"],
          spout_type=value["type"],
          spout_source=value["source"],
      )

    bolts_map = dict()
    for name, value in lplan['bolts'].items():
      bolts_map[name] = dict(
          inputComponents=[i['component_name'] for i in value['inputs']],
          inputs=value["inputs"],
          outputs=value["outputs"]
      )

    diameter = common.graph.TopologyDAG(lplan).diameter()
    # construct the result
    result = dict(
        status="success",
        message="",
        version=common.VERSION,
        executiontime=time.time() - start_time,
        result=dict(
            stages=diameter,
            spouts=spouts_map,
            bolts=bolts_map
        )
    )

    self.write(result)
Пример #2
0
    def get(self, cluster, environ, topology, comp_name):
        '''
    :param cluster:
    :param environ:
    :param topology:
    :param comp_name:
    :return:
    '''
        start_time = time.time()
        comp_names = []
        if comp_name == "All":
            lplan = yield access.get_logical_plan(cluster, environ, topology)
            if not lplan:
                self.write(dict())
                return

            if not lplan.has_key('spouts') or not lplan.has_key('bolts'):
                self.write(dict())
                return
            comp_names = lplan['spouts'].keys()
            comp_names.extend(lplan['bolts'].keys())
        else:
            comp_names = [comp_name]
        exception_infos = dict()
        for comp_name in comp_names:
            exception_infos[
                comp_name] = yield access.get_component_exceptionsummary(
                    cluster, environ, topology, comp_name)

        # Combine exceptions from multiple component
        aggregate_exceptions = dict()
        for comp_name, exception_logs in exception_infos.items():
            for exception_log in exception_logs:
                class_name = exception_log['class_name']
                if class_name != '':
                    if not class_name in aggregate_exceptions:
                        aggregate_exceptions[class_name] = 0
                    aggregate_exceptions[class_name] += int(
                        exception_log['count'])
        # Put the exception value in a table
        aggregate_exceptions_table = []
        for key in aggregate_exceptions:
            aggregate_exceptions_table.append(
                [key, str(aggregate_exceptions[key])])
        result = dict(status="success",
                      executiontime=time.time() - start_time,
                      result=aggregate_exceptions_table)
        self.write(result)
Пример #3
0
    def get(self, cluster, environ, topology):
        '''
    :param cluster:
    :param environ:
    :param topology:
    :return:
    '''

        start_time = time.time()
        lplan = yield access.get_logical_plan(cluster, environ, topology)

        if not lplan:
            self.write(dict())
            return

        if not lplan.has_key('spouts') or not lplan.has_key('bolts'):
            self.write(dict())
            return

        # format the logical plan as required by the web (because of Ambrose)
        # first, spouts followed by bolts
        spouts_map = dict()
        for name, value in lplan['spouts'].items():
            spouts_map[name] = dict(
                outputs=value["outputs"],
                spout_type=value["type"],
                spout_source=value["source"],
            )

        bolts_map = dict()
        for name, value in lplan['bolts'].items():
            bolts_map[name] = dict(
                inputComponents=[i['component_name'] for i in value['inputs']],
                inputs=value["inputs"],
                outputs=value["outputs"])

        diameter = common.graph.TopologyDAG(lplan).diameter()
        # construct the result
        result = dict(status="success",
                      message="",
                      version=common.VERSION,
                      executiontime=time.time() - start_time,
                      result=dict(stages=diameter,
                                  spouts=spouts_map,
                                  bolts=bolts_map))

        self.write(result)
Пример #4
0
  def get(self, cluster, environ, topology, comp_name):
    '''
    :param cluster:
    :param environ:
    :param topology:
    :param comp_name:
    :return:
    '''
    start_time = time.time()
    comp_names = []
    if comp_name == "All":
      lplan = yield access.get_logical_plan(cluster, environ, topology)
      if not lplan:
        self.write(dict())
        return

      if not lplan.has_key('spouts') or not lplan.has_key('bolts'):
        self.write(dict())
        return
      comp_names = lplan['spouts'].keys()
      comp_names.extend(lplan['bolts'].keys())
    else:
      comp_names = [comp_name]
    exception_infos = dict()
    for comp_name in comp_names:
      exception_infos[comp_name] = yield access.get_component_exceptionsummary(
          cluster, environ, topology, comp_name)

    # Combine exceptions from multiple component
    aggregate_exceptions = dict()
    for comp_name, exception_logs in exception_infos.items():
      for exception_log in exception_logs:
        class_name = exception_log['class_name']
        if class_name != '':
          if not class_name in aggregate_exceptions:
            aggregate_exceptions[class_name] = 0
          aggregate_exceptions[class_name] += int(exception_log['count'])
    # Put the exception value in a table
    aggregate_exceptions_table = []
    for key in aggregate_exceptions:
      aggregate_exceptions_table.append([key, str(aggregate_exceptions[key])])
    result = dict(
        status="success",
        executiontime=time.time() - start_time,
        result=aggregate_exceptions_table)
    self.write(result)