// Mark running queries that can't be found as complete - unknown
this.database.markOrphanedRunningQueriesComplete(CollectionUtils.subtract(this.database.getRunningQueries((long)tableId), currentQueries));
for (String queryUUID : currentQueries) {
BlurQueryStatus status;
try {
status = blurConnection.queryStatusById(tableName, queryUUID);
} catch (Exception e) {
log.error("Unable to get query status for query [" + queryUUID + "]." + e.getMessage());
continue;
}
Map<String, Object> oldQuery = this.database.getQuery(this.tableId, queryUUID);
String times;
try {
times = new ObjectMapper().writeValueAsString(status.getCpuTimes());
} catch (Exception e) {
log.error("Unable to parse cpu times.", e);
times = null;
}
if (oldQuery == null) {
Query query = status.getQuery().getQuery();
long startTimeLong = status.getQuery().getStartTime();
// Set the query creation time to now or given start time
Date startTime = (startTimeLong > 0) ? TimeHelper.getAdjustedTime(startTimeLong).getTime() : TimeHelper.now().getTime();
this.database.createQuery(status, query, times, startTime, this.tableId);