Commit 65e9aacc authored by cdelbe's avatar cdelbe
Browse files

PICKED FROM TRUNK 15112

* Fix Task duration field in taskResult, do not give access in user API
* Remove 2 constructors in taskResultImpl

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/proactive/scheduling/branches/Scheduling_2.0.x@15116 28e8926c-6b08-0410-baaa-805c5e19b8d6
parent a59e5315
......@@ -104,12 +104,4 @@ public interface TaskResult extends Serializable {
*/
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();
}
......@@ -1068,7 +1068,7 @@ public class SchedulerCore implements UserSchedulerInterface_, AdminMethodsInter
boolean noResult = (jobStatus == JobStatus.CANCELED && taskResult == null);
if (jobStatus == JobStatus.FAILED || noResult) {
taskResult = new TaskResultImpl(task.getId(), new Exception(errorMsg), new SimpleTaskLogs("",
errorMsg));
errorMsg), -1);
((JobResultImpl) job.getJobResult()).addTaskResult(task.getName(), taskResult, task
.isPreciousResult());
} else if (jobStatus == JobStatus.CANCELED) {
......@@ -1281,14 +1281,14 @@ public class SchedulerCore implements UserSchedulerInterface_, AdminMethodsInter
}
}
//to be done before terminating the task, once terminated it is not running anymore..
TaskDescriptor currentTD = job.getRunningTaskDescriptor(taskId);
descriptor = job.terminateTask(errorOccurred, taskId);
//store this task result in the job result.
((JobResultImpl) job.getJobResult()).addTaskResult(descriptor.getName(), res, descriptor
.isPreciousResult());
logger_dev.info("TaskResult added to job '" + job.getId() + "' - task name is '" +
descriptor.getName() + "'");
//to be done before terminating the task, once terminated it is not running anymore..
TaskDescriptor currentTD = job.getRunningTaskDescriptor(taskId);
descriptor = job.terminateTask(errorOccurred, taskId);
//and update database
DatabaseManager.getInstance().startTransaction();
......
......@@ -83,6 +83,7 @@ import org.ow2.proactive.scheduler.common.task.TaskStatus;
import org.ow2.proactive.scheduler.core.annotation.TransientInSerialization;
import org.ow2.proactive.scheduler.core.properties.PASchedulerProperties;
import org.ow2.proactive.scheduler.task.TaskIdImpl;
import org.ow2.proactive.scheduler.task.TaskResultImpl;
import org.ow2.proactive.scheduler.task.internal.InternalForkedJavaTask;
import org.ow2.proactive.scheduler.task.internal.InternalJavaTask;
import org.ow2.proactive.scheduler.task.internal.InternalNativeTask;
......@@ -336,7 +337,8 @@ 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());
descriptor.setExecutionDuration(((TaskResultImpl) getJobResult().getResult(descriptor.getName()))
.getTaskDuration());
setNumberOfRunningTasks(getNumberOfRunningTasks() - 1);
setNumberOfFinishedTasks(getNumberOfFinishedTasks() + 1);
......
......@@ -151,6 +151,7 @@ public class TaskResultImpl implements TaskResult {
@Type(type = "org.ow2.proactive.scheduler.core.db.schedulerType.CharacterLargeOBject")
private String[] jobClasspath;
//Managed by taskInfo, this field is here only to bring taskDuration to core AO
@Transient
private long taskDuration = -1;
......@@ -169,9 +170,11 @@ public class TaskResultImpl implements TaskResult {
* @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) {
public TaskResultImpl(TaskId id, Serializable value, TaskLogs output, long execDuration) {
this(id, output);
this.taskDuration = execDuration;
this.value = value;
try {
this.serializedValue = ObjectToByteConverter.ObjectStream.convert(value);
......@@ -186,9 +189,11 @@ public class TaskResultImpl implements TaskResult {
* @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) {
public TaskResultImpl(TaskId id, Throwable exception, TaskLogs output, long execDuration) {
this(id, output);
this.taskDuration = execDuration;
this.exception = exception;
try {
this.serializedException = ObjectToByteConverter.ObjectStream.convert(exception);
......@@ -197,32 +202,6 @@ public class TaskResultImpl implements TaskResult {
}
}
/**
* 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;
}
/**
* @see org.ow2.proactive.scheduler.common.task.TaskResult#hadException()
*/
......@@ -494,7 +473,9 @@ public class TaskResultImpl implements TaskResult {
}
/**
* {@inheritDoc}
* Get the real task duration. This duration is the CPU time usage of the associated executable.
*
* @return the real task duration.
*/
public long getTaskDuration() {
return taskDuration;
......
......@@ -124,7 +124,7 @@ public class TestDatabaseCRUD {
//add a taskResult
itfJob.setJobResult(new JobResultImpl(itfJob.getId()));
((JobResultImpl) itfJob.getJobResult()).addTaskResult("task2", new TaskResultImpl(TaskIdImpl
.nextId(itfJob.getJobInfo().getJobId()), "salut", null), true);
.nextId(itfJob.getJobInfo().getJobId()), "salut", null, 1), true);
//register the job
DatabaseManager.getInstance().register(itfJob);
//list of internal job to recover
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment