コード例 #1
0
  private void refresh() {

    // Abort the refresh if we are in the process of shutting down
    if (!PlatformUI.isWorkbenchRunning()) {
      return;
    }

    if (toolbar == null || toolbar.isDisposed()) {
      return;
    }

    JobTreeElement[] jobTreeElements = FinishedJobs.getInstance().getKeptElements();
    // search from end (youngest)
    for (int i = jobTreeElements.length - 1; i >= 0; i--) {
      if (jobTreeElements[i] instanceof JobInfo) {
        JobInfo ji = (JobInfo) jobTreeElements[i];
        Job job = ji.getJob();
        if (job != null) {
          IStatus status = job.getResult();
          if (status != null && status.getSeverity() == IStatus.ERROR) {
            // green arrow with error overlay
            initButton(
                errorImage, NLS.bind(ProgressMessages.ProgressAnimationItem_error, job.getName()));
            return;
          }
          IAction action = getAction(job);
          if (action != null && action.isEnabled()) {
            // green arrow with exclamation mark
            String tt = action.getToolTipText();
            if (tt == null || tt.trim().length() == 0) {
              tt = NLS.bind(ProgressMessages.ProgressAnimationItem_ok, job.getName());
            }
            initButton(okImage, tt);
            return;
          }
          // just the green arrow
          initButton(noneImage, ProgressMessages.ProgressAnimationItem_tasks);
          return;
        }
      }
    }

    if (animationRunning) {
      initButton(noneImage, ProgressMessages.ProgressAnimationItem_tasks);
      return;
    }

    // if nothing found hide tool item
    toolbar.setVisible(false);
  }
コード例 #2
0
  /**
   * Schedule (or postpone) the job to execute after a given delay. Any previous pending job is
   * canceled.
   */
  public final void reschedule(int delay) {
    final Job newJob =
        new Job(actualJob.getName() + " (Delayed)") {
          protected IStatus run(IProgressMonitor monitor) {
            synchronized (jobLock) {
              if (job == this) {
                actualJob.schedule();
                return Status.OK_STATUS;
              } else {
                return Status.CANCEL_STATUS;
              }
            }
          }
        };
    newJob.setPriority(Job.INTERACTIVE);

    // System jobs are not visible in the GUI. I leave it for now, it's quite
    // interesting to see auto update tasks in the jobs panel.
    //
    // newJob.setSystem(true);

    synchronized (jobLock) {
      /*
       * Cancel previous job, but start the new one regardless of the previous job's
       * running state.
       */
      if (job != null && job.getState() == Job.SLEEPING) {
        job.cancel();
      }

      job = newJob;
      job.schedule(delay);
    }
  }
コード例 #3
0
ファイル: JobsRunning.java プロジェクト: TheZorg/linuxtools
 @Override
 public String getFailureMessage() {
   String message = "---JOB RUN ERROR---";
   if (allJobs != null) {
     message += "\nJobs in family \"" + family + "\" still running at time of last test:";
     for (Job job : allJobs) {
       message += "\n\"" + job.getName() + "\" with state " + job.getState();
     }
   } else {
     message += "\nTimeout happened before first test.";
   }
   return message;
 }
コード例 #4
0
 public static void assertJobManagerIdle() {
   final IJobManager jm = Job.getJobManager();
   if (jm.isIdle()) {
     return; // OK!
   }
   // Make a nice message listing all the jobs and their present state.
   Job[] allJobs = jm.find(null);
   StringBuffer msg = new StringBuffer("JobManager not idle: \n");
   for (Job job : allJobs) {
     msg.append("   Job: " + job.getName() + " State: " + stateString(job) + "\n");
   }
   throw new AssertionFailedError(msg.toString());
 }
コード例 #5
0
ファイル: UIJobCollector.java プロジェクト: xored/rcptt
  /**
   * Wait untill will not be empty for timeout
   *
   * @param timeout
   * @throws InterruptedException
   */
  public void join(long timeout) throws InterruptedException {
    SWTTeslaActivator.debugLog("UIJobCollector is going to join");
    long startTime = System.currentTimeMillis();
    // Context ctx = ContextManagement.currentContext();
    while (true) {
      removeCanceledJobs();
      long delta = System.currentTimeMillis() - startTime;
      if (delta > timeout) {
        break;
      }
      if (isJoinEmpty()) {
        break;
      }

      List<Job> jobs2 = getJobs();
      for (Job job : jobs2) {
        SWTTeslaActivator.debugLog("Waiting for job:" + job.getName() + " " + job.getState());
      }
      SWTTeslaActivator.debugLog("UIJobCollector is going to join");
      Thread.sleep(50);
    }
  }
