use of org.apache.inlong.manager.dao.entity.InlongGroupExtEntity in project incubator-inlong by apache.
the class InlongGroupServiceTest method testSaveAndUpdateExt.
@Test
public void testSaveAndUpdateExt() {
// check insert
InlongGroupExtInfo groupExtInfo1 = new InlongGroupExtInfo();
groupExtInfo1.setId(1);
groupExtInfo1.setInlongGroupId(globalGroupId);
groupExtInfo1.setKeyName("pulsar_url");
groupExtInfo1.setKeyValue("http://127.0.0.1:8080");
InlongGroupExtInfo groupExtInfo2 = new InlongGroupExtInfo();
groupExtInfo2.setId(2);
groupExtInfo2.setInlongGroupId(globalGroupId);
groupExtInfo2.setKeyName("pulsar_secret");
groupExtInfo2.setKeyValue("QWEASDZXC");
List<InlongGroupExtInfo> groupExtInfoList = Arrays.asList(groupExtInfo1, groupExtInfo2);
groupService.saveOrUpdateExt(globalGroupId, groupExtInfoList);
List<InlongGroupExtEntity> extEntityList = groupExtMapper.selectByGroupId(globalGroupId);
Assert.assertEquals(2, extEntityList.size());
Assert.assertEquals("pulsar_url", extEntityList.get(0).getKeyName());
Assert.assertEquals("http://127.0.0.1:8080", extEntityList.get(0).getKeyValue());
// check update
groupExtInfo1.setKeyValue("http://127.0.0.1:8081");
groupService.saveOrUpdateExt(globalGroupId, groupExtInfoList);
extEntityList = groupExtMapper.selectByGroupId(globalGroupId);
Assert.assertEquals(2, extEntityList.size());
Assert.assertEquals("http://127.0.0.1:8081", extEntityList.get(0).getKeyValue());
groupExtInfo2.setKeyValue("qweasdzxc");
groupService.saveOrUpdateExt(globalGroupId, groupExtInfoList);
extEntityList = groupExtMapper.selectByGroupId(globalGroupId);
Assert.assertEquals(2, extEntityList.size());
Assert.assertEquals("qweasdzxc", extEntityList.get(1).getKeyValue());
}
use of org.apache.inlong.manager.dao.entity.InlongGroupExtEntity in project incubator-inlong by apache.
the class InlongGroupServiceImpl method saveOrUpdateExt.
@Override
@Transactional(rollbackFor = Throwable.class)
public void saveOrUpdateExt(String groupId, List<InlongGroupExtInfo> infoList) {
LOGGER.debug("begin to save or update inlong group ext info, groupId={}, ext={}", groupId, infoList);
if (CollectionUtils.isEmpty(infoList)) {
return;
}
List<InlongGroupExtEntity> entityList = CommonBeanUtils.copyListProperties(infoList, InlongGroupExtEntity::new);
Date date = new Date();
for (InlongGroupExtEntity entity : entityList) {
entity.setInlongGroupId(groupId);
entity.setModifyTime(date);
}
groupExtMapper.insertOnDuplicateKeyUpdate(entityList);
LOGGER.info("success to save or update inlong group ext for groupId={}", groupId);
}
use of org.apache.inlong.manager.dao.entity.InlongGroupExtEntity 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;
}
Aggregations