Java function moveFile uses the native move command to move the output report file to ready directory. It was working well earlier but now it started throwing the below disk space exception now. But when i check the diskspace there is a lot of sace available in the directories and i did a clean up also. I tried to rerun it but still i am getting the below error. Not sure what is the issue.
java.io.IOException: Cannot run program "mv": error=12, Not enough space
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at powertel.usageExtract.ctfCompactExtract.moveFile(ctfCompactExtract.java:507)
at powertel.usageExtract.ctfCompactExtract.run(ctfCompactExtract.java:1189)
Caused by: java.io.IOException: error=12, Not enough space
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
private int moveFile(int moveto) {
String runCmd = “”;
Process p = null;
int extVal = 0;
if (moveto == 1) {
runCmd = "mv "+ outfile + " " + localbaseDir+"/ctf/ready/";
}
else {
runCmd = "mv "+ outfile + " " + localbaseDir+"/ctf/error/";
}
try {
Runtime r = Runtime.getRuntime();
p = r.exec(runCmd);
p.waitFor();
extVal = p.exitValue();
log.debug("Process exit value: " + extVal);
}
catch (IOException e) {
extVal = 1;
log.error("IO Exception - "+ e.getMessage());
e.printStackTrace();
}
catch (InterruptedException e1) {
extVal = 1;
log.error("Interrupted Exception - "+e1.getMessage());
}
return extVal;
}
The ‘not enough space’ error isn’t referring to disk space, it’s referring to memory when trying to fork to execute a process.
When forking, temporarily your Java process’s memory is copied, and there needs to be enough swap space on the system to hold both the parent and child process (which for a certain time has the same memory usage as your parent process) for a short amount of time. If you are spawning lots of processes quickly, you might need even more memory.
This can be a major issue when your Java process is very large, such as an appserver.
The issue is well described here:
https://wiki.jenkins-ci.org/display/JENKINS/IOException+Not+enough+space