コード例 #6
0
 public void run() {
   DebugUtil.trace(
       DebugUtil.JOB_TRACING,
       "RTS {0}: started job thread",
       getResourceManager().getConfiguration().getName()); // $NON-NLS-1$
   try {
     while (connection != null) {
       Job job = pendingJobQueue.take();
       if (job instanceof IToolRuntimeSystemJob) {
         DebugUtil.trace(
             DebugUtil.JOB_TRACING,
             "RTS {0}: schedule job #{1}",
             getResourceManager().getConfiguration().getName(),
             ((IToolRuntimeSystemJob) job).getJobID()); // $NON-NLS-1$
       } else {
         DebugUtil.trace(
             DebugUtil.JOB_TRACING,
             "RTS {0}: schedule job #{1}",
             getResourceManager().getConfiguration().getName(),
             job.getName()); // $NON-NLS-1$
       }
       job.schedule();
     }
   } catch (InterruptedException e) {
     // Ignore
   } catch (Exception e) {
     DebugUtil.error(
         DebugUtil.JOB_TRACING,
         "RTS {0}: {1}",
         getResourceManager().getConfiguration().getName(),
         e); //$NON-NLS-1$
     RMCorePlugin.log(e);
   }
   DebugUtil.trace(
       DebugUtil.JOB_TRACING,
       "RTS {0}: terminated job thread",
       getResourceManager().getConfiguration().getName()); // $NON-NLS-1$
 }
