use of org.apache.inlong.manager.common.pojo.workflow.EventLogView in project incubator-inlong by apache.
the class InlongGroupImpl method generateSnapshot.
private InlongGroupContext generateSnapshot() {
// Fetch current group
InlongGroupResponse groupResponse = managerClient.getGroupInfo(groupContext.getGroupId());
InlongGroupInfo currentGroupInfo = CommonBeanUtils.copyProperties(groupResponse, InlongGroupInfo::new);
groupContext.setGroupInfo(currentGroupInfo);
String inlongGroupId = currentGroupInfo.getInlongGroupId();
// Fetch stream in group
List<InlongStream> dataStreams = fetchDataStreams(inlongGroupId);
if (CollectionUtils.isNotEmpty(dataStreams)) {
dataStreams.forEach(dataStream -> groupContext.setStream(dataStream));
}
// Create group context
InlongGroupContext inlongGroupContext = new InlongGroupContext(groupContext, groupConf);
// Fetch group logs
List<EventLogView> logViews = managerClient.getInlongGroupError(inlongGroupId);
if (CollectionUtils.isNotEmpty(logViews)) {
Map<String, List<String>> errMsgs = Maps.newHashMap();
Map<String, List<String>> groupLogs = Maps.newHashMap();
logViews.stream().filter(x -> StringUtils.isNotEmpty(x.getElementName())).forEach(eventLogView -> {
String taskName = eventLogView.getElementName();
if (StringUtils.isNotEmpty(eventLogView.getException())) {
errMsgs.computeIfAbsent(taskName, Lists::newArrayList).add(eventLogView.getException());
}
if (StringUtils.isNotEmpty(eventLogView.getRemark())) {
groupLogs.computeIfAbsent(taskName, Lists::newArrayList).add(eventLogView.getRemark());
}
});
inlongGroupContext.setErrMsgs(errMsgs);
inlongGroupContext.setGroupLogs(groupLogs);
}
// Fetch stream logs
Map<String, InlongStream> streams = inlongGroupContext.getInlongStreamMap();
streams.keySet().stream().forEach(streamName -> {
String inlongStreamId = "b_" + streamName;
List<InlongStreamConfigLogListResponse> logList = managerClient.getStreamLogs(inlongGroupId, inlongStreamId);
if (CollectionUtils.isNotEmpty(logList)) {
Map<String, List<String>> streamLogs = Maps.newHashMap();
logList.stream().filter(x -> StringUtils.isNotEmpty(x.getComponentName())).forEach(streamLog -> {
String componentName = streamLog.getComponentName();
String log = GsonUtil.toJson(streamLog);
streamLogs.computeIfAbsent(componentName, Lists::newArrayList).add(log);
});
inlongGroupContext.getStreamLogs().put(streamName, streamLogs);
}
});
return inlongGroupContext;
}
use of org.apache.inlong.manager.common.pojo.workflow.EventLogView in project incubator-inlong by apache.
the class InnerInlongManagerClient method getInlongGroupError.
/**
* get inlong group error messages
*/
public List<EventLogView> getInlongGroupError(String inlongGroupId) {
final String path = HTTP_PATH + "/workflow/event/list";
String url = formatUrl(path);
url = url + "&inlongGroupId=" + inlongGroupId + "&status=-1";
Request request = new Request.Builder().get().url(url).build();
Call call = httpClient.newCall(request);
try {
Response response = call.execute();
assert response.body() != null;
String body = response.body().string();
AssertUtil.isTrue(response.isSuccessful(), String.format("Inlong request failed: %s", body));
org.apache.inlong.manager.common.beans.Response responseBody = InlongParser.parseResponse(body);
AssertUtil.isTrue(responseBody.getErrMsg() == null, String.format("Inlong request failed: %s", responseBody.getErrMsg()));
PageInfo<EventLogView> pageInfo = InlongParser.parseEventLogViewList(responseBody);
return pageInfo.getList();
} catch (Exception e) {
throw new RuntimeException(String.format("Get inlong group error messages failed: %s", e.getMessage()), e);
}
}
use of org.apache.inlong.manager.common.pojo.workflow.EventLogView in project incubator-inlong by apache.
the class InlongParser method parseEventLogViewList.
public static PageInfo<EventLogView> parseEventLogViewList(Response response) {
Object data = response.getData();
String pageInfoJson = GsonUtil.toJson(data);
return GsonUtil.fromJson(pageInfoJson, new TypeToken<PageInfo<EventLogView>>() {
}.getType());
}
Aggregations