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);
}
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();
}
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());
}
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;
}
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);
}
Aggregations