mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-29 13:00:15 +02:00
6.45
-Upload speed improve (BufferInputStream) -GUI fix
This commit is contained in:
parent
51f029f2f6
commit
62e56ef8cb
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.tonikelope</groupId>
|
<groupId>com.tonikelope</groupId>
|
||||||
<artifactId>MegaBasterd</artifactId>
|
<artifactId>MegaBasterd</artifactId>
|
||||||
<version>6.44</version>
|
<version>6.45</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.tonikelope.megabasterd;
|
package com.tonikelope.megabasterd;
|
||||||
|
|
||||||
import static com.tonikelope.megabasterd.CryptTools.*;
|
import static com.tonikelope.megabasterd.CryptTools.*;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -172,7 +173,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
f.seek(chunk_offset);
|
f.seek(chunk_offset);
|
||||||
|
|
||||||
try (CipherInputStream cis = new CipherInputStream(Channels.newInputStream(f.getChannel()), genCrypter("AES", "AES/CTR/NoPadding", _upload.getByte_file_key(), forwardMEGALinkKeyIV(_upload.getByte_file_iv(), chunk_offset))); OutputStream out = new ThrottledOutputStream(con.getOutputStream(), _upload.getMain_panel().getStream_supervisor())) {
|
try (CipherInputStream cis = new CipherInputStream(new BufferedInputStream(Channels.newInputStream(f.getChannel())), genCrypter("AES", "AES/CTR/NoPadding", _upload.getByte_file_key(), forwardMEGALinkKeyIV(_upload.getByte_file_iv(), chunk_offset))); OutputStream out = new ThrottledOutputStream(con.getOutputStream(), _upload.getMain_panel().getStream_supervisor())) {
|
||||||
|
|
||||||
LOG.log(Level.INFO, "{0} Uploading chunk {1} from worker {2}...", new Object[]{Thread.currentThread().getName(), chunk_id, _id});
|
LOG.log(Level.INFO, "{0} Uploading chunk {1} from worker {2}...", new Object[]{Thread.currentThread().getName(), chunk_id, _id});
|
||||||
|
|
||||||
|
@ -1008,6 +1008,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog implements File
|
|||||||
skip_rest_button.setEnabled(true);
|
skip_rest_button.setEnabled(true);
|
||||||
dir_name_textfield.setEnabled(true);
|
dir_name_textfield.setEnabled(true);
|
||||||
dir_name_label.setEnabled(true);
|
dir_name_label.setEnabled(true);
|
||||||
|
upload_log_checkbox.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ import javax.swing.UIManager;
|
|||||||
*/
|
*/
|
||||||
public final class MainPanel {
|
public final class MainPanel {
|
||||||
|
|
||||||
public static final String VERSION = "6.44";
|
public static final String VERSION = "6.45";
|
||||||
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
||||||
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
|
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
|
||||||
public static final int STREAMER_PORT = 1337;
|
public static final int STREAMER_PORT = 1337;
|
||||||
@ -386,60 +386,14 @@ public final class MainPanel {
|
|||||||
|
|
||||||
long max_memory = instance.maxMemory();
|
long max_memory = instance.maxMemory();
|
||||||
|
|
||||||
if (used_memory < ((double) max_memory) * FORCE_GARBAGE_COLLECTION_MAX_MEMORY_PERCENT) {
|
swingInvoke(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
swingInvoke(new Runnable() {
|
_view.getMemory_status().setText(MiscTools.formatBytes(used_memory) + " / " + MiscTools.formatBytes(max_memory));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
_view.getMemory_status().setText(MiscTools.formatBytes(used_memory) + " / " + MiscTools.formatBytes(max_memory));
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
swingInvoke(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
_view.getMemory_status().setText("(!) " + MiscTools.formatBytes(used_memory) + " / " + MiscTools.formatBytes(max_memory));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!_forcing_gc) {
|
|
||||||
|
|
||||||
_forcing_gc = true;
|
|
||||||
|
|
||||||
THREAD_POOL.execute(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
long used_memory = instance.totalMemory() - instance.freeMemory();
|
|
||||||
|
|
||||||
long max_memory = instance.maxMemory();
|
|
||||||
|
|
||||||
while (used_memory >= ((double) max_memory) * FORCE_GARBAGE_COLLECTION_MAX_MEMORY_PERCENT) {
|
|
||||||
|
|
||||||
Logger.getLogger(MainPanelView.class.getName()).log(Level.INFO, "Forcing garbage collection...");
|
|
||||||
|
|
||||||
MiscTools.force_garbage_collection();
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(15000);
|
|
||||||
} catch (InterruptedException ex) {
|
|
||||||
Logger.getLogger(MainPanelView.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
used_memory = instance.totalMemory() - instance.freeMemory();
|
|
||||||
|
|
||||||
max_memory = instance.maxMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
_forcing_gc = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
|
@ -23,7 +23,6 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
@ -88,6 +87,7 @@ public final class MiscTools {
|
|||||||
public static final int EXP_BACKOFF_MAX_WAIT_TIME = 16;
|
public static final int EXP_BACKOFF_MAX_WAIT_TIME = 16;
|
||||||
public static final Object PASS_LOCK = new Object();
|
public static final Object PASS_LOCK = new Object();
|
||||||
public static final int HTTP_TIMEOUT = 30;
|
public static final int HTTP_TIMEOUT = 30;
|
||||||
|
private static volatile boolean _forcing_gc = false;
|
||||||
private static final Comparator<DefaultMutableTreeNode> TREE_NODE_COMPARATOR = new Comparator< DefaultMutableTreeNode>() {
|
private static final Comparator<DefaultMutableTreeNode> TREE_NODE_COMPARATOR = new Comparator< DefaultMutableTreeNode>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,22 +116,6 @@ public final class MiscTools {
|
|||||||
Files.delete(path);
|
Files.delete(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void force_garbage_collection() {
|
|
||||||
|
|
||||||
Object obj = new Object();
|
|
||||||
|
|
||||||
WeakReference ref = new WeakReference<Object>(obj);
|
|
||||||
|
|
||||||
do {
|
|
||||||
|
|
||||||
System.gc();
|
|
||||||
|
|
||||||
obj = null;
|
|
||||||
|
|
||||||
} while (ref.get() != null);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Font createAndRegisterFont(String name) {
|
public static Font createAndRegisterFont(String name) {
|
||||||
|
|
||||||
Font font = null;
|
Font font = null;
|
||||||
|
@ -700,7 +700,6 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
|||||||
_frozen = true;
|
_frozen = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (getWait_queue_lock()) {
|
synchronized (getWait_queue_lock()) {
|
||||||
|
@ -180,7 +180,7 @@ public final class UploadMACGenerator implements Runnable, SecureSingleThreadNot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.log(Level.INFO, "{0} MAC GENERATOR {1} finished MAC CALCULATION. Waiting workers to finish uploading...", new Object[]{Thread.currentThread().getName(), this.getUpload().getFile_name()});
|
LOG.log(Level.INFO, "{0} MAC GENERATOR {1} finished MAC CALCULATION. Waiting workers to finish uploading (if any)...", new Object[]{Thread.currentThread().getName(), this.getUpload().getFile_name()});
|
||||||
|
|
||||||
while (!_exit && !_upload.isStopped() && !_upload.getChunkworkers().isEmpty()) {
|
while (!_exit && !_upload.isStopped() && !_upload.getChunkworkers().isEmpty()) {
|
||||||
while (_upload.getMain_panel().isExit()) {
|
while (_upload.getMain_panel().isExit()) {
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 217 KiB After Width: | Height: | Size: 183 KiB |
Loading…
x
Reference in New Issue
Block a user