@Override public boolean isActive(ITimeGraphEntry element) { if (element instanceof ControlFlowEntry) { ControlFlowEntry cfe = (ControlFlowEntry) element; TmfTraceManager traceManager = TmfTraceManager.getInstance(); TmfTraceContext traceContext = traceManager.getCurrentTraceContext(); TmfTimeRange winRange = traceContext.getWindowRange(); TmfTimeRange selRange = traceContext.getSelectionRange(); /* Take precedence of selection over window range. */ long beginTS = selRange.getStartTime().getValue(); long endTS = selRange.getEndTime().getValue(); /* No selection, take window range */ if (beginTS == endTS) { beginTS = winRange.getStartTime().getValue(); endTS = winRange.getEndTime().getValue(); } ITmfTrace trace = cfe.getTrace(); ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID); if (ssq != null) { beginTS = Math.max(beginTS, ssq.getStartTime()); endTS = Math.min(endTS, ssq.getCurrentEndTime()); if (beginTS > endTS) { return false; } try { int statusQuark = ssq.getQuarkRelative(cfe.getThreadQuark(), Attributes.STATUS); /* Get the initial state at beginTS */ ITmfStateInterval currentInterval = ssq.querySingleState(beginTS, statusQuark); if (isIntervalInStateActive(currentInterval)) { return true; } /* Get the following state changes */ long ts = currentInterval.getEndTime(); while (ts != -1 && ts < endTS) { ts++; /* To "jump over" to the next state in the history */ currentInterval = ssq.querySingleState(ts, statusQuark); if (isIntervalInStateActive(currentInterval)) { return true; } ts = currentInterval.getEndTime(); } } catch (AttributeNotFoundException | StateSystemDisposedException e) { /* Ignore ... */ } } } return false; }
@Override protected void buildEntryList( @NonNull ITmfTrace trace, @NonNull ITmfTrace parentTrace, @NonNull IProgressMonitor monitor) { // TODO Auto-generated method stub // TODO Auto-generated method stub final ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, OPS_NEUTRON_MODULE.ID); if (ssq == null) { return; } Comparator<ITimeGraphEntry> comparator = new Comparator<ITimeGraphEntry>() { @Override public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) { return ((OPS_NEUTRON_ENTRY) o1).compareTo(o2); } }; // Map<Integer, ServiceEntry> entryMap = new HashMap<>(); TimeGraphEntry traceEntry = null; TimeGraphEntry traceEntry1 = null; Map<String, TimeGraphEntry> mapservice = new HashMap(); long startTime = ssq.getStartTime(); long start = startTime; setStartTime(Math.min(getStartTime(), startTime)); boolean complete = false; while (!complete) { if (monitor.isCanceled()) { return; } complete = ssq.waitUntilBuilt(BUILD_UPDATE_TIMEOUT); if (ssq.isCancelled()) { return; } long end = ssq.getCurrentEndTime(); if (start == end && !complete) { // when complete execute one last time regardless of end time continue; } long endTime = end + 1; setEndTime(Math.max(getEndTime(), endTime)); if (traceEntry == null) { traceEntry = new OPS_NEUTRON_ENTRY(trace, trace.getName(), startTime, endTime, "SERVICEs"); traceEntry.sortChildren(comparator); List<TimeGraphEntry> entryList = Collections.singletonList(traceEntry); addToEntryList(parentTrace, ssq, entryList); } else { traceEntry.updateEndTime(endTime); } // --------- if (traceEntry1 == null) { traceEntry1 = new OPS_NEUTRON_ENTRY(trace, trace.getName(), startTime, endTime, "SERVICEs"); } else { traceEntry1.updateEndTime(endTime); } List<Integer> servicesQuarks = ssq.getQuarks("SERVICEs", "*"); // $NON-NLS-1$ for (Integer serviceQuark : servicesQuarks) { String serv = ssq.getAttributeName(serviceQuark).toString(); if (serv.contains(".")) { String service = serv.split("\\.")[0]; // find service name String subservice = serv.replace(service + ".", ""); // get sub service name TimeGraphEntry subServiceEntry = new OPS_NEUTRON_ENTRY( serviceQuark, trace, startTime, endTime, Type.SERVICE, subservice); if (mapservice.containsKey(service)) { NonNullUtils.checkNotNull(mapservice.get(service)).addChild(subServiceEntry); } else { TimeGraphEntry ServiceEntry = new OPS_NEUTRON_ENTRY( serviceQuark, trace, startTime, endTime, Type.SERVICE, service); mapservice.put(service, ServiceEntry); ServiceEntry.addChild(subServiceEntry); traceEntry.addChild(ServiceEntry); } } } if (parentTrace.equals(getTrace())) { refresh(); } final List<? extends ITimeGraphEntry> traceEntryChildren = traceEntry1.getChildren(); final long resolution = Math.max(1, (endTime - ssq.getStartTime()) / getDisplayWidth()); final long qStart = start; final long qEnd = end; queryFullStates( ssq, qStart, qEnd, resolution, monitor, new IQueryHandler() { @Override public void handle( List<List<ITmfStateInterval>> fullStates, List<ITmfStateInterval> prevFullState) { for (ITimeGraphEntry child : traceEntryChildren) { if (monitor.isCanceled()) { return; } if (child instanceof TimeGraphEntry) { TimeGraphEntry entry = (TimeGraphEntry) child; List<ITimeEvent> eventList = getEventList(entry, ssq, fullStates, prevFullState, monitor); if (eventList != null) { for (ITimeEvent event : eventList) { entry.addEvent(event); } } } } } }); start = end; } }