\r
import java.util.List;\r
\r
+import org.apache.log4j.Logger;\r
+\r
import compbio.data.sequence.FastaSequence;\r
import compbio.engine.client.Executable;\r
import compbio.engine.local.LocalExecutorService;\r
import compbio.metadata.Limit;\r
import compbio.metadata.PresetManager;\r
\r
+/**\r
+ * This class decides where to execute the job. If the local engine is enabled\r
+ * in the configuration file and it has free threads and the size of the tasks\r
+ * permits the local execution, then the local execution will be favoured.\r
+ * \r
+ * @author pvtroshin\r
+ * @version 1.0 March 2009\r
+ */\r
public class LoadBalancer {\r
\r
+ private static Logger log = Logger.getLogger(LoadBalancer.class);\r
+\r
private LoadBalancer() {\r
}\r
\r
public static Executable.ExecProvider getEngine(Executable<?> executable) {\r
if (LocalExecutorService.getExecutor().canAcceptMoreWork()) {\r
+ log.debug("LOCAL engine HAS FREE threads will execute ... ");\r
return Executable.ExecProvider.Local;\r
}\r
+ log.debug("NO free threads on the LOCAL engine! Targeting for CLUSTER execution... ");\r
return Executable.ExecProvider.Cluster;\r
}\r
\r
// If data set is deemed too big for local execution, than give a\r
// cluster engine\r
// If limit is not defined then defaults to executing on the cluster\r
- Limit<V> limit = executable\r
- .getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET);\r
-\r
+ Limit<V> limit = executable.getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET);\r
+ log.trace("Inspecting whether the job can be executed locally using limit: " + limit);\r
if (limit == null || limit.isExceeded(dataSet)) {\r
+ log.debug("Job EXCEEDS LOCAL execution LIMIT targeting for cluster execution! ");\r
return Executable.ExecProvider.Cluster;\r
}\r
+ log.debug("Job FITS into the LOCAL execution limit consulting load balancer... ");\r
// Even if the data satisfies criteria for local execution it may still\r
// be executed on the cluster as the maximum capacity for local engine\r
// may be reached.\r