diff options
author | Simon Rettberg | 2015-09-16 10:33:32 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-09-16 10:33:32 +0200 |
commit | f1cacdea3a5e222a202e741d8188ee4a641a6107 (patch) | |
tree | 2c608e50754070a49b2cba3fd6cfce103fa19d91 | |
parent | [server] Add missing index to imageversion table (diff) | |
download | tutor-module-f1cacdea3a5e222a202e741d8188ee4a641a6107.tar.gz tutor-module-f1cacdea3a5e222a202e741d8188ee4a641a6107.tar.xz tutor-module-f1cacdea3a5e222a202e741d8188ee4a641a6107.zip |
[server] Adjust priority of file transfers
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java | 4 | ||||
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/SyncTransferHandler.java | 22 |
2 files changed, 24 insertions, 2 deletions
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 0e62d9c8..7c521b56 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 @@ -22,6 +22,7 @@ import org.openslx.bwlp.sat.util.Constants; import org.openslx.bwlp.sat.util.FileSystem; import org.openslx.bwlp.sat.util.Formatter; import org.openslx.bwlp.sat.util.Identity; +import org.openslx.bwlp.sat.util.PrioThreadFactory; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; import org.openslx.bwlp.thrift.iface.TTransferRejectedException; import org.openslx.bwlp.thrift.iface.UserInfo; @@ -42,7 +43,8 @@ public class FileServer implements IncomingEvent { private final Listener sslListener; private final ThreadPoolExecutor transferPool = new ThreadPoolExecutor(1, Constants.MAX_UPLOADS - + Constants.MAX_DOWNLOADS, 1, TimeUnit.MINUTES, new ArrayBlockingQueue<Runnable>(1)); + + Constants.MAX_DOWNLOADS, 1, TimeUnit.MINUTES, new ArrayBlockingQueue<Runnable>(1), + new PrioThreadFactory("ClientTransferPool", Thread.NORM_PRIORITY - 2)); /** * All currently running uploads, indexed by token diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/SyncTransferHandler.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/SyncTransferHandler.java index 82c4ab9e..29f47e05 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/SyncTransferHandler.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/SyncTransferHandler.java @@ -13,6 +13,7 @@ import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.openslx.bwlp.sat.util.Constants; import org.openslx.bwlp.sat.util.Formatter; +import org.openslx.bwlp.sat.util.PrioThreadFactory; import org.openslx.bwlp.thrift.iface.ImagePublishData; import org.openslx.bwlp.thrift.iface.InvocationError; import org.openslx.bwlp.thrift.iface.TAuthorizationException; @@ -32,7 +33,8 @@ public class SyncTransferHandler { private static final ThreadPoolExecutor transferPool = new ThreadPoolExecutor(1, Constants.MAX_MASTER_UPLOADS + Constants.MAX_MASTER_DOWNLOADS, 1, TimeUnit.MINUTES, - new ArrayBlockingQueue<Runnable>(1)); + new ArrayBlockingQueue<Runnable>(1), new PrioThreadFactory("MasterTransferPool", + Thread.NORM_PRIORITY - 3)); /** * All currently running uploads, indexed by token @@ -129,4 +131,22 @@ public class SyncTransferHandler { } } + /** + * Get an upload instance by given token. + * + * @param uploadToken + * @return + */ + public static OutgoingDataTransfer getUploadByToken(String uploadToken) { + if (uploadToken == null) + return null; + return uploads.get(uploadToken); + } + + public static IncomingDataTransfer getDownloadByToken(String downloadToken) { + if (downloadToken == null) + return null; + return downloads.get(downloadToken); + } + } |