hadoop java 追加数据_往hdfs上追加数据

在尝试使用Java代码向HDFS上的现有文件追加数据时,遇到错误提示:'current leaseholder is trying to recreate file'。错误发生在FSNamesystem的recoverLeaseInternal和appendFileInternal方法中。该问题可能由于当前持有文件租约的进程正在尝试重新创建文件导致。解决方法通常涉及处理文件租约和同步问题。
摘要由CSDN通过智能技术生成

代码是执行追加操作,往hdfs上已有的文件追加新数据,但是一直报错Pathhdfs_path=newPath(host+path+table+"/part.txt");Configurationconf=newConfiguration();FileSystemfs=FileSys...

代码是执行追加操作,往hdfs上已有的文件追加新数据,但是一直报错

Path hdfs_path = new Path(host + path + table + "/part.txt");

Configuration conf = new Configuration();

FileSystem fs = FileSystem.get(URI.create(hdfs_path.toString()), conf);

fs.setReplication(hdfs_path, (short)1);

InputStream in = new BufferedInputStream(new ByteArrayInputStream(data.getBytes()));

OutputStream out = fs.append(hdfs_path);

IOUtils.copyBytes(in, out, conf);

out.close();

fs.close();

IOUtils.closeStream(in);

in.close();

错误内容:

org.apache.hadoop.ipc.RemoteException: failed to create file /user/root/uair11/air_info_package_cache_/part.txt for DFSClient_NONMAPREDUCE_1195989360_48 on client 192.168.22.129 because current leaseholder is trying to recreate file.at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.recoverLeaseInternal(FSNamesystem.java:2342)at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.appendFileInternal(FSNamesystem.java:220)

at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.appendFileInt(FSNamesystem.java:2453)

at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.appendFile(FSNamesystem.java:2414)

at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.append(NameNodeRpcServer.java:508)

at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.append(ClientNamenodeProtocolServerSideTranslatorPB.java:320)

at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java:48063)

at

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值