Skip to content

Commit fa1f135

Browse files
committed
Dump jobs state: incremental builder seems to be blocking something
1 parent 251042d commit fa1f135

2 files changed

Lines changed: 45 additions & 8 deletions

File tree

  • plugins
    • com.google.cloud.tools.eclipse.integration.appengine
    • com.google.cloud.tools.eclipse.test.util/src/com/google/cloud/tools/eclipse/test/util/project
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
org.eclipse.core.resources/debug=true
22
org.eclipse.core.resources/build/failure=true
3-
org.eclipse.core.resources/build/interrupt=true
3+
#org.eclipse.core.resources/build/interrupt=true
44
org.eclipse.core.resources/build/invoking=true
55
org.eclipse.core.resources/build/needbuild=true

plugins/com.google.cloud.tools.eclipse.test.util/src/com/google/cloud/tools/eclipse/test/util/project/ProjectUtils.java

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.junit.Assert.assertNotNull;
2020
import static org.junit.Assert.assertTrue;
2121

22+
import com.google.cloud.tools.eclipse.test.util.reflection.ReflectionUtil;
2223
import com.google.common.base.Joiner;
2324
import com.google.common.base.Stopwatch;
2425
import java.io.File;
@@ -35,6 +36,7 @@
3536
import java.util.concurrent.TimeUnit;
3637
import java.util.zip.ZipEntry;
3738
import java.util.zip.ZipFile;
39+
import org.eclipse.core.internal.jobs.InternalJob;
3840
import org.eclipse.core.resources.IMarker;
3941
import org.eclipse.core.resources.IProject;
4042
import org.eclipse.core.resources.IProjectDescription;
@@ -227,20 +229,55 @@ public static void waitForProjects(Runnable delayTactic, IProject... projects) {
227229
timer, currentBuildErrors.size());
228230
}
229231
// Uncomment if tests are failing to identify any other build-related jobs.
230-
Job[] otherJobs = Job.getJobManager().find(null);
231-
if (otherJobs.length > 0) {
232-
System.err.printf("Ignoring %d unrelated jobs:\n", otherJobs.length);
233-
for (Job job : otherJobs) {
234-
System.err.printf(" %s: %s\n", job.getClass().getName(), job);
235-
}
236-
}
232+
dumpJobsState();
237233
}
238234
} while (!jobs.isEmpty() || buildErrorsChanging);
239235
} catch (CoreException | InterruptedException ex) {
240236
throw new RuntimeException(ex);
241237
}
242238
}
243239

240+
private static void dumpJobsState() {
241+
Job[] otherJobs = Job.getJobManager().find(null);
242+
if (otherJobs.length == 0) {
243+
System.err.printf("ProjectUtils#dumpJobsState: no jobs\n");
244+
return;
245+
}
246+
247+
System.err.printf("ProjectUtils#dumpJobsState: %d jobs:\n", otherJobs.length);
248+
for (Job job : otherJobs) {
249+
String status;
250+
switch (job.getState()) {
251+
case Job.RUNNING:
252+
status = "RUNNING";
253+
break;
254+
case Job.WAITING:
255+
status = "WAITING";
256+
break;
257+
case Job.SLEEPING:
258+
status = "SLEEPING";
259+
break;
260+
case Job.NONE:
261+
status = "NONE";
262+
break;
263+
default:
264+
status = "UNKNOWN(" + job.getState() + ")";
265+
break;
266+
}
267+
Object blockingJob = null;
268+
try {
269+
blockingJob =
270+
ReflectionUtil.invoke(Job.getJobManager(), "findBlockingJob", InternalJob.class, job);
271+
} catch (Exception ex) {
272+
System.err.println("Unable to fetch blocking-job: " + ex);
273+
}
274+
System.err.printf(" %s[%d,%s%s%s%s]: %s%s\n", job.getClass().getName(), job.getPriority(),
275+
status, (job.isUser() ? ",user" : ""), (job.isSystem() ? ",system" : ""),
276+
(job.isBlocking() ? ",blocking" : ""), job,
277+
(blockingJob != null ? "; blocked by: " + blockingJob : ""));
278+
}
279+
}
280+
244281
/** Identify all jobs that we know of that are related to building. */
245282
private static Collection<Job> findPendingBuildJobs(IProject... projects) {
246283
Set<Job> jobs = new HashSet<>();

0 commit comments

Comments
 (0)