use of com.dtstack.taier.common.exception.DtCenterDefException in project Taier by DTStack.
the class TimeParamOperator method doFormatFunction.
/**
* 处理 format 函数
* @param line
* @param cycTime
* @return
*/
private static String doFormatFunction(String line, String cycTime) {
Matcher formattedMatch = FORMAT_PATTERN.matcher(line);
if (!formattedMatch.find()) {
throw new DtCenterDefException("illegal command " + line);
}
// 获取需要处理的属性
String format = formattedMatch.group("format");
Boolean operate = "+".equals(formattedMatch.group("operate"));
Integer number = StringUtils.isBlank(formattedMatch.group("number")) ? 0 : Integer.valueOf(formattedMatch.group("number"));
String unit = formattedMatch.group("unit");
String formatResult = formattedMatch.group("formatResult");
return doFormatFunctionCyctime(cycTime, operate, number, unit, formatResult);
}
use of com.dtstack.taier.common.exception.DtCenterDefException in project Taier by DTStack.
the class SFTPHandler method deleteDir.
public void deleteDir(String ftpPath) {
try {
channelSftp.cd(ftpPath);
} catch (SftpException e) {
logger.info("", e);
return;
}
try {
Vector files = channelSftp.ls(ftpPath);
for (Iterator<ChannelSftp.LsEntry> iterator = files.iterator(); iterator.hasNext(); ) {
ChannelSftp.LsEntry str = iterator.next();
String filename = str.getFilename();
if (".".equals(filename) || "..".equals(filename)) {
continue;
}
SftpATTRS attrs = str.getAttrs();
if (attrs.isDir()) {
deleteDir(ftpPath + "/" + filename);
} else {
channelSftp.rm(ftpPath + "/" + filename);
}
}
if (channelSftp.ls(ftpPath).size() == 2) {
channelSftp.rmdir(ftpPath);
}
} catch (SftpException e) {
logger.error("", e);
throw new DtCenterDefException("删除sftp路径失败,sftpPath=" + ftpPath);
}
}
use of com.dtstack.taier.common.exception.DtCenterDefException in project Taier by DTStack.
the class DatasourceService method fillKerberosConfig.
/**
* 根据已有数据源主键填充confMap
* @param sourceId
* @return
*/
public Map<String, Object> fillKerberosConfig(Long sourceId) {
DsInfo dataSource = dsInfoService.getOneById(sourceId);
Long tenantId = dataSource.getTenantId();
// 获取Kerberos客户端
JSONObject kerberosConfig = DataSourceUtils.getOriginKerberosConfig(dataSource.getDataJson(), false);
if (MapUtils.isEmpty(kerberosConfig)) {
return Collections.emptyMap();
}
try {
// 获取kerberos本地路径
String localKerberosConf = kerberosService.getLocalKerberosPath(sourceId);
kerberosService.downloadKerberosFromSftp(dataSource.getIsMeta(), sourceId, DataSourceUtils.getDataSourceJson(dataSource.getDataJson()), localKerberosConf, tenantId);
} catch (SftpException e) {
throw new DtCenterDefException(String.format("获取kerberos认证文件失败,Caused by: %s", e.getMessage()), e);
}
return kerberosConfig;
}
use of com.dtstack.taier.common.exception.DtCenterDefException in project Taier by DTStack.
the class KerberosService method prepareKerberosConfig.
/**
* 预处理Kerberos配置
*/
public void prepareKerberosConfig(DsInfoBO dsInfoBO) {
if (dsInfoBO.getKerberosConfig() == null) {
return;
}
try {
// 获取kerberos本地路径
String localKerberosConf = getLocalKerberosPath(dsInfoBO.getId());
downloadKerberosFromSftp(dsInfoBO.getIsMeta(), dsInfoBO.getId(), DataSourceUtils.getDataSourceJson(dsInfoBO.getDataJson()), localKerberosConf, dsInfoBO.getTenantId());
} catch (SftpException e) {
throw new DtCenterDefException(String.format("获取kerberos认证文件失败,Caused by: %s", e.getMessage()), e);
}
String localKerberosPath = getLocalKerberosPath(dsInfoBO.getId());
JSONObject dataJson = dsInfoBO.getData();
// principal 键
String principal = dataJson.getString(FormNames.PRINCIPAL);
Map<String, Object> kerberosConfig = dsInfoBO.getKerberosConfig();
if (Strings.isNotBlank(principal)) {
kerberosConfig.put(HadoopConfTool.PRINCIPAL, principal);
}
// Hbase master kerberos Principal
String hbaseMasterPrincipal = dataJson.getString(FormNames.HBASE_MASTER_PRINCIPAL);
if (Strings.isNotBlank(hbaseMasterPrincipal)) {
kerberosConfig.put(HadoopConfTool.HBASE_MASTER_PRINCIPAL, hbaseMasterPrincipal);
}
// Hbase region kerberos Principal
String hbasePrincipal = dataJson.getString(FormNames.HBASE_REGION_PRINCIPAL);
if (Strings.isNotBlank(hbasePrincipal)) {
kerberosConfig.put(HadoopConfTool.HBASE_REGION_PRINCIPAL, hbasePrincipal);
}
DataSourceTypeEnum typeEnum = DataSourceTypeEnum.typeVersionOf(dsInfoBO.getDataType(), dsInfoBO.getDataVersion());
IKerberos kerberos = ClientCache.getKerberos(typeEnum.getVal());
kerberos.prepareKerberosForConnect(kerberosConfig, localKerberosPath);
dsInfoBO.setKerberosConfig(kerberosConfig);
}
use of com.dtstack.taier.common.exception.DtCenterDefException in project Taier by DTStack.
the class KerberosConfigVerify method parseConfMap.
@Deprecated
public static Map<String, Map<String, String>> parseConfMap(List<File> unzipFileList, String unZipLocation) throws Exception {
Map<String, File> confFileMap = new HashMap<>();
List<File> xmlFileList = new ArrayList<>();
filterXml(unzipFileList, unZipLocation, xmlFileList, confFileMap);
Map<String, Map<String, String>> confMap = null;
if (CollectionUtils.isNotEmpty(xmlFileList)) {
try {
confMap = parseAndRead(xmlFileList);
} catch (Exception e) {
logger.error("{}", e);
throw new DtCenterDefException("配置文件解析失败");
}
}
return confMap;
}
Aggregations