瀏覽代碼

Close window of missing clock action on a heavily loaded system.

The clock thread may not wake up during the daily pause
and daily resume minute, and when it does not, the corresponding
wall clock action will be missed.

The fix is in checkout the time of operations every time the
clock thread wakes up.

There is no longer need for the clock to wake up in the middle of
a wall clock minute.  So we improved the user experience by waking
up this thread at the beginning of every minute.
tags/1.0.32
ymlam 1 年之前
父節點
當前提交
c480c88ba9
共有 2 個文件被更改,包括 7 次插入14 次删除
  1. +3
    -0
      src/main/java/altk/comm/engine/Broadcast.java
  2. +4
    -14
      src/main/java/altk/comm/engine/CommEngine.java

+ 3
- 0
src/main/java/altk/comm/engine/Broadcast.java 查看文件

@@ -1021,6 +1021,7 @@ public abstract class Broadcast
protected String resume(String reason) {
if (reason == ACTION_BY_CLOCK) {
boolean inAcceptqble = false;
if (this.reason == null) return null;
for (String acceptable : getPauseModesResumableByClock()) {
if (this.reason.equalsIgnoreCase(acceptable)) inAcceptqble = true;
}
@@ -1437,6 +1438,8 @@ public abstract class Broadcast
if (state == BroadcastState.ABORTED) return;
if (!withinOperatingHours()) {
pause(ACTION_BY_CLOCK, null);
} else {
resume(ACTION_BY_CLOCK, null);
}
}



+ 4
- 14
src/main/java/altk/comm/engine/CommEngine.java 查看文件

@@ -95,25 +95,15 @@ public abstract class CommEngine extends HttpServlet
{
while (!threadShouldStop)
{
String timeOfDay = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));
// Check for pause
for (Broadcast broadcast : broadcasts.values())
{;
// Check for pause
if (broadcast.daily_stop.length() > 0)
{
if (timeOfDay.equals(broadcast.daily_stop)) broadcast.pause("clock", null);
}

// Check for resume
if (broadcast.daily_start.length() > 0)
{
if (timeOfDay.equals(broadcast.daily_start)) broadcast.resume(Broadcast.ACTION_BY_CLOCK);
}
{
broadcast.enforceOperationHours();
}

// sleep till next wall clock minute
long currentTime = System.currentTimeMillis();
long sleepTime = 60000 + 30000 - currentTime % 60000;
long sleepTime = 60000 - currentTime % 60000;
if (sleepTime > 0)
{
try


Loading…
取消
儲存