-Progress watchdog meter fix
This commit is contained in:
tonikelope 2019-11-09 19:45:41 +01:00
parent 9ba47c3381
commit 803a005efc
8 changed files with 21 additions and 22 deletions

View File

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

View File

@ -1,6 +1,7 @@
package com.tonikelope.megabasterd;
import static com.tonikelope.megabasterd.MainPanel.*;
import static com.tonikelope.megabasterd.MiscTools.formatBytes;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@ -22,7 +23,6 @@ import java.util.logging.Logger;
public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
public static final double SLOW_PROXY_PERC = 0.3;
public static final int READ_TIMEOUT_RETRY = 3;
private static final Logger LOG = Logger.getLogger(ChunkDownloader.class.getName());
private final boolean FORCE_SMART_PROXY = false; //True for debugging SmartProxy
private final int _id;
@ -276,7 +276,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
_download.getProgress_meter().secureNotify();
if (_download.isPaused() && !_download.isStopped()) {
if (_download.isPaused() && !_exit && !_download.isStopped() && !_download.getChunkmanager().isExit() && chunk_reads < chunk_size) {
_download.pause_worker();
@ -328,9 +328,7 @@ 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
@ -350,7 +348,8 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
}
}
}*/
}
if (!FORCE_SMART_PROXY) {
_current_smart_proxy = null;
}

View File

@ -136,7 +136,7 @@ public class ChunkDownloaderMono extends ChunkDownloader {
getDownload().getProgress_meter().secureNotify();
if (getDownload().isPaused() && !getDownload().isStopped()) {
if (getDownload().isPaused() && !getDownload().isStopped() && chunk_reads < chunk_size) {
getDownload().pause_worker_mono();

View File

@ -188,7 +188,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
tot_bytes_up += reads;
if (_upload.isPaused() && !_upload.isStopped()) {
if (_upload.isPaused() && !_exit && !_upload.isStopped() && tot_bytes_up < chunk_size) {
_upload.pause_worker();

View File

@ -655,9 +655,9 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
}
}
} while (!isExit() && (!isTurbo() || isPaused() || progress > last_progress));
} while (!isExit() && progress < getFile_size() && (!isTurbo() || isPaused() || progress > last_progress));
if (!isExit() && progress <= last_progress) {
if (!isExit() && progress < getFile_size() && progress <= last_progress) {
stopDownloader("PROGRESS WATCHDOG TIMEOUT!");
MainPanel.getProxy_manager().refreshProxyList(); //Force SmartProxy proxy list refresh
}

View File

@ -53,7 +53,7 @@ import javax.swing.UIManager;
*/
public final class MainPanel {
public static final String VERSION = "6.77";
public static final String VERSION = "6.78";
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

@ -18,7 +18,7 @@ import org.apache.commons.collections4.queue.CircularFifoQueue;
public class SpeedMeter implements Runnable {
public static final int SLEEP = 3000;
public static final int CHUNK_SPEED_QUEUE_MAX_SIZE = 10;
public static final int CHUNK_SPEED_QUEUE_MAX_SIZE = 20;
private static final Logger LOG = Logger.getLogger(SpeedMeter.class.getName());
private final JLabel _speed_label;
private final JLabel _rem_label;
@ -28,14 +28,14 @@ public class SpeedMeter implements Runnable {
private long _speed_acumulator;
private volatile long _max_avg_global_speed;
private volatile long _avg_chunk_speed;
private final CircularFifoQueue _chunk_speed_queue;
private final CircularFifoQueue _pepillo_chunk_speed_queue;
SpeedMeter(TransferenceManager trans_manager, JLabel sp_label, JLabel rem_label) {
_speed_label = sp_label;
_rem_label = rem_label;
_trans_manager = trans_manager;
_transferences = new ConcurrentHashMap<>();
_chunk_speed_queue = new CircularFifoQueue(CHUNK_SPEED_QUEUE_MAX_SIZE);
_pepillo_chunk_speed_queue = new CircularFifoQueue(CHUNK_SPEED_QUEUE_MAX_SIZE);
_speed_counter = 0L;
_speed_acumulator = 0L;
_max_avg_global_speed = 0L;
@ -56,22 +56,22 @@ public class SpeedMeter implements Runnable {
public void update_avg_chunk_speed(long speed) {
synchronized (_chunk_speed_queue) {
synchronized (_pepillo_chunk_speed_queue) {
this._chunk_speed_queue.add(speed);
this._pepillo_chunk_speed_queue.add(speed);
if (_chunk_speed_queue.size() == _chunk_speed_queue.maxSize()) {
if (_pepillo_chunk_speed_queue.size() == _pepillo_chunk_speed_queue.maxSize()) {
long acumulador = 0;
Iterator i = _chunk_speed_queue.iterator();
Iterator i = _pepillo_chunk_speed_queue.iterator();
while (i.hasNext()) {
acumulador += (long) i.next();
}
_avg_chunk_speed = Math.round(((double) acumulador) / _chunk_speed_queue.size());
_avg_chunk_speed = Math.round(((double) acumulador) / _pepillo_chunk_speed_queue.size());
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

After

Width:  |  Height:  |  Size: 194 KiB