3 Commits

3 changed files with 33 additions and 41 deletions
Split View
  1. +2
    -2
      pom.xml
  2. +0
    -19
      src/main/java/altk/comm/engine/Broadcast.java
  3. +31
    -20
      src/main/java/altk/comm/engine/CommEngine.java

+ 2
- 2
pom.xml View File

@@ -2,13 +2,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>alerttek</groupId>
<artifactId>CommEngine</artifactId>
<version>1.0.33-SNAPSHOT</version>
<version>1.0.33</version>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<scm>
<developerConnection>scm:git:https://git.link2tek.net/ymlam/CommEngine.git</developerConnection>
<tag>HEAD</tag>
<tag>1.0.33</tag>
</scm>

<build>


+ 0
- 19
src/main/java/altk/comm/engine/Broadcast.java View File

@@ -1411,25 +1411,6 @@ public abstract class Broadcast
if (timeChanged) enforceOperationHours();
}

/**
* YML: At this time, we only enforce pause action when a broadcast is
* outside its operating hours. The current design is not satisfactory and needs
* a better solution.
*
* We are not automatically resuming a paused broadcast because the difference
* between intention of an operator-initiated pause and
* that of a clock pause needs clarification in their operation paradigm.
* Question is when or if we allow a operator-initiated pause be resumed
* when someone changes the operating hours of a broadcast in such a way
* that the broadcast is at once within its operasting hours. it may be
* be counter to the intention of the original operator.
*
* On the other hand, if that places the broadcast outside it operating hours,
* it is safer to immediately pause it.
*
* To add clarity, we may need to separate the PAUSE state into OPERATOR_PAUSE and CLOCK_PAUSE,
* and similarly PAUING state.
*/
void enforceOperationHours() {
if (state == BroadcastState.ABORTED) return;
if (!withinOperatingHours()) {


+ 31
- 20
src/main/java/altk/comm/engine/CommEngine.java View File

@@ -89,34 +89,47 @@ public abstract class CommEngine extends HttpServlet
protected class DailyClock extends Thread
{
private static final String DAILY_CLOCK_THREAD_NAME = "DailyClock";
private boolean threadShouldStop = false;
DailyClock()
{
setName(DAILY_CLOCK_THREAD_NAME);
}
public void run()
{
while (!threadShouldStop)
try
{
// Check for pause
for (Broadcast broadcast : broadcasts.values())
{
broadcast.enforceOperationHours();
}

// sleep till next wall clock minute
long currentTime = System.currentTimeMillis();
long sleepTime = 60000 - currentTime % 60000;
if (sleepTime > 0)
while (!threadShouldStop)
{
try
// Check for pause
for (Broadcast broadcast : broadcasts.values())
{
Thread.sleep(sleepTime);
}
catch (Exception e)
broadcast.enforceOperationHours();
}
// sleep till next wall clock minute
long currentTime = System.currentTimeMillis();
long sleepTime = 60000 - currentTime % 60000;
if (sleepTime > 0)
{
myLogger.error("DailyClock thread caught: " + e.getMessage(), e);
return;
try
{
Thread.sleep(sleepTime);
}
catch (Exception e)
{
myLogger.error("DailyClock thread caught: " + e.getMessage(), e);
return;
}
}
}
}
catch (Throwable t)
{
myLogger.error(DAILY_CLOCK_THREAD_NAME + " thread caught: " + t.getMessage(), t);
}
}

public void terminate()
@@ -177,7 +190,7 @@ public abstract class CommEngine extends HttpServlet
// This change is backward compatible with placing the log4j.properties file in
// the class path.
String log4j_properties = confDirPath + "/log4j.properties";
// Relocate file property offetting it by the runtimeDirPath
// Relocate file property offsetting it by the runtimeDirPath
try
{
Properties prop = new Properties();
@@ -230,8 +243,6 @@ public abstract class CommEngine extends HttpServlet
return;
}
Thread dailyClock;
CommonLogger.startup.info(String.format("Dead broadcast viewing period: %d minutes", deadBroadcastViewingMinutes));

CommonLogger.startup.info(String.format("service thread pool size: %d", getServiceThreadPoolSize()));


Loading…
Cancel
Save