Search in sources :

Example 6 with EComponentType

use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.

the class FlinkResource method getComputeResourceType.

@Override
public ComputeResourceType getComputeResourceType(JobClient jobClient) {
    long tenantId = jobClient.getTenantId();
    EComponentType componentType = resourceComponents.computeIfAbsent(tenantId, e -> getResourceEComponentType(jobClient));
    Properties properties = jobClient.getConfProperties();
    ComputeType computeType = jobClient.getComputeType();
    String modeStr = properties.getProperty(FLINK_TASK_RUN_MODE_KEY);
    if (EComponentType.FLINK.getTypeCode().equals(componentType.getTypeCode())) {
        // flink on standalone
        return ComputeResourceType.FlinkOnStandalone;
    } else if (EComponentType.YARN.getTypeCode().equals(componentType.getTypeCode())) {
        if (StringUtils.isEmpty(modeStr)) {
            if (ComputeType.STREAM == computeType) {
                return ComputeResourceType.Yarn;
            } else {
                return ComputeResourceType.FlinkYarnSession;
            }
        }
        if (SESSION.equalsIgnoreCase(modeStr)) {
            return ComputeResourceType.FlinkYarnSession;
        } else if (PER_JOB.equalsIgnoreCase(modeStr)) {
            return ComputeResourceType.Yarn;
        } else if (STANDALONE.equals(modeStr)) {
            return ComputeResourceType.FlinkOnStandalone;
        }
    }
    throw new RdosDefineException("not support mode: " + modeStr);
}
Also used : RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Properties(java.util.Properties) ComputeType(com.dtstack.taier.pluginapi.enums.ComputeType) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Example 7 with EComponentType

use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.

the class UploadController method addOrUpdateComponent.

@PostMapping(value = "/component/addOrUpdateComponent")
public R<ComponentVO> addOrUpdateComponent(@RequestParam("resources1") List<MultipartFile> files1, @RequestParam("resources2") List<MultipartFile> files2, @RequestParam("clusterId") Long clusterId, @RequestParam(value = "componentConfig") String componentConfig, @RequestParam("versionName") @NotNull String versionName, @RequestParam("kerberosFileName") String kerberosFileName, @RequestParam("componentTemplate") String componentTemplate, @RequestParam("componentCode") Integer componentCode, @RequestParam("storeType") Integer storeType, @RequestParam("principals") String principals, @RequestParam("principal") String principal, @RequestParam(value = "isMetadata", defaultValue = "false") Boolean isMetadata, @RequestParam(value = "isDefault", defaultValue = "false") Boolean isDefault, @RequestParam(value = "deployType") Integer deployType) {
    List<Resource> resources = getResourcesFromFiles(files1);
    List<Resource> resourcesAdd = getResourcesFromFiles(files2);
    resources.addAll(resourcesAdd);
    return new APITemplate<ComponentVO>() {

        @Override
        protected void checkParams() throws IllegalArgumentException {
            if (null == componentCode) {
                throw new RdosDefineException("Component type cannot be empty");
            }
            if (null == clusterId) {
                throw new RdosDefineException("Cluster Id cannot be empty");
            }
            if (CollectionUtils.isNotEmpty(resources) && resources.size() >= 2 && StringUtils.isBlank(kerberosFileName)) {
                // 上传二份文件 需要kerberosFileName文件名字段
                throw new RdosDefineException("kerberosFileName不能为空");
            }
            // 校验引擎是否添加
            if (EComponentType.deployTypeComponents.contains(componentCode) && null == deployType) {
                throw new RdosDefineException(ErrorCode.EMPTY_PARAMETERS.getMsg() + ":deployType");
            }
        }

        @Override
        protected ComponentVO process() throws RdosDefineException {
            // 校验引擎是否添加
            EComponentType componentType = EComponentType.getByCode(componentCode);
            if (EComponentType.deployTypeComponents.contains(componentType) && null == deployType) {
                throw new RdosDefineException("deploy type cannot be empty");
            }
            return consoleComponentService.addOrUpdateComponent(clusterId, componentConfig, resources, versionName, kerberosFileName, componentTemplate, componentType, storeType, principals, principal, isMetadata, isDefault, deployType);
        }
    }.execute();
}
Also used : ComponentVO(com.dtstack.taier.scheduler.vo.ComponentVO) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Resource(com.dtstack.taier.dao.dto.Resource) EComponentType(com.dtstack.taier.common.enums.EComponentType) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 8 with EComponentType

use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.

the class StoragePart method getPluginName.

