Skip to content

Commit

Permalink
Fixing sync problems. issue #157
Browse files Browse the repository at this point in the history
  • Loading branch information
itaiag committed Sep 18, 2017
1 parent e579a81 commit 646b981
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,7 @@ public ExecutionMetadata getMetadata(int executionId) {

private void updateSingleExecutionMeta(int executionId) {
ExecutionMetadata executionMetaData = persistency.get(executionId);

try {
String timestamp = executionMetaData.getTimestamp();
if (!StringUtils.isEmpty(timestamp)) {
final Date startTime = Common.ELASTIC_SEARCH_TIMESTAMP_STRING_FORMATTER
.parse(executionMetaData.getTimestamp());
executionMetaData.setDuration(new Date().getTime() - startTime.getTime());
}
} catch (ParseException e) {
log.warn("Failed to parse start time of execution: " + executionMetaData.getTimestamp());
}
updateDuration(executionMetaData);

if (executionMetaData.getExecution() == null || executionMetaData.getExecution().getLastMachine() == null) {
return;
Expand Down Expand Up @@ -186,6 +176,23 @@ private void updateSingleExecutionMeta(int executionId) {

}

/**
* Updates the duration of the execution according to the start time.
*
* @param executionMetaData
*/
private synchronized void updateDuration(final ExecutionMetadata executionMetaData) {
final String timestamp = executionMetaData.getTimestamp();
try {
if (!StringUtils.isEmpty(timestamp)) {
final Date startTime = Common.ELASTIC_SEARCH_TIMESTAMP_STRING_FORMATTER.parse(timestamp);
executionMetaData.setDuration(new Date().getTime() - startTime.getTime());
}
} catch (ParseException | NumberFormatException e) {
log.warn("Failed to parse start time of execution '" + timestamp + "' due to '" + e.getMessage() + "'", e);
}
}

@Override
public ExecutionMetadata[] getAllMetaData() {
final List<ExecutionMetadata> result = persistency.getAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ spring.jersey.type=filter

# Levels: TRACE, DEBUG, INFO, WARN, ERROR
logging.level.org.springframework.web=ERROR
logging.level.il.co.topq.report=TRACE
logging.level.il.co.topq.report=DEBUG
logging.file=log/difido.log
multipart.maxFileSize:512MB
multipart.maxRequestSize=512MB
Expand Down

0 comments on commit 646b981

Please sign in to comment.