Search in sources :

Example 1 with InlongGroupPulsarInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo in project incubator-inlong by apache.

the class InlongGroupTransfer method createGroupInfo.

public static InlongGroupInfo createGroupInfo(InlongGroupConf groupConf) {
    InlongGroupInfo groupInfo = new InlongGroupInfo();
    AssertUtil.hasLength(groupConf.getGroupName(), "GroupName should not be empty");
    groupInfo.setName(groupConf.getGroupName());
    groupInfo.setCnName(groupConf.getCnName());
    groupInfo.setDescription(groupConf.getDescription());
    groupInfo.setZookeeperEnabled(groupConf.isZookeeperEnabled() ? 1 : 0);
    groupInfo.setDailyRecords(groupConf.getDailyRecords().intValue());
    groupInfo.setPeakRecords(groupConf.getPeakRecords().intValue());
    groupInfo.setMaxLength(groupConf.getMaxLength());
    groupInfo.setProxyClusterId(groupConf.getProxyClusterId());
    MqBaseConf mqConf = groupConf.getMqBaseConf();
    MqType mqType = MqType.NONE;
    if (null != mqConf) {
        mqType = mqConf.getType();
        groupInfo.setMiddlewareType(mqType.name());
    }
    groupInfo.setInCharges(groupConf.getOperator());
    groupInfo.setExtList(Lists.newArrayList());
    groupInfo.setCreator(groupConf.getOperator());
    if (mqType == MqType.PULSAR || mqType == MqType.TDMQ_PULSAR) {
        PulsarBaseConf pulsarBaseConf = (PulsarBaseConf) mqConf;
        groupInfo.setMqResourceObj(pulsarBaseConf.getNamespace());
        InlongGroupPulsarInfo pulsarInfo = createPulsarInfo(pulsarBaseConf);
        groupInfo.setMqExtInfo(pulsarInfo);
        List<InlongGroupExtInfo> extInfos = createPulsarExtInfo(pulsarBaseConf);
        groupInfo.getExtList().addAll(extInfos);
        groupInfo.setTopicPartitionNum(pulsarBaseConf.getTopicPartitionNum());
    } else if (mqType == MqType.TUBE) {
        TubeBaseConf tubeBaseConf = (TubeBaseConf) mqConf;
        List<InlongGroupExtInfo> extInfos = createTubeExtInfo(tubeBaseConf);
        groupInfo.setMqResourceObj(tubeBaseConf.getGroupName());
        groupInfo.getExtList().addAll(extInfos);
        groupInfo.setTopicPartitionNum(tubeBaseConf.getTopicPartitionNum());
    }
    SortBaseConf sortBaseConf = groupConf.getSortBaseConf();
    SortType sortType = sortBaseConf.getType();
    if (sortType == SortType.FLINK) {
        FlinkSortBaseConf flinkSortBaseConf = (FlinkSortBaseConf) sortBaseConf;
        List<InlongGroupExtInfo> sortExtInfos = createFlinkExtInfo(flinkSortBaseConf);
        groupInfo.getExtList().addAll(sortExtInfos);
    } else if (sortType == SortType.USER_DEFINED) {
        UserDefinedSortConf udf = (UserDefinedSortConf) sortBaseConf;
        List<InlongGroupExtInfo> sortExtInfos = createUserDefinedSortExtInfo(udf);
        groupInfo.getExtList().addAll(sortExtInfos);
    } else {
    // todo local
    }
    return groupInfo;
}
Also used : UserDefinedSortConf(org.apache.inlong.manager.client.api.UserDefinedSortConf) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) FlinkSortBaseConf(org.apache.inlong.manager.client.api.FlinkSortBaseConf) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo) InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) SortType(org.apache.inlong.manager.client.api.SortBaseConf.SortType) PulsarBaseConf(org.apache.inlong.manager.client.api.PulsarBaseConf) TubeBaseConf(org.apache.inlong.manager.client.api.TubeBaseConf) ArrayList(java.util.ArrayList) List(java.util.List) MqBaseConf(org.apache.inlong.manager.client.api.MqBaseConf) MqType(org.apache.inlong.manager.common.enums.MqType) SortBaseConf(org.apache.inlong.manager.client.api.SortBaseConf) FlinkSortBaseConf(org.apache.inlong.manager.client.api.FlinkSortBaseConf)

