Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use numbers for RAM output. #493

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions skaha/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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,)'

Expand Down
16 changes: 9 additions & 7 deletions skaha/src/main/java/org/opencadc/skaha/session/GetAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
44 changes: 22 additions & 22 deletions skaha/src/main/java/org/opencadc/skaha/session/ResourceStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,69 +73,69 @@
*
*/
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;
total = 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand All @@ -127,7 +127,7 @@ public void testNormalizeToLong() {
}
}

class TestGetAction extends GetAction {
static class TestGetAction extends GetAction {

}
}