set-hdfs连接超时

cpjpxq1n  于 2021-06-02  发布在  Hadoop
关注(0)|答案(0)|浏览(283)

我用hadoop的 FileSystem 用于删除某些hdfs文件的类。现在的问题是,客户端在持续时间太长之后获得连接超时,我需要缩短等待超时的时间,以便用户在网络之外时获得更快的响应!下面是我的代码片段:

try {
    System.setProperty("HADOOP_USER_NAME", "test");
    Configuration conf = new Configuration();
    File csvFile = new File(pathCsvFile);
    FileSystem hdfs = FileSystem.get(new URI(csvFile.getPath(), conf);
    if(hdfs.exists(new Path(filterValuesPath))) {
        hdfs.delete(new Path(filterValuesPath), true);
        setInfo("File deleted!");
    } else {
        setInfo("No file to delete!");
    }
} catch (Exception ex) {         // the timeout is too high!!!
    ex.printStackTrace();
    setInfo("No connection or no files to delete!");
}

在哪里以及如何设置应用程序的超时?我不想在任何hadoop配置文件中更改这一点,只在本地为我的java应用程序更改。谢谢您!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题