package com.neverwinterdp.hadoop.yarn.app.worker;

import java.io.Serializable;
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.NodeId;

public class AppWorkerContainerInfo implements Serializable {
  private int    containerId ;
  private String nodeId ;
  private int    memory ;
  private int    cores ;
  private List<String> commands ;
  private AppWorkerContainerProgressStatus progressStatus ;
  private Map<String, Object> reports  = new HashMap<String, Object> () ;
  
  public AppWorkerContainerInfo() {}
      
  public AppWorkerContainerInfo(Container container, List<String> commands) {
    nodeId = container.getNodeId().toString() ;
    this.containerId = container.getId().getId() ;
    this.memory = container.getResource().getMemory() ;
    this.cores = container.getResource().getVirtualCores() ;
    this.commands = commands ;
    this.progressStatus = new AppWorkerContainerProgressStatus(AppWorkerContainerState.ALLOCATED) ;
  }

  public int getContainerId() { return containerId; }
  
  public void setContainerId(int containerId) {
    this.containerId = containerId ;
  }
  
  public String getNodeId() { return nodeId; }
  public void setNodeId(String nodeId) { this.nodeId = nodeId ; }

  public int getMemory() { return memory; }
  public void setMemory(int memory) { this.memory = memory; }

  public int getCores() { return cores; }
  public void setCores(int cores) { this.cores = cores; }

  public List<String> getCommands() { return commands; }
  public void setCommands(List<String> commands) { this.commands = commands; }

  public AppWorkerContainerProgressStatus getProgressStatus() { return progressStatus; }
  public void setProgressStatus(AppWorkerContainerProgressStatus progressStatus) {
    this.progressStatus = progressStatus;
  }
  
  
}
@@ -77,43 +77,8 @@
 le;%0A
-import java.net.InetSocketAddress;%0A
 impo
@@ -99,16 +99,16 @@
 ashMap;%0A
+
 import j
@@ -201,113 +201,8 @@
 ner;
-%0Aimport org.apache.hadoop.yarn.api.records.ContainerId;%0Aimport org.apache.hadoop.yarn.api.records.NodeId;
 %0A%0Apu
@@ -485,22 +485,28 @@
 String, 
-Object
+Serializable
 %3E report
@@ -534,14 +534,20 @@
 ng, 
-Object
+Serializable
 %3E ()
@@ -1630,24 +1630,386 @@
 ommands; %7D%0A%0A
+  public void setReport(String name, Serializable report) %7B%0A    reports.put(name, report) ;%0A  %7D%0A  %0A  /**json serializer may need to have get/set method so I create get/set. should use add report method*/%0A  public Map%3CString, Object%3E getReports() %7B%0A    return reports;%0A  %7D%0A%0A  public void setReports(Map%3CString, Object%3E reports) %7B%0A    this.reports = reports;%0A  %7D%0A%0A
   public App

add reports holder