package org.apache.hadoo.yarn.server.resourcemanager.dockermonitor;

import java.util.HashMap;
import java.util.Map;

import org.apache.hadoop.yarn.api.records.Resource;

public class DockerCommand {
	
	static int DEHYDRATE = 00; 
	static int RESUME    = 01;
	static int UPDATE    = 02;
	
	String containerId;
	
	//updated resource
	Resource resource;

	//command type, now we support 3 commands
	int type;
	
	public DockerCommand(String id, Resource resource, int type){
		this.containerId = id;
		this.resource    = resource;
		this.type        = type;
	}
	
	public String getContainerId() {
		return containerId;
	}

	public Resource getResource() {
		return resource;
	}

	public int getType() {
		return type;
	}
	
	static Map<String,String> commandToMap(DockerCommand command){
		Map<String,String> dockerCommand = new HashMap<String,String>();
		dockerCommand.put("containerId", command.getContainerId());
		dockerCommand.put("commandType", Integer.toString(command.getType()));
		dockerCommand.put("resource.memory", Integer.toString(command.getResource().getMemory()));
		dockerCommand.put("resource.cores", Integer.toString(command.getResource().getVirtualCores()));
		return dockerCommand;
	}
}

@@ -844,16 +844,80 @@
 ing%3E();%0A
+%09%09dockerCommand.put(%22__name__%22, DockerCommand.class.getName());%0A
 %09%09docker
@@ -1037,32 +1037,130 @@
 .getType()));%0A%09%09
+%0A%09%09if(command.getResource().getMemory() %3E 0 && command.getResource().getVirtualCores() %3E 0)%7B%0A%09%09   
 dockerCommand.pu
@@ -1232,24 +1232,27 @@
 mory()));%0A%09%09
+   
 dockerComman
@@ -1267,16 +1267,17 @@
 esource.
+v
 cores%22, 
@@ -1336,16 +1336,130 @@
 es()));%0A
+%09%09%7Delse%7B%0A%09%09   dockerCommand.put(%22resource.memory%22,   %22-1%22);%0A%09%09   dockerCommand.put(%22resource.vcores%22, %22-1%22);%09%0A%09%09%7D%0A
 %09%09return

add yarn command java -1