diff options
author | Simon Rettberg | 2015-09-30 16:12:59 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-09-30 16:12:59 +0200 |
commit | 60e4edb0e128afb1732ac6a256001d100779e81a (patch) | |
tree | a0fea50dcee42c0edbfedb927051cc12d1d2aca7 /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Constants.java | |
parent | [server] Fix transfer timeout detection and active counting (diff) | |
download | tutor-module-60e4edb0e128afb1732ac6a256001d100779e81a.tar.gz tutor-module-60e4edb0e128afb1732ac6a256001d100779e81a.tar.xz tutor-module-60e4edb0e128afb1732ac6a256001d100779e81a.zip |
[server] Add missing constant
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Constants.java')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Constants.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Constants.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Constants.java index e45273db..8bb356e1 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Constants.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Constants.java @@ -14,6 +14,7 @@ public class Constants { public static final String INCOMPLETE_UPLOAD_SUFFIX = ".upload.partial"; public static final int MAX_UPLOADS; public static final int MAX_DOWNLOADS; + public static final int MAX_CONNECTIONS_PER_TRANSFER; public static final int MAX_MASTER_UPLOADS = 2; public static final int MAX_MASTER_DOWNLOADS = 3; public static final int TRANSFER_TIMEOUT = 15 * 1000; // 15s @@ -48,14 +49,28 @@ public class Constants { // Now maxMem is the amount of memory in MiB LOGGER.debug("Maximum JVM memory: " + maxMem + "MiB"); - MAX_UPLOADS = (int) Math.max(1, (maxMem - 64) / (FileChunk.CHUNK_SIZE_MIB * 2)); - MAX_DOWNLOADS = MAX_UPLOADS * 2; + int cpuCount = Runtime.getRuntime().availableProcessors(); int hashQueueLen = (int) (maxMem / 100); if (hashQueueLen < 1) { hashQueueLen = 1; } else if (hashQueueLen > 6) { hashQueueLen = 6; } + int maxPerTransfer = (int) Math.max(1, (maxMem - 400) / (FileChunk.CHUNK_SIZE_MIB * 8)); + if (maxPerTransfer > 4) { + maxPerTransfer = 4; + } + if (maxPerTransfer > cpuCount) { + maxPerTransfer = cpuCount; + } + int maxUploads = (int) Math.max(1, (maxMem - 64) / (FileChunk.CHUNK_SIZE_MIB * (hashQueueLen + 1))); + if (maxUploads > cpuCount * 4) { + maxUploads = cpuCount * 4; + } + + MAX_CONNECTIONS_PER_TRANSFER = maxPerTransfer; + MAX_UPLOADS = maxUploads; + MAX_DOWNLOADS = MAX_UPLOADS * 2; HASHCHECK_QUEUE_LEN = hashQueueLen; } } |