Search in sources :

Example 16 with DtCenterDefException

use of com.dtstack.taier.common.exception.DtCenterDefException in project Taier by DTStack.

the class ResponseAdvisor method exceptionHandler.

@ResponseBody
@ExceptionHandler(value = Throwable.class)
public R exceptionHandler(Throwable e) {
    ExceptionEnums errorCode = ErrorCode.UNKNOWN_ERROR;
    String errorMsg = null;
    RdosDefineException rdosDefineException = null;
    if (e.getCause() instanceof DtCenterDefException) {
        rdosDefineException = (RdosDefineException) e.getCause();
        if (rdosDefineException.getErrorCode() != null) {
            errorCode = rdosDefineException.getErrorCode();
        }
        errorMsg = rdosDefineException.getErrorMsg();
        if (e.getCause().getCause() != null) {
            LOGGER.error("", e.getCause().getCause());
        }
    } else if (e instanceof RdosDefineException) {
        rdosDefineException = (RdosDefineException) e;
        if (rdosDefineException.getErrorCode() != null) {
            errorCode = rdosDefineException.getErrorCode();
        }
        errorMsg = rdosDefineException.getErrorMsg();
        if (e.getCause() != null) {
            LOGGER.error("", e.getCause());
        }
    } else {
        errorCode = ErrorCode.SERVER_EXCEPTION;
        errorMsg = ErrorCode.SERVER_EXCEPTION.getDescription();
        LOGGER.error("", e);
    }
    if (errorCode.equals(ErrorCode.PERMISSION_LIMIT)) {
        return R.fail(errorCode.getCode(), errorMsg);
    }
    return R.fail(errorCode.getCode(), errorMsg);
}
Also used : ExceptionEnums(com.dtstack.taier.common.exception.ExceptionEnums) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 17 with DtCenterDefException

use of com.dtstack.taier.common.exception.DtCenterDefException in project Taier by DTStack.

the class HdfsOperator method getContentSummary.

/**
 * 获取hdfs上指定路径集合的ContentSummary
 *
 * @param conf
 * @param kerberos
 * @param targetPaths
 * @return
 */
public static List<HDFSContentSummary> getContentSummary(Map<String, Object> conf, Map<String, Object> kerberos, List<String> targetPaths) {
    try {
        HdfsSourceDTO sourceDTO = getSourceDTO(conf, kerberos);
        IHdfsFile hdfsClient = ClientCache.getHdfs(DataSourceType.HDFS.getVal());
        return hdfsClient.getContentSummary(sourceDTO, targetPaths);
    } catch (Exception e) {
        throw new DtCenterDefException(String.format("获取hdfs文件内容摘要异常!原因是:%s", e.getMessage()));
    }
}
Also used : IHdfsFile(com.dtstack.dtcenter.loader.client.IHdfsFile) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) HdfsSourceDTO(com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 18 with DtCenterDefException

use of com.dtstack.taier.common.exception.DtCenterDefException in project Taier by DTStack.

the class HdfsOperator method fileMerge.

/**
 * 获取hdfs上指定路径集合的ContentSummary
 *
 * @param conf hadoop配置
 * @param kerberos kerberos配置
 * @param src 原路径
 * @param mergePath 合并临时目录
 * @param fileFormat 文件存储格式
 * @param needCombineFileSizeLimit 需要合并的文件大小阈值
 * @param maxCombinedFileSize 合并后的最大大小
 */
public static void fileMerge(Map<String, Object> conf, Map<String, Object> kerberos, String src, String mergePath, FileFormat fileFormat, Long maxCombinedFileSize, Long needCombineFileSizeLimit) {
    try {
        HdfsSourceDTO sourceDTO = getSourceDTO(conf, kerberos);
        IHdfsFile hdfsClient = ClientCache.getHdfs(DataSourceType.HDFS.getVal());
        hdfsClient.fileMerge(sourceDTO, src, mergePath, fileFormat, maxCombinedFileSize, needCombineFileSizeLimit);
    } catch (Exception e) {
        throw new DtCenterDefException(String.format("文件合并异常!原因是:%s", e.getMessage()));
    }
}
Also used : IHdfsFile(com.dtstack.dtcenter.loader.client.IHdfsFile) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) HdfsSourceDTO(com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 19 with DtCenterDefException

use of com.dtstack.taier.common.exception.DtCenterDefException in project Taier by DTStack.

the class HdfsOperator method getContentSummary.

/**
 * 获取hdfs上指定路径的ContentSummary
 *
 * @param conf
 * @param kerberos
 * @param targetPath
 * @return
 */
public static HDFSContentSummary getContentSummary(Map<String, Object> conf, Map<String, Object> kerberos, String targetPath) {
    try {
        HdfsSourceDTO sourceDTO = getSourceDTO(conf, kerberos);
        IHdfsFile hdfsClient = ClientCache.getHdfs(DataSourceType.HDFS.getVal());
        return hdfsClient.getContentSummary(sourceDTO, targetPath);
    } catch (Exception e) {
        throw new DtCenterDefException(String.format("获取hdfs文件内容摘要异常!原因是:%s", e.getMessage()));
    }
}
Also used : IHdfsFile(com.dtstack.dtcenter.loader.client.IHdfsFile) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) HdfsSourceDTO(com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 20 with DtCenterDefException

use of com.dtstack.taier.common.exception.DtCenterDefException in project Taier by DTStack.

the class HdfsOperator method copyDirector.

/**
 * 获取hdfs上指定路径集合的ContentSummary
 *
 * @param conf hadoop配置
 * @param kerberos kerberos配置
 * @param src 原路径
 * @param dist 复制路径
 */
public static void copyDirector(Map<String, Object> conf, Map<String, Object> kerberos, String src, String dist) {
    try {
        HdfsSourceDTO sourceDTO = getSourceDTO(conf, kerberos);
        IHdfsFile hdfsClient = ClientCache.getHdfs(DataSourceType.HDFS.getVal());
        hdfsClient.copyDirector(sourceDTO, src, dist);
    } catch (Exception e) {
        throw new DtCenterDefException(String.format("hdfs内复制文件夹异常!原因是:%s", e.getMessage()));
    }
}
Also used : IHdfsFile(com.dtstack.dtcenter.loader.client.IHdfsFile) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) HdfsSourceDTO(com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

DtCenterDefException (com.dtstack.taier.common.exception.DtCenterDefException)26 IOException (java.io.IOException)11 JSONObject (com.alibaba.fastjson.JSONObject)7 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)7 SftpException (com.jcraft.jsch.SftpException)6 IHdfsFile (com.dtstack.dtcenter.loader.client.IHdfsFile)5 HdfsSourceDTO (com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO)5 UnknownHostException (java.net.UnknownHostException)5 Matcher (java.util.regex.Matcher)4 ArrayList (java.util.ArrayList)3 IClient (com.dtstack.dtcenter.loader.client.IClient)2 IKerberos (com.dtstack.dtcenter.loader.client.IKerberos)2 ColumnMetaDTO (com.dtstack.dtcenter.loader.dto.ColumnMetaDTO)2 SqlQueryDTO (com.dtstack.dtcenter.loader.dto.SqlQueryDTO)2 ISourceDTO (com.dtstack.dtcenter.loader.dto.source.ISourceDTO)2 DataSourceTypeEnum (com.dtstack.taier.common.enums.DataSourceTypeEnum)2 PubSvcDefineException (com.dtstack.taier.common.exception.PubSvcDefineException)2 DsInfo (com.dtstack.taier.dao.domain.DsInfo)2 File (java.io.File)2 HttpEntity (org.apache.http.HttpEntity)2