removed message history
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@167553 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fbc9cd8a7a
commit
fde2799ead
|
@ -41,11 +41,11 @@ public class DMConverter {
|
|||
* @param computationId the computation id
|
||||
* @return the task computation
|
||||
*/
|
||||
public static TaskComputation toDMComputationId(ComputationId computationId){
|
||||
public static TaskComputation toDMComputationId(ComputationId computationId, Long startTime, Long endTime){
|
||||
if(computationId==null)
|
||||
return null;
|
||||
|
||||
return new TaskComputation(computationId.getId(), computationId.getUrlId(), computationId.getOperatorId(), computationId.getOperatorName(), computationId.getEquivalentRequest());
|
||||
return new TaskComputation(computationId.getId(), computationId.getUrlId(), computationId.getOperatorId(), computationId.getOperatorName(), computationId.getEquivalentRequest(), startTime, endTime);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration
|
|||
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.util.Converter;
|
||||
import org.gcube.common.workspacetaskexecutor.util.EncrypterUtil;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
|
@ -42,15 +41,6 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class DataMinerAccessPoint {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final String NEW_STATUS_CHARS = "******* ";
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final String NEW_LINE = "\n";
|
||||
private static final String DASH = "-";
|
||||
private DataMinerService dataMinerService;
|
||||
private static Logger logger = LoggerFactory.getLogger(DataMinerAccessPoint.class);
|
||||
|
||||
|
@ -161,7 +151,7 @@ public class DataMinerAccessPoint {
|
|||
logger.debug("Start Computation");
|
||||
ComputationId computationId = sClient.startComputation(operator);
|
||||
logger.debug("Started ComputationId: " + computationId);
|
||||
return loadTaskExecutionStatus(taskConfiguration, DMConverter.toDMComputationId(computationId));
|
||||
return loadTaskExecutionStatus(taskConfiguration, DMConverter.toDMComputationId(computationId, System.currentTimeMillis(), null));
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -215,9 +205,11 @@ public class DataMinerAccessPoint {
|
|||
private TaskExecutionStatus loadTaskExecutionStatus(TaskConfiguration taskConfiguration, final TaskComputation taskComputation) throws TaskErrorException, TaskNotExecutableException{
|
||||
|
||||
TaskExecutionStatus oldTaskExecutionStatus = getRunningTask(taskConfiguration);
|
||||
boolean isStart = false;
|
||||
if(oldTaskExecutionStatus==null)
|
||||
isStart = true;
|
||||
|
||||
// Long startTime = taskComputation.getStartTime();
|
||||
// if(oldTaskExecutionStatus!=null)
|
||||
// startTime = oldTaskExecutionStatus.getTaskComputation().getStartTime(); //copyng start time from bean saved on server
|
||||
|
||||
|
||||
SClient sClient;
|
||||
ComputationId computationId = DMConverter.toComputationId(taskComputation);
|
||||
|
@ -232,9 +224,16 @@ public class DataMinerAccessPoint {
|
|||
|
||||
TaskExecutionStatus newTaskExecutionStatus = new TaskExecutionStatus(taskConfiguration, taskComputation);
|
||||
|
||||
/*
|
||||
if(!isStart)
|
||||
//adding previous log
|
||||
newTaskExecutionStatus.addLog(oldTaskExecutionStatus.getLog());
|
||||
if(oldTaskExecutionStatus.getLog().length()>maxLogSize){
|
||||
String confs=NEW_LINE+NEW_STATUS_CHARS+Converter.getCurrentFormattedDate(null)+NEW_LINE;
|
||||
confs+="Cancelled previous logs";
|
||||
newTaskExecutionStatus.addLog(confs);
|
||||
}else
|
||||
newTaskExecutionStatus.addLog(oldTaskExecutionStatus.getLog());
|
||||
|
||||
else{
|
||||
//first time adding the configurations
|
||||
String confs=NEW_LINE+NEW_STATUS_CHARS+Converter.getCurrentFormattedDate(null)+NEW_LINE;
|
||||
|
@ -244,7 +243,7 @@ public class DataMinerAccessPoint {
|
|||
confs+=NEW_LINE+NEW_LINE+DASH+DASH+"EquivalentRequest: "+NEW_LINE+newTaskExecutionStatus.getTaskComputation().getEquivalentRequest();
|
||||
confs+=NEW_LINE+NEW_LINE+DASH+DASH+"URL ID: "+NEW_LINE+newTaskExecutionStatus.getTaskComputation().getUrlId();
|
||||
newTaskExecutionStatus.addLog(confs+NEW_LINE);
|
||||
}
|
||||
}*/
|
||||
|
||||
logger.debug("Requesting operation progress");
|
||||
ComputationStatus computationStatus = null;
|
||||
|
@ -268,9 +267,10 @@ public class DataMinerAccessPoint {
|
|||
return newTaskExecutionStatus;
|
||||
}
|
||||
|
||||
newTaskExecutionStatus.setCurrentMessage(computationStatus.getMessage());
|
||||
newTaskExecutionStatus.setMessage(computationStatus.getMessage());
|
||||
newTaskExecutionStatus.setPercentCompleted((float) computationStatus.getPercentage());
|
||||
String historyMsg=NEW_LINE+NEW_STATUS_CHARS+Converter.getCurrentFormattedDate(null)+NEW_LINE;
|
||||
//String historyMsg=NEW_LINE+NEW_STATUS_CHARS+Converter.getCurrentFormattedDate(null)+NEW_LINE;
|
||||
String historyMsg="";
|
||||
switch (status) {
|
||||
case ACCEPTED:
|
||||
logger.debug("Operation "+TaskStatus.ACCEPTED);
|
||||
|
@ -283,18 +283,21 @@ public class DataMinerAccessPoint {
|
|||
newTaskExecutionStatus.setStatus(TaskStatus.CANCELLED);
|
||||
historyMsg+= "Status "+TaskStatus.CANCELLED;
|
||||
historyMsg+=computationStatus.getMessage()!=null?": "+computationStatus.getMessage():"";
|
||||
taskComputation.setEndTime(System.currentTimeMillis());
|
||||
break;
|
||||
case COMPLETE:
|
||||
logger.debug("Operation "+TaskStatus.COMPLETED);
|
||||
newTaskExecutionStatus.setStatus(TaskStatus.COMPLETED);
|
||||
historyMsg+= "Status "+TaskStatus.COMPLETED;
|
||||
historyMsg+=computationStatus.getMessage()!=null?": "+computationStatus.getMessage():"";
|
||||
taskComputation.setEndTime(System.currentTimeMillis());
|
||||
break;
|
||||
case FAILED:
|
||||
logger.debug("Operation "+TaskStatus.FAILED);
|
||||
newTaskExecutionStatus.setStatus(TaskStatus.FAILED);
|
||||
historyMsg+= "Status "+TaskStatus.FAILED;
|
||||
historyMsg+=computationStatus.getMessage()!=null?": "+computationStatus.getMessage():"";
|
||||
taskComputation.setEndTime(System.currentTimeMillis());
|
||||
break;
|
||||
case RUNNING:
|
||||
logger.debug("Operation "+TaskStatus.ONGOING);
|
||||
|
@ -310,7 +313,7 @@ public class DataMinerAccessPoint {
|
|||
|
||||
}
|
||||
|
||||
newTaskExecutionStatus.addLog(historyMsg+NEW_LINE);
|
||||
newTaskExecutionStatus.setMessage(historyMsg);
|
||||
saveTaskInMemory(taskConfiguration, newTaskExecutionStatus);
|
||||
return newTaskExecutionStatus;
|
||||
|
||||
|
|
|
@ -18,5 +18,20 @@ public interface BaseTaskComputation {
|
|||
*
|
||||
* @return the id
|
||||
*/
|
||||
public String getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Gets the start time.
|
||||
*
|
||||
* @return the start time
|
||||
*/
|
||||
Long getStartTime();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the end time.
|
||||
*
|
||||
* @return the end time
|
||||
*/
|
||||
Long getEndTime();
|
||||
}
|
||||
|
|
|
@ -25,19 +25,13 @@ public interface BaseTaskExecutionStatus {
|
|||
*/
|
||||
public TaskStatus getStatus();
|
||||
|
||||
/**
|
||||
* Gets the log.
|
||||
*
|
||||
* @return the log
|
||||
*/
|
||||
public String getLog();
|
||||
|
||||
/**
|
||||
* Gets the current message.
|
||||
* Gets the message.
|
||||
*
|
||||
* @return the current message
|
||||
* @return the message
|
||||
*/
|
||||
public String getCurrentMessage();
|
||||
public String getMessage();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -54,4 +48,5 @@ public interface BaseTaskExecutionStatus {
|
|||
* @return the task configuration
|
||||
*/
|
||||
public BaseTaskConfiguration getTaskConfiguration();
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ public class TaskComputation implements BaseTaskComputation, Serializable {
|
|||
private String operatorId;
|
||||
private String operatorName;
|
||||
private String equivalentRequest;
|
||||
private Long startTime;
|
||||
private Long endTime;
|
||||
|
||||
/**
|
||||
* Instantiates a new DM computation id.
|
||||
|
@ -36,115 +38,169 @@ public class TaskComputation implements BaseTaskComputation, Serializable {
|
|||
|
||||
|
||||
/**
|
||||
* Instantiates a new DM computation id.
|
||||
*
|
||||
* @param id the id
|
||||
* @param urlId the url id
|
||||
* @param operatorId the operator id
|
||||
* @param operatorName the operator name
|
||||
* @param equivalentRequest the equivalent request
|
||||
* @param id
|
||||
* @param urlId
|
||||
* @param operatorId
|
||||
* @param operatorName
|
||||
* @param equivalentRequest
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
*/
|
||||
public TaskComputation(String id, String urlId, String operatorId,
|
||||
String operatorName, String equivalentRequest) {
|
||||
public TaskComputation(
|
||||
String id, String urlId, String operatorId, String operatorName,
|
||||
String equivalentRequest, Long startTime, Long endTime) {
|
||||
|
||||
super();
|
||||
this.id = id;
|
||||
this.urlId = urlId;
|
||||
this.operatorId = operatorId;
|
||||
this.operatorName = operatorName;
|
||||
this.equivalentRequest = equivalentRequest;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the url id.
|
||||
*
|
||||
* @return the url id
|
||||
* @return the urlId
|
||||
*/
|
||||
public String getUrlId() {
|
||||
|
||||
return urlId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the url id.
|
||||
*
|
||||
* @param urlId the new url id
|
||||
*/
|
||||
public void setUrlId(String urlId) {
|
||||
this.urlId = urlId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the operator id.
|
||||
*
|
||||
* @return the operator id
|
||||
* @return the operatorId
|
||||
*/
|
||||
public String getOperatorId() {
|
||||
|
||||
return operatorId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the operator id.
|
||||
*
|
||||
* @param operatorId the new operator id
|
||||
*/
|
||||
public void setOperatorId(String operatorId) {
|
||||
this.operatorId = operatorId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the operator name.
|
||||
*
|
||||
* @return the operator name
|
||||
* @return the operatorName
|
||||
*/
|
||||
public String getOperatorName() {
|
||||
|
||||
return operatorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the operator name.
|
||||
*
|
||||
* @param operatorName the new operator name
|
||||
*/
|
||||
public void setOperatorName(String operatorName) {
|
||||
this.operatorName = operatorName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the equivalent request.
|
||||
*
|
||||
* @return the equivalent request
|
||||
* @return the equivalentRequest
|
||||
*/
|
||||
public String getEquivalentRequest() {
|
||||
|
||||
return equivalentRequest;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the equivalent request.
|
||||
*
|
||||
* @param equivalentRequest the new equivalent request
|
||||
* @return the startTime
|
||||
*/
|
||||
public Long getStartTime() {
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the endTime
|
||||
*/
|
||||
public Long getEndTime() {
|
||||
|
||||
return endTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param urlId the urlId to set
|
||||
*/
|
||||
public void setUrlId(String urlId) {
|
||||
|
||||
this.urlId = urlId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param operatorId the operatorId to set
|
||||
*/
|
||||
public void setOperatorId(String operatorId) {
|
||||
|
||||
this.operatorId = operatorId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param operatorName the operatorName to set
|
||||
*/
|
||||
public void setOperatorName(String operatorName) {
|
||||
|
||||
this.operatorName = operatorName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param equivalentRequest the equivalentRequest to set
|
||||
*/
|
||||
public void setEquivalentRequest(String equivalentRequest) {
|
||||
|
||||
this.equivalentRequest = equivalentRequest;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param startTime the startTime to set
|
||||
*/
|
||||
public void setStartTime(Long startTime) {
|
||||
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param endTime the endTime to set
|
||||
*/
|
||||
public void setEndTime(Long endTime) {
|
||||
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
|
@ -152,7 +208,7 @@ public class TaskComputation implements BaseTaskComputation, Serializable {
|
|||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DMComputationId [id=");
|
||||
builder.append("TaskComputation [id=");
|
||||
builder.append(id);
|
||||
builder.append(", urlId=");
|
||||
builder.append(urlId);
|
||||
|
@ -162,10 +218,13 @@ public class TaskComputation implements BaseTaskComputation, Serializable {
|
|||
builder.append(operatorName);
|
||||
builder.append(", equivalentRequest=");
|
||||
builder.append(equivalentRequest);
|
||||
builder.append(", startTime=");
|
||||
builder.append(startTime);
|
||||
builder.append(", endTime=");
|
||||
builder.append(endTime);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -21,8 +21,8 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
|
|||
private Long errorCount;
|
||||
private TaskStatus status;
|
||||
private Float percentCompleted = new Float(0);
|
||||
private String log;
|
||||
private String currentMessage="Waiting to start..";
|
||||
//private String log;
|
||||
private String message="Waiting to start..";
|
||||
private TaskComputation taskComputation;
|
||||
private TaskConfiguration taskConfiguration;
|
||||
|
||||
|
@ -47,26 +47,22 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new task execution status.
|
||||
*
|
||||
* @param errorCount the error count
|
||||
* @param status the status
|
||||
* @param percentCompleted the percent completed
|
||||
* @param log the log
|
||||
* @param currentMessage the current message
|
||||
* @param taskConfiguration the task configuration
|
||||
* @param taskComputation the task computation
|
||||
*/
|
||||
public TaskExecutionStatus(
|
||||
Long errorCount, TaskStatus status, Float percentCompleted, String log,
|
||||
String currentMessage, TaskConfiguration taskConfiguration, TaskComputation taskComputation) {
|
||||
public TaskExecutionStatus(Long errorCount, TaskStatus status, Float percentCompleted, String currentMessage, TaskConfiguration taskConfiguration, TaskComputation taskComputation) {
|
||||
this.errorCount = errorCount;
|
||||
this.status = status;
|
||||
this.percentCompleted = percentCompleted;
|
||||
this.log = log;
|
||||
this.currentMessage = currentMessage;
|
||||
//this.log = log;
|
||||
this.message = currentMessage;
|
||||
this.taskComputation = taskComputation;
|
||||
this.taskConfiguration = taskConfiguration;
|
||||
}
|
||||
|
@ -129,44 +125,45 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
|
|||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log builder.
|
||||
*
|
||||
* @return the log builder
|
||||
*/
|
||||
public String getLog() {
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the log.
|
||||
*
|
||||
* @param logMessage the log message
|
||||
*/
|
||||
public void addLog(String logMessage) {
|
||||
if(log==null)
|
||||
this.log = logMessage;
|
||||
else
|
||||
log=logMessage+log;
|
||||
}
|
||||
// /**
|
||||
// * Gets the log builder.
|
||||
// *
|
||||
// * @return the log builder
|
||||
// */
|
||||
// public String getLog() {
|
||||
// return log;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Adds the log.
|
||||
// *
|
||||
// * @param logMessage the log message
|
||||
// */
|
||||
// public void addLog(String logMessage) {
|
||||
// if(log==null)
|
||||
// this.log = logMessage;
|
||||
// else
|
||||
// log=logMessage+log;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the current message.
|
||||
*
|
||||
* @return the current message
|
||||
*/
|
||||
public String getCurrentMessage() {
|
||||
return currentMessage;
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the current message.
|
||||
* Sets the message.
|
||||
*
|
||||
* @param currentMessage the new current message
|
||||
* @param currentMessage the new message
|
||||
*/
|
||||
public void setCurrentMessage(String currentMessage) {
|
||||
this.currentMessage = currentMessage;
|
||||
public void setMessage(String currentMessage) {
|
||||
this.message = currentMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,10 +208,8 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
|
|||
builder.append(status);
|
||||
builder.append(", percentCompleted=");
|
||||
builder.append(percentCompleted);
|
||||
builder.append(", log=");
|
||||
builder.append(log);
|
||||
builder.append(", currentMessage=");
|
||||
builder.append(currentMessage);
|
||||
builder.append(message);
|
||||
builder.append(", taskComputation=");
|
||||
builder.append(taskComputation);
|
||||
builder.append(", taskConfiguration=");
|
||||
|
|
Loading…
Reference in New Issue