use of org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm in project incubator-inlong by apache.
the class CreatePulsarResourceTaskListener method listen.
@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
GroupResourceProcessForm form = (GroupResourceProcessForm) context.getProcessForm();
String groupId = form.getInlongGroupId();
log.info("begin to create pulsar resource for groupId={}", groupId);
InlongGroupInfo groupInfo = groupService.get(groupId);
if (groupInfo == null) {
throw new WorkflowListenerException("inlong group or pulsar cluster not found for groupId=" + groupId);
}
PulsarClusterInfo globalCluster = commonOperateService.getPulsarClusterInfo(groupInfo.getMiddlewareType());
try (PulsarAdmin globalPulsarAdmin = PulsarUtils.getPulsarAdmin(globalCluster)) {
List<String> pulsarClusters = PulsarUtils.getPulsarClusters(globalPulsarAdmin);
for (String cluster : pulsarClusters) {
String serviceUrl = PulsarUtils.getServiceUrl(globalPulsarAdmin, cluster);
PulsarClusterInfo pulsarClusterInfo = PulsarClusterInfo.builder().token(globalCluster.getToken()).adminUrl(serviceUrl).build();
this.createPulsarProcess(groupInfo, pulsarClusterInfo);
}
} catch (Exception e) {
log.error("create pulsar resource error for groupId={}", groupId, e);
throw new WorkflowListenerException("create pulsar resource error for groupId=" + groupId);
}
log.info("success to create pulsar resource for groupId={}", groupId);
return ListenerResult.success();
}
use of org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm in project incubator-inlong by apache.
the class DisableZkForSortTest method testCreateSortConfigInCreateWorkflow.
@Test
public void testCreateSortConfigInCreateWorkflow() {
InlongGroupInfo groupInfo = initGroupForm("PULSAR");
groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
groupInfo.setZookeeperEnabled(0);
groupService.update(groupInfo.genRequest(), OPERATOR);
InlongStreamInfo streamInfo = createStreamInfo(groupInfo);
createHiveSink(streamInfo);
createKafkaSource(streamInfo);
mockTaskListenerFactory();
WorkflowContext context = workflowEngine.processService().start(processName.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("initSort");
Assert.assertTrue(task instanceof ServiceTask);
Assert.assertEquals(1, task.getNameToListenerMap().size());
List<TaskEventListener> listeners = Lists.newArrayList(task.getNameToListenerMap().values());
Assert.assertTrue(listeners.get(0) instanceof CreateSortConfigListener);
ProcessForm form = context.getProcessForm();
InlongGroupInfo curGroupRequest = ((GroupResourceProcessForm) form).getGroupInfo();
Assert.assertTrue(curGroupRequest.getExtList().size() == 1);
}
use of org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm in project incubator-inlong by apache.
the class ServiceTaskListenerFactoryTest method testGetQueueOperateListener.
@Test
public void testGetQueueOperateListener() {
WorkflowContext context = new WorkflowContext();
GroupResourceProcessForm processForm = new GroupResourceProcessForm();
InlongGroupInfo groupInfo = new InlongGroupInfo();
// check pulsar listener
groupInfo.setMiddlewareType(Constant.MIDDLEWARE_PULSAR);
processForm.setGroupInfo(groupInfo);
context.setProcessForm(processForm);
List<QueueOperateListener> queueOperateListeners = serviceTaskListenerFactory.getQueueOperateListener(context);
Assert.assertEquals(2, queueOperateListeners.size());
Assert.assertTrue(queueOperateListeners.get(0) instanceof CreatePulsarResourceTaskListener);
Assert.assertTrue(queueOperateListeners.get(1) instanceof CreatePulsarGroupTaskListener);
// check tube listener
groupInfo.setMiddlewareType(Constant.MIDDLEWARE_TUBE);
queueOperateListeners = serviceTaskListenerFactory.getQueueOperateListener(context);
Assert.assertEquals(2, queueOperateListeners.size());
Assert.assertTrue(queueOperateListeners.get(0) instanceof CreateTubeTopicTaskListener);
Assert.assertTrue(queueOperateListeners.get(1) instanceof CreateTubeGroupTaskListener);
}
use of org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm in project incubator-inlong by apache.
the class WorkflowServiceImplTest method initGroupForm.
/**
* Init inlong group form
*/
public InlongGroupInfo initGroupForm(String middlewareType) {
processName = ProcessName.CREATE_GROUP_RESOURCE;
applicant = OPERATOR;
try {
streamService.logicDeleteAll(GROUP_ID, OPERATOR);
groupService.delete(GROUP_ID, OPERATOR);
} catch (Exception e) {
// ignore
}
InlongGroupInfo groupInfo = new InlongGroupInfo();
groupInfo.setName("test");
groupInfo.setInCharges(OPERATOR);
groupInfo.setInlongGroupId("b_test");
groupInfo.setMiddlewareType(middlewareType);
groupInfo.setMqExtInfo(new InlongGroupPulsarInfo());
groupInfo.setMqResourceObj("test-queue");
groupService.save(groupInfo.genRequest(), OPERATOR);
groupInfo.setStatus(GroupState.TO_BE_APPROVAL.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
groupInfo.setStatus(GroupState.APPROVE_PASSED.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
groupInfo.setStatus(GroupState.CONFIG_ING.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
form = new GroupResourceProcessForm();
form.setInlongStreamId(STREAM_ID);
form.setGroupInfo(groupInfo);
return groupInfo;
}
use of org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm in project incubator-inlong by apache.
the class CreateHiveTableEventSelectorTest method testAccept.
@Test
public void testAccept() {
WorkflowContext workflowContext = new WorkflowContext();
GroupResourceProcessForm processForm = new GroupResourceProcessForm();
workflowContext.setProcessForm(processForm);
Assert.assertFalse(createHiveTableEventSelector.accept(workflowContext));
processForm.setGroupInfo(new InlongGroupInfo());
Assert.assertFalse(createHiveTableEventSelector.accept(workflowContext));
processForm.getGroupInfo().setInlongGroupId("test");
Assert.assertTrue(createHiveTableEventSelector.accept(workflowContext));
}
Aggregations