mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-28 12:30:23 +02:00
6.67
-More timeouts tunning
This commit is contained in:
parent
5587e2079a
commit
5b2bca7e54
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.tonikelope</groupId>
|
||||
<artifactId>MegaBasterd</artifactId>
|
||||
<version>6.66</version>
|
||||
<version>6.67</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -23,6 +23,7 @@ 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;
|
||||
@ -112,7 +113,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
int http_error = 0, http_status = -1, conta_error = 0;
|
||||
|
||||
boolean timeout = false, chunk_error = false, slow_proxy = false, turbo_mode = false;
|
||||
boolean chunk_error = false, slow_proxy = false, turbo_mode = false;
|
||||
|
||||
String worker_url = null;
|
||||
|
||||
@ -234,8 +235,6 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
chunk_error = true;
|
||||
|
||||
timeout = false;
|
||||
|
||||
slow_proxy = false;
|
||||
|
||||
File tmp_chunk_file = null, chunk_file = null;
|
||||
@ -270,27 +269,44 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
int reads = 0;
|
||||
|
||||
while (!_exit && !_download.isStopped() && !_download.getChunkmanager().isExit() && chunk_reads < chunk_size && (reads = is.read(buffer, 0, Math.min((int) (chunk_size - chunk_reads), buffer.length))) != -1) {
|
||||
if (!_exit && !_download.isStopped() && !_download.getChunkmanager().isExit()) {
|
||||
|
||||
tmp_chunk_file_os.write(buffer, 0, reads);
|
||||
int retry_timeout = 0;
|
||||
|
||||
chunk_reads += reads;
|
||||
do {
|
||||
|
||||
_download.getPartialProgress().add((long) reads);
|
||||
try {
|
||||
|
||||
_download.getProgress_meter().secureNotify();
|
||||
if ((reads = is.read(buffer, 0, Math.min((int) (chunk_size - chunk_reads), buffer.length))) != -1) {
|
||||
|
||||
if (_download.isPaused() && !_download.isStopped()) {
|
||||
tmp_chunk_file_os.write(buffer, 0, reads);
|
||||
|
||||
_download.pause_worker();
|
||||
chunk_reads += reads;
|
||||
|
||||
pause_init_time = System.currentTimeMillis();
|
||||
_download.getPartialProgress().add((long) reads);
|
||||
|
||||
secureWait();
|
||||
_download.getProgress_meter().secureNotify();
|
||||
|
||||
paused += System.currentTimeMillis() - pause_init_time;
|
||||
if (_download.isPaused() && !_download.isStopped()) {
|
||||
|
||||
}
|
||||
_download.pause_worker();
|
||||
|
||||
pause_init_time = System.currentTimeMillis();
|
||||
|
||||
secureWait();
|
||||
|
||||
paused += System.currentTimeMillis() - pause_init_time;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (SocketTimeoutException timeout_exception) {
|
||||
LOG.log(Level.WARNING, timeout_exception.getMessage());
|
||||
retry_timeout++;
|
||||
}
|
||||
|
||||
} while (!_exit && !_download.isStopped() && !_download.getChunkmanager().isExit() && chunk_reads < chunk_size && reads != -1 && retry_timeout <= READ_TIMEOUT_RETRY);
|
||||
|
||||
}
|
||||
|
||||
@ -362,10 +378,6 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
} catch (IOException ex) {
|
||||
|
||||
if (ex instanceof SocketTimeoutException) {
|
||||
timeout = true;
|
||||
}
|
||||
|
||||
LOG.log(Level.SEVERE, ex.getMessage());
|
||||
|
||||
} finally {
|
||||
@ -385,7 +397,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
||||
_download.getProgress_meter().secureNotify();
|
||||
}
|
||||
|
||||
if (!_exit && !_download.isStopped() && !timeout && (http_error != 509 || _current_smart_proxy != null) && http_error != 403 && http_error != 503) {
|
||||
if (!_exit && !_download.isStopped() && (http_error != 509 || _current_smart_proxy != null) && http_error != 403 && http_error != 503) {
|
||||
|
||||
_error_wait = true;
|
||||
|
||||
|
@ -9,6 +9,7 @@ import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -22,6 +23,8 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ChunkDownloaderMono.class.getName());
|
||||
|
||||
public static final int READ_TIMEOUT_RETRY = 3;
|
||||
|
||||
public ChunkDownloaderMono(Download download) {
|
||||
super(1, download);
|
||||
}
|
||||
@ -124,27 +127,38 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
||||
|
||||
if (!isExit() && !getDownload().isStopped() && cis != null) {
|
||||
|
||||
int reads = 0;
|
||||
int reads = 0, retry_timeout = 0;
|
||||
|
||||
while (!getDownload().isStopped() && chunk_reads < chunk_size && (reads = cis.read(buffer, 0, Math.min((int) (chunk_size - chunk_reads), buffer.length))) != -1) {
|
||||
do {
|
||||
|
||||
getDownload().getOutput_stream().write(buffer, 0, reads);
|
||||
try {
|
||||
|
||||
chunk_reads += reads;
|
||||
if ((reads = cis.read(buffer, 0, Math.min((int) (chunk_size - chunk_reads), buffer.length))) != -1) {
|
||||
|
||||
getDownload().getPartialProgress().add((long) reads);
|
||||
getDownload().getOutput_stream().write(buffer, 0, reads);
|
||||
|
||||
getDownload().getProgress_meter().secureNotify();
|
||||
chunk_reads += reads;
|
||||
|
||||
if (getDownload().isPaused() && !getDownload().isStopped()) {
|
||||
getDownload().getPartialProgress().add((long) reads);
|
||||
|
||||
getDownload().pause_worker_mono();
|
||||
getDownload().getProgress_meter().secureNotify();
|
||||
|
||||
secureWait();
|
||||
if (getDownload().isPaused() && !getDownload().isStopped()) {
|
||||
|
||||
getDownload().pause_worker_mono();
|
||||
|
||||
secureWait();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (SocketTimeoutException timeout_exception) {
|
||||
LOG.log(Level.WARNING, timeout_exception.getMessage());
|
||||
|
||||
retry_timeout++;
|
||||
}
|
||||
|
||||
}
|
||||
} while (!getDownload().isStopped() && chunk_reads < chunk_size && reads != -1 && retry_timeout <= READ_TIMEOUT_RETRY);
|
||||
|
||||
if (chunk_reads == chunk_size) {
|
||||
|
||||
|
@ -10,6 +10,7 @@ import java.io.RandomAccessFile;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.util.logging.Level;
|
||||
@ -23,6 +24,7 @@ import javax.crypto.CipherInputStream;
|
||||
public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
public static final int MAX_CHUNK_ERROR = 100;
|
||||
public static final int READ_TIMEOUT_RETRY = 3;
|
||||
private static final Logger LOG = Logger.getLogger(ChunkUploader.class.getName());
|
||||
private final int _id;
|
||||
private final Upload _upload;
|
||||
@ -214,17 +216,28 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
||||
if (chunk_offset + chunk_size == _upload.getFile_size()) {
|
||||
LOG.log(Level.INFO, "{0} Worker {1} {2} waiting for completion handler...", new Object[]{Thread.currentThread().getName(), _id, _upload.getFile_name()});
|
||||
|
||||
String httpresponse;
|
||||
String httpresponse = null;
|
||||
|
||||
try (InputStream is = con.getInputStream(); ByteArrayOutputStream byte_res = new ByteArrayOutputStream()) {
|
||||
|
||||
while ((reads = is.read(buffer)) != -1) {
|
||||
int retry_timeout = 0;
|
||||
|
||||
byte_res.write(buffer, 0, reads);
|
||||
do {
|
||||
try {
|
||||
|
||||
if ((reads = is.read(buffer)) != -1) {
|
||||
byte_res.write(buffer, 0, reads);
|
||||
}
|
||||
} catch (SocketTimeoutException timeout_exception) {
|
||||
LOG.log(Level.WARNING, timeout_exception.getMessage());
|
||||
retry_timeout++;
|
||||
}
|
||||
|
||||
} while (reads != -1 && retry_timeout <= READ_TIMEOUT_RETRY);
|
||||
|
||||
if (retry_timeout <= READ_TIMEOUT_RETRY) {
|
||||
httpresponse = new String(byte_res.toByteArray(), "UTF-8");
|
||||
}
|
||||
|
||||
httpresponse = new String(byte_res.toByteArray(), "UTF-8");
|
||||
|
||||
}
|
||||
|
||||
if (httpresponse.length() > 0) {
|
||||
|
@ -53,7 +53,7 @@ import javax.swing.UIManager;
|
||||
*/
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION = "6.66";
|
||||
public static final String VERSION = "6.67";
|
||||
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;
|
||||
|
@ -10,9 +10,9 @@ public interface Transference {
|
||||
|
||||
int MIN_WORKERS = 1;
|
||||
int MAX_WORKERS = 20;
|
||||
int HTTP_CONNECT_TIMEOUT = 15000;
|
||||
int HTTP_CONNECT_TIMEOUT = 10000;
|
||||
int HTTP_PROXY_CONNECT_TIMEOUT = 15000;
|
||||
int HTTP_READ_TIMEOUT = 15000;
|
||||
int HTTP_READ_TIMEOUT = 10000;
|
||||
int HTTP_PROXY_READ_TIMEOUT = 15000;
|
||||
int MAX_SIM_TRANSFERENCES = 20;
|
||||
int SIM_TRANSFERENCES_DEFAULT = 4;
|
||||
|
@ -26,7 +26,7 @@ import javax.swing.JComponent;
|
||||
*/
|
||||
public class Upload implements Transference, Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
public static final int HTTP_READ_TIMEOUT = 30000;
|
||||
public static final int HTTP_READ_TIMEOUT = 60000;
|
||||
public static final int WORKERS_DEFAULT = 6;
|
||||
public static final int CHUNK_SIZE_MULTI = 1; //Otra cosa da errores al reanudar una subida (investigar)
|
||||
private static final Logger LOG = Logger.getLogger(Upload.class.getName());
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 219 KiB After Width: | Height: | Size: 217 KiB |
Loading…
x
Reference in New Issue
Block a user