get all task metrics in the specific component
@param info raw metric info
@param component component id
@param window window duration for metrics in seconds
@return the list of task metrics
482990
public static List<UITaskMetric> getTaskMetrics(MetricInfo info, String component, int window) {
        TreeMap<Integer, UITaskMetric> taskData = new TreeMap<>();
        if (info != null) {
            for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : info.get_metrics().entrySet()) {
                String name = metric.getKey();
                String[] split_name = name.split("@");
                int taskId = JStormUtils.parseInt(UIMetricUtils.extractTaskId(split_name));
                String componentName = UIMetricUtils.extractComponentName(split_name);
                if (componentName != null && !componentName.equals(component)) continue;

                //only handle the tasks belongs to the specific component
                String metricName = UIMetricUtils.extractMetricName(split_name);

                String parentComp = null;
                if (metricName != null && metricName.contains(".")) {
                    parentComp = metricName.split("\\.")[0];
                    metricName = metricName.split("\\.")[1];
                }

                if (!metric.getValue().containsKey(window)) {
                    LOG.info("task snapshot {} missing window:{}", metric.getKey(), window);
                    continue;
                }
                MetricSnapshot snapshot = metric.getValue().get(window);

                UITaskMetric taskMetric;
                if (taskData.containsKey(taskId)) {
                    taskMetric = taskData.get(taskId);
                } else {
                    taskMetric = new UITaskMetric(component, taskId);
                    taskData.put(taskId, taskMetric);
                }
                taskMetric.setMetricValue(snapshot, parentComp, metricName);
            }
        }
        for (UITaskMetric t : taskData.values()) {
            t.mergeValue();
        }
        return new ArrayList<>(taskData.values());
    }
257266
private static WindowFocusListener createRepaintWindowListener(final JComponent component) {
        return new WindowAdapter() {
            public void windowActivated(WindowEvent e) {
                component.repaint();
            }

            public void windowDeactivated(WindowEvent e) {
                component.repaint();
            }
        };
    }
1112229
public static List<TaskEntity> getTaskEntities(TopologyInfo topologyInfo, String componentName) {
        TreeMap<Integer, TaskEntity> tasks = new TreeMap<>();

        for (ComponentSummary cs : topologyInfo.get_components()) {
            String compName = cs.get_name();
            String type = cs.get_type();
            if (componentName.equals(compName)) {
                for (int id : cs.get_taskIds()) {
                    tasks.put(id, new TaskEntity(id, compName, type));
                }
            }
        }

        for (TaskSummary ts : topologyInfo.get_tasks()) {
            if (tasks.containsKey(ts.get_taskId())) {
                TaskEntity te = tasks.get(ts.get_taskId());
                te.setHost(ts.get_host());
                te.setPort(ts.get_port());
                te.setStatus(ts.get_status());
                te.setUptime(ts.get_uptime());
                te.setErrors(ts.get_errors());
            }
        }

        return new ArrayList<>(tasks.values());
    }
550693
def componentDoc(self, starttime=True):
        
        samplerate = self.samplerate()
        doc_list = []
        for row, track in enumerate(self._segments):
            start_time = 0
            for col, component in enumerate(track):
                info = component.stateDict()
                info['stim_type'] = component.name
                if starttime:
                    info['start_s'] = start_time
                info['index'] = (row, col)
                start_time += info['duration']
                doc_list.append(info)
                
        return {'samplerate_da':samplerate, 'components' : doc_list}
407782
@Override
	public List<Component> listComponents( String applicationName ) {

		this.logger.fine( "Request: list components for the application " + applicationName + "." );
		List<Component> result = new ArrayList<> ();
		Application app = this.manager.applicationMngr().findApplicationByName( applicationName );
		if( app != null )
			result.addAll( ComponentHelpers.findAllComponents( app ));

		return result;
	}
454222
@Override
    String[] executeCommand(int timeout, String componentName, Object... data) {
        mComponentsMap = new HashMap<>();

        Window[] displayableWindows = getDisplayableWindows();
        for (Window window : displayableWindows) {
            if (window.getName() != null) {
                addToMap(window);
            }
            browseComponent(window.getComponents());
        }

        ArrayList<String> list = new ArrayList<>();
        for (String key : mComponentsMap.keySet()) {
            list.add(key + "   (number of instance with this name :" + mComponentsMap.get(key).size() + ")");
        }
        Collections.sort(list);
        list.add("Number of ownerless windows : " + Window.getOwnerlessWindows().length);
        list.add("Number of displayable windows : " + displayableWindows.length);
        return list.toArray(new String[list.size()]);
    }
