Enhancement on Project Activity #11690
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@167304 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
eade7b7aef
commit
0e55e61c24
|
@ -70,34 +70,36 @@ public class DataMinerAccessPoint {
|
|||
/**
|
||||
* Gets the task.
|
||||
*
|
||||
* @param algConfiguration the alg configuration
|
||||
* @param taskConfiguration the task configuration
|
||||
* @return the task
|
||||
*/
|
||||
private TaskExecutionStatus getTask(BaseTaskConfiguration algConfiguration){
|
||||
return mapExecutionTask.get(algConfiguration.hashCode());
|
||||
private TaskExecutionStatus getTask(BaseTaskConfiguration taskConfiguration){
|
||||
return mapExecutionTask.get(taskConfiguration.getConfigurationKey());
|
||||
|
||||
}
|
||||
|
||||
//TODO
|
||||
public void abortTask(TaskConfiguration algConfiguration) throws TaskErrorException, TaskNotExecutableException{
|
||||
|
||||
TaskExecutionStatus task = getTask(algConfiguration);
|
||||
/**
|
||||
* Abort running task.
|
||||
*
|
||||
* @param taskConfiguration the alg configuration
|
||||
* @throws TaskErrorException the task error exception
|
||||
* @throws TaskNotExecutableException the task not executable exception
|
||||
*/
|
||||
public void abortRunningTask(TaskConfiguration taskConfiguration) throws TaskErrorException, TaskNotExecutableException{
|
||||
|
||||
TaskExecutionStatus task = getTask(taskConfiguration);
|
||||
|
||||
if(task==null)
|
||||
throw new TaskErrorException("The task with configuration: "+algConfiguration+" is not running");
|
||||
throw new TaskErrorException("The task with configuration: "+taskConfiguration+" is not running");
|
||||
|
||||
Operator operator;
|
||||
SClient sClient;
|
||||
try {
|
||||
sClient = dataMinerService.getClient();
|
||||
operator = sClient.getOperatorById(algConfiguration.getTaskId());
|
||||
addParametersToOperator(operator, algConfiguration.getMapParameters());
|
||||
|
||||
|
||||
//TODO
|
||||
sClient.cancelComputation(task.getComputationId());
|
||||
}
|
||||
catch (Exception e) {
|
||||
String error = "Error on get Client or the Operator for id: "+algConfiguration.getTaskId();
|
||||
String error = "Error on get Client or the Operator for id: "+taskConfiguration.getTaskId();
|
||||
logger.error(error, e);
|
||||
throw new TaskNotExecutableException(error);
|
||||
}
|
||||
|
@ -178,7 +180,7 @@ public class DataMinerAccessPoint {
|
|||
*/
|
||||
private TaskExecutionStatus startComputationOnDataMiner(BaseTaskConfiguration algConfiguration, final ComputationId computationId, final SClient sClient){
|
||||
|
||||
TaskExecutionStatus status = new TaskExecutionStatus(algConfiguration, computationId.getId());
|
||||
TaskExecutionStatus status = new TaskExecutionStatus(algConfiguration, computationId);
|
||||
|
||||
DMMonitorListener listener = new DMMonitorListener() {
|
||||
|
||||
|
|
|
@ -338,10 +338,13 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfig
|
|||
*/
|
||||
@Override
|
||||
public Boolean abortRun(TaskConfiguration taskConfiguration)
|
||||
throws TaskErrorException, Exception {
|
||||
throws TaskErrorException, TaskNotExecutableException, Exception {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
ValidateTaskConfiguration(taskConfiguration);
|
||||
|
||||
DataMinerAccessPoint dap = getDataMinerAccessPoint();
|
||||
dap.abortRunningTask(taskConfiguration);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.common.workspacetaskexecutor.shared;
|
|||
|
||||
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskErrorException;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskNotExecutableException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -32,9 +33,10 @@ public interface ExecutableTask<I extends BaseTaskConfiguration, O extends BaseT
|
|||
* @param taskConfiguration the task configuration
|
||||
* @return the boolean
|
||||
* @throws TaskErrorException the task error exception
|
||||
* @throws TaskNotExecutableException the task not executable exception
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
Boolean abortRun(I taskConfiguration) throws TaskErrorException, Exception;
|
||||
Boolean abortRun(I taskConfiguration) throws TaskErrorException, TaskNotExecutableException, Exception;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.io.Serializable;
|
|||
import org.gcube.common.workspacetaskexecutor.shared.BaseTaskConfiguration;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.BaseTaskExecutionStatus;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.Status;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -25,7 +26,7 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
|
|||
private Float percentCompleted = new Float(0);
|
||||
private String log;
|
||||
private String currentMessage="Waiting to start..";
|
||||
private String computationId;
|
||||
private ComputationId computationId;
|
||||
private BaseTaskConfiguration taskConfiguration;
|
||||
|
||||
|
||||
|
@ -42,7 +43,7 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
|
|||
* @param taskConfiguration the task configuration
|
||||
* @param computationId the computation id
|
||||
*/
|
||||
public TaskExecutionStatus(BaseTaskConfiguration taskConfiguration, String computationId) {
|
||||
public TaskExecutionStatus(BaseTaskConfiguration taskConfiguration, ComputationId computationId) {
|
||||
this.taskConfiguration = taskConfiguration;
|
||||
this.computationId = computationId;
|
||||
}
|
||||
|
@ -75,7 +76,7 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
|
|||
*
|
||||
* @return the computationId
|
||||
*/
|
||||
public String getComputationId() {
|
||||
public ComputationId getComputationId() {
|
||||
|
||||
return computationId;
|
||||
}
|
||||
|
@ -87,7 +88,7 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
|
|||
*
|
||||
* @param computationId the computationId to set
|
||||
*/
|
||||
public void setComputationId(String computationId) {
|
||||
public void setComputationId(ComputationId computationId) {
|
||||
|
||||
this.computationId = computationId;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue