浏览代码

Give derived class chance to wait for service activity to end

before progressing to COMPLETED state and issue state change
notification to portal.

Also make state change report to be a single line for ease
of grep'ing log file.
tags/1.0.5
ymlam 4 年前
父节点
当前提交
fe430891ac
共有 1 个文件被更改,包括 20 次插入22 次删除
  1. +20
    -22
      src/main/java/altk/comm/engine/Broadcast.java

+ 20
- 22
src/main/java/altk/comm/engine/Broadcast.java 查看文件

@@ -829,16 +829,15 @@ public abstract class Broadcast
+ "' recipient_count='" + recipientList.size() + "'");
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
+ "</service_start_time>\r\n");
+ "</service_start_time>");
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
+ "</state_change_time>\r\n");
+ "</state_change_time>");
if (state == BroadcastState.PAUSED
|| state == BroadcastState.ABORTED)
{
@@ -846,7 +845,7 @@ public abstract class Broadcast
{
// Escaping '&' and '<' in haltReason before enclosing it in <reason> tag
statusBf.append("<reason>" + Util.xmlEscape(haltReason)
+ "</reason>\r\n");
+ "</reason>");
}
if (stateErrorText != null)
{
@@ -860,8 +859,8 @@ public abstract class Broadcast
"' ready='" + getPendingJobCount() + "'");
statusBf.append(" active='" + getActiveJobCount() + "'");
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();
return statusReport;
}
@@ -1030,15 +1029,23 @@ public abstract class Broadcast
myLogger.error("Caught exception while waiting for a Service thread to terminate:" + e);
}
}
waitForEndOfService();
setState(BroadcastState.COMPLETED);
}
destroyResources();
postback.wrapup();
postback = null;
//setState(BroadcastState.ALLDONE);
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
*/
@@ -1174,13 +1181,12 @@ public abstract class Broadcast
*/
protected void postJobStatus(Job job, long rescheduleTimeMS)
{
//logJobCount("Entering postJobStatus");
if (job.jobStatus == JobStatus.SUCCESS) successCount++;
if (postback != null)
{
JobReport report = mkJobReport();
report.initBase(job, broadcastId, launchRecordId, activityRecordIdParamName, jobReportRootNodeName);
report.init(job);
if (job.jobStatus == JobStatus.SUCCESS) successCount++;
postback.queueReport(report.toString());
}
@@ -1299,17 +1305,9 @@ public abstract class Broadcast

public PostbackThreadActionOnEmpty 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;
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;
}

}

正在加载...
取消
保存