I use the Hadoop's FileSystem
class for deleting some HDFS files. The problem now is, that the client gets a Connection Timeout after a too long duration, I need to shrink the time to wait until the timeout, so that the user gets faster responses, if he/she is outside the network!
Here my codes snippet:
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!");
}
Where and how can I set the timeout for my application? I don't want to change this in any Hadoop config files, just locally for my Java app. Thank you!