Repository: airavata Updated Branches: refs/heads/master e5131ad87 -> fc25c7284
adding the missing class Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/fc25c728 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/fc25c728 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/fc25c728 Branch: refs/heads/master Commit: fc25c7284a77f51a68b7509a6366e733f66c59be Parents: e5131ad Author: lahiru <[email protected]> Authored: Fri Oct 24 11:09:02 2014 -0400 Committer: lahiru <[email protected]> Committed: Fri Oct 24 11:09:02 2014 -0400 ---------------------------------------------------------------------- .../util/AiravataServerThreadPoolExecutor.java | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/fc25c728/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AiravataServerThreadPoolExecutor.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AiravataServerThreadPoolExecutor.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AiravataServerThreadPoolExecutor.java new file mode 100644 index 0000000..29a77d3 --- /dev/null +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/AiravataServerThreadPoolExecutor.java @@ -0,0 +1,37 @@ +package org.apache.airavata.api.server.util; + +import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.common.logger.AiravataLogger; +import org.apache.airavata.common.logger.AiravataLoggerFactory; +import org.apache.airavata.common.utils.ServerSettings; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * Created by airavata on 10/24/14. + */ +public class AiravataServerThreadPoolExecutor { + private final static AiravataLogger logger = AiravataLoggerFactory.getLogger(AiravataServerThreadPoolExecutor.class); + public static final String AIRAVATA_SERVER_THREAD_POOL_SIZE = "airavata.server.thread.pool.size"; + + private static ExecutorService threadPool; + + public static ExecutorService getThreadPool() { + if(threadPool ==null){ + threadPool = Executors.newCachedThreadPool(); + } + return threadPool; + } + + public static ExecutorService getFixedThreadPool() { + if(threadPool ==null){ + try { + threadPool = Executors.newFixedThreadPool(Integer.parseInt(ServerSettings.getSetting(AIRAVATA_SERVER_THREAD_POOL_SIZE))); + } catch (ApplicationSettingsException e) { + logger.error("Error reading " + AIRAVATA_SERVER_THREAD_POOL_SIZE+ " property"); + } + } + return threadPool; + } +}
