use of org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo in project incubator-inlong by apache.
the class InlongGroupProcessOperationTest method before.
public void before(int status) {
MockPlugin mockPlugin = new MockPlugin();
serviceTaskListenerFactory.acceptPlugin(mockPlugin);
InlongGroupRequest groupInfo = new InlongGroupRequest();
groupInfo.setInlongGroupId(GROUP_ID);
groupInfo.setName(GROUP_NAME);
groupInfo.setInCharges(OPERATOR);
groupInfo.setMiddlewareType(Constant.MIDDLEWARE_PULSAR);
InlongGroupPulsarInfo pulsarInfo = new InlongGroupPulsarInfo();
pulsarInfo.setInlongGroupId(GROUP_ID);
groupInfo.setMqExtInfo(pulsarInfo);
groupService.save(groupInfo, OPERATOR);
groupService.update(groupInfo, OPERATOR);
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo in project incubator-inlong by apache.
the class InlongGroupServiceTest method saveGroup.
/**
* Test to save group
*/
public String saveGroup(String groupName, String operator) {
InlongGroupInfo groupInfo;
try {
groupInfo = groupService.get(globalGroupId);
if (groupInfo != null) {
return groupInfo.getInlongGroupId();
}
} catch (Exception e) {
// ignore
}
groupInfo = new InlongGroupInfo();
groupInfo.setName(groupName);
groupInfo.setMiddlewareType(Constant.MIDDLEWARE_PULSAR);
groupInfo.setCreator(operator);
groupInfo.setInCharges(operator);
groupInfo.setStatus(EntityStatus.GROUP_CONFIG_SUCCESSFUL.getCode());
InlongGroupPulsarInfo pulsarInfo = new InlongGroupPulsarInfo();
pulsarInfo.setMiddlewareType(Constant.MIDDLEWARE_PULSAR);
pulsarInfo.setEnsemble(3);
pulsarInfo.setWriteQuorum(3);
pulsarInfo.setAckQuorum(2);
groupInfo.setMqExtInfo(pulsarInfo);
return groupService.save(groupInfo.genRequest(), operator);
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo in project incubator-inlong by apache.
the class InlongGroupServiceImpl method get.
@Override
public InlongGroupInfo get(String groupId) {
LOGGER.debug("begin to get inlong group info by groupId={}", groupId);
Preconditions.checkNotNull(groupId, Constant.GROUP_ID_IS_EMPTY);
InlongGroupEntity entity = groupMapper.selectByGroupId(groupId);
if (entity == null) {
LOGGER.error("inlong group not found by groupId={}", groupId);
throw new BusinessException(ErrorCodeEnum.GROUP_NOT_FOUND);
}
InlongGroupInfo groupInfo = CommonBeanUtils.copyProperties(entity, InlongGroupInfo::new);
List<InlongGroupExtEntity> extEntityList = groupExtMapper.selectByGroupId(groupId);
List<InlongGroupExtInfo> extInfoList = CommonBeanUtils.copyListProperties(extEntityList, InlongGroupExtInfo::new);
groupInfo.setExtList(extInfoList);
// If the middleware is Pulsar, we need to encapsulate Pulsar related data
String mqType = entity.getMiddlewareType();
if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
InlongGroupPulsarEntity pulsarEntity = groupPulsarMapper.selectByGroupId(groupId);
Preconditions.checkNotNull(pulsarEntity, "Pulsar info not found by the groupId=" + groupId);
InlongGroupPulsarInfo pulsarInfo = CommonBeanUtils.copyProperties(pulsarEntity, InlongGroupPulsarInfo::new);
pulsarInfo.setMiddlewareType(mqType);
groupInfo.setMqExtInfo(pulsarInfo);
}
// For approved inlong group, encapsulate the cluster address of the middleware
if (GroupState.CONFIG_SUCCESSFUL == GroupState.forCode(groupInfo.getStatus())) {
if (Constant.MIDDLEWARE_TUBE.equalsIgnoreCase(mqType)) {
groupInfo.setTubeMaster(commonOperateService.getSpecifiedParam(Constant.TUBE_MASTER_URL));
} else if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
PulsarClusterInfo pulsarCluster = commonOperateService.getPulsarClusterInfo(mqType);
groupInfo.setPulsarAdminUrl(pulsarCluster.getAdminUrl());
groupInfo.setPulsarServiceUrl(pulsarCluster.getBrokerServiceUrl());
}
}
LOGGER.debug("success to get inlong group for groupId={}", groupId);
return groupInfo;
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo 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.group.InlongGroupPulsarInfo in project incubator-inlong by apache.
the class InlongGroupServiceImpl method update.
@Transactional(rollbackFor = Throwable.class)
@Override
public String update(InlongGroupRequest groupRequest, String operator) {
LOGGER.debug("begin to update inlong group={}", groupRequest);
Preconditions.checkNotNull(groupRequest, "inlong group is empty");
String groupId = groupRequest.getInlongGroupId();
Preconditions.checkNotNull(groupId, Constant.GROUP_ID_IS_EMPTY);
InlongGroupEntity entity = groupMapper.selectByGroupId(groupId);
if (entity == null) {
LOGGER.error("inlong group not found by groupId={}", groupId);
throw new BusinessException(ErrorCodeEnum.GROUP_NOT_FOUND);
}
// Check whether the current status can be modified
this.checkGroupCanUpdate(entity, groupRequest, operator);
CommonBeanUtils.copyProperties(groupRequest, entity, true);
if (GroupState.CONFIG_FAILED.getCode().equals(entity.getStatus())) {
entity.setStatus(GroupState.TO_BE_SUBMIT.getCode());
}
entity.setModifier(operator);
groupMapper.updateByIdentifierSelective(entity);
// Save extended information
this.saveOrUpdateExt(groupId, groupRequest.getExtList());
// Update the Pulsar info
String mqType = groupRequest.getMiddlewareType();
if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
InlongGroupPulsarInfo pulsarInfo = (InlongGroupPulsarInfo) groupRequest.getMqExtInfo();
Preconditions.checkNotNull(pulsarInfo, "Pulsar info cannot be empty, as the middleware is Pulsar");
Integer writeQuorum = pulsarInfo.getWriteQuorum();
Integer ackQuorum = pulsarInfo.getAckQuorum();
if (!(ackQuorum <= writeQuorum)) {
throw new BusinessException(ErrorCodeEnum.GROUP_SAVE_FAILED, "Pulsar params must meet: ackQuorum <= writeQuorum");
}
InlongGroupPulsarEntity pulsarEntity = CommonBeanUtils.copyProperties(pulsarInfo, InlongGroupPulsarEntity::new);
pulsarEntity.setInlongGroupId(groupId);
groupPulsarMapper.updateByIdentifierSelective(pulsarEntity);
}
LOGGER.debug("success to update inlong group for groupId={}", groupId);
return groupId;
}
Aggregations