use of org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogListResponse in project incubator-inlong by apache.
the class InnerInlongManagerClient method getStreamLogs.
/**
* get inlong group error messages
*/
public List<InlongStreamConfigLogListResponse> getStreamLogs(String inlongGroupId, String inlongStreamId) {
final String path = HTTP_PATH + "/stream/config/log/list";
String url = formatUrl(path);
url = url + "&inlongGroupId=" + inlongGroupId + "&inlongStreamId=" + inlongStreamId;
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<InlongStreamConfigLogListResponse> pageInfo = InlongParser.parseStreamLogList(responseBody);
return pageInfo.getList();
} catch (Exception e) {
throw new RuntimeException(String.format("Get inlong stream log failed: %s", e.getMessage()), e);
}
}
use of org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogListResponse in project incubator-inlong by apache.
the class StreamConfigLogServiceImpl method listByCondition.
@Override
public PageInfo<InlongStreamConfigLogListResponse> listByCondition(InlongStreamConfigLogPageRequest request) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("begin to list source page by " + request);
}
Preconditions.checkNotNull(request.getInlongGroupId(), Constant.GROUP_ID_IS_EMPTY);
PageHelper.startPage(request.getPageNum(), request.getPageSize());
if (request.getReportTime() == null) {
Instant instant = Instant.now().minus(Duration.ofMillis(5));
request.setReportTime(new Date(instant.toEpochMilli()));
}
Page<StreamConfigLogEntity> entityPage = (Page<StreamConfigLogEntity>) streamConfigLogEntityMapper.selectByCondition(request);
List<InlongStreamConfigLogListResponse> detailList = CommonBeanUtils.copyListProperties(entityPage, InlongStreamConfigLogListResponse::new);
PageInfo<InlongStreamConfigLogListResponse> pageInfo = new PageInfo<>(detailList);
pageInfo.setTotal(entityPage.getTotal());
return pageInfo;
}
use of org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogListResponse 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.stream.InlongStreamConfigLogListResponse in project incubator-inlong by apache.
the class InlongParser method parseStreamLogList.
public static PageInfo<InlongStreamConfigLogListResponse> parseStreamLogList(Response response) {
Object data = response.getData();
String pageInfoJson = GsonUtil.toJson(data);
return GsonUtil.fromJson(pageInfoJson, new TypeToken<PageInfo<InlongStreamConfigLogListResponse>>() {
}.getType());
}
Aggregations