@@ -829,16 +829,15 @@ public abstract class Broadcast
+ "' recipient_count='" + recipientList.size() + "'");
+ "' recipient_count='" + recipientList.size() + "'");
if (launchRecordId != null)
if (launchRecordId != null)
{
{
statusBf.append(" launch_record_id='" + launchRecordId + "'");
statusBf.append(" launch_record_id='" + launchRecordId + "'> ");
}
}
statusBf.append(">\r\n");
statusBf.append("<current_time>" + System.currentTimeMillis() + "</current_time>\r\n");
statusBf.append("<current_time>" + System.currentTimeMillis() + "</current_time>");
if (serviceStartTime > 0) statusBf.append("<service_start_time>" + serviceStartTime
if (serviceStartTime > 0) statusBf.append("<service_start_time>" + serviceStartTime
+ "</service_start_time>\r\n ");
+ "</service_start_time>");
if (serviceEndTime > 0) statusBf.append("<service_end_time>" + serviceEndTime
if (serviceEndTime > 0) statusBf.append("<service_end_time>" + serviceEndTime
+ "</service_end_time>\r\n ");
+ "</service_end_time>");
statusBf.append("<state>" + state + "</state><state_change_time>" + changeStateTime
statusBf.append("<state>" + state + "</state><state_change_time>" + changeStateTime
+ "</state_change_time>\r\n ");
+ "</state_change_time>");
if (state == BroadcastState.PAUSED
if (state == BroadcastState.PAUSED
|| state == BroadcastState.ABORTED)
|| state == BroadcastState.ABORTED)
{
{
@@ -846,7 +845,7 @@ public abstract class Broadcast
{
{
// Escaping '&' and '<' in haltReason before enclosing it in <reason> tag
// Escaping '&' and '<' in haltReason before enclosing it in <reason> tag
statusBf.append("<reason>" + Util.xmlEscape(haltReason)
statusBf.append("<reason>" + Util.xmlEscape(haltReason)
+ "</reason>\r\n ");
+ "</reason>");
}
}
if (stateErrorText != null)
if (stateErrorText != null)
{
{
@@ -860,8 +859,8 @@ public abstract class Broadcast
"' ready='" + getPendingJobCount() + "'");
"' ready='" + getPendingJobCount() + "'");
statusBf.append(" active='" + getActiveJobCount() + "'");
statusBf.append(" active='" + getActiveJobCount() + "'");
statusBf.append("></job_summary>");
statusBf.append("></job_summary>");
statusBf.append("\r\n" + additionalStatusXML() + "\r\n" );
statusBf.append("</" + topLevelTag + ">\r\n ");
statusBf.append(additionalStatusXML());
statusBf.append("</" + topLevelTag + ">");
String statusReport = statusBf.toString();
String statusReport = statusBf.toString();
return statusReport;
return statusReport;
}
}
@@ -1030,15 +1029,23 @@ public abstract class Broadcast
myLogger.error("Caught exception while waiting for a Service thread to terminate:" + e);
myLogger.error("Caught exception while waiting for a Service thread to terminate:" + e);
}
}
}
}
waitForEndOfService();
setState(BroadcastState.COMPLETED);
setState(BroadcastState.COMPLETED);
}
}
destroyResources();
destroyResources();
postback.wrapup();
postback.wrapup();
postback = null;
postback = null;
//setState(BroadcastState.ALLDONE);
myLogger.info("Broadcast " + getId() + " terminated");
myLogger.info("Broadcast " + getId() + " terminated");
}
}
/**
* Derived class should wait for end of service before returning.
* At this point all service threads have already ended. If the derived
* class has other threads still taking part in providing service, wait for
* them to terminate.
*/
protected void waitForEndOfService() {}
/**
/**
* Derived class destroy resources needed for providing service
* Derived class destroy resources needed for providing service
*/
*/
@@ -1174,13 +1181,12 @@ public abstract class Broadcast
*/
*/
protected void postJobStatus(Job job, long rescheduleTimeMS)
protected void postJobStatus(Job job, long rescheduleTimeMS)
{
{
//logJobCount("Entering postJobStatus") ;
if (job.jobStatus == JobStatus.SUCCESS) successCount++ ;
if (postback != null)
if (postback != null)
{
{
JobReport report = mkJobReport();
JobReport report = mkJobReport();
report.initBase(job, broadcastId, launchRecordId, activityRecordIdParamName, jobReportRootNodeName);
report.initBase(job, broadcastId, launchRecordId, activityRecordIdParamName, jobReportRootNodeName);
report.init(job);
report.init(job);
if (job.jobStatus == JobStatus.SUCCESS) successCount++;
postback.queueReport(report.toString());
postback.queueReport(report.toString());
}
}
@@ -1299,17 +1305,9 @@ public abstract class Broadcast
public PostbackThreadActionOnEmpty getPostbackThreadActionOnEmpty() {
public PostbackThreadActionOnEmpty getPostbackThreadActionOnEmpty() {
//logJobCount("getPostbackThreadActionOnEmpty");
//logJobCount("getPostbackThreadActionOnEmpty");
if (state==BroadcastState.CANCELED || state==BroadcastState.ALLDONE ) return PostbackThreadActionOnEmpty.STOP;
if (state.isFinal ) return PostbackThreadActionOnEmpty.STOP;
if (setState(BroadcastState.ALLDONE).stateChangeStatus == StateChangeStatus.SUCCESS) return PostbackThreadActionOnEmpty.CONTINUE;
if (setState(BroadcastState.ALLDONE).stateChangeStatus == StateChangeStatus.SUCCESS) return PostbackThreadActionOnEmpty.CONTINUE;
return PostbackThreadActionOnEmpty.WAIT;
return PostbackThreadActionOnEmpty.WAIT;
}
}
public boolean postbackThreadsShouldStop() {
if (state==BroadcastState.CANCELED || state==BroadcastState.ALLDONE) return true;
boolean shouldContinue = state==BroadcastState.COMPLETED && setState(BroadcastState.ALLDONE).stateChangeStatus == StateChangeStatus.SUCCESS;
return !shouldContinue;
//boolean doStop = setState(BroadcastState.ALLDONE).stateChangeStatus != StateChangeStatus.SUCCESS;
//return doStop;
}
}
}