use of com.dtstack.taier.develop.model.PartCluster in project Taier by DTStack.
the class ConsoleComponentService method refreshVersion.
/**
* yarn组件版本变更之后 hdfs组件保存一致
* 计算组件 如flink的typename也同步变更
*
* @param componentType
* @param clusterId
* @param addComponent
* @param dbHadoopVersion 形如 3.1.1
*/
public void refreshVersion(EComponentType componentType, Long clusterId, Component addComponent, String dbHadoopVersion) {
if (!EComponentType.YARN.equals(componentType)) {
return;
}
if (addComponent.getVersionValue().equals(dbHadoopVersion)) {
return;
}
List<Component> components = componentMapper.listByClusterId(clusterId, null, false);
PartCluster partCluster = clusterFactory.newImmediatelyLoadCluster(clusterId);
for (Component component : components) {
EComponentType eComponentType = EComponentType.getByCode(component.getComponentTypeCode());
if (!EComponentType.typeComponentVersion.contains(eComponentType)) {
continue;
}
EComponentType storeComponentType = EComponentType.getByCode(component.getStoreType());
Part part = partCluster.create(eComponentType, component.getVersionName(), storeComponentType, component.getDeployType());
String pluginName = part.getPluginName();
ComponentConfig typeNameComponentConfig = componentConfigService.getComponentConfigByKey(component.getId(), TYPE_NAME_KEY);
if (null != typeNameComponentConfig && StringUtils.isNotBlank(pluginName)) {
LOGGER.info("refresh clusterId {} component {} typeName {} to {}", component.getClusterId(), component.getComponentName(), typeNameComponentConfig.getValue(), pluginName);
typeNameComponentConfig.setValue(pluginName);
componentConfigService.updateValueComponentConfig(typeNameComponentConfig);
}
}
}
use of com.dtstack.taier.develop.model.PartCluster in project Taier by DTStack.
the class ConsoleComponentService method loadTemplate.
/**
* 加载各个组件的默认值
* 解析yml文件转换为前端渲染格式
*
* @param componentType 组件类型
* @param clusterId 集群ID
* @param versionName 组件版本名 如Hadoop 2.x
* @param storeType 存储组件type 如 HDFS
* @return
*/
public List<ClientTemplate> loadTemplate(Long clusterId, EComponentType componentType, String versionName, EComponentType storeType, Integer deployType) {
PartCluster cluster = clusterFactory.newImmediatelyLoadCluster(clusterId);
Part part = cluster.create(componentType, versionName, storeType, deployType);
List<ComponentConfig> componentConfigs = part.loadTemplate();
return ComponentConfigUtils.buildDBDataToClientTemplate(componentConfigs);
}
use of com.dtstack.taier.develop.model.PartCluster 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;
}
use of com.dtstack.taier.develop.model.PartCluster in project Taier by DTStack.
the class ConsoleComponentService method convertComponentTypeToClient.
/**
* 根据组件类型转换对应的插件名称
* 如果只配yarn 需要调用插件时候 hdfs给默认值
*
* @param clusterName
* @param componentType
* @param versionName
* @return
*/
public String convertComponentTypeToClient(String clusterName, Integer componentType, String versionName, Integer storeType, Integer deployType) {
Cluster cluster = clusterMapper.getByClusterName(clusterName);
EComponentType type = EComponentType.getByCode(componentType);
EComponentType storeComponent = null == storeType ? null : EComponentType.getByCode(storeType);
PartCluster partCluster = clusterFactory.newImmediatelyLoadCluster(cluster.getId());
Part part = partCluster.create(type, versionName, storeComponent, deployType);
return part.getPluginName();
}
Aggregations