Skip to content

Commit

Permalink
Log memory & core usage
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Mar 23, 2017
1 parent 335b042 commit f1d9cad
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/java/de/tudarmstadt/ukp/dariah/pipeline/RunPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryType;
import java.text.MessageFormat;
import java.util.Date;
import java.util.LinkedList;
Expand All @@ -40,6 +44,7 @@
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -457,6 +462,13 @@ public static void main(String[] args) {

logger.debug("==== Starting new session ====");
logger.debug("Arguments: " + Joiner.on(' ').join(args));

logger.info(MessageFormat.format("Running on up to {0} cores, max heap is about {1} GB",
Runtime.getRuntime().availableProcessors(),
ManagementFactory.getMemoryPoolMXBeans().stream()
.filter(pool -> pool.getType().equals(MemoryType.HEAP))
.mapToLong(pool -> pool.getUsage().getMax())
.sum() / (1024.0 * 1024 * 1024)));

System.setErr(IoBuilder.forLogger(logger.getName() + ".stderr").setLevel(Level.WARN) .setMarker(MarkerManager.getMarker("STDERR")).buildPrintStream());
System.setOut(IoBuilder.forLogger(logger.getName() + ".stdout").setLevel(Level.DEBUG).setMarker(MarkerManager.getMarker("STDOUT")).buildPrintStream());
Expand All @@ -470,7 +482,7 @@ public static void main(String[] args) {
}
} catch (ParseException e) {
logger.error("Error when parsing command line arguments. Use\njava -jar pipeline.jar -help\n to get further information", e);
return;
return;
}

LinkedList<String> configFiles = new LinkedList<>();
Expand Down Expand Up @@ -533,7 +545,7 @@ public static void main(String[] args) {
System.exit(1);
}

printConfiguration(configFiles.toArray(new String[0]));
printConfiguration(configFiles.toArray(new String[0]));



Expand Down

0 comments on commit f1d9cad

Please sign in to comment.