gpt4 book ai didi

java.io.IOException : Invalid argument and Too many open files

转载 作者:行者123 更新时间:2023-12-02 08:17:33 29 4
gpt4 key购买 nike

我使用下载种子的库。但今天发生了一些错误(日志):

Could not create temp files
java.io.IOException: Invalid argument
at java.io.RandomAccessFile.setLength(Native Method)
at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:261)
at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.IOException: Invalid argument
at java.io.RandomAccessFile.setLength(Native Method)
at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:261)
at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.IOException: Invalid argument
at java.io.RandomAccessFile.setLength(Native Method)
at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:261)
at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.IOException: Invalid argument
at java.io.RandomAccessFile.setLength(Native Method)
at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:261)
at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.FileNotFoundException: /root/TorrentStealer/downloads/MAME - Update ROMs (v0.141 to v0.141u2)/lah_l104.zip (Too many open files)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.(RandomAccessFile.java:212)
at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:260)
at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.FileNotFoundException: /root/TorrentStealer/downloads/Degrassi.Junior.High.S01-S03.INTERNAL.DVDRip.XviD-FFNDVD/Degrassi.Junior.High.S01.INTERNAL.DVDRip.XviD-FFNDVDDegrassi.Junior.High.S01E10.INTERNAL.DVDRip.XviD-FFNDVDdegrassi.junior.high.s01e10.internal.dvdrip.xvid-ffndvd.r10 (Too many open files)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.(RandomAccessFile.java:212)
at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:260)
at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.FileNotFoundException: /root/TorrentStealer/downloads/MAME - Update ROMs (v0.141 to v0.141u2)/lah_l108.zip (Too many open files)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.(RandomAccessFile.java:212)
at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:260)
at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
依此类推,日志继续。我发现这个文件存在,这是发生错误的代码的一部分:
    /**
* Check the existence of the files specified in the torrent and if necessary,
* create them
*
* @return int
* @todo Should return an integer representing some error message...
*/
public synchronized int checkTempFiles() {
String saveas = Constants.SAVEPATH; // Should be configurable
if (this.nbOfFiles > 1)
saveas += this.torrent.saveAs + "/";
else
{
this.torrent.saveAs = this.torrent.name.get(0).toString();
}
new File(saveas).mkdirs();
for (int i = 0; i < this.nbOfFiles; i++) {
File temp = new File(saveas + ((String) (this.torrent.name.get(i))));
try {
this.output_files[i] = new RandomAccessFile(temp, "rw");
this.output_files[i].setLength((Integer)this.torrent.length.get(
i));
} catch (IOException ioe) {
System.err.println("Could not create temp files");
ioe.printStackTrace();
}
}
return 0;
}
这里调用的是:
        // запуск закачки
dm.startListening(49152, 65535);
dm.startTrackerUpdate();<p></p>

<pre><code> while(true)
{
if(dm.isComplete())
{
break;
}

try
{
Thread.sleep(100);
}
catch(InterruptedException ex)
{
Logger.getLogger(DownloadTorrent.class.getName()).log(Level.SEVERE, null, ex);
}
}

dm.stopTrackerUpdate();
dm.closeTempFiles();</code></pre>
</code></pre>

<p>And upper code called here:

ex = Executors.newFixedThreadPool(3);</p>

for(String torrentFile : torrentFiles)
{
ex.submit(new DownloadTorrent("/root/TorrentStealer/torrents/" + torrentFile));
}

// ожидание завершения потоков загрузки файлов торрентов
ex.shutdown();

try
{
ex.awaitTermination(30, TimeUnit.MINUTES);
}
catch(InterruptedException ex1)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex1);
}

ex.shutdownNow();</code></pre>

以下是修复“打开文件过多”的说明: http://wiki.magnolia-cms.com/display/WIKI/Too+Many+Open+Files

我设置了999999个最大文件,修复了一段时间的错误,然后设置了9999999进行测试,并没有真正起作用,总是发生错误。服务器重启后运行后一瞬间不可能有9999999个打开的文件!

所以我不知道该怎么办。你能帮我吗?

以下是发生异常时打开文件的计数:T217:~# lsof |厕所-l结果是:2708

最佳答案

堆栈跟踪在 java.io.RandomAccessFile.setLength() 处指示错误,该错误接受 long数据类型。在您的代码中,您转换 this.torrent.length.get(i) 的结果为整数。

什么does this.torrent.length.get(i)返回?

当您将返回的数据转换为整数时,可能会出现一些缩小尺寸的问题,可能会返回负数,从而导致 RandomAccessFile.setLength()错误输出。

关于java.io.IOException : Invalid argument and Too many open files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6066126/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com