package com.hubspot.singularity;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public class SingularitySlaveUsage {

  private final long memoryBytesUsed;
  private final int numTasks;
  private final long timestamp;
  private final double cpusUsed;

  @JsonCreator
  public SingularitySlaveUsage(@JsonProperty("memoryBytesUsed") long memoryBytesUsed, @JsonProperty("timestamp") long timestamp, @JsonProperty("cpusUsed") double cpusUsed,
      @JsonProperty("numTasks") int numTasks) {
    this.memoryBytesUsed = memoryBytesUsed;
    this.timestamp = timestamp;
    this.cpusUsed = cpusUsed;
    this.numTasks = numTasks;
  }

  public long getMemoryBytesUsed() {
    return memoryBytesUsed;
  }

  public long getTimestamp() {
    return timestamp;
  }

  public double getCpusUsed() {
    return cpusUsed;
  }

  public int getNumTasks() {
    return numTasks;
  }

  @Override
  public String toString() {
    return "SingularitySlaveUsage [memoryBytesUsed=" + memoryBytesUsed + ", numTasks=" + numTasks + ", timestamp=" + timestamp + ", cpusUsed=" + cpusUsed + "]";
  }

}

@@ -27,16 +27,66 @@
 arity;%0A%0A
+import java.util.Map;%0Aimport java.util.Optional;%0A%0A
 import c
@@ -223,16 +223,130 @@
 sage %7B%0A%0A
+  public static final String CPU_USED = %22cpusUsed%22;%0A  public static final String MEMORY_USED = %22memoryRssBytes%22;%0A%0A
   privat
@@ -469,16 +469,178 @@
 pusUsed;
+%0A  private final Optional%3CLong%3E memoryTotal;%0A  private final Optional%3CDouble%3E cpuTotal;%0A  private final Map%3CRequestType, Map%3CString, Number%3E%3E usagePerRequestType;
 %0A%0A  @Jso
@@ -733,16 +733,47 @@
 tesUsed,
+%0A                              
  @JsonPr
@@ -807,16 +807,47 @@
 mestamp,
+%0A                              
  @JsonPr
@@ -878,24 +878,49 @@
 e cpusUsed,%0A
+                         
       @JsonP
@@ -951,16 +951,315 @@
 numTasks
+,%0A                               @JsonProperty(%22memoryTotal%22) Optional%3CLong%3E memoryTotal,%0A                               @JsonProperty(%22cpuTotal%22) Optional%3CDouble%3E cpuTotal,%0A                               @JsonProperty(%22usagePerRequestType%22) Map%3CRequestType, Map%3CString, Number%3E%3E usagePerRequestType
 ) %7B%0A    
@@ -1386,24 +1386,142 @@
 = numTasks;%0A
+    this.memoryTotal = memoryTotal;%0A    this.cpuTotal = cpuTotal;%0A    this.usagePerRequestType = usagePerRequestType;%0A
   %7D%0A%0A  publi
@@ -1754,16 +1754,573 @@
 s;%0A  %7D%0A%0A
+  public Optional%3CLong%3E getMemoryTotal() %7B%0A    // todo: this is in megabytes%0A    return memoryTotal;%0A  %7D%0A%0A  public Optional%3CDouble%3E getCpuTotal() %7B%0A    return cpuTotal;%0A  %7D%0A%0A  public Map%3CRequestType, Map%3CString, Number%3E%3E getUsagePerRequestType() %7B%0A    return usagePerRequestType;%0A  %7D%0A%0A  public double getCpusUsedForRequestType(RequestType type) %7B%0A    return usagePerRequestType.get(type).get(CPU_USED).doubleValue();%0A  %7D%0A%0A  public long getMemUsedForRequestType(RequestType type) %7B%0A    return usagePerRequestType.get(type).get(MEMORY_USED).longValue();%0A  %7D%0A%0A
   @Overr

add usage by request type