SlurmModeStageExecutor extends CheckpointedStageExecutor { public static int javaToSlurmGBRequest(String mem) { if (!mem.startsWith("-Xmx")) { throw new IllegalArgumentException("Should be given a Java Memory Spec: -Xmx???U, but found: " + mem); } char last = Character.toLowerCase(mem.charAt(mem.length() - 1)); long base; switch (last) { case 'm': base = MB; break; case 'g': base = GB; break; default: throw new IllegalArgumentException("Unknown memory unit: " + last + " found in " + mem); } double gbRequested = 0; try { String toParse = mem.substring(4, mem.length() - 1); long untypedReq = Long.parseLong(toParse); gbRequested = ((double) untypedReq * base) / (double) GB; } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Unknown memory unit: " + last + " found in " + mem); } gbRequested += 0.5; return Math.max((int) Math.ceil(gbRequested), 1); } SlurmModeStageExecutor(String[] args); void setMemoryUsage(String memory_x, String memory_s); @Override void shutdown(); static int javaToSlurmGBRequest(String mem); @Override StageExecutionStatus submit(String stageName, ArrayList<String> jobPaths,
                                       String temporary); public boolean verbose; public String command; public String classPath; static final String MEMORY_X; static final String MEMORY_S; static final String DEFAULT_ENCODING; static final String NODE_TEMP_DIR; public String memory_x; public String memory_s; public String nodeTempDir; static long MB; static long GB; }
@Test public void javaToSlurmGBRequest() throws Exception { assertEquals(3, SlurmModeStageExecutor.javaToSlurmGBRequest("-Xmx1700m")); assertEquals(3, SlurmModeStageExecutor.javaToSlurmGBRequest("-Xmx2400m")); assertEquals(1, SlurmModeStageExecutor.javaToSlurmGBRequest("-Xmx512m")); assertEquals(2, SlurmModeStageExecutor.javaToSlurmGBRequest("-Xmx513m")); assertEquals(8, SlurmModeStageExecutor.javaToSlurmGBRequest("-Xmx7G")); }