@Override
  protected @Nullable List<ITimeEvent> getEventList(
      @NonNull TimeGraphEntry entry,
      ITmfStateSystem ssq,
      @NonNull List<List<ITmfStateInterval>> fullStates,
      @Nullable List<ITmfStateInterval> prevFullState,
      @NonNull IProgressMonitor monitor) {
    List<ITimeEvent> eventList =
        null; // List<List<ITimeEvent>> List = new ArrayList<>(fullStates.size());
    OPS_NEUTRON_ENTRY resourcesEntry = (OPS_NEUTRON_ENTRY) entry;
    int quark = resourcesEntry.getQuark();
    if (resourcesEntry.getType().equals(Type.SERVICE)) {
      int statusQuark;
      try {
        statusQuark = ssq.getQuarkRelative(quark, "Action"); // $NON-NLS-1$
      } catch (AttributeNotFoundException e) {
        e.printStackTrace();
        return null;
      }
      eventList = new ArrayList<>(fullStates.size());
      ITmfStateInterval lastInterval =
          prevFullState == null || statusQuark >= prevFullState.size()
              ? null
              : prevFullState.get(statusQuark);
      long lastStartTime = lastInterval == null ? -1 : lastInterval.getStartTime();
      long lastEndTime = lastInterval == null ? -1 : lastInterval.getEndTime() + 1;
      for (List<ITmfStateInterval> fullState : fullStates) {

        if (monitor.isCanceled()) {
          return null;
        }
        if (statusQuark >= fullState.size()) {
          // No information on this CPU (yet?), skip it for now
          continue;
        }
        ITmfStateInterval statusInterval = fullState.get(statusQuark);
        int status = statusInterval.getStateValue().unboxInt();

        long time = statusInterval.getStartTime();
        long duration = statusInterval.getEndTime() - time + 1;
        if (time == lastStartTime) {
          continue;
        }
        if (!statusInterval.getStateValue().isNull()) {
          if (lastEndTime != time && lastEndTime != -1) {
            eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime));
          }
          eventList.add(new TimeEvent(entry, time, duration, status));
        } else {
          eventList.add(new NullTimeEvent(entry, time, duration));
        }
        lastStartTime = time;
        lastEndTime = time + duration;
      }
    }
    return eventList;
  }
Example #2
0
 /**
  * The method to fill up the stateInfo (passed on from the Current State Tree when it does a query
  * on the SHT). We'll replace the data in that vector with whatever relevant we can find from this
  * node
  *
  * @param stateInfo The same stateInfo that comes from SHT's doQuery()
  * @param t The timestamp for which the query is for. Only return intervals that intersect t.
  * @throws TimeRangeException If 't' is invalid
  */
 public void writeInfoFromNode(List<ITmfStateInterval> stateInfo, long t)
     throws TimeRangeException {
   /* This is from a state system query, we are "reading" this node */
   fRwl.readLock().lock();
   try {
     for (int i = getStartIndexFor(t); i < fIntervals.size(); i++) {
       /*
        * Now we only have to compare the Start times, since we now the
        * End times necessarily fit.
        *
        * Second condition is to ignore new attributes that might have
        * been created after stateInfo was instantiated (they would be
        * null anyway).
        */
       ITmfStateInterval interval = fIntervals.get(i);
       if (interval.getStartTime() <= t && interval.getAttribute() < stateInfo.size()) {
         stateInfo.set(interval.getAttribute(), interval);
       }
     }
   } finally {
     fRwl.readLock().unlock();
   }
 }