use of org.apache.inlong.manager.common.pojo.source.SourceResponse in project incubator-inlong by apache.
the class StreamSourceServiceTest method testListByIdentifier.
@Test
public void testListByIdentifier() {
Integer id = this.saveSource();
SourceResponse source = sourceService.get(id, Constant.SOURCE_BINLOG);
Assert.assertEquals(globalGroupId, source.getInlongGroupId());
sourceService.delete(id, Constant.SOURCE_BINLOG, globalOperator);
}
use of org.apache.inlong.manager.common.pojo.source.SourceResponse in project incubator-inlong by apache.
the class DataSourceListenerTest method testFrozenSource.
@Test
public void testFrozenSource() {
groupInfo = initGroupForm("PULSAR");
groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
final int sourceId = createBinlogSource(groupInfo);
streamSourceService.updateStatus(groupInfo.getInlongGroupId(), null, SourceState.SOURCE_NORMAL.getCode(), OPERATOR);
form = new UpdateGroupProcessForm();
form.setGroupInfo(groupInfo);
form.setOperateType(OperateType.SUSPEND);
WorkflowContext context = workflowEngine.processService().start(ProcessName.SUSPEND_GROUP_PROCESS.name(), applicant, form);
WorkflowResult result = WorkflowBeanUtils.result(context);
ProcessResponse response = result.getProcessInfo();
Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
WorkflowProcess process = context.getProcess();
WorkflowTask task = process.getTaskByName("stopSource");
Assert.assertTrue(task instanceof ServiceTask);
SourceResponse sourceResponse = streamSourceService.get(sourceId, SourceType.BINLOG.toString());
Assert.assertSame(SourceState.forCode(sourceResponse.getStatus()), SourceState.TO_BE_ISSUED_FROZEN);
}
use of org.apache.inlong.manager.common.pojo.source.SourceResponse in project incubator-inlong by apache.
the class CommonOperateService method createDataFlow.
/**
* Create dataflow info for sort.
*/
public DataFlowInfo createDataFlow(InlongGroupInfo groupInfo, SinkResponse sinkResponse) {
String groupId = sinkResponse.getInlongGroupId();
String streamId = sinkResponse.getInlongStreamId();
// TODO Support all source type, include AUTO_PUSH.
List<SourceResponse> sourceList = streamSourceService.listSource(groupId, streamId);
if (CollectionUtils.isEmpty(sourceList)) {
throw new WorkflowListenerException(String.format("Source not found by groupId=%s and streamId=%s", groupId, streamId));
}
// Get all field info
List<FieldInfo> sourceFields = new ArrayList<>();
List<FieldInfo> sinkFields = new ArrayList<>();
String partition = null;
if (SinkType.forType(sinkResponse.getSinkType()) == SinkType.HIVE) {
HiveSinkResponse hiveSink = (HiveSinkResponse) sinkResponse;
partition = hiveSink.getPrimaryPartition();
}
// TODO Support more than one source and one sink
final SourceResponse sourceResponse = sourceList.get(0);
boolean isAllMigration = SourceInfoUtils.isBinlogAllMigration(sourceResponse);
FieldMappingRule fieldMappingRule = FieldInfoUtils.createFieldInfo(isAllMigration, sinkResponse.getFieldList(), sourceFields, sinkFields, partition);
// Get source info
String masterAddress = getSpecifiedParam(Constant.TUBE_MASTER_URL);
PulsarClusterInfo pulsarCluster = getPulsarClusterInfo(groupInfo.getMiddlewareType());
InlongStreamInfo streamInfo = streamService.get(groupId, streamId);
SourceInfo sourceInfo = SourceInfoUtils.createSourceInfo(pulsarCluster, masterAddress, clusterBean, groupInfo, streamInfo, sourceResponse, sourceFields);
// Get sink info
SinkInfo sinkInfo = SinkInfoUtils.createSinkInfo(sourceResponse, sinkResponse, sinkFields);
// Get transformation info
TransformationInfo transInfo = new TransformationInfo(fieldMappingRule);
// Get properties
Map<String, Object> properties = new HashMap<>();
if (MapUtils.isNotEmpty(sinkResponse.getProperties())) {
properties.putAll(sinkResponse.getProperties());
}
properties.put(Constant.DATA_FLOW_GROUP_ID_KEY, groupId);
return new DataFlowInfo(sinkResponse.getId(), sourceInfo, transInfo, sinkInfo, properties);
}
use of org.apache.inlong.manager.common.pojo.source.SourceResponse in project incubator-inlong by apache.
the class StreamSourceServiceImpl method get.
@Override
public SourceResponse get(Integer id, String sourceType) {
LOGGER.debug("begin to get source by id={}, sourceType={}", id, sourceType);
StreamSourceOperation operation = operationFactory.getInstance(SourceType.forType(sourceType));
SourceResponse sourceResponse = operation.getById(id);
LOGGER.debug("success to get source info");
return sourceResponse;
}
use of org.apache.inlong.manager.common.pojo.source.SourceResponse in project incubator-inlong by apache.
the class AbstractSourceOperateListener method operateStreamSources.
protected void operateStreamSources(String groupId, String streamId, String operator) {
List<SourceResponse> sourceResponses = streamSourceService.listSource(groupId, streamId);
sourceResponses.forEach(sourceResponse -> {
SourceRequest sourceRequest = createSourceRequest(sourceResponse);
operateStreamSource(sourceRequest, operator);
});
}
Aggregations