diff options
author | Simon Rettberg | 2016-01-26 15:17:34 +0100 |
---|---|---|
committer | Simon Rettberg | 2016-01-26 15:17:34 +0100 |
commit | 3df5abcbb9dfaa0ccc4f53d11978e88ae055b479 (patch) | |
tree | 0e8ee7006c1d75643b511fc5164da18b0928e841 /dozentenmodulserver/src | |
parent | [client] Fix NPE (diff) | |
download | tutor-module-3df5abcbb9dfaa0ccc4f53d11978e88ae055b479.tar.gz tutor-module-3df5abcbb9dfaa0ccc4f53d11978e88ae055b479.tar.xz tutor-module-3df5abcbb9dfaa0ccc4f53d11978e88ae055b479.zip |
[server] Implement per-user upload limit
Diffstat (limited to 'dozentenmodulserver/src')
3 files changed, 11 insertions, 3 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/RuntimeConfig.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/RuntimeConfig.java index 0a4c0165..3a0aaf79 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/RuntimeConfig.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/RuntimeConfig.java @@ -19,7 +19,7 @@ public class RuntimeConfig { satConfig.setMaxLectureValidityDays(220); satConfig.setPageSize(Paginator.PER_PAGE); satConfig.setMaxConnectionsPerTransfer(Constants.MAX_CONNECTIONS_PER_TRANSFER); - satConfig.setMaxTransfers(Constants.MAX_UPLOADS / 2); + satConfig.setMaxTransfers(Constants.MAX_UPLOADS_PER_USER); satConfig.setMaxLocationsPerLecture(4); } diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java index 45e299d1..49e02552 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java @@ -31,6 +31,7 @@ import org.openslx.filetransfer.Downloader; import org.openslx.filetransfer.IncomingEvent; import org.openslx.filetransfer.Listener; import org.openslx.filetransfer.Uploader; +import org.openslx.thrifthelper.Comparators; public class FileServer implements IncomingEvent { @@ -132,6 +133,7 @@ public class FileServer implements IncomingEvent { Iterator<IncomingDataTransfer> it = uploads.values().iterator(); final long now = System.currentTimeMillis(); int activeUploads = 0; + int activeUserUploads = 0; while (it.hasNext()) { IncomingDataTransfer upload = it.next(); if (upload.isComplete(now) || upload.hasReachedIdleTimeout(now)) { @@ -140,11 +142,15 @@ public class FileServer implements IncomingEvent { continue; } if (upload.countsTowardsConnectionLimit(now)) { + if (upload.getOwner() != null && Comparators.user.compare(owner, upload.getOwner()) == 0) { + activeUserUploads += 1; + } activeUploads += 1; } } - if (activeUploads >= Constants.MAX_UPLOADS) { - throw new TTransferRejectedException("Server busy. Too many running uploads (" + activeUploads + if (activeUploads >= Constants.MAX_UPLOADS || activeUserUploads > Constants.MAX_UPLOADS_PER_USER) { + throw new TTransferRejectedException("Server busy. Too many running uploads (User: " + + activeUserUploads + "/" + Constants.MAX_UPLOADS_PER_USER + "; Total: " + activeUploads + "/" + Constants.MAX_UPLOADS + ")."); } File destinationFile = null; 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 8bb356e1..a48faed1 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 @@ -13,6 +13,7 @@ public class Constants { public static final String INCOMPLETE_UPLOAD_SUFFIX = ".upload.partial"; public static final int MAX_UPLOADS; + public static final int MAX_UPLOADS_PER_USER; public static final int MAX_DOWNLOADS; public static final int MAX_CONNECTIONS_PER_TRANSFER; public static final int MAX_MASTER_UPLOADS = 2; @@ -71,6 +72,7 @@ public class Constants { MAX_CONNECTIONS_PER_TRANSFER = maxPerTransfer; MAX_UPLOADS = maxUploads; MAX_DOWNLOADS = MAX_UPLOADS * 2; + MAX_UPLOADS_PER_USER = Math.min(MAX_UPLOADS / 2, 4); HASHCHECK_QUEUE_LEN = hashQueueLen; } } |