Search in sources :

Example 1 with SortType

use of org.apache.inlong.manager.client.api.SortBaseConf.SortType 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 SortType

use of org.apache.inlong.manager.client.api.SortBaseConf.SortType in project incubator-inlong by apache.

the class InlongGroupTransfer method parseSortBaseConf.

public static SortBaseConf parseSortBaseConf(InlongGroupResponse groupResponse) {
    List<InlongGroupExtInfo> groupExtInfos = groupResponse.getExtList();
    if (CollectionUtils.isEmpty(groupExtInfos)) {
        return null;
    }
    String type = null;
    for (InlongGroupExtInfo extInfo : groupExtInfos) {
        if (extInfo.getKeyName().equals(InlongGroupSettings.SORT_TYPE)) {
            type = extInfo.getKeyValue();
            break;
        }
    }
    if (type == null) {
        return null;
    }
    SortType sortType = SortType.forType(type);
    switch(sortType) {
        case FLINK:
            return parseFlinkSortConf(groupExtInfos);
        case USER_DEFINED:
            return parseUdf(groupExtInfos);
        default:
            throw new IllegalArgumentException(String.format("Unsupport sort type=%s for Inlong", sortType));
    }
}
Also used : SortType(org.apache.inlong.manager.client.api.SortBaseConf.SortType) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)

Aggregations

SortType (org.apache.inlong.manager.client.api.SortBaseConf.SortType)2 InlongGroupExtInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 FlinkSortBaseConf (org.apache.inlong.manager.client.api.FlinkSortBaseConf)1 MqBaseConf (org.apache.inlong.manager.client.api.MqBaseConf)1 PulsarBaseConf (org.apache.inlong.manager.client.api.PulsarBaseConf)1 SortBaseConf (org.apache.inlong.manager.client.api.SortBaseConf)1 TubeBaseConf (org.apache.inlong.manager.client.api.TubeBaseConf)1 UserDefinedSortConf (org.apache.inlong.manager.client.api.UserDefinedSortConf)1 MqType (org.apache.inlong.manager.common.enums.MqType)1 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)1 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)1