use of org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm 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