use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.
the class ComponentController method loadTemplate.
@PostMapping(value = "/loadTemplate")
@ApiOperation(value = "加载各个组件的前端渲染模版")
@ApiImplicitParams({ @ApiImplicitParam(name = "clusterId", value = "集群id", required = true, dataType = "long", example = "-1L"), @ApiImplicitParam(name = "versionName", value = "组件版本名称", required = true, dataType = "string"), @ApiImplicitParam(name = "deployType", value = "deploy类型", required = true, dataType = "int"), @ApiImplicitParam(name = "componentType", value = "组件code", required = true, dataType = "int"), @ApiImplicitParam(name = "storeType", value = "存储组件code", required = true, dataType = "int") })
public R<List<ClientTemplate>> loadTemplate(@RequestParam("componentType") Integer componentType, @RequestParam("clusterId") Long clusterId, @RequestParam("versionName") String versionName, @RequestParam("storeType") Integer storeType, @RequestParam("deployType") Integer deployType) {
EComponentType type = EComponentType.getByCode(componentType);
EComponentType storeComponentType = storeType == null ? null : EComponentType.getByCode(storeType);
return R.ok(consoleComponentService.loadTemplate(clusterId, type, versionName, storeComponentType, deployType));
}
use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.
the class ClusterService method pluginInfoJSON.
/**
* 内部使用
*/
public JSONObject pluginInfoJSON(Long tenantId, Integer taskType, Integer deployMode, String componentVersion) {
EScheduleJobType engineJobType = EScheduleJobType.getByTaskType(taskType);
EComponentType componentType = engineJobType.getComponentType();
if (componentType == null) {
return null;
}
Long clusterId = clusterTenantMapper.getClusterIdByTenantId(tenantId);
if (null == clusterId) {
clusterId = DEFAULT_CLUSTER_ID;
}
JSONObject clusterConfigJson = buildClusterConfig(clusterId, componentVersion, componentType);
JSONObject pluginJson = convertPluginInfo(clusterConfigJson, componentType, clusterId, deployMode);
if (pluginJson == null) {
throw new RdosDefineException(format("The cluster is not configured [%s] engine", componentType));
}
Queue queue = getQueue(tenantId, clusterId);
pluginJson.put(QUEUE, queue == null ? "" : queue.getQueueName());
setComponentSftpDir(clusterId, clusterConfigJson, pluginJson, componentType);
return pluginJson;
}
use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.
the class ClusterService method buildClusterConfig.
public JSONObject buildClusterConfig(Long clusterId, String componentVersion, EComponentType computeComponentType) {
Cluster cluster = clusterMapper.getOne(clusterId);
if (null == cluster) {
throw new RdosDefineException(ErrorCode.CANT_NOT_FIND_CLUSTER);
}
JSONObject config = new JSONObject();
List<Component> components = componentService.listAllComponents(clusterId);
for (Component component : components) {
EComponentType componentType = EComponentType.getByCode(component.getComponentTypeCode());
if (!EComponentScheduleType.COMPUTE.equals(EComponentType.getScheduleTypeByComponent(component.getComponentTypeCode()))) {
JSONObject componentConfig = componentService.getComponentByClusterId(clusterId, componentType.getTypeCode(), false, JSONObject.class, null);
config.put(componentType.getConfName(), componentConfig);
} else if (componentType.equals(computeComponentType)) {
JSONObject componentConfig = componentService.getComponentByClusterId(clusterId, componentType.getTypeCode(), false, JSONObject.class, componentVersion);
config.put(componentType.getConfName(), componentConfig);
}
// ignore other compute component
}
config.put(CLUSTER, cluster.getClusterName());
return config;
}
use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.
the class ScheduleDictService method loadExtraComponentConfig.
/**
* 根据版本和组件 加载出额外的配置参数(需以自定义参数的方式)
* yarn和hdfs的xml配置参数暂时不添加
*
* @param version
* @param componentCode
* @return
*/
public List<ComponentConfig> loadExtraComponentConfig(String version, Integer componentCode) {
if (StringUtils.isBlank(version) || defaultVersion.test(version) || !environmentContext.isCanAddExtraConfig()) {
return new ArrayList<>(0);
}
EComponentType componentType = EComponentType.getByCode(componentCode);
Dict extraConfig = dictMapper.getByNameValue(DictType.COMPONENT_CONFIG.type, version.trim(), null, componentType.name().toUpperCase());
if (null == extraConfig) {
return new ArrayList<>(0);
}
return componentConfigMapper.listByComponentId(Long.parseLong(extraConfig.getDictValue()), false);
}
use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.
the class ConsoleComponentService method addOrUpdateComponent.
@Transactional(rollbackFor = Exception.class)
public ComponentVO addOrUpdateComponent(Long clusterId, String componentConfig, List<Resource> resources, String versionName, String kerberosFileName, String componentTemplate, EComponentType componentType, Integer storeType, String principals, String principal, boolean isMetadata, Boolean isDefault, Integer deployType) {
if (StringUtils.isBlank(componentConfig)) {
componentConfig = new JSONObject().toJSONString();
}
EComponentType storeComponent = null == storeType ? null : EComponentType.getByCode(storeType);
PartCluster partCluster = clusterFactory.newImmediatelyLoadCluster(clusterId);
Part part = partCluster.create(componentType, versionName, storeComponent, deployType);
String versionValue = part.getVersionValue();
String pluginName = part.getPluginName();
Component componentDTO = new Component();
componentDTO.setComponentTypeCode(componentType.getTypeCode());
Cluster cluster = clusterMapper.getOne(clusterId);
if (null == cluster) {
throw new RdosDefineException(ErrorCode.CANT_NOT_FIND_CLUSTER);
}
String clusterName = cluster.getClusterName();
Component addComponent = new Component();
BeanUtils.copyProperties(componentDTO, addComponent);
// 判断是否是更新组件, 需要校验组件版本
com.dtstack.taier.dao.domain.Component dbComponent = componentMapper.getByClusterIdAndComponentType(clusterId, componentType.getTypeCode(), ComponentVersionUtil.isMultiVersionComponent(componentType.getTypeCode()) ? versionValue : null, deployType);
String dbHadoopVersion = "";
boolean isUpdate = false;
boolean isOpenKerberos = isOpenKerberos(kerberosFileName, dbComponent);
if (null != dbComponent) {
// 更新
dbHadoopVersion = dbComponent.getVersionValue();
addComponent = dbComponent;
isUpdate = true;
}
EComponentType storesComponent = this.checkStoresComponent(clusterId, storeType);
addComponent.setStoreType(storesComponent.getTypeCode());
addComponent.setVersionValue(versionValue);
addComponent.setComponentName(componentType.getName());
addComponent.setComponentTypeCode(componentType.getTypeCode());
addComponent.setDeployType(deployType);
if (EComponentType.HDFS == componentType) {
// hdfs的组件和yarn组件的版本保持强一致
com.dtstack.taier.dao.domain.Component yarnComponent = componentMapper.getByClusterIdAndComponentType(clusterId, EComponentType.YARN.getTypeCode(), null, null);
if (null != yarnComponent) {
versionName = yarnComponent.getVersionName();
}
}
addComponent.setVersionName(versionName);
if (StringUtils.isNotBlank(kerberosFileName)) {
addComponent.setKerberosFileName(kerberosFileName);
}
changeDefault(BooleanUtils.isTrue(isDefault), clusterId, componentType, addComponent);
// md5zip 会作为 config 表的一个属性
String md5Key = updateResource(clusterId, componentConfig, resources, kerberosFileName, componentType.getTypeCode(), principals, principal, addComponent, dbComponent);
addComponent.setClusterId(clusterId);
if (isUpdate) {
componentMapper.updateById(addComponent);
refreshVersion(componentType, clusterId, addComponent, dbHadoopVersion);
clusterMapper.updateGmtModified(clusterId);
} else {
componentMapper.insert(addComponent);
}
changeMetadata(componentType.getTypeCode(), isMetadata, clusterId, addComponent.getIsMetadata());
List<ClientTemplate> clientTemplates = this.buildTemplate(componentType, componentConfig, isOpenKerberos, md5Key, componentTemplate, pluginName);
componentConfigService.addOrUpdateComponentConfig(clientTemplates, addComponent.getId(), addComponent.getClusterId(), componentType.getTypeCode());
// 此时不需要查询默认版本
List<IComponentVO> componentVos = componentConfigService.getComponentVoByComponent(Lists.newArrayList(addComponent), true, clusterId, true, false);
this.updateCache();
if (CollectionUtils.isNotEmpty(componentVos)) {
ComponentVO componentVO = (ComponentVO) componentVos.get(0);
componentVO.setClusterName(clusterName);
componentVO.setPrincipal(principal);
componentVO.setPrincipals(principals);
componentVO.setDeployType(deployType);
componentVO.setIsMetadata(BooleanUtils.toInteger(isMetadata));
return componentVO;
}
return null;
}
Aggregations