Example #1
0
  /**
   * {@inheritDoc}
   *
   * @see org.eclim.command.Command#execute(CommandLine)
   */
  public String execute(CommandLine commandLine) throws Exception {
    Object family = getFamily(commandLine.getValue(Options.FAMILY_OPTION));
    IJobManager manager = Job.getJobManager();
    Job[] jobs = manager.find(family);

    StringBuffer buffer = new StringBuffer();
    int maxlength = 0;
    for (Job job : jobs) {
      int length = job.toString().length();
      if (length > maxlength) {
        maxlength = length;
      }
    }

    for (Job job : jobs) {
      if (buffer.length() > 0) {
        buffer.append('\n');
      }
      buffer
          .append(StringUtils.rightPad(job.toString(), maxlength))
          .append(" - ")
          .append(getStatus(job));
    }
    return buffer.toString();
  }
 /**
  * This is called by the registry controller to tell the registry to terminate with prejudice all
  * pending TerminateJobs.
  *
  * @since 1.1.0
  */
 public static void cancelAllTerminateJobs() {
   IJobManager jobManager = Job.getJobManager();
   jobManager.cancel(TERMINATE_JOB_FAMILY);
   try {
     jobManager.join(TERMINATE_JOB_FAMILY, null);
   } catch (OperationCanceledException e) {
   } catch (InterruptedException e) {
   }
 }
Example #3
0
 private void waitJobsToFinish(final Object family) {
   final IJobManager jobMan = Job.getJobManager();
   final Job[] build = jobMan.find(family);
   if (build.length == 1) {
     try {
       build[0].join();
     } catch (final InterruptedException e) {
     }
   }
 }
Example #4
0
  public static void waitForJobsToComplete(IProgressMonitor monitor)
      throws InterruptedException, CoreException {
    waitForBuildJobs();

    /*
     * First, make sure refresh job gets all resource change events
     *
     * Resource change events are delivered after WorkspaceJob#runInWorkspace returns
     * and during IWorkspace#run. Each change notification is delivered by
     * only one thread/job, so we make sure no other workspaceJob is running then
     * call IWorkspace#run from this thread.
     *
     * Unfortunately, this does not catch other jobs and threads that call IWorkspace#run
     * so we have to hard-code workarounds
     *
     * See http://www.eclipse.org/articles/Article-Resource-deltas/resource-deltas.html
     */
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IJobManager jobManager = Job.getJobManager();
    jobManager.suspend();
    try {
      Job[] jobs = jobManager.find(null);
      for (int i = 0; i < jobs.length; i++) {
        if (jobs[i] instanceof WorkspaceJob
            || jobs[i].getClass().getName().endsWith("JREUpdateJob")) {
          jobs[i].join();
        }
      }
      workspace.run(
          new IWorkspaceRunnable() {
            public void run(IProgressMonitor monitor) {}
          },
          workspace.getRoot(),
          0,
          monitor);

      // Now we flush all background processing queues
      boolean processed = flushProcessingQueues(jobManager, monitor);
      for (int i = 0; i < 10 && processed; i++) {
        processed = flushProcessingQueues(jobManager, monitor);
        try {
          Thread.sleep(10);
        } catch (InterruptedException e) {
        }
      }

      Assert.assertFalse(
          "Could not flush background processing queues: " + getProcessingQueues(jobManager),
          processed);
    } finally {
      jobManager.resume();
    }

    waitForBuildJobs();
  }
 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());
 }
Example #6
0
 void dispose() {
   if (es != null) {
     es.shutdown();
   }
   if (refreshJob != null) {
     refreshJob.cancel();
     refreshJob = null;
   }
   // Cancel any jobs we're running in the index!
   IJobManager jobManager = Job.getJobManager();
   if (jobManager != null) {
     jobManager.cancel(this);
   }
 }
Example #7
0
 private static List<IBackgroundProcessingQueue> getProcessingQueues(IJobManager jobManager) {
   ArrayList<IBackgroundProcessingQueue> queues = new ArrayList<IBackgroundProcessingQueue>();
   for (Job job : jobManager.find(null)) {
     if (job instanceof IBackgroundProcessingQueue) {
       queues.add((IBackgroundProcessingQueue) job);
     }
   }
   return queues;
 }
 private void unlockDocument(IJobManager jobMgr, ISchedulingRule rule) {
   if (rule != null) {
     jobMgr.endRule(rule);
   } else
     synchronized (fDocumentAccessorLock) {
       fDocumentLocked = false;
       fDocumentAccessorLock.notifyAll();
     }
 }
 public <T extends IRepositoryStore<? extends IRepositoryFileStore>> T getRepositoryStore(
     final Class<T> storeClass) {
   try {
     jobManager.join(
         WorkspaceInitializationJob.WORKSPACE_INIT_FAMILY, Repository.NULL_PROGRESS_MONITOR);
   } catch (OperationCanceledException | InterruptedException e) {
     BonitaStudioLog.error("Synchronization failed", e);
   }
   return repositoryManagerInstance.getRepositoryStore(storeClass);
 }
 public void run(IProgressMonitor monitor)
     throws InvocationTargetException, InterruptedException {
   if (fgFirstTime) {
     // Join the initialize after load job.
     IJobManager manager = Job.getJobManager();
     manager.join(JavaScriptUI.ID_PLUGIN, monitor);
   }
   OpenTypeHistory history = OpenTypeHistory.getInstance();
   if (fgFirstTime || history.isEmpty()) {
     monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100);
     if (history.needConsistencyCheck()) {
       refreshSearchIndices(new SubProgressMonitor(monitor, 90));
       history.checkConsistency(new SubProgressMonitor(monitor, 10));
     } else {
       refreshSearchIndices(monitor);
     }
     monitor.done();
     fgFirstTime = false;
   } else {
     history.checkConsistency(monitor);
   }
 }
 private void lockDocument(IProgressMonitor monitor, IJobManager jobMgr, ISchedulingRule rule) {
   if (rule != null) {
     jobMgr.beginRule(rule, monitor);
   } else
     synchronized (fDocumentAccessorLock) {
       while (fDocumentLocked) {
         try {
           fDocumentAccessorLock.wait();
         } catch (InterruptedException e) {
           // nobody interrupts us!
           throw new OperationCanceledException();
         }
       }
       fDocumentLocked = true;
     }
 }