Browse Source

Add support for SMS provider property 'service_threadpool_size'.

tags/1.0.2
Yuk-Ming Lam 4 years ago
parent
commit
0da88a02c7
2 changed files with 12 additions and 9 deletions
  1. +8
    -7
      src/main/java/altk/comm/engine/Broadcast.java
  2. +4
    -2
      src/main/java/altk/comm/engine/CommEngine.java

+ 8
- 7
src/main/java/altk/comm/engine/Broadcast.java View File

@@ -72,7 +72,7 @@ public abstract class Broadcast
private int completedJobCount; private int completedJobCount;
private ScheduledExecutorService scheduler; private ScheduledExecutorService scheduler;
private int serviceThreadPoolSize;
private int serviceThreadPoolSize_default;
private int jobsTotal; private int jobsTotal;


public static enum BroadcastState public static enum BroadcastState
@@ -433,7 +433,7 @@ public abstract class Broadcast
{ {
myLogger.debug("Entering Broadcast.doPost method"); myLogger.debug("Entering Broadcast.doPost method");
BroadcastException myException = null; BroadcastException myException = null;
this.serviceThreadPoolSize = commEngine.getServiceThreadPoolSize();
serviceThreadPoolSize_default = commEngine.getServiceThreadPoolSize();
try try
{ {
boolean notInService = commEngine.notInService(); boolean notInService = commEngine.notInService();
@@ -517,6 +517,7 @@ public abstract class Broadcast
// at the same time, setting up a list of service thread names // at the same time, setting up a list of service thread names
// for use by derived class to set up contexts in which // for use by derived class to set up contexts in which
// these threads run. // these threads run.
int serviceThreadPoolSize = getServiceThreadPoolSize();
myLogger.debug("At creating service threads, serviceThreadPoolSize = " + serviceThreadPoolSize); myLogger.debug("At creating service threads, serviceThreadPoolSize = " + serviceThreadPoolSize);
List<String> serviceThreadNames = new ArrayList<String>(); List<String> serviceThreadNames = new ArrayList<String>();
for (int i = 0; i < serviceThreadPoolSize; i++) for (int i = 0; i < serviceThreadPoolSize; i++)
@@ -542,6 +543,11 @@ public abstract class Broadcast
} }
} }
protected int getServiceThreadPoolSize()
{
return serviceThreadPoolSize_default;
}
protected abstract void returnPrerequisites(ServicePrerequisites prerequisites); protected abstract void returnPrerequisites(ServicePrerequisites prerequisites);
/** /**
@@ -1170,11 +1176,6 @@ public abstract class Broadcast
return completedJobCount; return completedJobCount;
} }


protected void setServiceThreadPoolsize(int serviceThreadPoolSize)
{
this.serviceThreadPoolSize = serviceThreadPoolSize;
}
public String getBroadcastType() { public String getBroadcastType() {
return broadcastType; return broadcastType;
} }


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

@@ -27,7 +27,9 @@ import altk.comm.engine.Broadcast.BroadcastState;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public abstract class CommEngine extends HttpServlet public abstract class CommEngine extends HttpServlet
{ {
static final String REQUEST_TOP_ELEMENT_NAME_DEFAULT = "Request";
public static final String SERVICE_THREADPOOL_SIZE_KEY = "service_threadpool_size";

static final String REQUEST_TOP_ELEMENT_NAME_DEFAULT = "Request";


private static final int SCHEDULER_THREAD_POOL_SIZE = 1; private static final int SCHEDULER_THREAD_POOL_SIZE = 1;
@@ -191,7 +193,7 @@ public abstract class CommEngine extends HttpServlet
deadBroadcastViewingMinutes = Long.parseLong(periodStr); deadBroadcastViewingMinutes = Long.parseLong(periodStr);
CommonLogger.startup.info(String.format("Dead broadcast viewing period: %d minutes", deadBroadcastViewingMinutes)); CommonLogger.startup.info(String.format("Dead broadcast viewing period: %d minutes", deadBroadcastViewingMinutes));


String str = config.getProperty("service_threadpool_size",
String str = config.getProperty(SERVICE_THREADPOOL_SIZE_KEY,
new Integer(SERVICE_THREADPOOL_SIZE_DEFAULT).toString()); new Integer(SERVICE_THREADPOOL_SIZE_DEFAULT).toString());
serviceThreadPoolSize = Integer.parseInt(str); serviceThreadPoolSize = Integer.parseInt(str);
CommonLogger.startup.info(String.format("service thread pool size: %d", serviceThreadPoolSize)); CommonLogger.startup.info(String.format("service thread pool size: %d", serviceThreadPoolSize));


Loading…
Cancel
Save