mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-16 20:12:02 +00:00
Configure swap compression method: bzip2 or gzip
This commit is contained in:
parent
8c0048b302
commit
169de1fead
4 changed files with 59 additions and 3 deletions
|
@ -26,6 +26,7 @@
|
|||
"minProjects": 50,
|
||||
"lowGiB": 128,
|
||||
"highGiB": 256,
|
||||
"intervalMillis": 3600000
|
||||
"intervalMillis": 3600000,
|
||||
"compressionMethod": "bzip2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"minProjects": 50,
|
||||
"lowGiB": 128,
|
||||
"highGiB": 256,
|
||||
"intervalMillis": 3600000
|
||||
"intervalMillis": 3600000,
|
||||
"compressionMethod": "bzip2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,46 @@ import java.util.Optional;
|
|||
*/
|
||||
public interface SwapJob {
|
||||
|
||||
enum CompressionMethod { Bzip2, Gzip }
|
||||
|
||||
static CompressionMethod stringToCompressionMethod(String compressionString) {
|
||||
if (compressionString == null) {
|
||||
return null;
|
||||
}
|
||||
CompressionMethod result;
|
||||
switch (compressionString) {
|
||||
case "gzip":
|
||||
result = CompressionMethod.Gzip;
|
||||
break;
|
||||
case "bzip2":
|
||||
result = CompressionMethod.Bzip2;
|
||||
break;
|
||||
default:
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static String compressionMethodAsString(CompressionMethod compressionMethod) {
|
||||
if (compressionMethod == null) {
|
||||
return null;
|
||||
}
|
||||
String result;
|
||||
switch (compressionMethod) {
|
||||
case Gzip:
|
||||
result = "gzip";
|
||||
break;
|
||||
case Bzip2:
|
||||
result = "bzip2";
|
||||
break;
|
||||
default:
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static SwapJob fromConfig(
|
||||
Optional<SwapJobConfig> cfg,
|
||||
ProjectLock lock,
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package uk.ac.ic.wlgitbridge.bridge.swap.job;
|
||||
|
||||
import uk.ac.ic.wlgitbridge.util.Log;
|
||||
import uk.ac.ic.wlgitbridge.bridge.swap.job.SwapJob.CompressionMethod;
|
||||
|
||||
/**
|
||||
* Created by winston on 23/08/2016.
|
||||
*/
|
||||
|
@ -9,17 +12,20 @@ public class SwapJobConfig {
|
|||
private final int lowGiB;
|
||||
private final int highGiB;
|
||||
private final long intervalMillis;
|
||||
private final String compressionMethod;
|
||||
|
||||
public SwapJobConfig(
|
||||
int minProjects,
|
||||
int lowGiB,
|
||||
int highGiB,
|
||||
long intervalMillis
|
||||
long intervalMillis,
|
||||
String compressionMethod
|
||||
) {
|
||||
this.minProjects = minProjects;
|
||||
this.lowGiB = lowGiB;
|
||||
this.highGiB = highGiB;
|
||||
this.intervalMillis = intervalMillis;
|
||||
this.compressionMethod = compressionMethod;
|
||||
}
|
||||
|
||||
public int getMinProjects() {
|
||||
|
@ -38,4 +44,12 @@ public class SwapJobConfig {
|
|||
return intervalMillis;
|
||||
}
|
||||
|
||||
public SwapJob.CompressionMethod getCompressionMethod() {
|
||||
CompressionMethod result = SwapJob.stringToCompressionMethod(compressionMethod);
|
||||
if (result == null) {
|
||||
Log.info("SwapJobConfig: un-supported compressionMethod '{}', default to 'bzip2'", compressionMethod);
|
||||
result = CompressionMethod.Bzip2;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue