-Auto restart SmartProxy download if is more than 2 minutes without receiving any data.
-SmartProxy benchmark temporarily disabled.
This commit is contained in:
tonikelope 2019-11-05 13:58:05 +01:00
parent fbf45c85bd
commit 23aa819fcb
6 changed files with 52 additions and 7 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId>
<artifactId>MegaBasterd</artifactId>
<version>6.74</version>
<version>6.75</version>
<packaging>jar</packaging>
<dependencies>
<dependency>

View File

@ -1,7 +1,6 @@
package com.tonikelope.megabasterd;
import static com.tonikelope.megabasterd.MainPanel.*;
import static com.tonikelope.megabasterd.MiscTools.*;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@ -230,6 +229,8 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
chunk_error = true;
timeout = false;
slow_proxy = false;
File tmp_chunk_file = null, chunk_file = null;
@ -327,6 +328,9 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
http_error = 0;
/*
//Proxy speed benchmark
if (_current_smart_proxy != null && finish_chunk_time != -1) {
//Update average chunk download speed using SmartProxy
@ -337,8 +341,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
long avg_chunk_speed = _download.getMain_panel().getGlobal_dl_speed().getAvg_chunk_speed();
if (avg_chunk_speed != -1) {
//Proxy speed benchmark
if (chunk_speed < Math.round(avg_chunk_speed * SLOW_PROXY_PERC)) {
LOG.log(Level.INFO, "{0} Worker [{1}] WARNING -> PROXY {2} CHUNK DOWNLOAD SPEED: {3}/s SEEMS TO BE SLOW (average is {4}/s) {4}", new Object[]{Thread.currentThread().getName(), _id, _current_smart_proxy, formatBytes(chunk_speed), formatBytes(avg_chunk_speed), _download.getFile_name()});
@ -346,8 +349,8 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
slow_proxy = true;
}
}
}
}*/
if (!FORCE_SMART_PROXY) {
_current_smart_proxy = null;
}

View File

@ -46,6 +46,7 @@ import javax.swing.JComponent;
public class Download implements Transference, Runnable, SecureSingleThreadNotifiable {
public static final boolean VERIFY_CBC_MAC_DEFAULT = false;
public static final int PROGRESS_WATCHDOG_TIMEOUT = 120;
public static final boolean USE_SLOTS_DEFAULT = true;
public static final int WORKERS_DEFAULT = 6;
public static final boolean USE_MEGA_ACCOUNT_DOWN = false;
@ -98,6 +99,7 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
private volatile boolean _canceled;
private volatile boolean _turbo;
private volatile boolean _closed;
private final Object _progress_watchdog_lock;
public Download(MainPanel main_panel, MegaAPI ma, String url, String download_path, String file_name, String file_key, Long file_size, String file_pass, String file_noexpire, boolean use_slots, boolean restart, String custom_chunks_dir) {
@ -114,6 +116,7 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
_closed = false;
_pause = false;
_exit = false;
_progress_watchdog_lock = new Object();
_last_download_url = null;
_provision_ok = true;
_progress = 0L;
@ -158,6 +161,7 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
_finishing_download = false;
_pause = false;
_exit = false;
_progress_watchdog_lock = new Object();
_last_download_url = null;
_provision_ok = true;
_progress = 0L;
@ -631,6 +635,36 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
}
});
THREAD_POOL.execute(() -> {
//PROGRESS WATCHDOG If a download (using SmartProxy) remains more than two minutes without advancing 1 byte, we restart it.
LOG.log(Level.INFO, "{0} PROGRESS WATCHDOG HELLO!", Thread.currentThread().getName());
long last_progress, progress = getProgress();
do {
last_progress = progress;
synchronized (_progress_watchdog_lock) {
try {
_progress_watchdog_lock.wait(PROGRESS_WATCHDOG_TIMEOUT * 1000);
progress = getProgress();
} catch (InterruptedException ex) {
progress = -1;
Logger.getLogger(Download.class.getName()).log(Level.SEVERE, null, ex);
}
}
} while (!isExit() && (!isTurbo() || isPaused() || progress > last_progress));
if (!isExit() && progress <= last_progress) {
stopDownloader("PROGRESS WATCHDOG TIMEOUT!");
}
LOG.log(Level.INFO, "{0} PROGRESS WATCHDOG BYE BYE!", Thread.currentThread().getName());
});
secureWait();
LOG.log(Level.INFO, "{0} Chunkdownloaders finished!", Thread.currentThread().getName());
@ -884,6 +918,12 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
});
}
_exit = true;
synchronized (_progress_watchdog_lock) {
_progress_watchdog_lock.notifyAll();
}
LOG.log(Level.INFO, "{0}{1} Downloader: bye bye", new Object[]{Thread.currentThread().getName(), _file_name});
}

View File

@ -53,7 +53,7 @@ import javax.swing.UIManager;
*/
public final class MainPanel {
public static final String VERSION = "6.74";
public static final String VERSION = "6.75";
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
public static final int STREAMER_PORT = 1337;

View File

@ -1000,6 +1000,8 @@ public class Upload implements Transference, Runnable, SecureSingleThreadNotifia
});
}
_exit = true;
LOG.log(Level.INFO, "{0} Uploader {1} BYE BYE", new Object[]{Thread.currentThread().getName(), this.getFile_name()});
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

After

Width:  |  Height:  |  Size: 195 KiB