use of org.apache.inlong.manager.client.api.InlongStream 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;
}
Aggregations