use of org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm.OperateType in project incubator-inlong by apache.
the class CreateSortConfigListener method listen.
@Override
public ListenerResult listen(WorkflowContext context) throws Exception {
LOGGER.info("Create sort config for context={}", context);
ProcessForm form = context.getProcessForm();
if (form instanceof UpdateGroupProcessForm) {
UpdateGroupProcessForm updateGroupProcessForm = (UpdateGroupProcessForm) form;
OperateType operateType = updateGroupProcessForm.getOperateType();
if (operateType == OperateType.SUSPEND || operateType == OperateType.DELETE) {
return ListenerResult.success();
}
}
InlongGroupInfo groupInfo = this.getGroupInfo(form);
String groupId = groupInfo.getInlongGroupId();
if (StringUtils.isEmpty(groupId)) {
LOGGER.warn("GroupId is null for context={}", context);
return ListenerResult.success();
}
List<SinkResponse> sinkResponseList = streamSinkService.listSink(groupId, null);
if (CollectionUtils.isEmpty(sinkResponseList)) {
LOGGER.warn("Sink not found by groupId={}", groupId);
return ListenerResult.success();
}
Map<String, DataFlowInfo> dataFlowInfoMap = sinkResponseList.stream().map(sink -> {
DataFlowInfo flowInfo = commonOperateService.createDataFlow(groupInfo, sink);
return Pair.of(sink.getInlongStreamId(), flowInfo);
}).collect(Collectors.toMap(Pair::getKey, Pair::getValue));
String dataFlows = OBJECT_MAPPER.writeValueAsString(dataFlowInfoMap);
InlongGroupExtInfo extInfo = new InlongGroupExtInfo();
extInfo.setInlongGroupId(groupId);
extInfo.setKeyName(InlongGroupSettings.DATA_FLOW);
extInfo.setKeyValue(dataFlows);
if (groupInfo.getExtList() == null) {
groupInfo.setExtList(Lists.newArrayList());
}
upsertDataFlow(groupInfo, extInfo);
return ListenerResult.success();
}
use of org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm.OperateType in project incubator-inlong by apache.
the class UpdateGroupCompleteListener method listen.
@Override
public ListenerResult listen(WorkflowContext context) throws Exception {
UpdateGroupProcessForm form = (UpdateGroupProcessForm) context.getProcessForm();
String username = context.getApplicant();
OperateType operateType = form.getOperateType();
InlongGroupInfo groupInfo = form.getGroupInfo();
Integer nextStatus;
switch(operateType) {
case RESTART:
nextStatus = GroupState.RESTARTED.getCode();
break;
case SUSPEND:
nextStatus = GroupState.SUSPENDED.getCode();
break;
case DELETE:
nextStatus = GroupState.DELETED.getCode();
break;
default:
throw new RuntimeException(String.format("Unsupported operation=%s for Inlong group", operateType));
}
// Update inlong group status and other info
groupService.updateStatus(groupInfo.getInlongGroupId(), nextStatus, username);
groupService.update(groupInfo.genRequest(), username);
return ListenerResult.success();
}
use of org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm.OperateType in project incubator-inlong by apache.
the class UpdateGroupListener method listen.
@Override
public ListenerResult listen(WorkflowContext context) throws Exception {
UpdateGroupProcessForm form = (UpdateGroupProcessForm) context.getProcessForm();
InlongGroupInfo groupInfo = groupService.get(context.getProcessForm().getInlongGroupId());
OperateType operateType = form.getOperateType();
String username = context.getApplicant();
if (groupInfo != null) {
switch(operateType) {
case SUSPEND:
groupService.updateStatus(groupInfo.getInlongGroupId(), GroupState.SUSPENDING.getCode(), username);
break;
case RESTART:
groupService.updateStatus(groupInfo.getInlongGroupId(), GroupState.RESTARTING.getCode(), username);
break;
case DELETE:
groupService.updateStatus(groupInfo.getInlongGroupId(), GroupState.DELETING.getCode(), username);
break;
default:
break;
}
form.setGroupInfo(groupInfo);
} else {
throw new BusinessException(ErrorCodeEnum.GROUP_NOT_FOUND);
}
return ListenerResult.success();
}
Aggregations