use of org.apache.inlong.manager.common.pojo.group.InlongGroupResponse in project incubator-inlong by apache.
the class InlongParser method parseGroupInfo.
public static InlongGroupResponse parseGroupInfo(Response response) {
Object data = response.getData();
JsonObject groupJson = GsonUtil.fromJson(GsonUtil.toJson(data), JsonObject.class);
InlongGroupResponse inlongGroupResponse = GsonUtil.fromJson(GsonUtil.toJson(data), InlongGroupResponse.class);
JsonObject mqExtInfo = groupJson.getAsJsonObject(MQ_EXT_INFO);
if (mqExtInfo != null && mqExtInfo.get(MIDDLEWARE_TYPE) != null) {
String middlewareType = mqExtInfo.get(MIDDLEWARE_TYPE).getAsString();
if (Constant.MIDDLEWARE_PULSAR.equals(middlewareType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(middlewareType)) {
InlongGroupPulsarInfo pulsarInfo = GsonUtil.fromJson(mqExtInfo.toString(), InlongGroupPulsarInfo.class);
inlongGroupResponse.setMqExtInfo(pulsarInfo);
}
}
return inlongGroupResponse;
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupResponse in project incubator-inlong by apache.
the class InlongGroupImpl method delete.
@Override
public InlongGroupContext delete() throws Exception {
InlongGroupResponse groupResponse = managerClient.getGroupInfo(groupContext.getGroupId());
boolean isDeleted = managerClient.deleteInlongGroup(groupResponse.getInlongGroupId());
if (isDeleted) {
groupResponse.setStatus(GroupState.DELETED.getCode());
}
return generateSnapshot();
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupResponse in project incubator-inlong by apache.
the class InlongClientImpl method listGroup.
@Override
public List<InlongGroup> listGroup(String expr, int status, int pageNum, int pageSize) throws Exception {
InnerInlongManagerClient managerClient = new InnerInlongManagerClient(this);
PageInfo<InlongGroupListResponse> responsePageInfo = managerClient.listGroups(expr, status, pageNum, pageSize);
if (CollectionUtils.isEmpty(responsePageInfo.getList())) {
return Lists.newArrayList();
} else {
return responsePageInfo.getList().stream().map(response -> {
String groupId = response.getInlongGroupId();
InlongGroupResponse groupResponse = managerClient.getGroupInfo(groupId);
InlongGroupConf groupConf = InlongGroupTransfer.parseGroupResponse(groupResponse);
return new InlongGroupImpl(groupConf, this);
}).collect(Collectors.toList());
}
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupResponse in project incubator-inlong by apache.
the class InlongClientImpl method getGroup.
@Override
public InlongGroup getGroup(String groupName) throws Exception {
InnerInlongManagerClient managerClient = new InnerInlongManagerClient(this);
final String groupId = "b_" + groupName;
InlongGroupResponse groupResponse = managerClient.getGroupInfo(groupId);
if (groupResponse == null) {
return new BlankInlongGroup();
}
InlongGroupConf groupConf = InlongGroupTransfer.parseGroupResponse(groupResponse);
return new InlongGroupImpl(groupConf, this);
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupResponse 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