Search in sources :

Example 1 with InlongGroupExtInfo

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

the class InlongGroupTransfer method parseFlinkSortConf.

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

Example 2 with InlongGroupExtInfo

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

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

the class InlongGroupTransfer method createFlinkExtInfo.

public static List<InlongGroupExtInfo> createFlinkExtInfo(FlinkSortBaseConf flinkSortBaseConf) {
    List<InlongGroupExtInfo> extInfos = new ArrayList<>();
    InlongGroupExtInfo sortType = new InlongGroupExtInfo();
    sortType.setKeyName(InlongGroupSettings.SORT_TYPE);
    sortType.setKeyValue(SortType.FLINK.getType());
    extInfos.add(sortType);
    if (flinkSortBaseConf.getAuthentication() != null) {
        Authentication authentication = flinkSortBaseConf.getAuthentication();
        AuthType authType = authentication.getAuthType();
        AssertUtil.isTrue(authType == AuthType.SECRET_AND_TOKEN, String.format("Unsupported authentication:%s for flink", authType.name()));
        final SecretTokenAuthentication secretTokenAuthentication = (SecretTokenAuthentication) authentication;
        InlongGroupExtInfo authTypeExt = new InlongGroupExtInfo();
        authTypeExt.setKeyName(InlongGroupSettings.SORT_AUTHENTICATION_TYPE);
        authTypeExt.setKeyValue(authType.toString());
        extInfos.add(authTypeExt);
        InlongGroupExtInfo authValue = new InlongGroupExtInfo();
        authValue.setKeyName(InlongGroupSettings.SORT_AUTHENTICATION);
        authValue.setKeyValue(secretTokenAuthentication.toString());
        extInfos.add(authValue);
    }
    if (StringUtils.isNotEmpty(flinkSortBaseConf.getServiceUrl())) {
        InlongGroupExtInfo flinkUrl = new InlongGroupExtInfo();
        flinkUrl.setKeyName(InlongGroupSettings.SORT_URL);
        flinkUrl.setKeyValue(flinkSortBaseConf.getServiceUrl());
        extInfos.add(flinkUrl);
    }
    if (MapUtils.isNotEmpty(flinkSortBaseConf.getProperties())) {
        InlongGroupExtInfo flinkProperties = new InlongGroupExtInfo();
        flinkProperties.setKeyName(InlongGroupSettings.SORT_PROPERTIES);
        flinkProperties.setKeyValue(JsonUtils.toJson(flinkSortBaseConf.getProperties()));
        extInfos.add(flinkProperties);
    }
    return extInfos;
}
Also used : TokenAuthentication(org.apache.inlong.manager.client.api.auth.TokenAuthentication) SecretTokenAuthentication(org.apache.inlong.manager.client.api.auth.SecretTokenAuthentication) Authentication(org.apache.inlong.manager.client.api.auth.Authentication) ArrayList(java.util.ArrayList) SecretTokenAuthentication(org.apache.inlong.manager.client.api.auth.SecretTokenAuthentication) AuthType(org.apache.inlong.manager.client.api.auth.Authentication.AuthType) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)

Example 4 with InlongGroupExtInfo

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

the class InlongGroupTransfer method createUserDefinedSortExtInfo.

public static List<InlongGroupExtInfo> createUserDefinedSortExtInfo(UserDefinedSortConf userDefinedSortConf) {
    List<InlongGroupExtInfo> extInfos = new ArrayList<>();
    InlongGroupExtInfo sortType = new InlongGroupExtInfo();
    sortType.setKeyName(InlongGroupSettings.SORT_TYPE);
    sortType.setKeyValue(SortType.USER_DEFINED.getType());
    extInfos.add(sortType);
    InlongGroupExtInfo sortName = new InlongGroupExtInfo();
    sortName.setKeyName(InlongGroupSettings.SORT_NAME);
    sortName.setKeyValue(userDefinedSortConf.getSortName());
    extInfos.add(sortName);
    if (MapUtils.isNotEmpty(userDefinedSortConf.getProperties())) {
        InlongGroupExtInfo flinkProperties = new InlongGroupExtInfo();
        flinkProperties.setKeyName(InlongGroupSettings.SORT_PROPERTIES);
        flinkProperties.setKeyValue(JsonUtils.toJson(userDefinedSortConf.getProperties()));
        extInfos.add(flinkProperties);
    }
    return extInfos;
}
Also used : ArrayList(java.util.ArrayList) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)

Example 5 with InlongGroupExtInfo

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

the class InlongGroupTransfer method createPulsarExtInfo.

public static List<InlongGroupExtInfo> createPulsarExtInfo(PulsarBaseConf pulsarBaseConf) {
    List<InlongGroupExtInfo> extInfos = new ArrayList<>();
    if (pulsarBaseConf.getAuthentication() != null) {
        Authentication authentication = pulsarBaseConf.getAuthentication();
        AuthType authType = authentication.getAuthType();
        AssertUtil.isTrue(authType == AuthType.TOKEN, String.format("Unsupported authentication:%s for pulsar", authType.name()));
        TokenAuthentication tokenAuthentication = (TokenAuthentication) authentication;
        InlongGroupExtInfo authTypeExt = new InlongGroupExtInfo();
        authTypeExt.setKeyName(InlongGroupSettings.PULSAR_AUTHENTICATION_TYPE);
        authTypeExt.setKeyValue(tokenAuthentication.getAuthType().toString());
        extInfos.add(authTypeExt);
        InlongGroupExtInfo authValue = new InlongGroupExtInfo();
        authValue.setKeyName(InlongGroupSettings.PULSAR_AUTHENTICATION);
        authValue.setKeyValue(tokenAuthentication.getToken());
        extInfos.add(authValue);
    }
    if (StringUtils.isNotEmpty(pulsarBaseConf.getPulsarAdminUrl())) {
        InlongGroupExtInfo pulsarAdminUrl = new InlongGroupExtInfo();
        pulsarAdminUrl.setKeyName(InlongGroupSettings.PULSAR_ADMIN_URL);
        pulsarAdminUrl.setKeyValue(pulsarBaseConf.getPulsarAdminUrl());
        extInfos.add(pulsarAdminUrl);
    }
    if (StringUtils.isNotEmpty(pulsarBaseConf.getPulsarServiceUrl())) {
        InlongGroupExtInfo pulsarServiceUrl = new InlongGroupExtInfo();
        pulsarServiceUrl.setKeyName(InlongGroupSettings.PULSAR_SERVICE_URL);
        pulsarServiceUrl.setKeyValue(pulsarBaseConf.getPulsarServiceUrl());
        extInfos.add(pulsarServiceUrl);
    }
    return extInfos;
}
Also used : TokenAuthentication(org.apache.inlong.manager.client.api.auth.TokenAuthentication) SecretTokenAuthentication(org.apache.inlong.manager.client.api.auth.SecretTokenAuthentication) Authentication(org.apache.inlong.manager.client.api.auth.Authentication) ArrayList(java.util.ArrayList) TokenAuthentication(org.apache.inlong.manager.client.api.auth.TokenAuthentication) SecretTokenAuthentication(org.apache.inlong.manager.client.api.auth.SecretTokenAuthentication) AuthType(org.apache.inlong.manager.client.api.auth.Authentication.AuthType) 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