@Override
public String getPluginName() {
    List<Component> components = componentScheduleGroup.get(EComponentScheduleType.RESOURCE);
    if (CollectionUtils.isEmpty(components)) {
        throw new RdosDefineException(ErrorCode.RESOURCE_COMPONENT_NOT_CONFIG);
    }
    Component resourceComponent = components.get(0);
    String resourceVersion = resourceComponent.getVersionName();
    EComponentType resourceType = EComponentType.getByCode(resourceComponent.getComponentTypeCode());
    Optional<JSONObject> resourceModelConfig = context.getModelConfig(resourceType, resourceVersion);
    JSONObject storageModelConfig = resourceModelConfig.map(res -> res.getJSONObject(type.name())).orElseThrow(() -> new RdosDefineException(Strings.format(ErrorCode.RESOURCE_NOT_SUPPORT_COMPONENT_VERSION.getMsg(), resourceComponent.getComponentName(), type.name(), versionName)));
    return storageModelConfig.getString(type.name());
}
Also used : Strings(com.dtstack.taier.common.util.Strings) DataSource(com.dtstack.taier.develop.model.DataSource) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) StringUtils(org.apache.commons.lang3.StringUtils) EComponentType(com.dtstack.taier.common.enums.EComponentType) List(java.util.List) CollectionUtils(org.apache.commons.collections.CollectionUtils) Component(com.dtstack.taier.dao.domain.Component) Map(java.util.Map) Context(com.dtstack.taier.develop.model.system.Context) Optional(java.util.Optional) JSONObject(com.alibaba.fastjson.JSONObject) EComponentScheduleType(com.dtstack.taier.common.enums.EComponentScheduleType) ErrorCode(com.dtstack.taier.common.exception.ErrorCode) JSONObject(com.alibaba.fastjson.JSONObject) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Component(com.dtstack.taier.dao.domain.Component) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Example 9 with EComponentType

use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.

the class DependComputePart method getExtraVersionParameters.

public Long getExtraVersionParameters() {
    Component resourceComponent = componentScheduleGroup.get(EComponentScheduleType.RESOURCE).get(0);
    String resourceVersion = resourceComponent.getVersionName();
    EComponentType resourceType = EComponentType.getByCode(resourceComponent.getComponentTypeCode());
    Optional<JSONObject> resourceModelExtraConfig = context.getModelExtraVersionParameters(resourceType, resourceVersion);
    String extraTemplateId = null;
    if (resourceModelExtraConfig.isPresent()) {
        extraTemplateId = getValueInConfigWithResourceStore(resourceModelExtraConfig.get(), resourceComponent, null);
        if (StringUtils.isNotBlank(extraTemplateId)) {
            return Long.parseLong(extraTemplateId);
        }
    }
    // 依赖resource 但是不依赖resource的类型拼接额外参数信息 如hive2
    extraTemplateId = context.getModelExtraVersionParameters(type, versionName).map((extraConfig) -> extraConfig.getString(versionName)).orElse(null);
    if (StringUtils.isNotBlank(extraTemplateId)) {
        return Long.parseLong(extraTemplateId);
    }
    return null;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Component(com.dtstack.taier.dao.domain.Component) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Example 10 with EComponentType

use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.

the class DependComputePart method getPluginName.

@Override
public String getPluginName() {
    validDeployType(deployType);
    if (null == storageType) {
        throw new RdosDefineException(ErrorCode.STORE_COMPONENT_NOT_CONFIG);
    }
    List<Component> components = componentScheduleGroup.get(EComponentScheduleType.RESOURCE);
    if (CollectionUtils.isEmpty(components)) {
        throw new RdosDefineException(ErrorCode.RESOURCE_COMPONENT_NOT_CONFIG);
    }
    Component resourceComponent = components.get(0);
    String resourceVersion = resourceComponent.getVersionName();
    EComponentType resourceType = EComponentType.getByCode(resourceComponent.getComponentTypeCode());
    Optional<JSONObject> resourceModelConfig = context.getModelConfig(resourceType, resourceVersion);
    if (!resourceModelConfig.isPresent()) {
        throw new RdosDefineException(Strings.format(ErrorCode.RESOURCE_NOT_SUPPORT_COMPONENT_VERSION.getMsg(), resourceType, type, versionName));
    }
    // 唯一的pluginName
    return getValueInConfigWithResourceStore(resourceModelConfig.get(), resourceComponent, this::getPluginNameInModelOrByConfigVersion);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Component(com.dtstack.taier.dao.domain.Component) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Aggregations

EComponentType (com.dtstack.taier.common.enums.EComponentType)23 JSONObject (com.alibaba.fastjson.JSONObject)10 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)10 Component (com.dtstack.taier.dao.domain.Component)9 ComponentVO (com.dtstack.taier.scheduler.vo.ComponentVO)4 EScheduleJobType (com.dtstack.taier.common.enums.EScheduleJobType)3 Part (com.dtstack.taier.develop.model.Part)3 PartCluster (com.dtstack.taier.develop.model.PartCluster)3 EComponentScheduleType (com.dtstack.taier.common.enums.EComponentScheduleType)2 Cluster (com.dtstack.taier.dao.domain.Cluster)2 Dict (com.dtstack.taier.dao.domain.Dict)2 KerberosConfig (com.dtstack.taier.dao.domain.KerberosConfig)2 IComponentService (com.dtstack.taier.develop.service.develop.IComponentService)2 ClientTemplate (com.dtstack.taier.scheduler.impl.pojo.ClientTemplate)2 IComponentVO (com.dtstack.taier.scheduler.vo.IComponentVO)2 Map (java.util.Map)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ErrorCode (com.dtstack.taier.common.exception.ErrorCode)1 Strings (com.dtstack.taier.common.util.Strings)1 com.dtstack.taier.dao.domain (com.dtstack.taier.dao.domain)1