java 无效参数异常,java.io.IOException:参数无效

I have a web application running in cluster mode with a load balancer.

It consists in two tomcats (T1, and T2) addressing only one DB.

T2 is nfs mounted to T1. This is the only dofference between both nodes.

I have a java method generating some files. If the request

runs on T1 there is no problem but if the request is running on node 2

I get an exception as follows:

java.io.IOException: Invalid argument

at java.io.FileOutputStream.close0(Native Method)

at java.io.FileOutputStream.close(FileOutputStream.java:279)

The corresponding code is as follows:

for (int i = 0; i < dataFileList.size(); i++) {

outputFileName = outputFolder + fileNameList.get(i);

FileOutputStream fileOut = new FileOutputStream(outputFileName);

fileOut.write(dataFileList.get(i), 0, dataFileList.get(i).length);

fileOut.flush();

fileOut.close();

}

The exception appears at the fileOut.close()

Any hint?

Luis

解决方案

Finally I found the reason.

First I've notices that NOT always this exception comes

at the same point.

Sometimes was a

java.io.IOException: Invalid argument

at java.io.FileOutputStream.close0(Native Method)

at java.io.FileOutputStream.close(FileOutputStream.java:279)

^^^^^

and sometimes was

java.io.IOException: Invalid argument

at java.io.FileOutputStream.writeBytes(Native Method)

at java.io.FileOutputStream.write(FileOutputStream.java:260)

Therefore the problem is NOT a java problem. Not even a NFS problem.

The problem is the underlying File System type which is an DRBD

file system.

Testing at a shell to write across the nodes works if one is writing a small

file. I.e:

at the nfs mounted node

cd /tmp

date > /shared/path-to-some-not-mounted-dir/today

will work

but

cat myBigFile > /shared/path-to-some-not-mounted-dir/today

will deliver the following error

cat: write error: Invalid argument

Therefore the solution is to use other type of file system, gfs for example.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值