Example 2 with InlongGroupPulsarInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo in project incubator-inlong by apache.

the class InlongParser method parseGroupInfo.

public static InlongGroupResponse parseGroupInfo(Response response) {
    Object data = response.getData();
    JsonObject groupJson = GsonUtil.fromJson(GsonUtil.toJson(data), JsonObject.class);
    InlongGroupResponse inlongGroupResponse = GsonUtil.fromJson(GsonUtil.toJson(data), InlongGroupResponse.class);
    JsonObject mqExtInfo = groupJson.getAsJsonObject(MQ_EXT_INFO);
    if (mqExtInfo != null && mqExtInfo.get(MIDDLEWARE_TYPE) != null) {
        String middlewareType = mqExtInfo.get(MIDDLEWARE_TYPE).getAsString();
        if (Constant.MIDDLEWARE_PULSAR.equals(middlewareType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(middlewareType)) {
            InlongGroupPulsarInfo pulsarInfo = GsonUtil.fromJson(mqExtInfo.toString(), InlongGroupPulsarInfo.class);
            inlongGroupResponse.setMqExtInfo(pulsarInfo);
        }
    }
    return inlongGroupResponse;
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)

Example 3 with InlongGroupPulsarInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo in project incubator-inlong by apache.

the class InlongGroupTransfer method parsePulsarConf.

private static PulsarBaseConf parsePulsarConf(InlongGroupResponse groupResponse) {
    PulsarBaseConf pulsarBaseConf = new PulsarBaseConf();
    pulsarBaseConf.setNamespace(groupResponse.getMqResourceObj());
    InlongGroupPulsarInfo inlongGroupPulsarInfo = (InlongGroupPulsarInfo) groupResponse.getMqExtInfo();
    pulsarBaseConf.setAckQuorum(inlongGroupPulsarInfo.getAckQuorum());
    pulsarBaseConf.setWriteQuorum(inlongGroupPulsarInfo.getWriteQuorum());
    pulsarBaseConf.setEnsemble(inlongGroupPulsarInfo.getEnsemble());
    pulsarBaseConf.setTtl(inlongGroupPulsarInfo.getTtl());
    pulsarBaseConf.setTenant(inlongGroupPulsarInfo.getTenant());
    pulsarBaseConf.setRetentionTime(inlongGroupPulsarInfo.getRetentionTime());
    pulsarBaseConf.setRetentionSize(inlongGroupPulsarInfo.getRetentionSize());
    pulsarBaseConf.setRetentionSizeUnit(inlongGroupPulsarInfo.getRetentionSizeUnit());
    pulsarBaseConf.setRetentionTimeUnit(inlongGroupPulsarInfo.getRetentionTimeUnit());
    pulsarBaseConf.setEnableCreateResource(inlongGroupPulsarInfo.getEnableCreateResource() == 1 ? true : false);
    List<InlongGroupExtInfo> groupExtInfos = groupResponse.getExtList();
    for (InlongGroupExtInfo extInfo : groupExtInfos) {
        if (extInfo.getKeyName().equals(InlongGroupSettings.PULSAR_ADMIN_URL)) {
            pulsarBaseConf.setPulsarAdminUrl(extInfo.getKeyValue());
        }
        if (extInfo.getKeyName().equals(InlongGroupSettings.PULSAR_SERVICE_URL)) {
            pulsarBaseConf.setPulsarServiceUrl(extInfo.getKeyValue());
        }
    }
    return pulsarBaseConf;
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) PulsarBaseConf(org.apache.inlong.manager.client.api.PulsarBaseConf) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)

Example 4 with InlongGroupPulsarInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo in project incubator-inlong by apache.

