use of org.apache.inlong.manager.common.pojo.sink.SinkResponse in project incubator-inlong by apache.
the class HiveStreamSinkOperation method getById.
@Override
public SinkResponse getById(@NotNull String sinkType, @NotNull Integer id) {
StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(id);
Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
String existType = entity.getSinkType();
Preconditions.checkTrue(Constant.SINK_HIVE.equals(existType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_HIVE, existType));
SinkResponse response = this.getFromEntity(entity, HiveSinkResponse::new);
List<StreamSinkFieldEntity> entities = sinkFieldMapper.selectBySinkId(id);
List<SinkFieldResponse> infos = CommonBeanUtils.copyListProperties(entities, SinkFieldResponse::new);
response.setFieldList(infos);
return response;
}
use of org.apache.inlong.manager.common.pojo.sink.SinkResponse in project incubator-inlong by apache.
the class IcebergStreamSinkOperation method getById.
@Override
public SinkResponse getById(String sinkType, Integer id) {
StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(id);
Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
String existType = entity.getSinkType();
Preconditions.checkTrue(Constant.SINK_ICEBERG.equals(existType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_ICEBERG, existType));
SinkResponse response = this.getFromEntity(entity, IcebergSinkResponse::new);
List<StreamSinkFieldEntity> entities = sinkFieldMapper.selectBySinkId(id);
List<SinkFieldResponse> infos = CommonBeanUtils.copyListProperties(entities, SinkFieldResponse::new);
response.setFieldList(infos);
return response;
}
use of org.apache.inlong.manager.common.pojo.sink.SinkResponse 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.sink.SinkResponse in project incubator-inlong by apache.
the class KafkaStreamSinkServiceTest method testListByIdentifier.
@Test
public void testListByIdentifier() {
SinkResponse sink = sinkService.get(kafkaSinkId, Constant.SINK_KAFKA);
Assert.assertEquals(globalGroupId, sink.getInlongGroupId());
}
use of org.apache.inlong.manager.common.pojo.sink.SinkResponse in project incubator-inlong by apache.
the class KafkaStreamSinkOperation method getById.
@Override
public SinkResponse getById(@NotNull String sinkType, @NotNull Integer id) {
StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(id);
Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
String existType = entity.getSinkType();
Preconditions.checkTrue(Constant.SINK_KAFKA.equals(existType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_KAFKA, existType));
SinkResponse response = this.getFromEntity(entity, KafkaSinkResponse::new);
List<StreamSinkFieldEntity> entities = sinkFieldMapper.selectBySinkId(id);
List<SinkFieldResponse> infos = CommonBeanUtils.copyListProperties(entities, SinkFieldResponse::new);
response.setFieldList(infos);
return response;
}
Aggregations