Browse Source

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 year ago
parent
commit
c480c88ba9
2 changed files with 7 additions and 14 deletions
  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 View File

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




+ 4
- 14
src/main/java/altk/comm/engine/CommEngine.java View File

@@ -95,25 +95,15 @@ public abstract class CommEngine extends HttpServlet
{ {
while (!threadShouldStop) while (!threadShouldStop)
{ {
String timeOfDay = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));
// Check for pause // Check for pause
for (Broadcast broadcast : broadcasts.values()) 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 currentTime = System.currentTimeMillis();
long sleepTime = 60000 + 30000 - currentTime % 60000;
long sleepTime = 60000 - currentTime % 60000;
if (sleepTime > 0) if (sleepTime > 0)
{ {
try try


Loading…
Cancel
Save