Example #1
0
def logical_plan_json(cluster: str, environment: str,
                      topology: str) -> ApiEnvelope:
    """Return the logical plan object for a topology."""
    return api_topology_json(lambda: tracker.get_logical_plan(
        cluster,
        environment,
        topology,
        None,
    ))
Example #2
0
def run(component_type: str, cluster: str, role: str, environment: str, topology: str):
  """ run command """
  try:
    components = tracker.get_logical_plan(cluster, environment, topology, role)
    topo_info = tracker.get_topology_info(cluster, environment, topology, role)
  except requests.ConnectionError as e:
    Log.error(f"Fail to connect to tracker: {e}")
    sys.exit(1)
  table, header = to_table(components, topo_info, component_type)
  print(tabulate(table, headers=header))
Example #3
0
def exception_summary_json(cluster: str, environment: str, topology: str,
                           component: str) -> ApiEnvelope:
    """Return a table of exception classes to totals."""
    started = time.time()
    if component.lower() == "all":
        logical_plan = tracker.get_logical_plan(cluster, environment, topology)
        if not logical_plan or not {"bolts", "spouts"} <= logical_plan.keys():
            return {}
        # looks like topologies can have spouts but no bolts, so they're assumed to be empty - should
        # the above key check be removed and replaced with bolts defaulting to an empty list?
        component_names = [*logical_plan["spouts"], *logical_plan["bolts"]]
    else:
        component_names = [component]

    exception_infos = {
        c: tracker.get_component_exceptionsummary(cluster, environment,
                                                  topology, c)
        for c in component_names
    }

    class_counts = Counter()
    for exception_logs in exception_infos.values():
        for exception_log in exception_logs:
            class_counts[exception_log["class_name"]] += int(
                exception_log["count"])

    aggregate_exceptions_table = [
        [class_name, str(count)] for class_name, count in class_counts.items()
    ]

    return ApiEnvelope(
        status="success",
        message="",
        executiontime=time.time() - started,
        result=aggregate_exceptions_table,
    )