コード例 #7
0
ファイル: UIJobCollector.java プロジェクト: xored/rcptt
  public boolean isEmpty(Context context, Q7WaitInfoRoot info) {
    // Filter already executed UI jobs with async finish status.
    List<Job> realJobs = new ArrayList<Job>();
    long current = System.currentTimeMillis();
    boolean wasInStepMode = false;
    List<Job> jobsInUI = new ArrayList<Job>();
    synchronized (jobs) {
      // Remove all canceled jobs
      removeCanceledJobs();
      if (jobs.isEmpty()) {
        return logReturnResult(true, realJobs, jobsInUI, info);
      }
      for (JobInfo jobInfo : jobs.values()) {
        if (!jobInfo.isActive()) continue;
        Job job = jobInfo.job;
        IJobCollector[] collectors = JobCollectorExtensions.getDefault().getCollectors();
        boolean allowSkip = true;
        for (IJobCollector ext : collectors) {
          if (ext.noSkipMode(job)) {
            allowSkip = false;
            break;
          }
        }
        if (allowSkip) {
          continue;
        }
        // SWTTeslaActivator.debugLog("Waiting job:" + job.getName() +
        // ": "
        // + job.getClass().getName());
        long jobStartTime = jobInfo.startingTime;

        if (job.getClass().getName().contains("org.eclipse.debug.internal.ui.DebugUIPlugin$")) {
          // It looks like background launching job.
          Thread thread = job.getThread();
          if (thread == null) {
            SWTTeslaActivator.logToReport("Active job " + job.getName() + " has no thread");
            jobInfo.done(false);
          }
          Context ctx = ContextManagement.makeContext(thread.getStackTrace());
          // If Autobuild job is active and on lock and there is Modal
          // Dialog in main thread,
          // lets' skip job from important for us.
          if (ctx.contains("java.util.concurrent.locks.LockSupport", "park")
              || ctx.contains("java.lang.Object", "wait")) {
            // We are waiting some stuff, let's check if main thread
            // have a MessageDialog and if so skip this job right
            // now.
            if (context.contains("org.eclipse.jface.dialogs.MessageDialogWithToggle", "open")
                || context.contains("org.eclipse.jface.dialogs.MessageDialog", "open")) {
              // Skip job from processing since it in lock and
              // waits for a dialog.
              SWTTeslaActivator.logToReport(
                  "Active job "
                      + job.getName()
                      + " has skipped since it in lock state and Message dialog are active");
              continue;
            }
          }
        }

        if (jobInfo.checkForTimeout) {
          if (jobStartTime + TeslaLimits.getStepModeEnableTimeout() < current
              && job.getState() == Job.RUNNING
              && stepModeNext < current) {
            // Job is sleepping to long time already.
            // Check for job are slepping
            // String name = job.getClass().getName();
            // Locate thread
            Thread thread = job.getThread();
            if (thread == null) {
              SWTTeslaActivator.logToReport("Active job " + job.getName() + " has no thread");
              jobInfo.done(false);
            }
            Context ctx = ContextManagement.makeContext(thread.getStackTrace());
            // if (ctx.contains(
            // "org.eclipse.jface.operation.ModalContext$ModalContextThread",
            // "block")) {
            // // Skip model context, since it could
            // continue;
            // }

            if (ctx.contains("java.lang.Thread", "sleep")
                || ctx.contains("java.lang.Object", "wait")
                || ctx.contains("java.util.concurrent.locks.LockSupport", "park")) {
              /*
               * Job are in Thread.sleep(), lets allow one
               * operation.
               */
              if (!jobInfo.jobInStepMode) {
                // Print step information
                SWTTeslaActivator.logToReport(
                    "---->>> Begin step mode for Job: "
                        + getCurrentReportNodeName()
                        + " <<---\n(skipping)"
                        + getJobMessage(jobInfo));
              }
              jobInfo.jobInStepMode = true;
              wasInStepMode = true;
              continue;
            }
          }

          long timeout = TeslaLimits.getJobTimeout();
          if (job.belongsTo(getFamilyAutoBuild())) {
            timeout = TeslaLimits.getAutoBuildJobTimeout();
          }
          if (jobInfo.jobInStepMode) {
            timeout = TeslaLimits.getStepModeTimeout();
          }
          if (job.getClass().getName().contains("org.eclipse.debug.internal.ui.DebugUIPlugin")) {
            timeout = TeslaLimits.getDebugJobTimeout();
          }
          if (jobStartTime + timeout < current) {
            if (context != null && TeslaEventManager.getManager().isJobInSyncExec(job, context)) {
              // Remove from stop waited jobs if called sync
              // exec
              jobInfo.checkForTimeout = false;
            } else {
              printJobTimeoutLogEntry(job);
              continue;
            }
          }
        }
        if (context != null) {
          if (isAsyncSupported()) {
            // If we are executed from async finished job lets
            // filter it
            if (JobsManager.getInstance().isFinishedAsyncJob(job)) {
              if (context.containsClass(job.getClass().getName())) {
                jobsInUI.add(job);
                continue;
              }
            }
          }
          if (isSyncSupported()) {
            // Check for any other job running Display.sleep()
            if (context.contains(Display.class.getName(), "sleep")) {
              if (TeslaEventManager.getManager().isJobInSyncExec(job, context)) {
                // If and only if job is already in synchronizer
                Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
                Set<String> names = getSuperClassNames(job);
                Thread jobThread = null;
                Context jobContext = null;
                for (Map.Entry<Thread, StackTraceElement[]> thread : traces.entrySet()) {
                  Context ctx = ContextManagement.makeContext(thread.getValue());
                  for (String name : names) {
                    if (ctx.contains("org.eclipse.core.internal.jobs.Worker", "run")
                        && ctx.contains(name, "run")) {
                      jobThread = thread.getKey();
                      jobContext = ctx;
                    }
                  }
                }
                if (jobThread != null && jobContext != null) {
                  if (jobContext.contains("org.eclipse.ui.internal.UISynchronizer", "syncExec")
                      && jobContext.contains("org.eclipse.ui.internal.Semaphore", "acquire")) {
                    if (!SWTUIPlayer.hasRunnables(RWTUtils.findDisplay())) {
                      // also check what sync exec are on
                      // current stack trace
                      List<Context> execs = TeslaEventManager.getManager().getSyncExecs();
                      boolean toContinue = true;
                      for (Context context2 : execs) {
                        StackTraceElement[] stackTrace = context2.getStackTrace();
                        String className = null;
                        for (int i = 0; i < stackTrace.length; i++) {
                          if (stackTrace[i].getClassName().equals("org.eclipse.swt.widgets.Display")
                              && stackTrace[i].getMethodName().equals("syncExec")) {
                            className = stackTrace[i + 1].getClassName();
                            break;
                          }
                        }
                        if (!context.containsClass(className)) {
                          toContinue = false;
                        }
                      }
                      if (toContinue) {
                        jobsInUI.add(job);
                        continue;
                      }
                    }
                  }
                }
              }
            }
          }
        }
        if (jobInfo.isActive()) realJobs.add(job);
      }
    }
    if (!jobsInUI.isEmpty()) {
      if (realJobs.size() == 1 && realJobs.get(0).belongsTo(getFamilyAutoBuild())) {
        realJobs.clear();
      }
    }
    if (realJobs.size() == 1) {
      Job job = realJobs.iterator().next();
      if (job.belongsTo(getFamilyAutoBuild())) {
        // Check for modal dialogs are visible
        int flags = TeslaSWTAccess.getJobFlags(job);
        // Job is alone and blocked
        if ((flags & 0xFF) == 0x08) {
          return logReturnResult(true, realJobs, jobsInUI, info);
        }
        final Display display = RWTUtils.findDisplay();
        final boolean value[] = {false};
        display.syncExec(
            new Runnable() {

              public void run() {
                Shell[] shells = display.getShells();
                for (Shell shell : shells) {
                  if (isModal(shell)) {
                    value[0] = true;
                  }
                }
              }
            });
        if (value[0]) {
          return logReturnResult(true, realJobs, jobsInUI, info);
        }
        if (job.getState() != Job.NONE) {
          return logReturnResult(false, realJobs, jobsInUI, info);
        }
        return logReturnResult(true, realJobs, jobsInUI, info);
      }
    }
    if (wasInStepMode && realJobs.isEmpty()) {
      stepModeNext = current + TeslaLimits.getStepModeStepTime();
    }
    return logReturnResult(realJobs.isEmpty(), realJobs, jobsInUI, info);
  }
