Context context = new Context();
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
Path dirPath = new Path(hdfsPath);
fs.delete(dirPath, true);
fs.mkdirs(dirPath);
context.put("hdfs.path", hdfsPath);
context.put("hdfs.closeTries",
String.valueOf(numberOfClosesRequired));
context.put("hdfs.rollCount", "1");
context.put("hdfs.retryInterval", "1");