Enhancement on Project Activity #11690
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@167292 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
dca15a6a93
commit
6a5ee65cd9
|
@ -1,48 +0,0 @@
|
||||||
package org.gcube.common.workspacetaskexecutor;
|
|
||||||
|
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Interface ExecutableTask.
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
||||||
* Apr 27, 2018
|
|
||||||
* @param <T> the generic type
|
|
||||||
*/
|
|
||||||
public interface ExecutableTask<T> {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do run.
|
|
||||||
*
|
|
||||||
* @param itemId the item id
|
|
||||||
* @return the o
|
|
||||||
* @throws ItemNotExecutableException the item not executable
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
|
||||||
T doRun(String itemId) throws ItemNotExecutableException, Exception;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stop run.
|
|
||||||
*
|
|
||||||
* @param itemId the item id
|
|
||||||
* @return the boolean
|
|
||||||
* @throws ItemNotExecutableException the item not executable exception
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
|
||||||
Boolean stopRun(String itemId) throws ItemNotExecutableException, Exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Monitor run status.
|
|
||||||
*
|
|
||||||
* @param itemId the item id
|
|
||||||
* @return the t
|
|
||||||
* @throws ItemNotExecutableException the item not executable exception
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
|
||||||
T monitorRunStatus(String itemId) throws ItemNotExecutableException, Exception;
|
|
||||||
|
|
||||||
}
|
|
|
@ -9,9 +9,11 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.gcube.common.workspacetaskexecutor.shared.BaseTaskConfiguration;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.Status;
|
import org.gcube.common.workspacetaskexecutor.shared.Status;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.TaskExecutionStatus;
|
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.dataminer.AlgorithmConfiguration;
|
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
|
||||||
|
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskErrorException;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskNotExecutableException;
|
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskNotExecutableException;
|
||||||
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
|
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
|
||||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||||
|
@ -28,11 +30,12 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class DataMinerAccessPoint.
|
* The Class DataMinerAccessPoint.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Apr 27, 2018
|
* May 2, 2018
|
||||||
*/
|
*/
|
||||||
public class DataMinerAccessPoint {
|
public class DataMinerAccessPoint {
|
||||||
|
|
||||||
|
@ -41,25 +44,26 @@ public class DataMinerAccessPoint {
|
||||||
|
|
||||||
/** The map call back. */
|
/** The map call back. */
|
||||||
// Fully synchronized HashMap
|
// Fully synchronized HashMap
|
||||||
private Map<Integer, TaskExecutionStatus> mapCallBack = Collections.synchronizedMap(new HashMap<>());
|
private Map<Integer, TaskExecutionStatus> mapExecutionTask = Collections.synchronizedMap(new HashMap<>());
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new data miner access point.
|
* Instantiates a new data miner access point.
|
||||||
*
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
*/
|
||||||
public DataMinerAccessPoint() throws Exception {
|
public DataMinerAccessPoint() {
|
||||||
dataMinerService = new DataMinerService();
|
dataMinerService = new DataMinerService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save task.
|
* Save task.
|
||||||
*
|
*
|
||||||
* @param algConfiguration the alg configuration
|
* @param algConfiguration the alg configuration
|
||||||
* @param taskStatus the task status
|
* @param taskStatus the task status
|
||||||
*/
|
*/
|
||||||
private void saveTask(AlgorithmConfiguration algConfiguration, TaskExecutionStatus taskStatus){
|
private void saveTask(BaseTaskConfiguration algConfiguration, TaskExecutionStatus taskStatus){
|
||||||
|
|
||||||
mapCallBack.put(algConfiguration.hashCode(), taskStatus);
|
mapExecutionTask.put(algConfiguration.hashCode(), taskStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,8 +73,8 @@ public class DataMinerAccessPoint {
|
||||||
* @param algConfiguration the alg configuration
|
* @param algConfiguration the alg configuration
|
||||||
* @return the task
|
* @return the task
|
||||||
*/
|
*/
|
||||||
private TaskExecutionStatus getTask(AlgorithmConfiguration algConfiguration){
|
private TaskExecutionStatus getTask(BaseTaskConfiguration algConfiguration){
|
||||||
return mapCallBack.get(algConfiguration.hashCode());
|
return mapExecutionTask.get(algConfiguration.hashCode());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +86,7 @@ public class DataMinerAccessPoint {
|
||||||
* @return the task execution status
|
* @return the task execution status
|
||||||
* @throws TaskNotExecutableException the task not executable exception
|
* @throws TaskNotExecutableException the task not executable exception
|
||||||
*/
|
*/
|
||||||
public TaskExecutionStatus doRunTask(AlgorithmConfiguration algConfiguration) throws TaskNotExecutableException{
|
public TaskExecutionStatus doRunTask(TaskConfiguration algConfiguration) throws TaskNotExecutableException{
|
||||||
|
|
||||||
Operator operator;
|
Operator operator;
|
||||||
SClient sClient;
|
SClient sClient;
|
||||||
|
@ -116,19 +120,22 @@ public class DataMinerAccessPoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitoring computation.
|
* Gets the task status. To monitor the task exection..
|
||||||
*
|
*
|
||||||
* @param operatorId the operator id
|
* @param algConfiguration the alg configuration
|
||||||
* @return the task execution status
|
* @return the task status
|
||||||
|
* @throws TaskErrorException the task error exception
|
||||||
*/
|
*/
|
||||||
public TaskExecutionStatus getTaskStatus(AlgorithmConfiguration algConfiguration) {
|
public TaskExecutionStatus getTaskStatus(BaseTaskConfiguration algConfiguration) throws TaskErrorException{
|
||||||
|
|
||||||
TaskExecutionStatus task = getTask(algConfiguration);
|
TaskExecutionStatus task = getTask(algConfiguration);
|
||||||
|
|
||||||
if(task==null){
|
if(task==null){
|
||||||
//TODO
|
//TODO
|
||||||
//startComputationOnDM(computationId, sClient);
|
//startComputationOnDM(computationId, sClient);
|
||||||
|
throw new TaskErrorException("No Task running with configuration: "+algConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
|
@ -137,16 +144,16 @@ public class DataMinerAccessPoint {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start computation on dm.
|
* Start computation on data miner.
|
||||||
*
|
*
|
||||||
* @param algConfiguration the alg configuration
|
* @param algConfiguration the alg configuration
|
||||||
* @param computationId the computation id
|
* @param computationId the computation id
|
||||||
* @param sClient the s client
|
* @param sClient the s client
|
||||||
* @return the task execution status
|
* @return the task execution status
|
||||||
*/
|
*/
|
||||||
private TaskExecutionStatus startComputationOnDataMiner(AlgorithmConfiguration algConfiguration, final ComputationId computationId, final SClient sClient){
|
private TaskExecutionStatus startComputationOnDataMiner(BaseTaskConfiguration algConfiguration, final ComputationId computationId, final SClient sClient){
|
||||||
|
|
||||||
TaskExecutionStatus status = new TaskExecutionStatus();
|
TaskExecutionStatus status = new TaskExecutionStatus(algConfiguration);
|
||||||
|
|
||||||
DMMonitorListener listener = new DMMonitorListener() {
|
DMMonitorListener listener = new DMMonitorListener() {
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,14 @@ package org.gcube.common.workspacetaskexecutor.dataminer;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
import org.gcube.common.workspacetaskexecutor.CheckableTask;
|
import org.gcube.common.workspacetaskexecutor.shared.CheckableTask;
|
||||||
import org.gcube.common.workspacetaskexecutor.ConfigurableTask;
|
import org.gcube.common.workspacetaskexecutor.shared.ConfigurableTask;
|
||||||
import org.gcube.common.workspacetaskexecutor.ExecutableTask;
|
import org.gcube.common.workspacetaskexecutor.shared.ExecutableTask;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.TaskExecutionStatus;
|
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.dataminer.AlgorithmConfiguration;
|
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
||||||
|
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskErrorException;
|
||||||
|
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskNotExecutableException;
|
||||||
import org.gcube.common.workspacetaskexecutor.util.JsonUtil;
|
import org.gcube.common.workspacetaskexecutor.util.JsonUtil;
|
||||||
import org.gcube.common.workspacetaskexecutor.util.WsUtil;
|
import org.gcube.common.workspacetaskexecutor.util.WsUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -20,7 +22,7 @@ import org.slf4j.LoggerFactory;
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Apr 26, 2018
|
* Apr 26, 2018
|
||||||
*/
|
*/
|
||||||
public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskExecutionStatus>, ConfigurableTask<AlgorithmConfiguration>, CheckableTask<AlgorithmConfiguration>{
|
public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfiguration, TaskExecutionStatus>, ConfigurableTask<TaskConfiguration>, CheckableTask<TaskConfiguration>{
|
||||||
|
|
||||||
/** The logger. */
|
/** The logger. */
|
||||||
private static Logger logger = LoggerFactory.getLogger(WorkspaceDataMinerTaskExecutor.class);
|
private static Logger logger = LoggerFactory.getLogger(WorkspaceDataMinerTaskExecutor.class);
|
||||||
|
@ -33,9 +35,16 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskExecut
|
||||||
|
|
||||||
private DataMinerAccessPoint dataMinerAP;
|
private DataMinerAccessPoint dataMinerAP;
|
||||||
|
|
||||||
private JsonUtil<AlgorithmConfiguration> jsonUtil = new JsonUtil<AlgorithmConfiguration>();
|
private JsonUtil<TaskConfiguration> jsonUtil = new JsonUtil<TaskConfiguration>();
|
||||||
|
|
||||||
|
|
||||||
|
private DataMinerAccessPoint getDataMinerAccessPoint(){
|
||||||
|
if(dataMinerAP==null)
|
||||||
|
dataMinerAP = new DataMinerAccessPoint();
|
||||||
|
|
||||||
|
return dataMinerAP;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new workspace data miner task executor.
|
* Instantiates a new workspace data miner task executor.
|
||||||
*/
|
*/
|
||||||
|
@ -78,13 +87,25 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskExecut
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate task configuration.
|
||||||
|
*
|
||||||
|
* @param taskConfiguration the task configuration
|
||||||
|
*/
|
||||||
|
private static void ValidateTaskConfiguration(TaskConfiguration taskConfiguration) throws Exception {
|
||||||
|
Validate.notNull(taskConfiguration, "The "+TaskConfiguration.class.getSimpleName()+" is null");
|
||||||
|
Validate.notNull(taskConfiguration.getWorkspaceItemId(), "The WorkspaceItem Id in the configuration is null");
|
||||||
|
Validate.notNull(taskConfiguration.getTaskId(), "The Task Id in the configuration is null");
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.common.workspacetaskexecutor.CheckableTask#checkItemExecutable(java.lang.String)
|
* @see org.gcube.common.workspacetaskexecutor.CheckableTask#checkItemExecutable(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AlgorithmConfiguration checkItemExecutable(String workspaceItemId) throws ItemNotExecutableException, Exception {
|
public TaskConfiguration checkItemExecutable(String workspaceItemId) throws ItemNotExecutableException, Exception {
|
||||||
|
|
||||||
AlgorithmConfiguration conf = null;
|
TaskConfiguration conf = null;
|
||||||
checkOwner();
|
checkOwner();
|
||||||
WorkspaceItem item = WsUtil.getItem(usernameOwner, workspaceItemId);
|
WorkspaceItem item = WsUtil.getItem(usernameOwner, workspaceItemId);
|
||||||
String propConfigValue = WsUtil.getPropertyValue(item, WS_TASK_TASK_CONF);
|
String propConfigValue = WsUtil.getPropertyValue(item, WS_TASK_TASK_CONF);
|
||||||
|
@ -92,13 +113,13 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskExecut
|
||||||
logger.info("Read "+WS_TASK_TASK_CONF+" value: "+propConfigValue);
|
logger.info("Read "+WS_TASK_TASK_CONF+" value: "+propConfigValue);
|
||||||
|
|
||||||
if(propConfigValue==null || propConfigValue.isEmpty())
|
if(propConfigValue==null || propConfigValue.isEmpty())
|
||||||
throw new ItemNotExecutableException("The item id "+workspaceItemId+" has not a "+AlgorithmConfiguration.class.getSimpleName());
|
throw new ItemNotExecutableException("The item id "+workspaceItemId+" has not a "+TaskConfiguration.class.getSimpleName());
|
||||||
|
|
||||||
try{
|
try{
|
||||||
conf = jsonUtil.readObject(propConfigValue, AlgorithmConfiguration.class);
|
conf = jsonUtil.readObject(propConfigValue, TaskConfiguration.class);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Error on serializing configuration: "+propConfigValue, e);
|
logger.error("Error on serializing configuration: "+propConfigValue, e);
|
||||||
throw new ItemNotExecutableException("The item id "+workspaceItemId+" has a wrong "+AlgorithmConfiguration.class.getSimpleName()+". Do you want create a new one?");
|
throw new ItemNotExecutableException("The item id "+workspaceItemId+" has a wrong "+TaskConfiguration.class.getSimpleName()+". Do you want create a new one?");
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Found configuration: "+conf);
|
logger.info("Found configuration: "+conf);
|
||||||
|
@ -122,7 +143,7 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskExecut
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
jsonUtil.readObject(propConfigValue, AlgorithmConfiguration.class);
|
jsonUtil.readObject(propConfigValue, TaskConfiguration.class);
|
||||||
logger.debug("The item: "+workspaceItemId+" has a valid "+WS_TASK_TASK_CONF+" configuration");
|
logger.debug("The item: "+workspaceItemId+" has a valid "+WS_TASK_TASK_CONF+" configuration");
|
||||||
return true;
|
return true;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
@ -137,19 +158,19 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskExecut
|
||||||
* @see org.gcube.common.workspacetaskexecutor.ConfigurableTask#removeTaskConfig(java.lang.Object)
|
* @see org.gcube.common.workspacetaskexecutor.ConfigurableTask#removeTaskConfig(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean removeTaskConfiguration(String workspaceItemId) throws ItemNotExecutableException, Exception {
|
public Boolean removeTaskConfiguration(TaskConfiguration taskConfiguration) throws ItemNotExecutableException, Exception {
|
||||||
|
|
||||||
Validate.notNull(workspaceItemId, "The worksapce item id is null");
|
|
||||||
|
|
||||||
|
ValidateTaskConfiguration(taskConfiguration);
|
||||||
checkOwner();
|
checkOwner();
|
||||||
WorkspaceItem item = WsUtil.getItem(usernameOwner, workspaceItemId);
|
|
||||||
|
WorkspaceItem item = WsUtil.getItem(usernameOwner, taskConfiguration.getWorkspaceItemId());
|
||||||
String propConfig = WsUtil.getPropertyValue(item, WS_TASK_TASK_CONF);
|
String propConfig = WsUtil.getPropertyValue(item, WS_TASK_TASK_CONF);
|
||||||
|
|
||||||
if(propConfig==null || propConfig.isEmpty())
|
if(propConfig==null || propConfig.isEmpty())
|
||||||
throw new ItemNotExecutableException("The item id "+workspaceItemId+" has not a "+AlgorithmConfiguration.class.getSimpleName());
|
throw new ItemNotExecutableException("The item id "+taskConfiguration.getWorkspaceItemId()+" has not a "+TaskConfiguration.class.getSimpleName());
|
||||||
|
|
||||||
WsUtil.setPropertyValue(item, WS_TASK_TASK_CONF, null);
|
WsUtil.setPropertyValue(item, WS_TASK_TASK_CONF, null);
|
||||||
logger.info("Set property value "+WS_TASK_TASK_CONF+" as null for the workspace item id: "+workspaceItemId);
|
logger.info("Set property value "+WS_TASK_TASK_CONF+" as null for the workspace item id: "+taskConfiguration.getWorkspaceItemId());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -158,18 +179,18 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskExecut
|
||||||
* @see org.gcube.common.workspacetaskexecutor.ConfigurableTask#addTaskConfig(java.lang.Object)
|
* @see org.gcube.common.workspacetaskexecutor.ConfigurableTask#addTaskConfig(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean setTaskConfiguration(AlgorithmConfiguration config) throws Exception {
|
public Boolean setTaskConfiguration(TaskConfiguration taskConfiguration) throws Exception {
|
||||||
|
|
||||||
Validate.notNull(config, "The "+AlgorithmConfiguration.class.getSimpleName()+" instance is null");
|
ValidateTaskConfiguration(taskConfiguration);
|
||||||
checkOwner();
|
checkOwner();
|
||||||
WorkspaceItem item = WsUtil.getItem(usernameOwner, config.getWorkspaceItemId());
|
WorkspaceItem item = WsUtil.getItem(usernameOwner, taskConfiguration.getWorkspaceItemId());
|
||||||
String jsonConfValue = null;
|
String jsonConfValue = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
jsonConfValue = jsonUtil.toJSON(config);
|
jsonConfValue = jsonUtil.toJSON(taskConfiguration);
|
||||||
logger.debug("The json configuration is: "+jsonConfValue);
|
logger.debug("The json configuration is: "+jsonConfValue);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
throw new Exception("This "+config+" is wrong!. Please create a new one");
|
throw new Exception("This "+taskConfiguration+" is wrong!. Please create a new one");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(jsonConfValue!=null){
|
if(jsonConfValue!=null){
|
||||||
|
@ -181,48 +202,43 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskExecut
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.common.workspacetaskexecutor.ExecutableTask#doRun(java.lang.String)
|
* @see org.gcube.common.workspacetaskexecutor.ExecutableTask#doRun(org.gcube.common.workspacetaskexecutor.BaseTaskConfiguration)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TaskExecutionStatus doRun(String workspaceItemId) throws ItemNotExecutableException, Exception {
|
public TaskExecutionStatus doRun(TaskConfiguration taskConfiguration)
|
||||||
|
throws ItemNotExecutableException, TaskNotExecutableException, Exception {
|
||||||
|
|
||||||
Validate.notNull(workspaceItemId, "The worksapce item id is null");
|
ValidateTaskConfiguration(taskConfiguration);
|
||||||
checkOwner();
|
checkOwner();
|
||||||
|
|
||||||
AlgorithmConfiguration conf = checkItemExecutable(workspaceItemId);
|
TaskConfiguration conf = checkItemExecutable(taskConfiguration.getWorkspaceItemId());
|
||||||
|
|
||||||
if(dataMinerAP==null)
|
DataMinerAccessPoint dap = getDataMinerAccessPoint();
|
||||||
dataMinerAP = new DataMinerAccessPoint();
|
return dap.doRunTask(conf);
|
||||||
|
|
||||||
dataMinerAP.doRunTask(conf);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.common.workspacetaskexecutor.ExecutableTask#stopRun(java.lang.String)
|
* @see org.gcube.common.workspacetaskexecutor.ExecutableTask#stopRun(org.gcube.common.workspacetaskexecutor.BaseTaskConfiguration)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean stopRun(String itemId)
|
public Boolean stopRun(TaskConfiguration taskConfiguration)
|
||||||
throws ItemNotExecutableException, Exception {
|
throws TaskErrorException, Exception {
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.common.workspacetaskexecutor.ExecutableTask#monitorRunStatus(java.lang.String)
|
* @see org.gcube.common.workspacetaskexecutor.ExecutableTask#monitorRunStatus(org.gcube.common.workspacetaskexecutor.BaseTaskConfiguration)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TaskExecutionStatus monitorRunStatus(String itemId)
|
public TaskExecutionStatus monitorRunStatus(
|
||||||
throws ItemNotExecutableException, Exception {
|
TaskConfiguration taskConfiguration)
|
||||||
|
throws TaskErrorException, Exception {
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
ValidateTaskConfiguration(taskConfiguration);
|
||||||
return null;
|
DataMinerAccessPoint dap = getDataMinerAccessPoint();
|
||||||
|
return dap.getTaskStatus(taskConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.common.workspacetaskexecutor;
|
package org.gcube.common.workspacetaskexecutor.shared;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Interface DoTaskConfiguration.
|
* The Interface BaseTaskConfiguration.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Apr 26, 2018
|
* May 2, 2018
|
||||||
*/
|
*/
|
||||||
public interface TaskConfiguration {
|
public interface BaseTaskConfiguration {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +22,14 @@ public interface TaskConfiguration {
|
||||||
*/
|
*/
|
||||||
String getTaskId();
|
String getTaskId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the workspace item id where execute the Task.
|
||||||
|
*
|
||||||
|
* @return the workspace item id
|
||||||
|
*/
|
||||||
|
String getWorkspaceItemId();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the task description.
|
* Gets the task description.
|
||||||
*
|
*
|
||||||
|
@ -37,14 +46,4 @@ public interface TaskConfiguration {
|
||||||
Map<String, String> getMapParameters();
|
Map<String, String> getMapParameters();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the workspace item id where execute the Task
|
|
||||||
*
|
|
||||||
* @return the workspace item id
|
|
||||||
*/
|
|
||||||
String getWorkspaceItemId();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package org.gcube.common.workspacetaskexecutor.shared;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface BaseTaskExecutionStatus.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* May 2, 2018
|
||||||
|
*/
|
||||||
|
public interface BaseTaskExecutionStatus {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the error count.
|
||||||
|
*
|
||||||
|
* @return the error count
|
||||||
|
*/
|
||||||
|
public Long getErrorCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the status.
|
||||||
|
*
|
||||||
|
* @return the status
|
||||||
|
*/
|
||||||
|
public Status getStatus();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the log.
|
||||||
|
*
|
||||||
|
* @return the log
|
||||||
|
*/
|
||||||
|
public String getLog();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current message.
|
||||||
|
*
|
||||||
|
* @return the current message
|
||||||
|
*/
|
||||||
|
public String getCurrentMessage();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the percent completed.
|
||||||
|
*
|
||||||
|
* @return the percent completed
|
||||||
|
*/
|
||||||
|
public Float getPercentCompleted();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the task configuration.
|
||||||
|
*
|
||||||
|
* @return the task configuration
|
||||||
|
*/
|
||||||
|
public BaseTaskConfiguration getTaskConfiguration();
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.common.workspacetaskexecutor;
|
package org.gcube.common.workspacetaskexecutor.shared;
|
||||||
|
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutable
|
||||||
* Apr 26, 2018
|
* Apr 26, 2018
|
||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
*/
|
*/
|
||||||
public interface CheckableTask<T> {
|
public interface CheckableTask<T extends BaseTaskConfiguration> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,13 +21,12 @@ public interface CheckableTask<T> {
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @return the t
|
* @return the t
|
||||||
* @throws ItemNotExecutableException the item not executable
|
* @throws ItemNotExecutableException the item not executable exception
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
T checkItemExecutable(String itemId) throws ItemNotExecutableException, Exception;
|
T checkItemExecutable(String itemId) throws ItemNotExecutableException, Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is item executable.
|
* Checks if is item executable.
|
||||||
*
|
*
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.common.workspacetaskexecutor;
|
package org.gcube.common.workspacetaskexecutor.shared;
|
||||||
|
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
||||||
|
|
||||||
|
@ -10,23 +10,21 @@ import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutable
|
||||||
* The Interface ConfigurableTask.
|
* The Interface ConfigurableTask.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Apr 26, 2018
|
* May 2, 2018
|
||||||
* @param <I> the generic type
|
* @param <I> the generic type
|
||||||
*/
|
*/
|
||||||
public interface ConfigurableTask<I> {
|
public interface ConfigurableTask<I extends BaseTaskConfiguration> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the task configuration.
|
* Removes the task configuration.
|
||||||
*
|
*
|
||||||
* @param workspaceItemId the workspace item id
|
* @param config the config
|
||||||
* @return the boolean
|
* @return the boolean
|
||||||
* @throws ItemNotExecutableException the item not executable exception
|
* @throws ItemNotExecutableException the item not executable exception
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
Boolean removeTaskConfiguration(String workspaceItemId) throws ItemNotExecutableException, Exception;
|
Boolean removeTaskConfiguration(I config) throws ItemNotExecutableException, Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -0,0 +1,50 @@
|
||||||
|
package org.gcube.common.workspacetaskexecutor.shared;
|
||||||
|
|
||||||
|
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
||||||
|
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskErrorException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface ExecutableTask.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* May 2, 2018
|
||||||
|
* @param <I> the generic type must extend {@link BaseTaskConfiguration}
|
||||||
|
* @param <O> the generic type must extend {@link BaseTaskExecutionStatus}
|
||||||
|
*/
|
||||||
|
public interface ExecutableTask<I extends BaseTaskConfiguration, O extends BaseTaskExecutionStatus> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do run.
|
||||||
|
*
|
||||||
|
* @param taskConfiguration the base task configuration
|
||||||
|
* @return the o
|
||||||
|
* @throws ItemNotExecutableException the item not executable exception
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
O doRun(I taskConfiguration) throws ItemNotExecutableException, Exception;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop run.
|
||||||
|
*
|
||||||
|
* @param taskConfiguration the task configuration
|
||||||
|
* @return the boolean
|
||||||
|
* @throws TaskErrorException the task error exception
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
Boolean stopRun(I taskConfiguration) throws TaskErrorException, Exception;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Monitor run status.
|
||||||
|
*
|
||||||
|
* @param taskConfiguration the task configuration
|
||||||
|
* @return the o
|
||||||
|
* @throws TaskErrorException the task error exception
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
O monitorRunStatus(I taskConfiguration) throws TaskErrorException, Exception;
|
||||||
|
|
||||||
|
}
|
|
@ -7,24 +7,24 @@ package org.gcube.common.workspacetaskexecutor.shared.dataminer;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.common.workspacetaskexecutor.TaskConfiguration;
|
import org.gcube.common.workspacetaskexecutor.shared.BaseTaskConfiguration;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class AlgorithmConfiguration.
|
* The Class TaskConfiguration.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Apr 26, 2018
|
* May 2, 2018
|
||||||
*/
|
*/
|
||||||
public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
public class TaskConfiguration implements BaseTaskConfiguration, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -3380573762288127547L;
|
private static final long serialVersionUID = -3380573762288127547L;
|
||||||
private String taskId;
|
private String algorithmId;
|
||||||
@JsonIgnoreProperties
|
@JsonIgnoreProperties
|
||||||
private String taskDescription; //optional
|
private String taskDescription; //optional
|
||||||
private String token;
|
private String token;
|
||||||
|
@ -34,25 +34,26 @@ public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
||||||
/**
|
/**
|
||||||
* Instantiates a new run algorithm configuration.
|
* Instantiates a new run algorithm configuration.
|
||||||
*/
|
*/
|
||||||
public AlgorithmConfiguration() {
|
public TaskConfiguration() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new algorithm configuration.
|
* Instantiates a new task configuration.
|
||||||
*
|
*
|
||||||
* @param taskId the task id
|
* @param algorithmId the algorithm id
|
||||||
* @param taskDescription the task description
|
* @param taskDescription the task description
|
||||||
* @param token the token
|
* @param token the token
|
||||||
* @param workspaceItemId the workspace item id
|
* @param workspaceItemId the workspace item id
|
||||||
* @param mapParameters the map parameters
|
* @param mapParameters the map parameters
|
||||||
*/
|
*/
|
||||||
public AlgorithmConfiguration(
|
public TaskConfiguration(
|
||||||
String taskId, String taskDescription, String token,
|
String algorithmId, String taskDescription, String token,
|
||||||
String workspaceItemId, Map<String, String> mapParameters) {
|
String workspaceItemId, Map<String, String> mapParameters) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
this.taskId = taskId;
|
this.algorithmId = algorithmId;
|
||||||
this.taskDescription = taskDescription;
|
this.taskDescription = taskDescription;
|
||||||
this.token = token;
|
this.token = token;
|
||||||
this.workspaceItemId = workspaceItemId;
|
this.workspaceItemId = workspaceItemId;
|
||||||
|
@ -60,17 +61,28 @@ public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* Gets the task id.
|
* @see org.gcube.common.workspacetaskexecutor.TaskConfiguration#getTaskId()
|
||||||
*
|
|
||||||
* @return the taskId
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getTaskId() {
|
public String getTaskId() {
|
||||||
|
|
||||||
return taskId;
|
return algorithmId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the algorithm id.
|
||||||
|
*
|
||||||
|
* @return the algorithmId
|
||||||
|
*/
|
||||||
|
public String getAlgorithmId() {
|
||||||
|
|
||||||
|
return algorithmId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the task description.
|
* Gets the task description.
|
||||||
*
|
*
|
||||||
|
@ -82,6 +94,7 @@ public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the token.
|
* Gets the token.
|
||||||
*
|
*
|
||||||
|
@ -93,6 +106,7 @@ public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the workspace item id.
|
* Gets the workspace item id.
|
||||||
*
|
*
|
||||||
|
@ -104,6 +118,7 @@ public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map parameters.
|
* Gets the map parameters.
|
||||||
*
|
*
|
||||||
|
@ -115,17 +130,19 @@ public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the task id.
|
|
||||||
*
|
|
||||||
* @param taskId the taskId to set
|
|
||||||
*/
|
|
||||||
public void setTaskId(String taskId) {
|
|
||||||
|
|
||||||
this.taskId = taskId;
|
/**
|
||||||
|
* Sets the algorithm id.
|
||||||
|
*
|
||||||
|
* @param algorithmId the algorithmId to set
|
||||||
|
*/
|
||||||
|
public void setAlgorithmId(String algorithmId) {
|
||||||
|
|
||||||
|
this.algorithmId = algorithmId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the task description.
|
* Sets the task description.
|
||||||
*
|
*
|
||||||
|
@ -137,6 +154,7 @@ public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the token.
|
* Sets the token.
|
||||||
*
|
*
|
||||||
|
@ -147,6 +165,8 @@ public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the workspace item id.
|
* Sets the workspace item id.
|
||||||
*
|
*
|
||||||
|
@ -158,6 +178,7 @@ public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the map parameters.
|
* Sets the map parameters.
|
||||||
*
|
*
|
||||||
|
@ -168,36 +189,20 @@ public class AlgorithmConfiguration implements TaskConfiguration, Serializable {
|
||||||
this.mapParameters = mapParameters;
|
this.mapParameters = mapParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#hashCode()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
||||||
int hash = 1;
|
int hash = 1;
|
||||||
hash = hash * 13 + (taskId == null ? 0 : taskId.hashCode());
|
hash = hash * 13 + (algorithmId == null ? 0 : algorithmId.hashCode());
|
||||||
hash = hash * 17 + (workspaceItemId == null ? 0 : workspaceItemId.hashCode());
|
hash = hash * 17 + (workspaceItemId == null ? 0 : workspaceItemId.hashCode());
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("AlgorithmConfiguration [taskId=");
|
|
||||||
builder.append(taskId);
|
|
||||||
builder.append(", taskDescription=");
|
|
||||||
builder.append(taskDescription);
|
|
||||||
builder.append(", token=");
|
|
||||||
builder.append(token);
|
|
||||||
builder.append(", workspaceItemId=");
|
|
||||||
builder.append(workspaceItemId);
|
|
||||||
builder.append(", mapParameters=");
|
|
||||||
builder.append(mapParameters);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,7 +1,11 @@
|
||||||
package org.gcube.common.workspacetaskexecutor.shared;
|
package org.gcube.common.workspacetaskexecutor.shared.dataminer;
|
||||||
|
|
||||||
import java.io.Serializable;
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +14,7 @@ import java.io.Serializable;
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Apr 27, 2018
|
* Apr 27, 2018
|
||||||
*/
|
*/
|
||||||
public class TaskExecutionStatus implements Serializable {
|
public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -19,36 +23,51 @@ public class TaskExecutionStatus implements Serializable {
|
||||||
|
|
||||||
private Long errorCount;
|
private Long errorCount;
|
||||||
private Status status;
|
private Status status;
|
||||||
private float percentCompleted = 0;
|
private Float percentCompleted = new Float(0);
|
||||||
private String log;
|
private String log;
|
||||||
private String currentMessage="Waiting to start..";
|
private String currentMessage="Waiting to start..";
|
||||||
|
private BaseTaskConfiguration taskConfiguration;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new task exection status.
|
* Instantiates a new task execution status.
|
||||||
*/
|
*/
|
||||||
public TaskExecutionStatus() {
|
public TaskExecutionStatus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new task execution status.
|
||||||
|
*
|
||||||
|
* @param taskConfiguration the task configuration
|
||||||
|
*/
|
||||||
|
public TaskExecutionStatus(BaseTaskConfiguration taskConfiguration) {
|
||||||
|
this.taskConfiguration = taskConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new task execution status.
|
* Instantiates a new task execution status.
|
||||||
*
|
*
|
||||||
* @param errorCount the error count
|
* @param errorCount the error count
|
||||||
* @param status the status
|
* @param status the status
|
||||||
|
* @param percentCompleted the percent completed
|
||||||
* @param log the log
|
* @param log the log
|
||||||
* @param currentMessage the current message
|
* @param currentMessage the current message
|
||||||
* @param percentCompleted the percent completed
|
* @param taskConfiguration the task configuration
|
||||||
*/
|
*/
|
||||||
public TaskExecutionStatus(Long errorCount, Status status,
|
public TaskExecutionStatus(
|
||||||
String log, String currentMessage, float percentCompleted) {
|
Long errorCount, Status status, Float percentCompleted, String log,
|
||||||
super();
|
String currentMessage, TaskConfiguration taskConfiguration) {
|
||||||
this.errorCount = errorCount;
|
this.errorCount = errorCount;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
this.percentCompleted = percentCompleted;
|
||||||
this.log = log;
|
this.log = log;
|
||||||
this.currentMessage = currentMessage;
|
this.currentMessage = currentMessage;
|
||||||
this.percentCompleted = percentCompleted;
|
this.taskConfiguration = taskConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the error count.
|
* Gets the error count.
|
||||||
*
|
*
|
||||||
|
@ -130,7 +149,7 @@ public class TaskExecutionStatus implements Serializable {
|
||||||
*
|
*
|
||||||
* @return the percent completed
|
* @return the percent completed
|
||||||
*/
|
*/
|
||||||
public float getPercentCompleted() {
|
public Float getPercentCompleted() {
|
||||||
return percentCompleted;
|
return percentCompleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +162,18 @@ public class TaskExecutionStatus implements Serializable {
|
||||||
this.percentCompleted = percentCompleted;
|
this.percentCompleted = percentCompleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the task configuration.
|
||||||
|
*
|
||||||
|
* @return the task configuration
|
||||||
|
*/
|
||||||
|
public BaseTaskConfiguration getTaskConfiguration() {
|
||||||
|
|
||||||
|
return taskConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
|
@ -150,7 +181,7 @@ public class TaskExecutionStatus implements Serializable {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("RunningTaskStatus [errorCount=");
|
builder.append("TaskExecutionStatus [errorCount=");
|
||||||
builder.append(errorCount);
|
builder.append(errorCount);
|
||||||
builder.append(", status=");
|
builder.append(", status=");
|
||||||
builder.append(status);
|
builder.append(status);
|
||||||
|
@ -160,6 +191,8 @@ public class TaskExecutionStatus implements Serializable {
|
||||||
builder.append(log);
|
builder.append(log);
|
||||||
builder.append(", currentMessage=");
|
builder.append(", currentMessage=");
|
||||||
builder.append(currentMessage);
|
builder.append(currentMessage);
|
||||||
|
builder.append(", taskConfiguration=");
|
||||||
|
builder.append(taskConfiguration);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
|
@ -8,8 +8,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.common.workspacetaskexecutor.dataminer.WorkspaceDataMinerTaskExecutor;
|
import org.gcube.common.workspacetaskexecutor.dataminer.WorkspaceDataMinerTaskExecutor;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.dataminer.AlgorithmConfiguration;
|
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
|
||||||
import org.gcube.common.workspacetaskexecutor.shared.exception.ItemNotExecutableException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,20 +30,21 @@ public class TestDataMinerTaskExecutor {
|
||||||
WorkspaceDataMinerTaskExecutor exec = WorkspaceDataMinerTaskExecutor.getInstance();
|
WorkspaceDataMinerTaskExecutor exec = WorkspaceDataMinerTaskExecutor.getInstance();
|
||||||
exec.withOwner(USERNAME);
|
exec.withOwner(USERNAME);
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
exec.removeTaskConfiguration(WORKSPACE_FOLDER_ID);
|
// new TaskConfiguration(algorithmId, taskDescription, token, workspaceItemId, mapParameters)
|
||||||
//exec.checkItemExecutable(WORKSPACE_FOLDER_ID);
|
// exec.removeTaskConfiguration(WORKSPACE_FOLDER_ID);
|
||||||
}
|
// //exec.checkItemExecutable(WORKSPACE_FOLDER_ID);
|
||||||
catch (ItemNotExecutableException e) {
|
// }
|
||||||
// TODO Auto-generated catch block
|
// catch (ItemNotExecutableException e) {
|
||||||
e.printStackTrace();
|
// // TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
System.out.println("The item is not executable...");
|
//
|
||||||
}
|
// System.out.println("The item is not executable...");
|
||||||
catch (Exception e) {
|
// }
|
||||||
// TODO Auto-generated catch block
|
// catch (Exception e) {
|
||||||
e.printStackTrace();
|
// // TODO Auto-generated catch block
|
||||||
}
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,10 +74,10 @@ public class TestDataMinerTaskExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static AlgorithmConfiguration createDummyConfiguration(){
|
public static TaskConfiguration createDummyConfiguration(){
|
||||||
Map<String, String> mapParameters = new HashMap<String, String>();
|
Map<String, String> mapParameters = new HashMap<String, String>();
|
||||||
mapParameters.put("publiclink", "this is the public link");
|
mapParameters.put("publiclink", "this is the public link");
|
||||||
return new AlgorithmConfiguration("this is the task id", null, "my token", WORKSPACE_FOLDER_ID, mapParameters);
|
return new TaskConfiguration("this is the task id", null, "my token", WORKSPACE_FOLDER_ID, mapParameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue