Java Code Examples for org.eclipse.core.runtime.jobs.Job#RUNNING
The following examples show how to use
org.eclipse.core.runtime.jobs.Job#RUNNING .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CloudSdkModifyJobTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testRun_mutualExclusion() throws InterruptedException { FakeModifyJob job1 = new FakeModifyJob(true /* blockOnStart */); FakeModifyJob job2 = new FakeModifyJob(true /* blockOnStart */); job1.schedule(); while (job1.getState() != Job.RUNNING) { Thread.sleep(50); } job2.schedule(); // Incomplete test, but if it ever fails, something is surely broken. assertNotEquals(Job.RUNNING, job2.getState()); job1.unblock(); job2.unblock(); job1.join(); job2.join(); }
Example 2
Source File: CloudSdkModifyJobTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testRun_blockedUntilWritable() throws InterruptedException { assertTrue(readWriteLock.readLock().tryLock()); boolean locked = true; try { FakeModifyJob job = new FakeModifyJob(true /* blockOnStart */); job.schedule(); while (job.getState() != Job.RUNNING) { Thread.sleep(50); } // Incomplete test, but if it ever fails, something is surely broken. assertFalse(job.modifiedSdk); readWriteLock.readLock().unlock(); locked = false; job.unblock(); job.join(); } finally { if (locked) { readWriteLock.readLock().unlock(); } } }
Example 3
Source File: CloudSdkManagerTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testPreventModifyingSdk_blocksRunInstallJob() throws InterruptedException { fixture.preventModifyingSdk(); boolean prevented = true; try { final CloudSdkModifyJob installJob = new FakeModifyJob(Status.OK_STATUS); Job concurrentLauncher = new Job("concurrent thread attempting runInstallJob()") { @Override public IStatus run(IProgressMonitor monitor) { // Should block until we allow SDK modification below. CloudSdkManager.runInstallJob(null, installJob, monitor); return Status.OK_STATUS; } }; concurrentLauncher.schedule(); while (installJob.getState() != Job.RUNNING) { Thread.sleep(50); } // Incomplete test, but if it ever fails, something is surely broken. assertEquals(Job.RUNNING, concurrentLauncher.getState()); fixture.allowModifyingSdk(); prevented = false; concurrentLauncher.join(); // Incomplete test, but if it ever fails, something is surely broken. assertTrue(installJob.getResult().isOK()); assertTrue(concurrentLauncher.getResult().isOK()); } finally { if (prevented) { fixture.allowModifyingSdk(); } } }
Example 4
Source File: RunOptionsDefaultsComponent.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * Fetch the staging locations from GCS in a background task and update the Staging Locations * combo. */ @VisibleForTesting void updateStagingLocations(long scheduleDelay) { Credential credential = accountSelector.getSelectedCredential(); String selectedEmail = accountSelector.getSelectedEmail(); GcpProject project = projectInput.getProject(); // Retrieving staging locations requires an authenticated user and project. // Check if there is an update is in progress; if it matches our user and project, // then quick-return, otherwise it is stale and should be cancelled. if (fetchStagingLocationsJob != null) { if (project != null && Objects.equals(project.getId(), fetchStagingLocationsJob.getProjectId()) && Objects.equals(selectedEmail, fetchStagingLocationsJob.getAccountEmail()) && fetchStagingLocationsJob.getState() == Job.RUNNING) { return; } fetchStagingLocationsJob.abandon(); } fetchStagingLocationsJob = null; if (project != null && credential != null) { fetchStagingLocationsJob = new FetchStagingLocationsJob(getGcsClient(), selectedEmail, project.getId()); fetchStagingLocationsJob.onSuccess( displayExecutor, stagingLocations -> { updateStagingLocations(stagingLocations); validate(); // reports message back to UI }); fetchStagingLocationsJob.onError( displayExecutor, exception -> { DataflowUiPlugin.logError( exception, "Exception while retrieving staging locations"); // $NON-NLS-1$ validate(); }); fetchStagingLocationsJob.schedule(scheduleDelay); } }
Example 5
Source File: RunOptionsDefaultsComponent.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * Ensure the staging location specified in the input combo is valid. */ @VisibleForTesting void startStagingLocationCheck(long schedulingDelay) { String accountEmail = getAccountEmail(); String stagingLocation = getStagingLocation(); if (verifyStagingLocationJob != null) { if (Objects.equals(accountEmail, verifyStagingLocationJob.getEmail()) && Objects.equals(stagingLocation, verifyStagingLocationJob.getStagingLocation()) && verifyStagingLocationJob.getState() == Job.RUNNING) { // an update is in progress return; } // Cancel any existing verifyStagingLocationJob verifyStagingLocationJob.abandon(); verifyStagingLocationJob = null; } if (Strings.isNullOrEmpty(accountEmail) || Strings.isNullOrEmpty(stagingLocation)) { return; } verifyStagingLocationJob = new VerifyStagingLocationJob(getGcsClient(), accountEmail, stagingLocation); verifyStagingLocationJob.onSuccess(displayExecutor, this::validate); verifyStagingLocationJob.schedule(schedulingDelay); }
Example 6
Source File: FindBugsJob.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
public static void cancelSimilarJobs(FindBugsJob job) { if (job.getResource() == null) { return; } Job[] jobs = Job.getJobManager().find(FindbugsPlugin.class); for (Job job2 : jobs) { if (job2 instanceof FindBugsJob && job.getResource().equals(((FindBugsJob) job2).getResource())) { if (job2.getState() != Job.RUNNING) { job2.cancel(); } } } }
Example 7
Source File: ProverHelper.java From tlaplus with MIT License | 5 votes |
/** * Sends a signal to the prover indicating that the obligation, * whose status is represented by marker, should be stopped. * * The marker should by of the type {@link #OBLIGATION_MARKER}. * * This method assumes that there is at most one prover job currently * running and that this marker is for an obligation from that prover * job. * * @param marker */ public static void stopObligation(IMarker marker) { ProverUIActivator.getDefault().logDebug("Stop obligation " + marker.getAttribute(OBLIGATION_ID, -1)); // a count of running prover jobs for debugging // check to see that there is at most 1 int numProverJobs = 0; Job[] jobs = Job.getJobManager().find(new ProverJob.ProverJobMatcher()); for (int i = 0; i < jobs.length; i++) { if (jobs[i] instanceof ProverJob && jobs[i].getState() == Job.RUNNING) { numProverJobs++; ProverJob proverJob = (ProverJob) jobs[i]; proverJob.stopObligation(marker.getAttribute(OBLIGATION_ID, -1)); } } if (numProverJobs > 1) { ProverUIActivator.getDefault().logDebug("We found " + numProverJobs + " running when obligation " + marker.getAttribute(OBLIGATION_ID, -1) + " was stopped. This is a bug."); } }
Example 8
Source File: WaitUtils.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static String jobStateToString(int jobState) { switch (jobState) { case Job.RUNNING: return "RUNNING"; //$NON-NLS-1$ case Job.WAITING: return "WAITING"; //$NON-NLS-1$ case Job.SLEEPING: return "SLEEPING"; //$NON-NLS-1$ case Job.NONE: return "NONE"; //$NON-NLS-1$ default: return "UNKNOWN"; //$NON-NLS-1$ } }
Example 9
Source File: TmfNavigatorLabelProvider.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static StyledString formatTraceRange(TmfTraceElement traceElement) { ITmfTimestamp start = traceElement.getStartTime(); ITmfTimestamp end = traceElement.getEndTime(); if (start == null) { boundsToUpdate.add(traceElement); if (updateBounds.getState() != Job.RUNNING) { updateBounds.schedule(); } return new StyledString(" [...]", StyledString.DECORATIONS_STYLER); //$NON-NLS-1$ } if (start.equals(TmfTimestamp.BIG_BANG)) { /* Not a trace or empty */ return new StyledString(); } if (end == null || end.equals(TmfTimestamp.BIG_BANG)) { return new StyledString(" [" + TmfTimestampFormat.getDefaulTimeFormat().format(start.toNanos()) //$NON-NLS-1$ + " - ...]", //$NON-NLS-1$ StyledString.DECORATIONS_STYLER); } return new StyledString(" [" + TmfTimestampFormat.getDefaulTimeFormat().format(start.toNanos()) //$NON-NLS-1$ + " - " + TmfTimestampFormat.getDefaulTimeFormat().format(end.toNanos()) + "]", //$NON-NLS-1$ //$NON-NLS-2$ StyledString.DECORATIONS_STYLER); }
Example 10
Source File: ThreadDumpingWatchdog.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
private static void dumpJob(StringBuilder sb, String linePrefix, Job job, Thread thread) { String status; switch (job.getState()) { case Job.RUNNING: status = "RUNNING"; break; case Job.WAITING: status = "WAITING"; break; case Job.SLEEPING: status = "SLEEPING"; break; case Job.NONE: status = "NONE"; break; default: status = "UNKNOWN(" + job.getState() + ")"; break; } Object blockingJob = null; try { blockingJob = ReflectionUtil.invoke(Job.getJobManager(), "findBlockingJob", InternalJob.class, new Class<?>[] {InternalJob.class}, job); } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { System.err.println("Unable to fetch blocking-job: " + ex); } sb.append("\n").append(linePrefix); sb.append( String.format( " %s%s{pri=%d%s%s%s%s} %s (%s)%s", status, (job.isBlocking() ? "<BLOCKING>" : ""), job.getPriority(), (job.isSystem() ? ",system" : ""), (job.isUser() ? ",user" : ""), (job.getRule() != null ? ",rule=" + job.getRule() : ""), (thread != null ? ",thr=" + thread : ""), job, job.getClass().getName(), (job.getJobGroup() != null ? " [group=" + job.getJobGroup() + "]" : ""))); if (blockingJob != null) { sb.append("\n").append(linePrefix) .append(String.format(" - blocked by: %s (%s)", blockingJob, blockingJob.getClass())); } }
Example 11
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 4 votes |
/** * Schedules progress message refresh. */ public void scheduleProgressMessageRefresh() { if (filterJob.getState() != Job.RUNNING && refreshProgressMessageJob.getState() != Job.RUNNING) refreshProgressMessageJob.scheduleProgressRefresh(null); }