コード例 #8
0
ファイル: UIJobCollector.java プロジェクト: xored/rcptt
  private String getJobMessage(JobInfo jobInfo) {
    Job job = jobInfo.job;
    StringBuilder msg = new StringBuilder();
    msg.append("Job: ").append(job.getName()).append("\n");

    msg.append("\tclass: ")
        .append(job.getClass().getName())
        .append(" ")
        .append(DetailUtils.extractSupers(job.getClass()))
        .append("\n");

    Long startTime = jobInfo.startingTime;

    long currentTimeMillis = System.currentTimeMillis();
    long time = 0;
    if (startTime != null) {
      time = currentTimeMillis - startTime.longValue();
    }

    msg.append("\tworking time: ").append(time).append("(ms)\n");
    msg.append("\tstate: ").append(job.getState()).append("\n");

    ISchedulingRule rule = job.getRule();
    if (rule != null) {
      if (rule instanceof IResource) {
        IPath location = ((IResource) rule).getLocation();
        msg.append("\trule is resource: ")
            .append(location != null ? location.toOSString() : "/")
            .append("\n");
      } else {
        msg.append("\trule: ").append(rule.toString()).append("\n");
      }
    } else {
      msg.append("\trule: Empty\n");
    }

    Thread thread = job.getThread();
    if (thread != null) {
      StackTraceElement[] trace = thread.getStackTrace();
      msg.append("\tstack trace: \n");
      // Print 5 lines of stack trace for job
      int c = 0;
      for (StackTraceElement stackTraceElement : trace) {
        if (c > 15) {
          msg.append("\t\t....");
          break;
        }
        c++;
        msg.append(
                "\t\t"
                    + stackTraceElement.getClassName()
                    + "."
                    + stackTraceElement.getMethodName()
                    + ":"
                    + stackTraceElement.getLineNumber()
                    + (stackTraceElement.getFileName() != null
                        ? (" [" + stackTraceElement.getFileName() + "]")
                        : ""))
            .append("\n");
      }
    }
    return msg.toString();
  }