diff --git a/skaha/build.gradle b/skaha/build.gradle index c6fe533e..31c2fb31 100644 --- a/skaha/build.gradle +++ b/skaha/build.gradle @@ -24,6 +24,10 @@ copy { into 'src/main/resources' } +tasks.withType(Copy) { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} + dependencies { providedCompile 'javax.servlet:javax.servlet-api:[3.1.0,)' diff --git a/skaha/src/main/java/org/opencadc/skaha/session/GetAction.java b/skaha/src/main/java/org/opencadc/skaha/session/GetAction.java index 390ddb4f..bf9f2553 100644 --- a/skaha/src/main/java/org/opencadc/skaha/session/GetAction.java +++ b/skaha/src/main/java/org/opencadc/skaha/session/GetAction.java @@ -214,13 +214,15 @@ private ResourceStats getResourceStats() throws Exception { String withRAMStr = String.valueOf(formatter.format(Double.valueOf(normalizeToLong(withRAM))/(1024 * 1024 * 1024))) + "G"; String maxRAMStr = String.valueOf(formatter.format(Double.valueOf(maxRAM)/(1024 * 1024 * 1024))) + "G"; */ - String withRAMStr = formatter.format(Double.valueOf( - (double) (normalizeToLong(withRAM)) / (1024 * 1024 * 1024))) + "G"; - String maxRAMStr = formatter.format(Double.valueOf((double) (maxRAM) / (1024 * 1024 * 1024))) + "G"; - String requestedRAMStr = formatter.format(requestedRAM) + "G"; - String ramAvailableStr = formatter.format(Double.valueOf((double) (ramAvailable) / (1024 * 1024 * 1024))) + "G"; - return new ResourceStats(desktopCount, headlessCount, totalCount, requestedCPUCores, requestedRAMStr, - coresAvailable, ramAvailableStr, maxCores, withRAMStr, maxRAMStr, withCores); +// String withRAMStr = formatter.format(Double.valueOf( +// (double) (normalizeToLong(withRAM)) / (1024 * 1024 * 1024))) + "G"; +// String maxRAMStr = formatter.format(Double.valueOf((double) (maxRAM) / (1024 * 1024 * 1024))) + "G"; +// String requestedRAMStr = formatter.format(requestedRAM) + "G"; +// String ramAvailableStr = formatter.format(Double.valueOf((double) (ramAvailable) / (1024 * 1024 * 1024))) + "G"; + return new ResourceStats(desktopCount, headlessCount, totalCount, requestedCPUCores, requestedRAM, + coresAvailable, ramAvailable, maxCores, + (double) (normalizeToLong(withRAM)) / (1024 * 1024 * 1024), + (double) (maxRAM) / (1024 * 1024 * 1024), withCores); } catch (Exception e) { log.error(e); throw new IllegalStateException("failed to gather resource statistics", e); diff --git a/skaha/src/main/java/org/opencadc/skaha/session/ResourceStats.java b/skaha/src/main/java/org/opencadc/skaha/session/ResourceStats.java index 1464f64d..9c41e2ff 100644 --- a/skaha/src/main/java/org/opencadc/skaha/session/ResourceStats.java +++ b/skaha/src/main/java/org/opencadc/skaha/session/ResourceStats.java @@ -73,41 +73,41 @@ * */ public class ResourceStats { - + private static final Logger log = Logger.getLogger(ResourceStats.class); - + private JobInstances instances; private Core cores; private Ram ram; - public ResourceStats(int desktopCount, int headlessCount, int totalCount, - Double requestedCPUCores, String requestedRAM, Double coresAvailable, String ramAvailable, - Double mCores, String withRAM, String mRAM, Double withCores) { + public ResourceStats(int desktopCount, int headlessCount, int totalCount, + Double requestedCPUCores, Double requestedRAMGB, Double coresAvailable, Double ramAvailableGB, + Double mCores, Double withRAMGB, Double mRAMGB, Double withCores) { instances = new JobInstances(desktopCount, headlessCount, totalCount); MaxCoreResource maxCores = new MaxCoreResource(); maxCores.cpuCores = mCores; - maxCores.withRam = withRAM; + maxCores.withRamGB = withRAMGB; cores = new Core(); cores.maxCPUCores = maxCores; cores.cpuCoresAvailable = coresAvailable; cores.requestedCPUCores = requestedCPUCores; MaxRamResource maxRAM = new MaxRamResource(); - maxRAM.ram = mRAM; + maxRAM.ramGB = mRAMGB; maxRAM.withCPUCores = withCores; ram = new Ram(); ram.maxRAM = maxRAM; - ram.ramAvailable = ramAvailable; - ram.requestedRAM = requestedRAM; + ram.ramAvailableGB = ramAvailableGB; + ram.requestedRAMGB = requestedRAMGB; } - + class JobInstances { private int session; private int desktopApp; private int headless; private int total; - + public JobInstances(int desktopCount, int headlessCount, int totalCount) { desktopApp = desktopCount; headless = headlessCount; @@ -115,27 +115,27 @@ public JobInstances(int desktopCount, int headlessCount, int totalCount) { session = totalCount - desktopCount - headlessCount; } } - + class Core { - Double requestedCPUCores = 0.0; - Double cpuCoresAvailable = 0.0; + Double requestedCPUCores = 0.0D; + Double cpuCoresAvailable = 0.0D; MaxCoreResource maxCPUCores; } - + class Ram { - String requestedRAM = "0G"; - String ramAvailable = "0G"; + Double requestedRAMGB = 0.0D; + Double ramAvailableGB = 0.0D; MaxRamResource maxRAM; } class MaxCoreResource { - public Double cpuCores = 0.0; - public String withRam = "0G"; + public Double cpuCores = 0.0D; + public Double withRamGB = 0.0D; } class MaxRamResource { - public String ram = "0G"; - - public Double withCPUCores = 0.0; + public Double ramGB = 0.0D; + + public Double withCPUCores = 0.0D; } } diff --git a/skaha/src/test/java/org/opencadc/skaha/session/GetActionTests.java b/skaha/src/test/java/org/opencadc/skaha/session/GetActionTests.java index 6d7d4178..8d187e35 100644 --- a/skaha/src/test/java/org/opencadc/skaha/session/GetActionTests.java +++ b/skaha/src/test/java/org/opencadc/skaha/session/GetActionTests.java @@ -98,11 +98,11 @@ public class GetActionTests { private static final long INVALID_VALUE = 6; private static final String NO_UNIT_VALUE_STR = String.valueOf(NO_UNIT_VALUE); - private static final String K_VALUE_STR = String.valueOf(2) + "K"; - private static final String M_VALUE_STR = String.valueOf(3) + "M"; - private static final String G_VALUE_STR = String.valueOf(4) + "G"; - private static final String T_VALUE_STR = String.valueOf(5) + "T"; - private static final String INVALID_VALUE_STR = String.valueOf(5) + "A"; + private static final String K_VALUE_STR = 2 + "K"; + private static final String M_VALUE_STR = 3 + "M"; + private static final String G_VALUE_STR = 4 + "G"; + private static final String T_VALUE_STR = 5 + "T"; + private static final String INVALID_VALUE_STR = 5 + "A"; public GetActionTests() { } @@ -127,7 +127,7 @@ public void testNormalizeToLong() { } } - class TestGetAction extends GetAction { + static class TestGetAction extends GetAction { } }