Я использую библиотеку, которая скачивает торренты. Но сегодня произошла ошибка (журнал):
<pre>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)
И так далее, журнал продолжается. Я обнаружил, что этот файл существует, и вот часть кода, где происходит ошибка:
<pre> /**
* 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;
}
Который называется здесь:
<pre> // запуск закачки
dm.startListening(49152, 65535);
dm.startTrackerUpdate();</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();
И верхний код называется здесь:
ex = Executors.newFixedThreadPool (3);
для (Строка torrentFile: torrentFiles)
{
ex.submit (новый DownloadTorrent ("/ root / TorrentStealer / torrents /" + torrentFile));
}
// ожидание завершения потоковой загрузки файлов торрентов
ex.shutdown ();
пытаться
{
ex.awaitTermination (30, TimeUnit.MINUTES);
}
catch (InterruptedException ex1)
{
Logger.getLogger (Main.class.getName ()). Log (Level.SEVERE, null, ex1);
}
ex.shutdownNow ();
Вот описание исправления «Слишком много открытых файлов»:
http://wiki.magnolia -cms.com / дисплей / ЭНЦИКЛОПЕДИЯ / Too + Много + Open + Файлы
Я установил максимум 999999 файлов, которые исправили ошибку на некоторое время, затем настроил 9999999 для тестирования, на самом деле не работает, постоянно возникает ошибка. Не может быть 9999999 открытых файлов в один момент после запуска, когда сервер был перезагружен!
Итак, мужчины, я не знаю, что делать. Вы можете мне помочь?
Вот количество открытых файлов при возникновении исключений:
T217: ~ # lsof | туалет
Результат: 2708