the class PulsarEventSelector method accept.

@Override
public boolean accept(WorkflowContext context) {
    ProcessForm processForm = context.getProcessForm();
    if (!(processForm instanceof GroupResourceProcessForm)) {
        return false;
    }
    GroupResourceProcessForm form = (GroupResourceProcessForm) processForm;
    String mqType = form.getGroupInfo().getMiddlewareType();
    if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
        InlongGroupPulsarInfo pulsarInfo = (InlongGroupPulsarInfo) form.getGroupInfo().getMqExtInfo();
        return pulsarInfo.getEnableCreateResource() == 1;
    }
    log.warn("no need to create pulsar subscription group for groupId={}, as the middlewareType={}", form.getInlongGroupId(), mqType);
    return false;
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)

Example 5 with InlongGroupPulsarInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo in project incubator-inlong by apache.

the class SourceInfoUtils method createPulsarSourceInfo.

/**
 * Create source info for Pulsar
 */
private static SourceInfo createPulsarSourceInfo(PulsarClusterInfo pulsarCluster, ClusterBean clusterBean, InlongGroupInfo groupInfo, InlongStreamInfo streamInfo, DeserializationInfo deserializationInfo, List<FieldInfo> fieldInfos) {
    String topicName = streamInfo.getMqResourceObj();
    InlongGroupPulsarInfo pulsarInfo = (InlongGroupPulsarInfo) groupInfo.getMqExtInfo();
    String tenant = clusterBean.getDefaultTenant();
    if (StringUtils.isNotEmpty(pulsarInfo.getTenant())) {
        tenant = pulsarInfo.getTenant();
    }
    final String namespace = groupInfo.getMqResourceObj();
    // Full name of topic in Pulsar
    final String fullTopicName = "persistent://" + tenant + "/" + namespace + "/" + topicName;
    final String consumerGroup = clusterBean.getAppName() + "_" + topicName + "_consumer_group";
    FieldInfo[] fieldInfosArr = fieldInfos.toArray(new FieldInfo[0]);
    String type = pulsarCluster.getType();
    if (StringUtils.isNotEmpty(type) && Constant.MIDDLEWARE_TDMQ_PULSAR.equals(type)) {
        return new TDMQPulsarSourceInfo(pulsarCluster.getBrokerServiceUrl(), fullTopicName, consumerGroup, pulsarCluster.getToken(), deserializationInfo, fieldInfosArr);
    } else {
        return new PulsarSourceInfo(pulsarCluster.getAdminUrl(), pulsarCluster.getBrokerServiceUrl(), fullTopicName, consumerGroup, deserializationInfo, fieldInfosArr, pulsarCluster.getToken());
    }
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) TDMQPulsarSourceInfo(org.apache.inlong.sort.protocol.source.TDMQPulsarSourceInfo) PulsarSourceInfo(org.apache.inlong.sort.protocol.source.PulsarSourceInfo) TDMQPulsarSourceInfo(org.apache.inlong.sort.protocol.source.TDMQPulsarSourceInfo) FieldInfo(org.apache.inlong.sort.protocol.FieldInfo)

Aggregations

InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)13 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)4 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)3 InlongGroupExtInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)3 InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)3 InlongGroupPulsarEntity (org.apache.inlong.manager.dao.entity.InlongGroupPulsarEntity)3 JsonObject (com.google.gson.JsonObject)2 PulsarBaseConf (org.apache.inlong.manager.client.api.PulsarBaseConf)2 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)2 Transactional (org.springframework.transaction.annotation.Transactional)2 TypeToken (com.google.common.reflect.TypeToken)1 JsonArray (com.google.gson.JsonArray)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)1 FlinkSortBaseConf (org.apache.inlong.manager.client.api.FlinkSortBaseConf)1 MqBaseConf (org.apache.inlong.manager.client.api.MqBaseConf)1 SortBaseConf (org.apache.inlong.manager.client.api.SortBaseConf)1 SortType (org.apache.inlong.manager.client.api.SortBaseConf.SortType)1