diff options
author | Simon Rettberg | 2015-06-02 19:53:31 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-06-02 19:53:31 +0200 |
commit | 1bc83891c68ee269727e81a13cc70da698bcc7a7 (patch) | |
tree | b052a72ad7d65864068752f71c5ed2b49a171276 /dozentenmodulserver/src/main/java/util/Constants.java | |
parent | [server] Started work on the internal file server (diff) | |
download | tutor-module-1bc83891c68ee269727e81a13cc70da698bcc7a7.tar.gz tutor-module-1bc83891c68ee269727e81a13cc70da698bcc7a7.tar.xz tutor-module-1bc83891c68ee269727e81a13cc70da698bcc7a7.zip |
[server] Compiling again, still lots of stubs
Diffstat (limited to 'dozentenmodulserver/src/main/java/util/Constants.java')
-rw-r--r-- | dozentenmodulserver/src/main/java/util/Constants.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/dozentenmodulserver/src/main/java/util/Constants.java b/dozentenmodulserver/src/main/java/util/Constants.java new file mode 100644 index 00000000..8ac5dabd --- /dev/null +++ b/dozentenmodulserver/src/main/java/util/Constants.java @@ -0,0 +1,21 @@ +package util; + +import fileserv.FileChunk; + +public class Constants { + public static final String INCOMPLETE_UPLOAD_SUFFIX = ".part"; + public static final int MAX_UPLOADS; + + static { + long maxMem = Runtime.getRuntime().maxMemory(); + if (maxMem == Long.MAX_VALUE) { + // Apparently the JVM was started without a memory limit (no -Xmx cmdline), + // so we assume a default of 256MB + maxMem = 256l * 1024l * 1024l; + } + maxMem /= 1024l * 1024l; + // Now maxMem is the amount of memory in MiB + + MAX_UPLOADS = (int) Math.max(1, (maxMem - 64) / (FileChunk.CHUNK_SIZE_MIB + 1)); + } +} |