Search in sources :

Example 11 with InlongGroupExtInfo

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

the class InlongGroupTransfer method createTubeExtInfo.

public static List<InlongGroupExtInfo> createTubeExtInfo(TubeBaseConf tubeBaseConf) {
    List<InlongGroupExtInfo> extInfos = new ArrayList<>();
    if (StringUtils.isNotEmpty(tubeBaseConf.getTubeMasterUrl())) {
        InlongGroupExtInfo tubeManagerUrl = new InlongGroupExtInfo();
        tubeManagerUrl.setKeyName(InlongGroupSettings.TUBE_MANAGER_URL);
        tubeManagerUrl.setKeyValue(tubeBaseConf.getTubeManagerUrl());
        extInfos.add(tubeManagerUrl);
    }
    if (StringUtils.isNotEmpty(tubeBaseConf.getTubeMasterUrl())) {
        InlongGroupExtInfo tubeMasterUrl = new InlongGroupExtInfo();
        tubeMasterUrl.setKeyName(InlongGroupSettings.TUBE_MASTER_URL);
        tubeMasterUrl.setKeyValue(tubeBaseConf.getTubeMasterUrl());
        extInfos.add(tubeMasterUrl);
    }
    if (tubeBaseConf.getTubeClusterId() > 0) {
        InlongGroupExtInfo tubeClusterId = new InlongGroupExtInfo();
        tubeClusterId.setKeyName(InlongGroupSettings.TUBE_CLUSTER_ID);
        tubeClusterId.setKeyValue(String.valueOf(tubeBaseConf.getTubeClusterId()));
        extInfos.add(tubeClusterId);
    }
    return extInfos;
}
Also used : ArrayList(java.util.ArrayList) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)

Example 12 with InlongGroupExtInfo

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

the class InlongGroupTransfer method parseTubeConf.

private static TubeBaseConf parseTubeConf(InlongGroupResponse groupResponse) {
    TubeBaseConf tubeBaseConf = new TubeBaseConf();
    tubeBaseConf.setGroupName(groupResponse.getMqResourceObj());
    List<InlongGroupExtInfo> groupExtInfos = groupResponse.getExtList();
    for (InlongGroupExtInfo extInfo : groupExtInfos) {
        if (extInfo.getKeyName().equals(InlongGroupSettings.TUBE_CLUSTER_ID)) {
            tubeBaseConf.setTubeClusterId(Integer.parseInt(extInfo.getKeyValue()));
        }
        if (extInfo.getKeyName().equals(InlongGroupSettings.TUBE_MANAGER_URL)) {
            tubeBaseConf.setTubeManagerUrl(extInfo.getKeyValue());
        }
        if (extInfo.getKeyName().equals(InlongGroupSettings.TUBE_MASTER_URL)) {
            tubeBaseConf.setTubeMasterUrl(extInfo.getKeyValue());
        }
    }
    return tubeBaseConf;
}
Also used : TubeBaseConf(org.apache.inlong.manager.client.api.TubeBaseConf) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)

Example 13 with InlongGroupExtInfo

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

the class InlongGroupTransfer method parseUdf.

private static UserDefinedSortConf parseUdf(List<InlongGroupExtInfo> groupExtInfos) {
    UserDefinedSortConf sortConf = new UserDefinedSortConf();
    for (InlongGroupExtInfo extInfo : groupExtInfos) {
        if (extInfo.getKeyName().equals(InlongGroupSettings.SORT_NAME)) {
            sortConf.setSortName(extInfo.getKeyValue());
        }
        if (extInfo.getKeyName().equals(InlongGroupSettings.SORT_PROPERTIES)) {
            Map<String, String> properties = GsonUtil.fromJson(extInfo.getKeyValue(), new TypeToken<Map<String, String>>() {
            }.getType());
            sortConf.setProperties(properties);
        }
    }
    return sortConf;
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) UserDefinedSortConf(org.apache.inlong.manager.client.api.UserDefinedSortConf) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)

Example 14 with InlongGroupExtInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo 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

InlongGroupExtInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)14 ArrayList (java.util.ArrayList)5 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)4 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)3 TypeToken (com.google.gson.reflect.TypeToken)2 List (java.util.List)2 FlinkSortBaseConf (org.apache.inlong.manager.client.api.FlinkSortBaseConf)2 PulsarBaseConf (org.apache.inlong.manager.client.api.PulsarBaseConf)2 SortType (org.apache.inlong.manager.client.api.SortBaseConf.SortType)2 TubeBaseConf (org.apache.inlong.manager.client.api.TubeBaseConf)2 UserDefinedSortConf (org.apache.inlong.manager.client.api.UserDefinedSortConf)2 Authentication (org.apache.inlong.manager.client.api.auth.Authentication)2 AuthType (org.apache.inlong.manager.client.api.auth.Authentication.AuthType)2 SecretTokenAuthentication (org.apache.inlong.manager.client.api.auth.SecretTokenAuthentication)2 TokenAuthentication (org.apache.inlong.manager.client.api.auth.TokenAuthentication)2 InlongGroupExtEntity (org.apache.inlong.manager.dao.entity.InlongGroupExtEntity)2 Lists (com.google.common.collect.Lists)1 Field (java.lang.reflect.Field)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1