458675
public static Map<String, Double> getMetrics(Map conf, String topologyName, MetaType metricType, Integer window) {
        NimbusClientWrapper nimbusClient = null;
        Iface client = null;
        Map<String, Double> summary = new HashMap<>();

        try {
            nimbusClient = new NimbusClientWrapper();
            nimbusClient.init(conf);

            client = nimbusClient.getClient();

            String topologyId = client.getTopologyId(topologyName);

            if (metricType == null) {
                metricType = MetaType.TASK;
            }

            List<MetricInfo> allTaskMetrics = client.getMetrics(topologyId, metricType.getT());
            if (allTaskMetrics == null) {
                throw new RuntimeException("Failed to get metrics");
            }

            if (window == null || !AsmWindow.TIME_WINDOWS.contains(window)) {
                window = AsmWindow.M1_WINDOW;
            }

            for (MetricInfo taskMetrics : allTaskMetrics) {

                Map<String, Map<Integer, MetricSnapshot>> metrics = taskMetrics.get_metrics();
                if (metrics == null) {
                    System.out.println("Failed to get task metrics");
                    continue;
                }
                for (Entry<String, Map<Integer, MetricSnapshot>> entry : metrics.entrySet()) {
                    String key = entry.getKey();

                    MetricSnapshot metric = entry.getValue().get(window);
                    if (metric == null) {
                        throw new RuntimeException("Failed to get one minute metrics of " + key);
                    }

                    if (metric.get_metricType() == MetricType.COUNTER.getT()) {
                        summary.put(key, (double) metric.get_longValue());
                    } else if (metric.get_metricType() == MetricType.GAUGE.getT()) {
                        summary.put(key, metric.get_doubleValue());
                    } else {
                        summary.put(key, metric.get_mean());
                    }
                }
            }

            return summary;

        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (client != null) {
                nimbusClient.cleanup();
            }
        }
    }
1310860
public java.util.List<ScheduledWindowExecution> getScheduledWindowExecutions() {
        if (scheduledWindowExecutions == null) {
            scheduledWindowExecutions = new com.amazonaws.internal.SdkInternalList<ScheduledWindowExecution>();
        }
        return scheduledWindowExecutions;
    }
280591
public synchronized TaskManagerMetricStore getTaskManagerMetricStore(String tmID) {
		return tmID == null ? null : TaskManagerMetricStore.unmodifiable(taskManagers.get(tmID));
	}
244655
@Override
    public final Collection<Metric> gatherMetrics(final ICommandLine cl) throws MetricGatheringException {
        List<Metric> metrics = new ArrayList<Metric>();
        String hostname = cl.getOptionValue("hostname");
        if (hostname == null) {
            throw new MetricGatheringException("No hostname specified.", Status.WARNING, null);
        }

        String port = cl.getOptionValue("port", DEFAULT_PORT);
        String path = cl.getOptionValue("url", DEFAULT_PATH);
        String method = cl.getOptionValue("method", DEFAULT_METHOD);

        int timeout = DEFAULT_TIMEOUT;
        if (cl.hasOption("post")) {
            method = "POST";
        }
        boolean ssl = false;
        if (cl.hasOption("ssl") || cl.getOptionValue("certificate") != null) {
            port = cl.getOptionValue("ssl", DEFAULT_SSL_PORT);
            ssl = true;
        }

        if (cl.hasOption("timeout")) {
            try {
                timeout = Integer.parseInt(cl.getOptionValue("timeout"));
            } catch (NumberFormatException e) {
                throw new MetricGatheringException("Invalid numeric value for timeout.", Status.CRITICAL, e);
            }
        }
        if (!path.startsWith("/")) {
            path = "/" + path;
        }
        if (hostname.endsWith("/")) {
            hostname = hostname.substring(0, hostname.length() - 1);
        }

        long then = System.currentTimeMillis();

        String response = getHttpResponse(cl, hostname, port, method, path, timeout, ssl, metrics);
        int elapsed = (int) Utils.milliToSec(System.currentTimeMillis() - then);
        if (response != null) {
            metrics.addAll(analyzeResponse(cl, response, elapsed));
        }
        return metrics;
    }
586481
@Override
  public TaskTrackerUtilization getTaskTrackerUtilization(String hostName)
          throws IOException {
    if (taskTrackerReports.get(hostName) == null) {
      return null;
    }
    return taskTrackerReports.get(hostName).getTaskTrackerUtilization();
  }
909042
private static Window getWindowAncestor(JTextComponent component) {
        if (component == null) {
            return null;
        }
        return SwingUtilities.getWindowAncestor(component);
    }
379782
public static ArrayList<InfoWindow> getOpenedInfoWindowsOn(MapView mapView) {
        int count = mapView.getChildCount();
        ArrayList<InfoWindow> opened = new ArrayList<InfoWindow>(count);
        for (int i = 0; i < count; i++) {
            final View child = mapView.getChildAt(i);
            Object tag = child.getTag();
            if (tag != null && tag instanceof InfoWindow) {
                InfoWindow infoWindow = (InfoWindow) tag;
                opened.add(infoWindow);
            }
        }
        return opened;
    }
623503
public ComponentVisitor createtVisitor(SessionWrapper session, TargetMetaDef targetMetaDef) {
		if (session != null)
			return createtSessionVisitor(session, targetMetaDef);
		else
			return new NoSessionProxyComponentVisitor(componentVisitor, targetMetaRequestsHolder);

	}
715219
public long getWindowMinLoadTime(final String intervalName, final TimeUnit unit) {
		final long min = windowMinLoadTime.getValueAsLong(intervalName);
		return min == Constants.MIN_TIME_DEFAULT ? min : unit.transformMillis(min);
	}
933419
@SuppressWarnings("unchecked")
	<T extends Component> T getComponent (ComponentType componentType) {
		int componentTypeIndex = componentType.getIndex();

		if (componentTypeIndex < components.getCapacity()) {
			return (T)components.get(componentType.getIndex());
		} else {
			return null;
		}
	}
611861
public TaskCompletionEvent[] getTaskCompletionEvents(int startFrom
                                                       ) throws IOException {
    ensureState(JobState.RUNNING);
    return info.getTaskCompletionEvents(startFrom);
  }