Commit 5c99c016 authored by Michael Menzel's avatar Michael Menzel

Added settings class to store global paths to run the server on a custom server

parent cf0f79a6
......@@ -17,6 +17,7 @@
package de.thm.positionData;
import de.thm.misc.Genome;
import de.thm.spring.backend.Settings;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteStreamHandler;
......@@ -71,10 +72,7 @@ public class AssemblyGuesser {
assemblies.add(assembly.toString());
// get contigs file for each assembly
if (!System.getenv("HOME").contains("menzel"))
assemblies.forEach(a -> contigsPaths.add("/home/mmnz21/con/contigs_" + a));
else //on local pc:
assemblies.forEach(a -> contigsPaths.add( "/home/menzel/Desktop/THM/promotion/enhort/dat/" + a + "/inout/contigs"));
assemblies.forEach(a -> contigsPaths.add(Settings.getContigsPath() + "contigs_" + a));
Pattern p = Pattern.compile("[\r\n]");
......
......@@ -65,14 +65,10 @@ public final class BackendConnector {
private String secret;
BackendConnector(){
BackendConnector(String ip) {
this.port = 42412;
if (System.getenv("HOME").contains("menzel"))
this.ip = "127.0.0.1";
else
this.ip = "bioinf-ladon.mni.thm.de";
this.ip = ip;
id = clientID.getAndIncrement();
......
......@@ -53,7 +53,7 @@ public final class Session {
this.customTracks = customTracks;
StatisticsCollector.getInstance().addSessionC();
connector = new BackendConnector();
connector = new BackendConnector(Settings.getBackendip());
}
Session(String key, Date date) {
......@@ -61,7 +61,7 @@ public final class Session {
this.date = date;
StatisticsCollector.getInstance().addSessionC();
connector = new BackendConnector();
connector = new BackendConnector(Settings.getBackendip());
}
public String getKey() {
......
package de.thm.spring.backend;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.net.InetAddress;
import java.nio.file.Path;
public class Settings {
private static String contigsPath;
private static String backendip;
private static Path logfile;
private static Logger logger = LoggerFactory.getLogger(StatisticsCollector.class);
public static String getBackendip() {
return backendip;
}
public static void setBackendip(String ip) {
try {
InetAddress address = InetAddress.getByName(ip);
if (!address.isReachable(1000))
throw new Exception("Backend Server " + ip + " not reachable");
} catch (Exception e) {
logger.error("Exception {}", e.getMessage(), e);
}
Settings.backendip = ip;
}
public static Path getLogfile_path() {
return logfile;
}
public static void setLogfile_path(String logfile_path) {
Settings.logfile = new File(logfile_path).toPath().toAbsolutePath();
}
public static String getContigsPath() {
return contigsPath;
}
public static void setContigsPath(String contigsPath) {
if (!new File(contigsPath).exists())
logger.error("Exception {}", "Contigs path missing", "The contigs path " + contigsPath + " is missing");
Settings.contigsPath = contigsPath;
}
}
......@@ -20,7 +20,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
......@@ -37,7 +36,7 @@ import java.util.stream.Stream;
*/
public final class StatisticsCollector {
private static final StatisticsCollector instance = new StatisticsCollector(new File("/home/mmnz21/enhort.log").toPath());
private static final StatisticsCollector instance = new StatisticsCollector(Settings.getLogfile_path());
private final Path logPath;
private final Logger logger = LoggerFactory.getLogger(StatisticsCollector.class);
......@@ -72,7 +71,6 @@ public final class StatisticsCollector {
downloadCount = new AtomicInteger(0);
date = new Date();
saveStats();
try {
......@@ -97,7 +95,9 @@ public final class StatisticsCollector {
downloadCount = new AtomicInteger(Integer.parseInt(values[4]));
date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(values[5]);
lines.close();
} catch (ArrayIndexOutOfBoundsException e) {
logPath.toFile().delete();
logger.error("Exception {}", "Corrupt log file", "The logfile was corrupt and was deleted. Please restart the server to enable logging again");
} catch (IOException | ParseException e) {
logger.error("Exception {}", e.getMessage(), e);
......
......@@ -97,7 +97,7 @@ public class BatchController {
}
Comparator<TestResult> byPackage = Comparator.comparing(t -> t.getTrack().getPack());
Comparator<TestResult> byTrack = byPackage.thenComparing(Comparator.comparing(t -> t.getTrack().getName()));
Comparator<TestResult> byTrack = byPackage.thenComparing(t -> t.getTrack().getName());
Comparator<String> byIndex = Comparator.comparing(names::indexOf); // sort by index of names of user uploaded bed file names
for (MultipartFile mf : files) {
......@@ -164,6 +164,8 @@ public class BatchController {
List<Number> tmp = new ArrayList<>();
//TODO CSV:
//TODO real fold change
//csv.append(tr.getTrack().getName()).append(" Fold change (log2): ").append(tr.getEffectSize()).append(" In sites: ").append(tr.getMeasuredIn()).append(" In control: ").append(tr.getExpectedIn()).append(" Out sites: ").append(tr.getMeasuredOut()).append(" Out control: ").append(tr.getExpectedOut()).append(" P value: ").append(tr.getpValue());
csv.append(tr.getTrack().getName()).append(" Fold change (log2): ").append(tr.getEffectSize()).append(" In sites: ").append(tr.getMeasuredIn()).append(" In control: ").append(tr.getExpectedIn()).append(" Out sites: ").append(tr.getMeasuredOut()).append(" Out control: ").append(tr.getExpectedOut()).append(" P value: ").append(tr.getpValue());
csv.append(lb);
......
......@@ -17,6 +17,7 @@
package de.thm.spring.run;
import de.thm.spring.backend.Sessions;
import de.thm.spring.backend.Settings;
import de.thm.spring.backend.StatisticsCollector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -37,8 +38,14 @@ public class Webinterface {
public static void main(String[] args) {
/* Set up Settings */
Settings.setBackendip(args[0]);
Settings.setContigsPath(args[1]);
Settings.setLogfile_path(args[2]);
try {
SpringApplication.run(Webinterface.class, args);
Sessions.getInstance().addSession("monitorsession");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment