use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.
the class ConsoleComponentService method checkStoresComponent.
private EComponentType checkStoresComponent(Long clusterId, Integer storeType) {
// 默认为hdfs
if (null == storeType) {
return EComponentType.HDFS;
}
EComponentType componentType = EComponentType.getByCode(MathUtil.getIntegerVal(storeType));
Component storeComponent = componentMapper.getByClusterIdAndComponentType(clusterId, componentType.getTypeCode(), null, null);
if (null == storeComponent) {
throw new RdosDefineException(ErrorCode.PRE_COMPONENT_NOT_EXISTS.getMsg() + ":" + componentType.getName());
}
return componentType;
}
use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.
the class ConsoleComponentService method downloadFile.
/**
* 下载文件
*
* @param componentId
* @param downloadType 0:kerberos配置文件 1:配置文件 2:模板文件
* @return
*/
public File downloadFile(Long componentId, Integer downloadType, Integer componentType, String versionName, Long clusterId, Integer deployType) {
String localDownLoadPath = "";
String uploadFileName = "";
if (null == componentId) {
EComponentType type = EComponentType.getByCode(componentType);
// 解析模版中的信息 作为默认值 返回json
List<ClientTemplate> clientTemplates = this.loadTemplate(clusterId, type, versionName, null, deployType);
if (CollectionUtils.isNotEmpty(clientTemplates)) {
Map<String, Object> fileMap = ComponentConfigUtils.convertClientTemplateToMap(clientTemplates);
uploadFileName = EComponentType.getByCode(componentType).name() + ".json";
localDownLoadPath = USER_DIR_DOWNLOAD + File.separator + uploadFileName;
try {
FileUtils.write(new File(localDownLoadPath), JSONObject.toJSONString(fileMap));
} catch (Exception e) {
throw new RdosDefineException("file does not exist");
}
}
} else {
Component component = componentMapper.selectById(componentId);
if (null == component) {
throw new RdosDefineException("Component does not exist");
}
SftpConfig sftpConfig = componentService.getComponentByClusterId(clusterId, EComponentType.SFTP.getTypeCode(), false, SftpConfig.class, null);
if (null == sftpConfig) {
throw new RdosDefineException("sftp component does not exist");
}
localDownLoadPath = USER_DIR_DOWNLOAD + File.separator + component.getComponentName();
String remoteDir = sftpConfig.getPath() + File.separator + this.buildSftpPath(clusterId, component.getComponentTypeCode());
SftpFileManage sftpFileManage = null;
if (DownloadType.Kerberos.getCode() == downloadType) {
remoteDir = remoteDir + File.separator + KERBEROS;
localDownLoadPath = localDownLoadPath + File.separator + KERBEROS;
sftpFileManage = SftpFileManage.getSftpManager(sftpConfig);
sftpFileManage.downloadDir(remoteDir, localDownLoadPath);
} else {
if (StringUtils.isBlank(component.getUploadFileName())) {
// 一种是 全部手动填写的 如flink
EComponentType type = EComponentType.getByCode(componentType);
String componentConfig = componentService.getComponentByClusterId(clusterId, type.getTypeCode(), true, String.class, component.getVersionValue());
try {
localDownLoadPath = localDownLoadPath + ".json";
FileUtils.write(new File(localDownLoadPath), filterConfigMessage(componentConfig));
} catch (IOException e) {
LOGGER.error("write upload file {} error", componentConfig, e);
}
} else {
sftpFileManage = SftpFileManage.getSftpManager(sftpConfig);
// 一种是 上传配置文件的需要到sftp下载
sftpFileManage.downloadDir(remoteDir + File.separator + component.getUploadFileName(), localDownLoadPath);
}
}
uploadFileName = component.getUploadFileName();
}
File file = new File(localDownLoadPath);
if (!file.exists()) {
throw new RdosDefineException("file does not exist");
}
String zipFilename = StringUtils.isBlank(uploadFileName) ? "download.zip" : uploadFileName;
if (file.isDirectory()) {
// 将文件夹压缩成zip文件
return zipFile(componentId, downloadType, componentType, file, zipFilename);
} else {
return new File(localDownLoadPath);
}
}
use of com.dtstack.taier.common.enums.EComponentType 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.common.enums.EComponentType in project Taier by DTStack.
the class TenantService method initDataDevelop.
@Transactional(rollbackFor = Exception.class)
public void initDataDevelop(Long clusterId, Long tenantId, Long userId, String tenantName, String tenantDesc, List<ComponentBindDBDTO> bindDBDTOList) throws Exception {
// 初始化目录
List<Component> components = componentService.listAllComponents(clusterId);
List<ComponentVO> componentVOS = ComponentVO.toVOS(components);
batchCatalogueService.initCatalogue(tenantId, userId, componentVOS);
// 初始化数据源相关的信息
IComponentService componentService = null;
for (ComponentBindDBDTO componentBindDBDTO : bindDBDTOList) {
EComponentType eComponentType = EComponentType.getByCode(componentBindDBDTO.getComponentCode());
String componentIdentity = tenantName;
// db相关的操作
if (BooleanUtils.isTrue(componentBindDBDTO.getCreateFlag())) {
componentService = multiEngineServiceFactory.getComponentService(eComponentType.getTypeCode());
componentService.createDatabase(clusterId, eComponentType, componentIdentity, tenantDesc);
} else {
componentIdentity = componentBindDBDTO.getDbName();
}
// 初始化数据源
datasourceService.initDefaultSource(clusterId, eComponentType, tenantId, componentIdentity, tenantDesc, userId);
// 初始化租户引擎关系
TenantComponent tenantEngine = new TenantComponent();
tenantEngine.setTaskType(ComponentTypeToEScheduleJobMapping.getEScheduleTypeByComponentCode(eComponentType.getTypeCode()).getType());
tenantEngine.setTenantId(tenantId);
tenantEngine.setComponentIdentity(componentIdentity);
tenantEngine.setCreateUserId(userId);
tenantEngine.setStatus(0);
developTenantComponentService.insert(tenantEngine);
}
}
use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.
the class TenantService method checkClusterCanUse.
public void checkClusterCanUse(String clusterName) throws Exception {
List<ComponentMultiTestResult> testConnectionVO = consoleComponentService.testConnects(clusterName);
boolean canUse = true;
StringBuilder msg = new StringBuilder();
msg.append("此集群不可用,测试连通性为通过:\n");
for (ComponentMultiTestResult testResult : testConnectionVO) {
EComponentType componentType = EComponentType.getByCode(testResult.getComponentTypeCode());
if (!EComponentType.notCheckComponent.contains(componentType) && !testResult.getResult()) {
canUse = false;
msg.append("组件:").append(componentType.getName()).append(" ").append(JSON.toJSONString(testResult.getErrorMsg())).append("\n");
}
}
if (!canUse) {
throw new RdosDefineException(msg.toString());
}
}
Aggregations