Search in sources :

Example 6 with HdfsSourceDTO

use of com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO in project Taier by DTStack.

the class HdfsOperator method getDirSize.

public static long getDirSize(Map<String, Object> conf, Map<String, Object> kerberos, String dir) {
    long size = 0;
    try {
        HdfsSourceDTO sourceDTO = getSourceDTO(conf, kerberos);
        IHdfsFile hdfsClient = ClientCache.getHdfs(DataSourceType.HDFS.getVal());
        size = hdfsClient.getDirSize(sourceDTO, dir);
    } catch (Exception e) {
        logger.error("get dir size error:", e);
    }
    return size;
}
Also used : IHdfsFile(com.dtstack.dtcenter.loader.client.IHdfsFile) HdfsSourceDTO(com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 7 with HdfsSourceDTO

use of com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO in project Taier by DTStack.

the class HdfsOperator method setPermission.

public static void setPermission(Map<String, Object> conf, Map<String, Object> kerberos, String path, String mode) {
    HdfsSourceDTO sourceDTO = getSourceDTO(conf, kerberos);
    IHdfsFile hdfsClient = ClientCache.getHdfs(DataSourceType.HDFS.getVal());
    hdfsClient.setPermission(sourceDTO, path, mode);
}
Also used : IHdfsFile(com.dtstack.dtcenter.loader.client.IHdfsFile) HdfsSourceDTO(com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO)

Example 8 with HdfsSourceDTO

use of com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO in project Taier by DTStack.

the class HdfsOperator method getSourceDTO.

private static HdfsSourceDTO getSourceDTO(Map<String, Object> conf, Map<String, Object> kerberos) {
    conf = Objects.isNull(conf) ? Maps.newHashMap() : conf;
    HdfsSourceDTO hdfsSourceDTO = HdfsSourceDTO.builder().defaultFS(conf.getOrDefault("fs.defaultFS", "").toString()).kerberosConfig(kerberos).config(JSONObject.toJSONString(conf)).build();
    return hdfsSourceDTO;
}
Also used : HdfsSourceDTO(com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO)

Example 9 with HdfsSourceDTO

use of com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO in project Taier by DTStack.

the class HdfsOperator method downloadFileFromHDFS.

/**
 * 从HDFS上下载文件或文件夹到本地
 *
 * @throws IOException
 */
public static void downloadFileFromHDFS(Map<String, Object> conf, Map<String, Object> kerberos, String remotePath, String localDir) {
    HdfsSourceDTO sourceDTO = getSourceDTO(conf, kerberos);
    IHdfsFile hdfsClient = ClientCache.getHdfs(DataSourceType.HDFS.getPluginName());
    hdfsClient.downloadFileFromHdfs(sourceDTO, remotePath, localDir);
}
Also used : IHdfsFile(com.dtstack.dtcenter.loader.client.IHdfsFile) HdfsSourceDTO(com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO)

Example 10 with HdfsSourceDTO

use of com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO in project Taier by DTStack.

the class HdfsOperator method copyFile.

public static void copyFile(Map<String, Object> conf, Map<String, Object> kerberos, String src, String dist, boolean overwrite) {
    HdfsSourceDTO sourceDTO = getSourceDTO(conf, kerberos);
    IHdfsFile hdfsClient = ClientCache.getHdfs(DataSourceType.HDFS.getVal());
    hdfsClient.copyFile(sourceDTO, src, dist, overwrite);
}
Also used : IHdfsFile(com.dtstack.dtcenter.loader.client.IHdfsFile) HdfsSourceDTO(com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO)

Aggregations

HdfsSourceDTO (com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO)28 IHdfsFile (com.dtstack.dtcenter.loader.client.IHdfsFile)26 DtCenterDefException (com.dtstack.taier.common.exception.DtCenterDefException)6 IOException (java.io.IOException)5 UnknownHostException (java.net.UnknownHostException)5 IClient (com.dtstack.dtcenter.loader.client.IClient)1 SqlQueryDTO (com.dtstack.dtcenter.loader.dto.SqlQueryDTO)1 Map (java.util.Map)1