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:
Francesco Mangiacrapa 2018-05-17 10:39:44 +00:00
parent fbc9cd8a7a
commit fde2799ead
6 changed files with 197 additions and 130 deletions

View File

@ -41,11 +41,11 @@ public class DMConverter {
* @param computationId the computation id * @param computationId the computation id
* @return the task computation * @return the task computation
*/ */
public static TaskComputation toDMComputationId(ComputationId computationId){ public static TaskComputation toDMComputationId(ComputationId computationId, Long startTime, Long endTime){
if(computationId==null) if(computationId==null)
return 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);
} }

View File

@ -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.dataminer.TaskExecutionStatus;
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskErrorException; 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.common.workspacetaskexecutor.util.Converter;
import org.gcube.common.workspacetaskexecutor.util.EncrypterUtil; import org.gcube.common.workspacetaskexecutor.util.EncrypterUtil;
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;
@ -42,15 +41,6 @@ import org.slf4j.LoggerFactory;
*/ */
public class DataMinerAccessPoint { 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 DataMinerService dataMinerService;
private static Logger logger = LoggerFactory.getLogger(DataMinerAccessPoint.class); private static Logger logger = LoggerFactory.getLogger(DataMinerAccessPoint.class);
@ -161,7 +151,7 @@ public class DataMinerAccessPoint {
logger.debug("Start Computation"); logger.debug("Start Computation");
ComputationId computationId = sClient.startComputation(operator); ComputationId computationId = sClient.startComputation(operator);
logger.debug("Started ComputationId: " + computationId); logger.debug("Started ComputationId: " + computationId);
return loadTaskExecutionStatus(taskConfiguration, DMConverter.toDMComputationId(computationId)); return loadTaskExecutionStatus(taskConfiguration, DMConverter.toDMComputationId(computationId, System.currentTimeMillis(), null));
} }
catch (Exception e) { catch (Exception e) {
@ -215,9 +205,11 @@ public class DataMinerAccessPoint {
private TaskExecutionStatus loadTaskExecutionStatus(TaskConfiguration taskConfiguration, final TaskComputation taskComputation) throws TaskErrorException, TaskNotExecutableException{ private TaskExecutionStatus loadTaskExecutionStatus(TaskConfiguration taskConfiguration, final TaskComputation taskComputation) throws TaskErrorException, TaskNotExecutableException{
TaskExecutionStatus oldTaskExecutionStatus = getRunningTask(taskConfiguration); TaskExecutionStatus oldTaskExecutionStatus = getRunningTask(taskConfiguration);
boolean isStart = false;
if(oldTaskExecutionStatus==null) // Long startTime = taskComputation.getStartTime();
isStart = true; // if(oldTaskExecutionStatus!=null)
// startTime = oldTaskExecutionStatus.getTaskComputation().getStartTime(); //copyng start time from bean saved on server
SClient sClient; SClient sClient;
ComputationId computationId = DMConverter.toComputationId(taskComputation); ComputationId computationId = DMConverter.toComputationId(taskComputation);
@ -232,9 +224,16 @@ public class DataMinerAccessPoint {
TaskExecutionStatus newTaskExecutionStatus = new TaskExecutionStatus(taskConfiguration, taskComputation); TaskExecutionStatus newTaskExecutionStatus = new TaskExecutionStatus(taskConfiguration, taskComputation);
/*
if(!isStart) if(!isStart)
//adding previous log //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{ else{
//first time adding the configurations //first time adding the configurations
String confs=NEW_LINE+NEW_STATUS_CHARS+Converter.getCurrentFormattedDate(null)+NEW_LINE; 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+"EquivalentRequest: "+NEW_LINE+newTaskExecutionStatus.getTaskComputation().getEquivalentRequest();
confs+=NEW_LINE+NEW_LINE+DASH+DASH+"URL ID: "+NEW_LINE+newTaskExecutionStatus.getTaskComputation().getUrlId(); confs+=NEW_LINE+NEW_LINE+DASH+DASH+"URL ID: "+NEW_LINE+newTaskExecutionStatus.getTaskComputation().getUrlId();
newTaskExecutionStatus.addLog(confs+NEW_LINE); newTaskExecutionStatus.addLog(confs+NEW_LINE);
} }*/
logger.debug("Requesting operation progress"); logger.debug("Requesting operation progress");
ComputationStatus computationStatus = null; ComputationStatus computationStatus = null;
@ -268,9 +267,10 @@ public class DataMinerAccessPoint {
return newTaskExecutionStatus; return newTaskExecutionStatus;
} }
newTaskExecutionStatus.setCurrentMessage(computationStatus.getMessage()); newTaskExecutionStatus.setMessage(computationStatus.getMessage());
newTaskExecutionStatus.setPercentCompleted((float) computationStatus.getPercentage()); 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) { switch (status) {
case ACCEPTED: case ACCEPTED:
logger.debug("Operation "+TaskStatus.ACCEPTED); logger.debug("Operation "+TaskStatus.ACCEPTED);
@ -283,18 +283,21 @@ public class DataMinerAccessPoint {
newTaskExecutionStatus.setStatus(TaskStatus.CANCELLED); newTaskExecutionStatus.setStatus(TaskStatus.CANCELLED);
historyMsg+= "Status "+TaskStatus.CANCELLED; historyMsg+= "Status "+TaskStatus.CANCELLED;
historyMsg+=computationStatus.getMessage()!=null?": "+computationStatus.getMessage():""; historyMsg+=computationStatus.getMessage()!=null?": "+computationStatus.getMessage():"";
taskComputation.setEndTime(System.currentTimeMillis());
break; break;
case COMPLETE: case COMPLETE:
logger.debug("Operation "+TaskStatus.COMPLETED); logger.debug("Operation "+TaskStatus.COMPLETED);
newTaskExecutionStatus.setStatus(TaskStatus.COMPLETED); newTaskExecutionStatus.setStatus(TaskStatus.COMPLETED);
historyMsg+= "Status "+TaskStatus.COMPLETED; historyMsg+= "Status "+TaskStatus.COMPLETED;
historyMsg+=computationStatus.getMessage()!=null?": "+computationStatus.getMessage():""; historyMsg+=computationStatus.getMessage()!=null?": "+computationStatus.getMessage():"";
taskComputation.setEndTime(System.currentTimeMillis());
break; break;
case FAILED: case FAILED:
logger.debug("Operation "+TaskStatus.FAILED); logger.debug("Operation "+TaskStatus.FAILED);
newTaskExecutionStatus.setStatus(TaskStatus.FAILED); newTaskExecutionStatus.setStatus(TaskStatus.FAILED);
historyMsg+= "Status "+TaskStatus.FAILED; historyMsg+= "Status "+TaskStatus.FAILED;
historyMsg+=computationStatus.getMessage()!=null?": "+computationStatus.getMessage():""; historyMsg+=computationStatus.getMessage()!=null?": "+computationStatus.getMessage():"";
taskComputation.setEndTime(System.currentTimeMillis());
break; break;
case RUNNING: case RUNNING:
logger.debug("Operation "+TaskStatus.ONGOING); logger.debug("Operation "+TaskStatus.ONGOING);
@ -310,7 +313,7 @@ public class DataMinerAccessPoint {
} }
newTaskExecutionStatus.addLog(historyMsg+NEW_LINE); newTaskExecutionStatus.setMessage(historyMsg);
saveTaskInMemory(taskConfiguration, newTaskExecutionStatus); saveTaskInMemory(taskConfiguration, newTaskExecutionStatus);
return newTaskExecutionStatus; return newTaskExecutionStatus;

View File

@ -18,5 +18,20 @@ public interface BaseTaskComputation {
* *
* @return the id * @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();
} }

View File

@ -25,19 +25,13 @@ public interface BaseTaskExecutionStatus {
*/ */
public TaskStatus getStatus(); 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 * @return the task configuration
*/ */
public BaseTaskConfiguration getTaskConfiguration(); public BaseTaskConfiguration getTaskConfiguration();
} }

View File

@ -27,6 +27,8 @@ public class TaskComputation implements BaseTaskComputation, Serializable {
private String operatorId; private String operatorId;
private String operatorName; private String operatorName;
private String equivalentRequest; private String equivalentRequest;
private Long startTime;
private Long endTime;
/** /**
* Instantiates a new DM computation id. * Instantiates a new DM computation id.
@ -36,115 +38,169 @@ public class TaskComputation implements BaseTaskComputation, Serializable {
/** /**
* Instantiates a new DM computation id. * @param id
* * @param urlId
* @param id the id * @param operatorId
* @param urlId the url id * @param operatorName
* @param operatorId the operator id * @param equivalentRequest
* @param operatorName the operator name * @param startTime
* @param equivalentRequest the equivalent request * @param endTime
*/ */
public TaskComputation(String id, String urlId, String operatorId, public TaskComputation(
String operatorName, String equivalentRequest) { String id, String urlId, String operatorId, String operatorName,
String equivalentRequest, Long startTime, Long endTime) {
super(); super();
this.id = id; this.id = id;
this.urlId = urlId; this.urlId = urlId;
this.operatorId = operatorId; this.operatorId = operatorId;
this.operatorName = operatorName; this.operatorName = operatorName;
this.equivalentRequest = equivalentRequest; this.equivalentRequest = equivalentRequest;
this.startTime = startTime;
this.endTime = endTime;
} }
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public String getId() { public String getId() {
return id; return id;
} }
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(String id) {
this.id = id;
}
/** /**
* Gets the url id. * @return the urlId
*
* @return the url id
*/ */
public String getUrlId() { public String getUrlId() {
return urlId; 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 operatorId
*
* @return the operator id
*/ */
public String getOperatorId() { public String getOperatorId() {
return operatorId; 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 operatorName
*
* @return the operator name
*/ */
public String getOperatorName() { public String getOperatorName() {
return operatorName; 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 equivalentRequest
*
* @return the equivalent request
*/ */
public String getEquivalentRequest() { public String getEquivalentRequest() {
return equivalentRequest; return equivalentRequest;
} }
/** /**
* Sets the equivalent request. * @return the startTime
* */
* @param equivalentRequest the new equivalent request 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) { public void setEquivalentRequest(String equivalentRequest) {
this.equivalentRequest = 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) /* (non-Javadoc)
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
@ -152,7 +208,7 @@ public class TaskComputation implements BaseTaskComputation, Serializable {
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("DMComputationId [id="); builder.append("TaskComputation [id=");
builder.append(id); builder.append(id);
builder.append(", urlId="); builder.append(", urlId=");
builder.append(urlId); builder.append(urlId);
@ -162,10 +218,13 @@ public class TaskComputation implements BaseTaskComputation, Serializable {
builder.append(operatorName); builder.append(operatorName);
builder.append(", equivalentRequest="); builder.append(", equivalentRequest=");
builder.append(equivalentRequest); builder.append(equivalentRequest);
builder.append(", startTime=");
builder.append(startTime);
builder.append(", endTime=");
builder.append(endTime);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -21,8 +21,8 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
private Long errorCount; private Long errorCount;
private TaskStatus status; private TaskStatus status;
private Float percentCompleted = new Float(0); private Float percentCompleted = new Float(0);
private String log; //private String log;
private String currentMessage="Waiting to start.."; private String message="Waiting to start..";
private TaskComputation taskComputation; private TaskComputation taskComputation;
private TaskConfiguration taskConfiguration; private TaskConfiguration taskConfiguration;
@ -47,26 +47,22 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
} }
/** /**
* 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 percentCompleted the percent completed
* @param log the log
* @param currentMessage the current message * @param currentMessage the current message
* @param taskConfiguration the task configuration * @param taskConfiguration the task configuration
* @param taskComputation the task computation * @param taskComputation the task computation
*/ */
public TaskExecutionStatus( public TaskExecutionStatus(Long errorCount, TaskStatus status, Float percentCompleted, String currentMessage, TaskConfiguration taskConfiguration, TaskComputation taskComputation) {
Long errorCount, TaskStatus status, Float percentCompleted, String log,
String currentMessage, TaskConfiguration taskConfiguration, TaskComputation taskComputation) {
this.errorCount = errorCount; this.errorCount = errorCount;
this.status = status; this.status = status;
this.percentCompleted = percentCompleted; this.percentCompleted = percentCompleted;
this.log = log; //this.log = log;
this.currentMessage = currentMessage; this.message = currentMessage;
this.taskComputation = taskComputation; this.taskComputation = taskComputation;
this.taskConfiguration = taskConfiguration; this.taskConfiguration = taskConfiguration;
} }
@ -129,44 +125,45 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
this.status = status; this.status = status;
} }
/** // /**
* Gets the log builder. // * Gets the log builder.
* // *
* @return the log builder // * @return the log builder
*/ // */
public String getLog() { // public String getLog() {
return log; // return log;
} // }
//
//
/** // /**
* Adds the log. // * Adds the log.
* // *
* @param logMessage the log message // * @param logMessage the log message
*/ // */
public void addLog(String logMessage) { // public void addLog(String logMessage) {
if(log==null) // if(log==null)
this.log = logMessage; // this.log = logMessage;
else // else
log=logMessage+log; // log=logMessage+log;
} // }
/** /**
* Gets the current message. * Gets the current message.
* *
* @return the current message * @return the current message
*/ */
public String getCurrentMessage() { public String getMessage() {
return currentMessage; 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) { public void setMessage(String currentMessage) {
this.currentMessage = currentMessage; this.message = currentMessage;
} }
/** /**
@ -211,10 +208,8 @@ public class TaskExecutionStatus implements BaseTaskExecutionStatus, Serializabl
builder.append(status); builder.append(status);
builder.append(", percentCompleted="); builder.append(", percentCompleted=");
builder.append(percentCompleted); builder.append(percentCompleted);
builder.append(", log=");
builder.append(log);
builder.append(", currentMessage="); builder.append(", currentMessage=");
builder.append(currentMessage); builder.append(message);
builder.append(", taskComputation="); builder.append(", taskComputation=");
builder.append(taskComputation); builder.append(taskComputation);
builder.append(", taskConfiguration="); builder.append(", taskConfiguration=");