-Upload speed improve (BufferInputStream)
-GUI fix
This commit is contained in:
tonikelope 2019-09-26 18:12:40 +02:00
parent 51f029f2f6
commit 62e56ef8cb
8 changed files with 12 additions and 73 deletions

View File

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

View File

@ -1,6 +1,7 @@
package com.tonikelope.megabasterd;
import static com.tonikelope.megabasterd.CryptTools.*;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@ -172,7 +173,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
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});

View File

@ -1008,6 +1008,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog implements File
skip_rest_button.setEnabled(true);
dir_name_textfield.setEnabled(true);
dir_name_label.setEnabled(true);
upload_log_checkbox.setEnabled(true);
}
}

View File

@ -50,7 +50,7 @@ import javax.swing.UIManager;
*/
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 DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
public static final int STREAMER_PORT = 1337;
@ -386,8 +386,6 @@ public final class MainPanel {
long max_memory = instance.maxMemory();
if (used_memory < ((double) max_memory) * FORCE_GARBAGE_COLLECTION_MAX_MEMORY_PERCENT) {
swingInvoke(new Runnable() {
@Override
public void run() {
@ -397,50 +395,6 @@ public final class MainPanel {
}
});
} 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 {
Thread.sleep(2000);
} catch (InterruptedException ex) {

View File

@ -23,7 +23,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.management.ManagementFactory;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
import java.math.BigInteger;
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 Object PASS_LOCK = new Object();
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>() {
@Override
@ -116,22 +116,6 @@ public final class MiscTools {
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) {
Font font = null;

View File

@ -700,7 +700,6 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
_frozen = true;
}
}
synchronized (getWait_queue_lock()) {

View File

@ -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 (_upload.getMain_panel().isExit()) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 183 KiB