Merge "SSH show-queue: option to group output by queue and print queue info"
This commit is contained in:
@@ -113,6 +113,7 @@ public class ListTasks implements RestReadView<ConfigResource> {
|
||||
public String command;
|
||||
public String remoteName;
|
||||
public String projectName;
|
||||
public String queueName;
|
||||
|
||||
public TaskInfo(Task<?> task) {
|
||||
this.id = IdGenerator.format(task.getTaskId());
|
||||
@@ -120,6 +121,7 @@ public class ListTasks implements RestReadView<ConfigResource> {
|
||||
this.startTime = new Timestamp(task.getStartTime().getTime());
|
||||
this.delay = task.getDelay(TimeUnit.MILLISECONDS);
|
||||
this.command = task.toString();
|
||||
this.queueName = task.getQueueName();
|
||||
|
||||
if (task instanceof ProjectTask) {
|
||||
ProjectTask<?> projectTask = ((ProjectTask<?>) task);
|
||||
|
||||
@@ -152,6 +152,15 @@ public class WorkQueue {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Executor getExecutor(String queueName) {
|
||||
for (Executor e : queues) {
|
||||
if (e.queueName.equals(queueName)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void stop() {
|
||||
for (final Executor p : queues) {
|
||||
p.shutdown();
|
||||
@@ -170,8 +179,9 @@ public class WorkQueue {
|
||||
/** An isolated queue. */
|
||||
public class Executor extends ScheduledThreadPoolExecutor {
|
||||
private final ConcurrentHashMap<Integer, Task<?>> all;
|
||||
private final String queueName;
|
||||
|
||||
Executor(final int corePoolSize, final String prefix) {
|
||||
Executor(int corePoolSize, final String prefix) {
|
||||
super(corePoolSize, new ThreadFactory() {
|
||||
private final ThreadFactory parent = Executors.defaultThreadFactory();
|
||||
private final AtomicInteger tid = new AtomicInteger(1);
|
||||
@@ -190,6 +200,7 @@ public class WorkQueue {
|
||||
0.75f, // load factor
|
||||
corePoolSize + 4 // concurrency level
|
||||
);
|
||||
queueName = prefix;
|
||||
}
|
||||
|
||||
public void unregisterWorkQueue() {
|
||||
@@ -325,6 +336,10 @@ public class WorkQueue {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public String getQueueName() {
|
||||
return executor.queueName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancel(boolean mayInterruptIfRunning) {
|
||||
if (task.cancel(mayInterruptIfRunning)) {
|
||||
|
||||
Reference in New Issue
Block a user