Commit d0a5a4ca authored by cdelbe's avatar cdelbe
Browse files

PICKED FROM TRUNK 14988

Fix SCHEDULING-522 :
Add real task execution information into taskinfo

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/proactive/scheduling/branches/Scheduling_2.0.x@15114 28e8926c-6b08-0410-baaa-805c5e19b8d6
parent 6f90a6a7
......@@ -105,8 +105,11 @@ public class TaskComposite extends Composite {
/** the unique id and the title for the column "Finished time" */
public static final String COLUMN_FINISHED_TIME_TITLE = "Finished time";
/** the unique id and the title for the column "Duration" */
public static final String COLUMN_DURATION_TITLE = "Duration";
/** the unique id and the title for the column "Total Duration" */
public static final String COLUMN_DURATION_TITLE = "Tot Duration";
/** the unique id and the title for the column "Exec Duration" */
public static final String COLUMN_EXEC_DURATION_TITLE = "Exec Duration";
/** the unique id and the title for the column "host name" */
public static final String COLUMN_HOST_NAME_TITLE = "Host name";
......@@ -171,6 +174,7 @@ public class TaskComposite extends Composite {
TableColumn tc7 = new TableColumn(table, SWT.LEFT);
TableColumn tc8 = new TableColumn(table, SWT.LEFT);
TableColumn tc9 = new TableColumn(table, SWT.LEFT);
TableColumn tc10 = new TableColumn(table, SWT.LEFT);
// addSelectionListener
tc1.addSelectionListener(new SelectionAdapter() {
......@@ -212,16 +216,22 @@ public class TaskComposite extends Composite {
tc7.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
sort(event, SORT_BY_DURATION);
sort(event, TaskState.SORT_BY_EXEC_DURATION);
}
});
tc8.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
sort(event, TaskState.SORT_BY_EXECUTIONLEFT);
sort(event, SORT_BY_DURATION);
}
});
tc9.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
sort(event, TaskState.SORT_BY_EXECUTIONONFAILURELEFT);
}
});
tc10.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
sort(event, TaskState.SORT_BY_DESCRIPTION);
......@@ -234,9 +244,10 @@ public class TaskComposite extends Composite {
tc4.setText(COLUMN_HOST_NAME_TITLE);
tc5.setText(COLUMN_START_TIME_TITLE);
tc6.setText(COLUMN_FINISHED_TIME_TITLE);
tc7.setText(COLUMN_DURATION_TITLE);
tc8.setText(COLUMN_NODEFAILURE_TITLE);
tc9.setText(COLUMN_DESCRIPTION_TITLE);
tc7.setText(COLUMN_EXEC_DURATION_TITLE);
tc8.setText(COLUMN_DURATION_TITLE);
tc9.setText(COLUMN_NODEFAILURE_TITLE);
tc10.setText(COLUMN_DESCRIPTION_TITLE);
// setWidth
tc1.setWidth(68);
tc2.setWidth(110);
......@@ -245,8 +256,9 @@ public class TaskComposite extends Composite {
tc5.setWidth(130);
tc6.setWidth(130);
tc7.setWidth(110);
tc8.setWidth(100);
tc9.setWidth(200);
tc8.setWidth(110);
tc9.setWidth(100);
tc10.setWidth(200);
// setMoveable
tc1.setMoveable(true);
tc2.setMoveable(true);
......@@ -257,6 +269,7 @@ public class TaskComposite extends Composite {
tc7.setMoveable(true);
tc8.setMoveable(true);
tc9.setMoveable(true);
tc10.setMoveable(true);
table.addListener(SWT.Selection, new Listener() {
......@@ -569,6 +582,8 @@ public class TaskComposite extends Composite {
} else if (title.equals(COLUMN_DURATION_TITLE)) {
item.setText(i, Tools.getFormattedDuration(taskState.getFinishedTime(), taskState
.getStartTime()));
} else if (title.equals(COLUMN_EXEC_DURATION_TITLE)) {
item.setText(i, Tools.getFormattedDuration(0, taskState.getExecutionDuration()));
} else if (title.equals(COLUMN_NODEFAILURE_TITLE)) {
if (taskState.getStatus() == TaskStatus.FAILED) {
item.setText(i, taskState.getMaxNumberOfExecutionOnFailure() + "/" +
......
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.4"?>
<product name="ProActive Scheduler" id="org.ow2.proactive.scheduler.scheduler" application="org.ow2.proactive.scheduler.application" useFeatures="false">
<aboutInfo>
<image path="/org.ow2.proactive.scheduler/icons/alt_about.gif"/>
<text>
%About.text
</text>
</aboutInfo>
<configIni use="default">
</configIni>
<launcherArgs>
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.4"?>
<product name="ProActive Scheduler" id="org.ow2.proactive.scheduler.scheduler" application="org.ow2.proactive.scheduler.application" useFeatures="false">
<aboutInfo>
<image path="/org.ow2.proactive.scheduler/icons/alt_about.gif"/>
<text>
%About.text
</text>
</aboutInfo>
<configIni use="default">
</configIni>
<launcherArgs>
<vmArgs>-Xmx512M -Xms512M
-Dproactive.net.nolocal=true
-Dlog4j.configuration=file:proactive-log4j
-Dproactive.configuration=file:ProActiveConfiguration.xml
-Dpa.scheduler.logs.provider=org.ow2.proactive.scheduler.common.util.logforwarder.providers.ProActiveBasedForwardingProvider</vmArgs>
</launcherArgs>
<windowImages i16="/org.ow2.proactive.scheduler/icons/alt_window_16.gif" i32="/org.ow2.proactive.scheduler/icons/alt_window_32.gif"/>
<splash
location="org.ow2.proactive.scheduler"
startupProgressRect="10,10,435,15"
startupMessageRect="10,30,435,20"
startupForegroundColor="EB791F" />
<launcher name="Scheduler">
<solaris/>
<win useIco="false">
<bmp/>
</win>
</launcher>
<vm>
</vm>
<plugins>
<plugin id="org.objectweb.proactive.ic2d.chartit"/>
<plugin id="org.ow2.proactive.scheduler"/>
<plugin id="org.ow2.proactive.scheduler.lib"/>
<plugin id="org.ow2.proactive.scheduler.plugin"/>
</plugins>
</product>
-Dpa.scheduler.logs.provider=org.ow2.proactive.scheduler.common.util.logforwarder.providers.ProActiveBasedForwardingProvider</vmArgs>
</launcherArgs>
<windowImages i16="/org.ow2.proactive.scheduler/icons/alt_window_16.gif" i32="/org.ow2.proactive.scheduler/icons/alt_window_32.gif"/>
<splash
location="org.ow2.proactive.scheduler"
startupProgressRect="10,10,435,15"
startupMessageRect="10,30,435,20"
startupForegroundColor="EB791F" />
<launcher name="Scheduler">
<solaris/>
<win useIco="false">
<bmp/>
</win>
</launcher>
<vm>
</vm>
<plugins>
<plugin id="com.ibm.icu"/>
<plugin id="org.apache.batik.bridge"/>
<plugin id="org.apache.batik.css"/>
<plugin id="org.apache.batik.dom"/>
<plugin id="org.apache.batik.dom.svg"/>
<plugin id="org.apache.batik.ext.awt"/>
<plugin id="org.apache.batik.parser"/>
<plugin id="org.apache.batik.svggen"/>
<plugin id="org.apache.batik.transcoder"/>
<plugin id="org.apache.batik.util"/>
<plugin id="org.apache.batik.util.gui"/>
<plugin id="org.apache.batik.xml"/>
<plugin id="org.apache.commons.codec"/>
<plugin id="org.eclipse.birt.chart.device.swt"/>
<plugin id="org.eclipse.birt.chart.engine"/>
<plugin id="org.eclipse.birt.chart.engine.extension"/>
<plugin id="org.eclipse.birt.chart.ui"/>
<plugin id="org.eclipse.birt.chart.ui.extension"/>
<plugin id="org.eclipse.birt.core"/>
<plugin id="org.eclipse.birt.core.ui"/>
<plugin id="org.eclipse.birt.data"/>
<plugin id="org.eclipse.birt.data.aggregation"/>
<plugin id="org.eclipse.birt.report.data.adapter"/>
<plugin id="org.eclipse.birt.report.engine"/>
<plugin id="org.eclipse.birt.report.model"/>
<plugin id="org.eclipse.core.commands"/>
<plugin id="org.eclipse.core.contenttype"/>
<plugin id="org.eclipse.core.databinding"/>
<plugin id="org.eclipse.core.expressions"/>
<plugin id="org.eclipse.core.filesystem"/>
<plugin id="org.eclipse.core.filesystem.hpux.ia64_32" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.linux.ppc" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.linux.x86" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.linux.x86_64" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.macosx" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.solaris.sparc" fragment="true"/>
<plugin id="org.eclipse.core.filesystem.win32.x86" fragment="true"/>
<plugin id="org.eclipse.core.jobs"/>
<plugin id="org.eclipse.core.net"/>
<plugin id="org.eclipse.core.net.linux.x86" fragment="true"/>
<plugin id="org.eclipse.core.net.win32.x86" fragment="true"/>
<plugin id="org.eclipse.core.resources"/>
<plugin id="org.eclipse.core.resources.compatibility" fragment="true"/>
<plugin id="org.eclipse.core.resources.win32.x86" fragment="true"/>
<plugin id="org.eclipse.core.runtime"/>
<plugin id="org.eclipse.core.runtime.compatibility"/>
<plugin id="org.eclipse.core.runtime.compatibility.auth"/>
<plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/>
<plugin id="org.eclipse.core.variables"/>
<plugin id="org.eclipse.datatools.connectivity"/>
<plugin id="org.eclipse.datatools.connectivity.oda"/>
<plugin id="org.eclipse.datatools.connectivity.oda.consumer"/>
<plugin id="org.eclipse.datatools.connectivity.oda.profile"/>
<plugin id="org.eclipse.draw2d"/>
<plugin id="org.eclipse.emf.common"/>
<plugin id="org.eclipse.emf.ecore"/>
<plugin id="org.eclipse.emf.ecore.xmi"/>
<plugin id="org.eclipse.equinox.app"/>
<plugin id="org.eclipse.equinox.common"/>
<plugin id="org.eclipse.equinox.preferences"/>
<plugin id="org.eclipse.equinox.registry"/>
<plugin id="org.eclipse.equinox.security"/>
<plugin id="org.eclipse.equinox.security.macosx" fragment="true"/>
<plugin id="org.eclipse.equinox.security.win32.x86" fragment="true"/>
<plugin id="org.eclipse.gef"/>
<plugin id="org.eclipse.help"/>
<plugin id="org.eclipse.jface"/>
<plugin id="org.eclipse.jface.databinding"/>
<plugin id="org.eclipse.jface.text"/>
<plugin id="org.eclipse.osgi"/>
<plugin id="org.eclipse.swt"/>
<plugin id="org.eclipse.swt.carbon.macosx" fragment="true"/>
<plugin id="org.eclipse.swt.gtk.linux.ppc" fragment="true"/>
<plugin id="org.eclipse.swt.gtk.linux.x86" fragment="true"/>
<plugin id="org.eclipse.swt.gtk.linux.x86_64" fragment="true"/>
<plugin id="org.eclipse.swt.gtk.solaris.sparc" fragment="true"/>
<plugin id="org.eclipse.swt.motif.aix.ppc" fragment="true"/>
<plugin id="org.eclipse.swt.motif.hpux.ia64_32" fragment="true"/>
<plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/>
<plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true"/>
<plugin id="org.eclipse.swt.wpf.win32.x86" fragment="true"/>
<plugin id="org.eclipse.text"/>
<plugin id="org.eclipse.ui"/>
<plugin id="org.eclipse.ui.carbon" fragment="true"/>
<plugin id="org.eclipse.ui.console"/>
<plugin id="org.eclipse.ui.forms"/>
<plugin id="org.eclipse.ui.views"/>
<plugin id="org.eclipse.ui.views.properties.tabbed"/>
<plugin id="org.eclipse.ui.workbench"/>
<plugin id="org.eclipse.ui.workbench.texteditor"/>
<plugin id="org.eclipse.update.configurator"/>
<plugin id="org.eclipse.update.core"/>
<plugin id="org.eclipse.update.core.linux" fragment="true"/>
<plugin id="org.eclipse.update.core.win32" fragment="true"/>
<plugin id="org.eclipse.update.ui"/>
<plugin id="org.mozilla.rhino"/>
<plugin id="org.objectweb.proactive.ic2d.chartit"/>
<plugin id="org.ow2.proactive.scheduler"/>
<plugin id="org.ow2.proactive.scheduler.lib"/>
<plugin id="org.ow2.proactive.scheduler.plugin"/>
<plugin id="org.w3c.css.sac"/>
<plugin id="org.w3c.dom.smil"/>
<plugin id="org.w3c.dom.svg"/>
<plugin id="org.w3c.sac"/>
</plugins>
</product>
......@@ -130,4 +130,11 @@ public interface TaskInfo extends Serializable {
*/
public int getNumberOfExecutionOnFailureLeft();
/**
* Get the execution duration of the task. It is the real execution time, CPU usage.
*
* @return the execution duration in millis
*/
public long getExecutionDuration();
}
......@@ -103,4 +103,13 @@ public interface TaskResult extends Serializable {
* @return a string describing this result.
*/
public String getTextualDescription();
/**
* Get the real task duration in millis. It is the CPU time used by the task not including
* communication and initialization.
* It also include time spent in Pre and Post scripts.
*
* @return the real task duration in millis
*/
public long getTaskDuration();
}
......@@ -61,6 +61,7 @@ public abstract class TaskState extends Task implements Comparable<TaskState> {
public static final int SORT_BY_STARTED_TIME = 8;
public static final int SORT_BY_FINISHED_TIME = 9;
public static final int SORT_BY_HOST_NAME = 10;
public static final int SORT_BY_EXEC_DURATION = 11;
public static final int ASC_ORDER = 1;
public static final int DESC_ORDER = 2;
protected static int currentSort = SORT_BY_ID;
......@@ -132,6 +133,10 @@ public abstract class TaskState extends Task implements Comparable<TaskState> {
return (currentOrder == ASC_ORDER) ? (getExecutionHostName().compareTo(task
.getExecutionHostName())) : (task.getExecutionHostName()
.compareTo(getExecutionHostName()));
case SORT_BY_EXEC_DURATION:
return (currentOrder == ASC_ORDER) ? (int) (getExecutionDuration() - task
.getExecutionDuration())
: (int) (task.getExecutionDuration() - getExecutionDuration());
default:
return (currentOrder == ASC_ORDER) ? (getId().compareTo(task.getId())) : (task.getId()
.compareTo(getId()));
......@@ -227,6 +232,17 @@ public abstract class TaskState extends Task implements Comparable<TaskState> {
return getTaskInfo().getNumberOfExecutionOnFailureLeft();
}
/**
* Get the real task duration in millis. It is the CPU time used by the task not including
* communication and initialization.
* It also include time spent in Pre and Post scripts.
*
* @return the real task duration in millis
*/
public long getExecutionDuration() {
return getTaskInfo().getExecutionDuration();
}
/**
* Get the number of execution on failure allowed by the task.
*
......
......@@ -480,7 +480,8 @@ public class UserSchedulerModel extends ConsoleModel {
list.add("NAME");
list.add("STATUS");
list.add("HOSTNAME");
list.add("DURATION");
list.add("EXEC DURATION");
list.add("TOT DURATION");
list.add("#EXECUTIONS");
list.add("#NODES KILLED");
oaf.setTitle(list);
......@@ -494,7 +495,8 @@ public class UserSchedulerModel extends ConsoleModel {
list.add(ts.getId().toString());
list.add(ts.getName());
list.add(ts.getStatus().toString());
list.add(ts.getExecutionHostName());
list.add((ts.getExecutionHostName() == null) ? "unknown" : ts.getExecutionHostName());
list.add(Tools.getFormattedDuration(0, ts.getExecutionDuration()));
list.add(Tools.getFormattedDuration(ts.getFinishedTime(), ts.getStartTime()));
if (ts.getMaxNumberOfExecution() - ts.getNumberOfExecutionLeft() < ts
.getMaxNumberOfExecution()) {
......
......@@ -336,6 +336,7 @@ public abstract class InternalJob extends JobState {
InternalTask descriptor = tasks.get(taskId);
descriptor.setFinishedTime(System.currentTimeMillis());
descriptor.setStatus(errorOccurred ? TaskStatus.FAULTY : TaskStatus.FINISHED);
descriptor.setExecutionDuration(getJobResult().getResult(descriptor.getName()).getTaskDuration());
setNumberOfRunningTasks(getNumberOfRunningTasks() - 1);
setNumberOfFinishedTasks(getNumberOfFinishedTasks() + 1);
......
......@@ -102,6 +102,11 @@ public class TaskInfoImpl implements TaskInfo {
@Column(name = "FINISHED_TIME")
private long finishedTime = -1;
/** task real execution time : DEFAULT HAS TO BE SET TO -1 */
@Alterable
@Column(name = "EXEC_DURATION")
private long executionDuration = -1;
/** Current taskStatus of the task */
@Alterable
@Column(name = "TASK_STATE")
......@@ -319,6 +324,22 @@ public class TaskInfoImpl implements TaskInfo {
numberOfExecutionOnFailureLeft--;
}
/**
* {@inheritDoc}
*/
public long getExecutionDuration() {
return executionDuration;
}
/**
* Set the execution duration value to the given executionDuration value
*
* @param executionDuration the executionDuration to be set
*/
public void setExecutionDuration(long executionDuration) {
this.executionDuration = executionDuration;
}
/**
* @see java.lang.Object#toString()
*/
......
......@@ -151,10 +151,18 @@ public class TaskResultImpl implements TaskResult {
@Type(type = "org.ow2.proactive.scheduler.core.db.schedulerType.CharacterLargeOBject")
private String[] jobClasspath;
@Transient
private long taskDuration = -1;
/** ProActive empty constructor. */
public TaskResultImpl() {
}
private TaskResultImpl(TaskId id, TaskLogs output) {
this.id = id;
this.output = output;
}
/**
* Return a new instance of task result represented by a task id, its result and its output.
*
......@@ -163,14 +171,13 @@ public class TaskResultImpl implements TaskResult {
* @param output the output of the task.
*/
public TaskResultImpl(TaskId id, Serializable value, TaskLogs output) {
this.id = id;
this(id, output);
this.value = value;
try {
this.serializedValue = ObjectToByteConverter.ObjectStream.convert(value);
} catch (IOException e) {
logger_dev.error("", e);
}
this.output = output;
}
/**
......@@ -181,14 +188,39 @@ public class TaskResultImpl implements TaskResult {
* @param output the output of the task.
*/
public TaskResultImpl(TaskId id, Throwable exception, TaskLogs output) {
this.id = id;
this(id, output);
this.exception = exception;
try {
this.serializedException = ObjectToByteConverter.ObjectStream.convert(exception);
} catch (IOException e) {
logger_dev.error("", e);
}
this.output = output;
}
/**
* Return a new instance of task result represented by a task id, its result and its output.
*
* @param id the identification of the task that send this result.
* @param value the result of the task.
* @param output the output of the task.
* @param execDuration the execution duration of the task itself
*/
public TaskResultImpl(TaskId id, Serializable value, TaskLogs output, long execDuration) {
this(id, value, output);
this.taskDuration = execDuration;
}
/**
* Return a new instance of task result represented by a task id and its exception.
*
* @param id the identification of the task that send this result.
* @param exception the exception that occurred in the task.
* @param output the output of the task.
* @param execDuration the execution duration of the task itself
*/
public TaskResultImpl(TaskId id, Throwable exception, TaskLogs output, long execDuration) {
this(id, exception, output);
this.taskDuration = execDuration;
}
/**
......@@ -461,6 +493,13 @@ public class TaskResultImpl implements TaskResult {
return jobClasspath;
}
/**
* {@inheritDoc}
*/
public long getTaskDuration() {
return taskDuration;
}
/**
* @see java.lang.Object#toString()
*/
......
......@@ -282,6 +282,15 @@ public abstract class InternalTask extends TaskState {
taskInfo.setStatus(taskStatus);
}
/**
* Set the real execution duration for the task.
*
* @param duration the real duration of the execution of the task
*/
public void setExecutionDuration(long duration) {
taskInfo.setExecutionDuration(duration);
}
/**
* To get the dependences of this task as internal tasks.
* Return null if this task has no dependence.
......
......@@ -89,6 +89,7 @@ public class ForkedJavaTaskLauncher extends JavaTaskLauncher {
@Override
public TaskResult doTask(TaskTerminateNotification core, ExecutableContainer executableContainer,
TaskResult... results) {
long duration = -1;
try {
// create the executable (will set the context class loader to the taskclassserver)
currentExecutable = executableContainer.getExecutable();
......@@ -106,14 +107,17 @@ public class ForkedJavaTaskLauncher extends JavaTaskLauncher {
//schedule timer at any time
scheduleTimer();
duration = System.currentTimeMillis();
//launch task : here, result is obviously a TaskResult
TaskResult userResult = (TaskResult) currentExecutable.execute(results);
duration = System.currentTimeMillis() - duration;
return userResult;
} catch (Throwable ex) {
logger_dev.info("", ex);
return new TaskResultImpl(taskId, ex, this.getLogs());
return new TaskResultImpl(taskId, ex, this.getLogs(), duration);
} finally {
cancelTimer();
finalizeTask(core);
......
......@@ -84,15 +84,19 @@ public class JavaTaskLauncher extends TaskLauncher {
@Override
public TaskResult doTask(TaskTerminateNotification core, ExecutableContainer executableContainer,
TaskResult... results) {
long duration = -1;
long sample = 0;
try {
//copy datas from OUTPUT or INPUT to local scratch
copyInputDataToScratch();
sample = System.currentTimeMillis();
//launch pre script
if (pre != null) {
this.executePreScript(PAActiveObject.getNode());
}
duration = System.currentTimeMillis() - sample;
// create the executable (will set the context class loader to the taskclassserver)
currentExecutable = executableContainer.getExecutable();
......@@ -103,20 +107,24 @@ public class JavaTaskLauncher extends TaskLauncher {
Throwable exception = null;
Serializable userResult = null;
sample = System.currentTimeMillis();
try {
//launch task
userResult = currentExecutable.execute(results);
} catch (Throwable t) {
exception = t;
}
duration += System.currentTimeMillis() - sample;
//copy output file
copyScratchDataToOutput();
sample = System.currentTimeMillis();