Skip to content
Snippets Groups Projects
Commit af9624ad authored by tjc's avatar tjc
Browse files

remove jobcontrol.jar

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@6675 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 209e521e
Branches
Tags
No related merge requests found
File deleted
......@@ -20,18 +20,18 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/ExternalProgramEvent.java,v 1.1 2004-06-09 09:44:29 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/ExternalProgramEvent.java,v 1.2 2007-11-09 10:36:30 tjc Exp $
*/
package uk.ac.sanger.artemis;
import uk.ac.sanger.jcon.job.*;
//import uk.ac.sanger.jcon.job.*;
/**
* An event that represents a change in the state of an ExternalProgram.
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: ExternalProgramEvent.java,v 1.1 2004-06-09 09:44:29 tjc Exp $
* @version $Id: ExternalProgramEvent.java,v 1.2 2007-11-09 10:36:30 tjc Exp $
**/
public class ExternalProgramEvent {
......@@ -40,12 +40,14 @@ public class ExternalProgramEvent {
* @param message A summary of the event.
* @param task The Task that caused this event.
**/
/*
public ExternalProgramEvent (final int type, final String message,
final Task task) {
this.type = type;
this.message = message;
this.task = task;
}
*/
/**
* Create a new ExternalProgramEvent object of the given type.
......@@ -87,9 +89,9 @@ public class ExternalProgramEvent {
* Return the Task that was passed to the constructor or null if a Process
* was passed to the constructor.
**/
public Task getTask () {
/*public Task getTask () {
return task;
}
}*/
/**
* Return the Process that was passed to the constructor or null if a
......@@ -113,7 +115,7 @@ public class ExternalProgramEvent {
* The Task that was passed to the constructor or null if a Process was
* passed to the constructor.
**/
private Task task = null;
//private Task task = null;
/**
* The Process that was passed to the constructor or null if a Task was
......
/* ExternalProgram.java
*
* created: Fri Nov 28 2003
*
* This file is part of Artemis
*
* Copyright (C) 1998-2003 Genome Research Limited
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/ExternalProgramUtils.java,v 1.1 2004-06-09 09:44:34 tjc Exp $
*/
package uk.ac.sanger.artemis;
import uk.ac.sanger.artemis.util.StringVector;
import uk.ac.sanger.artemis.io.Qualifier;
/**
* Static utilities for the ExternalProgram class.
**/
public class ExternalProgramUtils {
public static ExternalProgramMonitor runJConProgram (final ExternalProgram external_program,
final FeatureVector features,
final StringVector sequence_file_names,
final Logger logger)
throws ExternalProgramException
{
try {
final uk.ac.sanger.jcon.JobControl jc = new uk.ac.sanger.jcon.JobControl();
final Integer job_control_id =
Options.getOptions ().getIntegerProperty ("jcon_" + external_program.getName ()+
"_program_id");
final Integer min_jc_jobs =
Options.getOptions ().getIntegerProperty ("jcon_min_jobs");
String jcon_template =
Options.getOptions ().getProperty ("jcon_" + external_program.getName () + "_template");
final String jcon_batch_queue =
Options.getOptions ().getProperty ("jcon_batch_queue");
jcon_template =
jcon_template.replaceAll ("\\$database", external_program.getProgramOptions ());
final uk.ac.sanger.jcon.manager.Administrator administrator = jc.createAdministrator ();
final uk.ac.sanger.jcon.job.Executable executable =
administrator.getExecutableById (job_control_id.intValue ());
final uk.ac.sanger.jcon.dao.StatusDAO status_dao = jc.createStatusDAO ();
final uk.ac.sanger.jcon.job.JobBatchImpl head_job =
new uk.ac.sanger.jcon.job.JobBatchImpl (administrator.getExecutableById (1));
head_job.setStatus (status_dao.readStatusById (uk.ac.sanger.jcon.job.Status.WAITING));
head_job.setOutputName ("/dev/null");
head_job.setInputName ("/dev/null");
head_job.setErrorName ("/dev/null");
head_job.setWorkDirectoryName (System.getProperty ("user.dir"));
head_job.setCommandTemplate ("$executable");
head_job.setQueue (jcon_batch_queue);
final uk.ac.sanger.jcon.job.Job [] jobs = new uk.ac.sanger.jcon.job.Job [features.size ()];
for (int i = 0 ; i < features.size () ; ++i) {
final uk.ac.sanger.jcon.job.BatchJob job =
new uk.ac.sanger.jcon.job.JobBatchImpl (executable);
job.setStatus (status_dao.readStatusById ( uk.ac.sanger.jcon.job.Status.WAITING));
job.setWorkDirectoryName (System.getProperty ("user.dir"));
final String input_file_name = sequence_file_names.elementAt (i);
job.setInputName (input_file_name);
job.setOutputName (input_file_name + ".out");
job.setCommandTemplate (jcon_template);
job.setQueue (jcon_batch_queue);
head_job.add (job);
jobs[i] = job;
}
final uk.ac.sanger.jcon.job.Owner owner =
administrator.getOwnerByUserName (System.getProperty ("user.name"));
final uk.ac.sanger.jcon.job.Task task =
new uk.ac.sanger.jcon.job.TaskDefaultImpl (external_program.getName () + " from Artemis",
external_program.getName () + " from Artemis",
owner, new uk.ac.sanger.jcon.job.Job [] { head_job });
final uk.ac.sanger.jcon.manager.TaskManager task_manager = jc.createTaskManager ();
final int task_id = task_manager.createTask (task);
task_manager.submitTask (task_id);
for (int i = 0 ; i < features.size () ; ++i) {
final Qualifier qualifier =
new Qualifier ("job",
"job: " + jobs[i].getId () + " " +
"task: " + task.getId () + " " +
"program: " + external_program.getName () + " " +
"options: " + external_program.getProgramOptions ());
features.elementAt (i).addQualifierValues (qualifier);
}
return new TaskMonitor (task, external_program.getName (), logger);
} catch (Exception e) {
throw new ExternalProgramException ("exception while running " +
external_program.getName () + ": " +
e.getMessage ());
}
}
}
/* TaskMonitor.java
*
* created: Thu Aug 7 2003
*
* This file is part of Artemis
*
* Copyright (C) 2003 Genome Research Limited
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/TaskMonitor.java,v 1.1 2004-06-09 09:45:11 tjc Exp $
*/
package uk.ac.sanger.artemis;
import uk.ac.sanger.jcon.job.*;
/**
* Objects of this class watch a Task object and then display a
* MessageFrame window when the process status changes (eg. the end of a
* process) and send a ExternalProgramEvent.
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: TaskMonitor.java,v 1.1 2004-06-09 09:45:11 tjc Exp $
**/
public class TaskMonitor
extends SimpleExternalProgramMonitor
implements ExternalProgramMonitor {
/**
* Create a new ProcessMonitor object for the given Process.
* @param task The Task to monitor.
* @param name The name of the Task that is being monitored (eg. blastn).
* @param logger The log for errors, STDOUT and STDERR of the task.
**/
public TaskMonitor (final Task task, final String name,
final Logger logger) {
super (name, logger);
this.task = task;
SLEEP_TIME =
1000 *
Options.getOptions ().getIntegerProperty ("jcon_task_check_time").intValue ();
}
/**
* The length of time (in seconds) to sleep for.
**/
private final int SLEEP_TIME;
/**
* Wait for the status of a Task to change then log it and call sendEvent().
**/
public void run () {
while (true) {
try {
final Status status = task.getStatus ();
String message = null;
if (status == null) {
message = getProgramName () + " disappeared";
} else {
final int status_id = status.getId ();
switch (status_id) {
case Status.COMPLETED:
message = getProgramName () + " completed";
break;
case Status.FAILED:
message = getProgramName () + " failed";
break;
case Status.CANCELLED:
message = getProgramName () + " cancelled";
break;
case Status.SKIPPED:
message = getProgramName () + " skipped";
break;
default:
// keep going
}
}
if (message != null) {
final ExternalProgramEvent event =
new ExternalProgramEvent (ExternalProgramEvent.FINISHED,
message, task);
sendEvent (event);
getLogger ().log (message + "\n");
return;
}
Thread.sleep (SLEEP_TIME);
} catch (IllegalStateException e) {
return;
} catch (InterruptedException _) {
// ignore interrupt during a sleep()
}
}
}
/**
* The Task that was passed to the constructor.
**/
final public Task task;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment