|
|
@@ -27,6 +27,7 @@ import org.json.simple.JSONObject; |
|
|
import com.opencsv.CSVWriter; |
|
|
import com.opencsv.CSVWriter; |
|
|
|
|
|
|
|
|
import altk.comm.engine.Job.CommJobStatus; |
|
|
import altk.comm.engine.Job.CommJobStatus; |
|
|
|
|
|
import altk.comm.engine.Job.JobStatus; |
|
|
import altk.comm.engine.exception.BroadcastError; |
|
|
import altk.comm.engine.exception.BroadcastError; |
|
|
import altk.comm.engine.exception.BroadcastException; |
|
|
import altk.comm.engine.exception.BroadcastException; |
|
|
import altk.comm.engine.exception.EngineException; |
|
|
import altk.comm.engine.exception.EngineException; |
|
|
@@ -94,7 +95,7 @@ public abstract class Broadcast |
|
|
private Queue<Job> readyQueue; |
|
|
private Queue<Job> readyQueue; |
|
|
/** Count of items in scheduler */ |
|
|
/** Count of items in scheduler */ |
|
|
private int scheduledJobs; |
|
|
private int scheduledJobs; |
|
|
/** Instantaneous number of jobs being serviced by service provider */ |
|
|
|
|
|
|
|
|
/** Instantaneous number of jobs being serviced by service provider and JobStatus not final */ |
|
|
private int serviceActivityCount; |
|
|
private int serviceActivityCount; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1233,7 +1234,7 @@ public abstract class Broadcast |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected void updateServiceActivityCount(int increment) |
|
|
|
|
|
|
|
|
private void updateServiceActivityCount(int increment) |
|
|
{ |
|
|
{ |
|
|
synchronized (readyQueue) |
|
|
synchronized (readyQueue) |
|
|
{ |
|
|
{ |
|
|
@@ -1272,58 +1273,9 @@ public abstract class Broadcast |
|
|
report.initBase(job, broadcastId, launchRecordId, activityRecordIdParamName, jobReportRootNodeName); |
|
|
report.initBase(job, broadcastId, launchRecordId, activityRecordIdParamName, jobReportRootNodeName); |
|
|
report.init(job); |
|
|
report.init(job); |
|
|
postback.queueReport(report.toString()); |
|
|
postback.queueReport(report.toString()); |
|
|
if (job.statusIsFinal()) updateServiceActivityCount(-1); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Logs completedJobCount, readyQueue.size(), |
|
|
|
|
|
* active job count, and total. |
|
|
|
|
|
* Job statistics are collected by length of readyQueue, completedJobCount, |
|
|
|
|
|
*/ |
|
|
|
|
|
private void logJobCount(String title) |
|
|
|
|
|
{ |
|
|
|
|
|
if (postback == null) { |
|
|
|
|
|
myLogger.debug(title + ": postback = null"); |
|
|
|
|
|
myLogger.debug(String.format("%s: state %s, completed: %d, active: %d, ready: %d, scheduled: %d, total jobs: %d, remaining: %d, postQueue: ", |
|
|
|
|
|
title, |
|
|
|
|
|
state, |
|
|
|
|
|
getCompletedJobCount(), |
|
|
|
|
|
getActiveJobCount(), |
|
|
|
|
|
readyQueue.size(), |
|
|
|
|
|
scheduledJobs, |
|
|
|
|
|
jobsTotal, |
|
|
|
|
|
getRemainingJobCount() |
|
|
|
|
|
)); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if (postback.postQueue == null) { |
|
|
|
|
|
myLogger.debug(title + ": postback.postQueue = null"); |
|
|
|
|
|
myLogger.debug(String.format("%s: state %s, completed: %d, active: %d, ready: %d, scheduled: %d, total jobs: %d, remaining: %d, postQueue: ", |
|
|
|
|
|
title, |
|
|
|
|
|
state, |
|
|
|
|
|
getCompletedJobCount(), |
|
|
|
|
|
getActiveJobCount(), |
|
|
|
|
|
readyQueue.size(), |
|
|
|
|
|
scheduledJobs, |
|
|
|
|
|
jobsTotal, |
|
|
|
|
|
getRemainingJobCount() |
|
|
|
|
|
)); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
myLogger.debug(String.format("%s: state %s, completed: %d, active: %d, ready: %d, scheduled %d, total jobs: %d, remaining: %d, postQueue: %d", |
|
|
|
|
|
title, |
|
|
|
|
|
state, |
|
|
|
|
|
getCompletedJobCount(), |
|
|
|
|
|
getActiveJobCount(), |
|
|
|
|
|
readyQueue.size(), |
|
|
|
|
|
scheduledJobs, |
|
|
|
|
|
jobsTotal, |
|
|
|
|
|
getRemainingJobCount(), |
|
|
|
|
|
postback.postQueue.size() |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Number of jobs to be completed. |
|
|
* Number of jobs to be completed. |
|
|
* @return |
|
|
* @return |
|
|
@@ -1532,5 +1484,21 @@ public abstract class Broadcast |
|
|
|
|
|
|
|
|
protected void childAddConfigJSON(JSONObject dataMap) { |
|
|
protected void childAddConfigJSON(JSONObject dataMap) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean setJobStatus(Job job, JobStatus status) { |
|
|
|
|
|
if (job.statusIsFinal()) { |
|
|
|
|
|
myLogger.warn("Forbidden ttempt to overwrite a final job status '" + job.jobStatus + "' with '" + status + "'", new Exception("info")); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
job.setStatus(status); |
|
|
|
|
|
if (status.isFinal()) updateServiceActivityCount(-1); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean setJobStatus(Job job, JobStatus status, String errorText) { |
|
|
|
|
|
if (!setJobStatus(job, status)) return false; |
|
|
|
|
|
job.setErrorText(errorText); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |