use of com.netflix.conductor.common.metadata.tasks.TaskExecLog in project conductor by Netflix.
the class TestElasticSearchDAOV5 method taskExecutionLogs.
@Test
public void taskExecutionLogs() throws Exception {
TaskExecLog taskExecLog1 = new TaskExecLog();
taskExecLog1.setTaskId("some-task-id");
long createdTime1 = LocalDateTime.of(2018, 11, 01, 06, 33, 22).toEpochSecond(ZoneOffset.UTC);
taskExecLog1.setCreatedTime(createdTime1);
taskExecLog1.setLog("some-log");
TaskExecLog taskExecLog2 = new TaskExecLog();
taskExecLog2.setTaskId("some-task-id");
long createdTime2 = LocalDateTime.of(2018, 11, 01, 06, 33, 22).toEpochSecond(ZoneOffset.UTC);
taskExecLog2.setCreatedTime(createdTime2);
taskExecLog2.setLog("some-log");
List<TaskExecLog> logsToAdd = Arrays.asList(taskExecLog1, taskExecLog2);
indexDAO.addTaskExecutionLogs(logsToAdd);
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
List<TaskExecLog> taskExecutionLogs = indexDAO.getTaskExecutionLogs("some-task-id");
assertEquals(2, taskExecutionLogs.size());
});
}
use of com.netflix.conductor.common.metadata.tasks.TaskExecLog in project conductor by Netflix.
the class ElasticSearchRestDAOV6 method addTaskExecutionLogs.
@Override
public void addTaskExecutionLogs(List<TaskExecLog> taskExecLogs) {
if (taskExecLogs.isEmpty()) {
return;
}
long startTime = Instant.now().toEpochMilli();
BulkRequest bulkRequest = new BulkRequest();
for (TaskExecLog log : taskExecLogs) {
byte[] docBytes;
try {
docBytes = objectMapper.writeValueAsBytes(log);
} catch (JsonProcessingException e) {
logger.error("Failed to convert task log to JSON for task {}", log.getTaskId());
continue;
}
String docType = StringUtils.isBlank(docTypeOverride) ? LOG_DOC_TYPE : docTypeOverride;
IndexRequest request = new IndexRequest(logIndexName, docType);
request.source(docBytes, XContentType.JSON);
bulkRequest.add(request);
}
try {
new RetryUtil<BulkResponse>().retryOnException(() -> {
try {
return elasticSearchClient.bulk(bulkRequest);
} catch (IOException e) {
throw new RuntimeException(e);
}
}, null, BulkResponse::hasFailures, RETRY_COUNT, "Indexing task execution logs", "addTaskExecutionLogs");
long endTime = Instant.now().toEpochMilli();
logger.debug("Time taken {} for indexing taskExecutionLogs", endTime - startTime);
Monitors.recordESIndexTime("index_task_execution_logs", LOG_DOC_TYPE, endTime - startTime);
Monitors.recordWorkerQueueSize("logQueue", ((ThreadPoolExecutor) logExecutorService).getQueue().size());
} catch (Exception e) {
List<String> taskIds = taskExecLogs.stream().map(TaskExecLog::getTaskId).collect(Collectors.toList());
logger.error("Failed to index task execution logs for tasks: {}", taskIds, e);
}
}
use of com.netflix.conductor.common.metadata.tasks.TaskExecLog in project conductor by Netflix.
the class ElasticSearchDAOV6 method mapTaskExecLogsResponse.
private List<TaskExecLog> mapTaskExecLogsResponse(SearchResponse response) throws IOException {
SearchHit[] hits = response.getHits().getHits();
List<TaskExecLog> logs = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
String source = hit.getSourceAsString();
TaskExecLog tel = objectMapper.readValue(source, TaskExecLog.class);
logs.add(tel);
}
return logs;
}
use of com.netflix.conductor.common.metadata.tasks.TaskExecLog in project conductor by Netflix.
the class ElasticSearchRestDAOV6 method mapTaskExecLogsResponse.
private List<TaskExecLog> mapTaskExecLogsResponse(SearchResponse response) throws IOException {
SearchHit[] hits = response.getHits().getHits();
List<TaskExecLog> logs = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
String source = hit.getSourceAsString();
TaskExecLog tel = objectMapper.readValue(source, TaskExecLog.class);
logs.add(tel);
}
return logs;
}
use of com.netflix.conductor.common.metadata.tasks.TaskExecLog in project conductor by Netflix.
the class ElasticSearchRestDAOV7 method mapTaskExecLogsResponse.
private List<TaskExecLog> mapTaskExecLogsResponse(SearchResponse response) throws IOException {
SearchHit[] hits = response.getHits().getHits();
List<TaskExecLog> logs = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
String source = hit.getSourceAsString();
TaskExecLog tel = objectMapper.readValue(source, TaskExecLog.class);
logs.add(tel);
}
return logs;
}
Aggregations