use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.
the class InlongGroupServiceImpl method getTopic.
@Override
public InlongGroupTopicResponse getTopic(String groupId) {
LOGGER.debug("begin to get topic by groupId={}", groupId);
InlongGroupInfo groupInfo = this.get(groupId);
String mqType = groupInfo.getMiddlewareType();
InlongGroupTopicResponse topicVO = new InlongGroupTopicResponse();
if (Constant.MIDDLEWARE_TUBE.equals(mqType)) {
// Tube Topic corresponds to inlong group one-to-one
topicVO.setMqResourceObj(groupInfo.getMqResourceObj());
topicVO.setTubeMasterUrl(commonOperateService.getSpecifiedParam(Constant.TUBE_MASTER_URL));
} else if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
// Pulsar's topic corresponds to the inlong stream one-to-one
topicVO.setDsTopicList(streamService.getTopicList(groupId));
topicVO.setPulsarAdminUrl(commonOperateService.getSpecifiedParam(Constant.PULSAR_ADMINURL));
topicVO.setPulsarServiceUrl(commonOperateService.getSpecifiedParam(Constant.PULSAR_SERVICEURL));
} else {
LOGGER.error("middleware type={} not supported", mqType);
throw new BusinessException(ErrorCodeEnum.MIDDLEWARE_TYPE_NOT_SUPPORTED);
}
topicVO.setInlongGroupId(groupId);
topicVO.setMiddlewareType(mqType);
return topicVO;
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.
the class PushSortConfigListener method listen.
@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("begin to push sort config by context={}", context);
}
GroupResourceProcessForm form = (GroupResourceProcessForm) context.getProcessForm();
String groupId = form.getGroupInfo().getInlongGroupId();
InlongGroupInfo groupInfo = groupService.get(groupId);
// if streamId not null, just push the config belongs to the groupId and the streamId
String streamId = form.getInlongStreamId();
List<SinkResponse> sinkResponseList = streamSinkService.listSink(groupId, streamId);
if (CollectionUtils.isEmpty(sinkResponseList)) {
LOGGER.warn("Sink not found by groupId={}", groupId);
return ListenerResult.success();
}
for (SinkResponse sinkResponse : sinkResponseList) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("sink info: {}", sinkResponse);
}
DataFlowInfo dataFlowInfo = commonOperateService.createDataFlow(groupInfo, sinkResponse);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("try to push config to sort: {}", JsonUtils.toJson(dataFlowInfo));
}
Integer sinkId = sinkResponse.getId();
try {
String zkUrl = clusterBean.getZkUrl();
String zkRoot = clusterBean.getZkRoot();
// push data flow info to zk
String sortClusterName = clusterBean.getAppName();
ZkTools.updateDataFlowInfo(dataFlowInfo, sortClusterName, sinkId, zkUrl, zkRoot);
// add sink id to zk
ZkTools.addDataFlowToCluster(sortClusterName, sinkId, zkUrl, zkRoot);
} catch (Exception e) {
LOGGER.error("push sort config to zookeeper failed, sinkId={} ", sinkId, e);
throw new WorkflowListenerException("push sort config to zookeeper failed: " + e.getMessage());
}
}
return ListenerResult.success();
}
Aggregations