// Path: Framework/Manager/CodeOffload/src/main/java/cs/mc/ut/ee/allocation/Surrogate.java
// public class Surrogate {
// 	String jarFile;  //code to reconstruct the request in each component of the system
// 	
// 	LinkedList<String> apkPool;   //ports in which the app is listening
// 	
// 	String ipAddress; //surrogate address
// 	
// 	/*
// 	 *String accelerationType;       //other attributes about the server can be defined 
// 	 */
// 	  
// 	
// 	public Surrogate(LinkedList<String> apkPool, String ipAddress, String jarFile){
// 		setApkPool(apkPool);
// 		setSurrogateIP(ipAddress);
// 		setJarFile(jarFile);
// 	}
// 	
// 	public void setApkPool(LinkedList<String> apkPool){
// 		this.apkPool = apkPool;
// 	}
// 	
// 	public void setSurrogateIP(String surrogateIP){
// 		this.ipAddress = surrogateIP;
// 	
// 	}
// 	
// 	public LinkedList<String> getApkPool(){
// 		return this.apkPool;
// 	}
// 	
// 	public String getSurrogateIP(){
// 		return this.ipAddress;
// 	}
// 	
// 	public String getJarFile(){
// 		return this.jarFile;
// 	}
// 
// 	
// 	public void setJarFile(String jarFile){
// 		this.jarFile = jarFile;
// 	}
// 
// }


import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import cs.mc.ut.ee.allocation.Surrogate;
    			return resources.get(i);
    		}
    	}
    	return null;
    }
    
    
    /**
     * 
     * @param appName is the id of the app
     * @param backEnd contains the information about the surrogates that contain the app
     */
    private void addResource(String appName, List<Surrogate> backEnd){
    	resources.add(new AppResources(appName, backEnd));
		
    }
    
    
     /**
      * 
      * @param filePath contains the information about the APK files in each surrogate
      * AppName<IP<Ports,<value1,value2,...,valueN>>>
      * 
      * An APK file (AppName) can be in different surrogates (IPs), each APK file listen(s) in multiple ports (Ports).
      * 
      */
	 public void loadBackEndAPKS(String filePath){
		 InputStream in;
		 LinkedList<String> apkPool=null;
		 String path="";
// Path: Framework/Manager/CodeOffload/src/main/java/cs/mc/ut/ee/allocation/Surrogate.java
// public class Surrogate {
// 	String jarFile;  //code to reconstruct the request in each component of the system
// 	
// 	LinkedList<String> apkPool;   //ports in which the app is listening
// 	
// 	String ipAddress; //surrogate address
// 	
// 	/*
// 	 *String accelerationType;       //other attributes about the server can be defined 
// 	 */
// 	  
// 	
// 	public Surrogate(LinkedList<String> apkPool, String ipAddress, String jarFile){
// 		setApkPool(apkPool);
// 		setSurrogateIP(ipAddress);
// 		setJarFile(jarFile);
// 	}
// 	
// 	public void setApkPool(LinkedList<String> apkPool){
// 		this.apkPool = apkPool;
// 	}
// 	
// 	public void setSurrogateIP(String surrogateIP){
// 		this.ipAddress = surrogateIP;
// 	
// 	}
// 	
// 	public LinkedList<String> getApkPool(){
// 		return this.apkPool;
// 	}
// 	
// 	public String getSurrogateIP(){
// 		return this.ipAddress;
// 	}
// 	
// 	public String getJarFile(){
// 		return this.jarFile;
// 	}
// 
// 	
// 	public void setJarFile(String jarFile){
// 		this.jarFile = jarFile;
// 	}
// 
// }


// Path: Framework/Manager/CodeOffload/src/main/java/cs/mc/ut/ee/manager/FrontEnd.java
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import cs.mc.ut.ee.allocation.Surrogate;

    			return resources.get(i);
    		}
    	}
    	return null;
    }
    
    
    /**
     * 
     * @param appName is the id of the app
     * @param backEnd contains the information about the surrogates that contain the app
     */
    private void addResource(String appName, List<Surrogate> backEnd){
    	resources.add(new AppResources(appName, backEnd));
		
    }
    
    
     /**
      * 
      * @param filePath contains the information about the APK files in each surrogate
      * AppName<IP<Ports,<value1,value2,...,valueN>>>
      * 
      * An APK file (AppName) can be in different surrogates (IPs), each APK file listen(s) in multiple ports (Ports).
      * 
      */
	 public void loadBackEndAPKS(String filePath){
		 InputStream in;
		 LinkedList<String> apkPool=null;
		 String path="";
		 List<Surrogate> backEnd = null;