|
|
|
@@ -197,6 +197,7 @@ public abstract class Broadcast |
|
|
|
String haltReason; |
|
|
|
String stateErrorText; |
|
|
|
public long changeStateTime; |
|
|
|
private int completedJobCount = 0; |
|
|
|
|
|
|
|
protected class Service extends Thread |
|
|
|
{ |
|
|
|
@@ -578,10 +579,10 @@ public abstract class Broadcast |
|
|
|
+ "</error_text>"); |
|
|
|
} |
|
|
|
} |
|
|
|
statusBf.append("<remaining_jobs total='" + remainingJobs + "'"); |
|
|
|
int activeCount = getActiveCount(); |
|
|
|
if (activeCount > -1) statusBf.append(" active='" + activeCount + "'"); |
|
|
|
statusBf.append("></remaining_jobs></" + topLevelTag + ">\r\n"); |
|
|
|
statusBf.append("<job_summary completed='" + getCompletedJobCount() + |
|
|
|
"' ready='" + getReadyJobCount() + "'"); |
|
|
|
statusBf.append(" active='" + getActiveJobCount() + "'"); |
|
|
|
statusBf.append("></job_summary></" + topLevelTag + ">\r\n"); |
|
|
|
String statusReport = statusBf.toString(); |
|
|
|
return statusReport; |
|
|
|
} |
|
|
|
@@ -604,7 +605,7 @@ public abstract class Broadcast |
|
|
|
* |
|
|
|
* @return number of active jobs. -1 if there is no concept of being active. |
|
|
|
*/ |
|
|
|
private int getActiveCount() |
|
|
|
protected int getActiveJobCount() |
|
|
|
{ |
|
|
|
return remainingJobs - readyQueue.size(); |
|
|
|
} |
|
|
|
@@ -677,7 +678,7 @@ public abstract class Broadcast |
|
|
|
*/ |
|
|
|
protected void cancel() |
|
|
|
{ |
|
|
|
if (this.getActiveCount() == 0) setState(BroadcastState.CANCELED); |
|
|
|
if (this.getActiveJobCount() == 0) setState(BroadcastState.CANCELED); |
|
|
|
// Sets state to CANCELING, which is monitored by its Broadcast.Service threads. |
|
|
|
else setState(BroadcastState.CANCELING); |
|
|
|
synchronized(resumeFlag) |
|
|
|
@@ -849,7 +850,7 @@ public abstract class Broadcast |
|
|
|
{ |
|
|
|
terminate(BroadcastState.COMPLETED); |
|
|
|
} |
|
|
|
else if (getActiveCount() == 0) |
|
|
|
else if (getActiveJobCount() == 0) |
|
|
|
{ |
|
|
|
if (state == BroadcastState.CANCELING) setState(BroadcastState.CANCELED); |
|
|
|
else if (state == BroadcastState.HALTING) setState(BroadcastState.HALTED); |
|
|
|
@@ -868,6 +869,10 @@ public abstract class Broadcast |
|
|
|
protected void postJobStatus(Job job, long rescheduleTimeMS) |
|
|
|
{ |
|
|
|
postJobStatus(job); |
|
|
|
if (rescheduleTimeMS < 0) |
|
|
|
{ |
|
|
|
completedJobCount ++; |
|
|
|
} |
|
|
|
if (rescheduleTimeMS == 0) |
|
|
|
{ |
|
|
|
addJob(job); |
|
|
|
@@ -889,5 +894,22 @@ public abstract class Broadcast |
|
|
|
return state; |
|
|
|
} |
|
|
|
|
|
|
|
public int getReadyJobCount() |
|
|
|
{ |
|
|
|
switch (state) |
|
|
|
{ |
|
|
|
case RUNNING: |
|
|
|
case HALTING: |
|
|
|
case HALTED: |
|
|
|
return readyQueue.size(); |
|
|
|
default: |
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public int getCompletedJobCount() |
|
|
|
{ |
|
|
|
return completedJobCount; |
|
|
|
} |
|
|
|
} |