| @@ -89,34 +89,47 @@ public abstract class CommEngine extends HttpServlet | |||||
| protected class DailyClock extends Thread | protected class DailyClock extends Thread | ||||
| { | { | ||||
| private static final String DAILY_CLOCK_THREAD_NAME = "DailyClock"; | |||||
| private boolean threadShouldStop = false; | private boolean threadShouldStop = false; | ||||
| DailyClock() | |||||
| { | |||||
| setName(DAILY_CLOCK_THREAD_NAME); | |||||
| } | |||||
| public void run() | 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() | 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 | // This change is backward compatible with placing the log4j.properties file in | ||||
| // the class path. | // the class path. | ||||
| String log4j_properties = confDirPath + "/log4j.properties"; | String log4j_properties = confDirPath + "/log4j.properties"; | ||||
| // Relocate file property offetting it by the runtimeDirPath | |||||
| // Relocate file property offsetting it by the runtimeDirPath | |||||
| try | try | ||||
| { | { | ||||
| Properties prop = new Properties(); | Properties prop = new Properties(); | ||||
| @@ -230,8 +243,6 @@ public abstract class CommEngine extends HttpServlet | |||||
| return; | return; | ||||
| } | } | ||||
| Thread dailyClock; | |||||
| CommonLogger.startup.info(String.format("Dead broadcast viewing period: %d minutes", deadBroadcastViewingMinutes)); | CommonLogger.startup.info(String.format("Dead broadcast viewing period: %d minutes", deadBroadcastViewingMinutes)); | ||||
| CommonLogger.startup.info(String.format("service thread pool size: %d", getServiceThreadPoolSize())); | CommonLogger.startup.info(String.format("service thread pool size: %d", getServiceThreadPoolSize())); | ||||