X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=engine%2Fcompbio%2Fengine%2FLoadBalancer.java;h=6185d424eb9ccfc0ca3037148cb7bdaa6bccff49;hb=HEAD;hp=b23b57c66bbabc322254209b6308c6ed82d96c25;hpb=535359a3d592ee41bda72e7356f0181f6cee9d07;p=jabaws.git diff --git a/engine/compbio/engine/LoadBalancer.java b/engine/compbio/engine/LoadBalancer.java index b23b57c..6185d42 100644 --- a/engine/compbio/engine/LoadBalancer.java +++ b/engine/compbio/engine/LoadBalancer.java @@ -20,21 +20,35 @@ package compbio.engine; import java.util.List; +import org.apache.log4j.Logger; + import compbio.data.sequence.FastaSequence; import compbio.engine.client.Executable; import compbio.engine.local.LocalExecutorService; import compbio.metadata.Limit; import compbio.metadata.PresetManager; +/** + * This class decides where to execute the job. If the local engine is enabled + * in the configuration file and it has free threads and the size of the tasks + * permits the local execution, then the local execution will be favoured. + * + * @author pvtroshin + * @version 1.0 March 2009 + */ public class LoadBalancer { + private static Logger log = Logger.getLogger(LoadBalancer.class); + private LoadBalancer() { } public static Executable.ExecProvider getEngine(Executable executable) { if (LocalExecutorService.getExecutor().canAcceptMoreWork()) { + log.debug("LOCAL engine HAS FREE threads will execute ... "); return Executable.ExecProvider.Local; } + log.debug("NO free threads on the LOCAL engine! Targeting for CLUSTER execution... "); return Executable.ExecProvider.Cluster; } @@ -46,10 +60,13 @@ public class LoadBalancer { // If limit is not defined then defaults to executing on the cluster Limit limit = executable .getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET); - + log.trace("Inspecting whether the job can be executed locally using limit: " + + limit); if (limit == null || limit.isExceeded(dataSet)) { + log.debug("Job EXCEEDS LOCAL execution LIMIT targeting for cluster execution! "); return Executable.ExecProvider.Cluster; } + log.debug("Job FITS into the LOCAL execution limit consulting load balancer... "); // Even if the data satisfies criteria for local execution it may still // be executed on the cluster as the maximum capacity for local engine // may be reached.