1. 程式人生 > >Hadoop javaAPI執行append時報錯 lease recovery is in progress 處理辦法

Hadoop javaAPI執行append時報錯 lease recovery is in progress 處理辦法

如叢集節點少於3個在執行時就會拋異常;解決方案修改【dfs.client.block.write.replace-datanode-on-failure.policy=NEVER】

Configuration conf = new Configuration();

conf.set("dfs.client.block.write.replace-datanode-on-failure.policy", "NEVER");    //修改屬性引數

全部程式碼如下

public void  appendByAPI() throws IOException{
        Configuration conf = new Configuration();
        conf.set("dfs.client.block.write.replace-datanode-on-failure.policy", "NEVER");    //修改屬性引數
        FileSystem fs = FileSystem.get(conf);
        Path file = new Path("/spaceQuota/hello.txt");
        FSDataOutputStream out = fs.append(file);
        out.writeChars("aaaa");
        out.close();