Commits

Cristian Viorel Pasat  committed bb0b384 Draft

(no commit message)mfnhvbdvhmbdvjhdbmvndmnvdb

  • Participants

Comments (0)

Files changed (19)

File docs/all_tasks_variables.txt

+
+min_resource_load ,
+
+max_resource_load ,
+
+min_resource_load_id ,
+
+max_resource_load_id ,
+
+max_resource_load_threshold ,
+
+min_resource_load_threshold ,
+
+min_transport_cost ,
+
+max_transport_cost ,
+
+min_transport_cost_resource_id,
+
+max_transport_cost_resource_id,
+
+min_total_resource_execution_time ,
+
+max_total_resource_execution_time ,
+min_total_resource_execution_time_id ,
+
+max_total_resource_execution_time_id 

File docs/infile.json

+
+{
+    "from_machine":
+        {
+            "condition": "if (resource_load>90 && monetary_cost>0.8) return true else return false",
+            single_task_variables:
+                [ "resource_load", "monetary_cost"],
+
+        },
+    "to_machine":
+        {
+            "condition": "if (resource_load==min_resource_load && monetary_cost==min_monetary_cost)",
+            single_task_variables:
+                [ "resource_load","monetary_cost" ],
+            all_tasks_variables:
+                [ "min_resource_load","min_resource_load_threshold" ],
+        }
+}

File docs/single_task_variables.txt

+
+resource_load,
+
+monetary_cost ,
+
+transport_cost ,
+
+resource_execution_cost 
+		... use this piece of software?
+		
+		
+Pretty simple: the TestClass in package main holds the main method.
+Using it you can do wonderful things! (more or less related to this programs' scope.
+
+
+This program is used to read the data from a json file, 
+populate it's related beans accordingly and provide methods 
+for calculating resource load and relocation cost.
+
+The content of the packages otherClasses and allTasksVariablesComputator
+contain the main classes while the packages Beans and fileIO
+represent the dependencies.
+
+
+PopulateBean is used to read the the json file 
+located in the docs folder verify it's content and populate the class
+GigaBean.
+At the creation of a PopulateBean object, the content of the json is 
+compared to the data found in the files all_tasks_variables.txt and 
+single_task_variables.txt found in the docs folder. 
+
+GigaBean is made of 2 other beans: FromMachineBean and ToMachineBean,
+which contain information regarding the load state of a machine.
+
+
+AllTasksVariablesComputator is used to compute different resource 
+loads or relocation costs and implements iAllTasksVariablesComputator.
+At instantiation, the constructor receives a Vector containing all 
+the nodes created so far.
+The objects returned in a MinMaxResource bean containing the ID of 
+a node and the respective load/cost.
+
+
+MakeJson is used to create a json object from a bean. (this is done pretty straight forward)
+
+
+interpret groovy====>>>>>
+

File libraries/platform_manager-20081208.jar

Binary file added.

File logging.properties

+log4j.rootLogger=info, stdout, R
+# Info shows all the errors, from the least important to the most important
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=%5p | %d | Line: %L | Thread: %t | Class: %C: %m%n
+
+
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=logs\\log file.log
+
+log4j.appender.R.MaxFileSize=8KB
+# Keep one backup file
+#log4j.appender.R.MaxBackupIndex=5
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern= %5p | %d | Line: %L | Thread: %t | Class: %C: %m%n
+
+
+
+# Initial pattern, by Marc: log4j.appender.R.layout.ConversionPattern=%5p | %t | %d | %m%n

File methods to be implemented for single_task_variables - condition

+resource_load (CPU, memory, disk): exists for both Node and Partition, so which one to use?
+
+monetary_cost ( $ ), 
+transport_cost (throughput in s), 
+resource_execution_cost ( s ): DO NOT EXIST =>
+=> need to be implemented. 

File src/Beans/FromMachineBean.java

+package Beans;
+
+import java.util.Vector;
+
+/**
+ * 
+ * @author The Best Pessimist
+ *
+ */
+public class FromMachineBean
+{
+	private Vector <String> single_task_variables = new Vector <String>();
+	private String condition = "";
+	
+	/**
+	 * @return the single_task_variables
+	 */
+	public Vector<String> getSingle_task_variables() {
+		return single_task_variables;
+	}
+	/**
+	 * @param single_task_variables the single_task_variables to set
+	 */
+	public void setSingle_task_variables(Vector<String> single_task_variables) {
+		this.single_task_variables = single_task_variables;
+	}
+	/**
+	 * @return the condition
+	 */
+	public String getCondition() {
+		return condition;
+	}
+	/**
+	 * @param condition the condition to set
+	 */
+	public void setCondition(String condition) {
+		this.condition = condition;
+	}
+
+}

File src/Beans/GigaBean.java

+package Beans;
+
+/**
+ * This is the bean that holds the other 2 beans: FromMachineBean and ToMachineBean
+ * @author The Best Pessimist
+ */
+public class GigaBean {
+	
+	FromMachineBean from_machine = new FromMachineBean();
+	ToMachineBean to_machine = new ToMachineBean();
+	/**
+	 * @return the from_machine
+	 */
+	public FromMachineBean getFrom_machine() {
+		return from_machine;
+	}
+	/**
+	 * @param from_machine the from_machine to set
+	 */
+	public void setFrom_machine(FromMachineBean from_machine) {
+		this.from_machine = from_machine;
+	}
+	/**
+	 * @return the to_machine
+	 */
+	public ToMachineBean getTo_machine() {
+		return to_machine;
+	}
+	/**
+	 * @param to_machine the to_machine to set
+	 */
+	public void setTo_machine(ToMachineBean to_machine) {
+		this.to_machine = to_machine;
+	}
+	
+	
+}

File src/Beans/ToMachineBean.java

+package Beans;
+/**
+ *
+ */
+
+import java.util.Vector;
+
+/**
+ * 
+ * @author The Best Pessimist
+ * @tibi Tibi
+ *
+ */
+public class ToMachineBean {
+
+	private Vector <String> single_task_variables = new Vector <String>();
+	private Vector <String> all_tasks_variables = new Vector <String>();
+	private String condition = "";
+
+/**
+	 * @return the single_task_variables
+	 */
+	public Vector<String> getSingle_task_variables() {
+		return single_task_variables;
+	}
+	/**
+	 * @param single_task_variables the single_task_variables to set
+	 */
+	public void setSingle_task_variables(Vector<String> single_task_variables) {
+		this.single_task_variables = single_task_variables;
+	}
+	/**
+	 * @return the all_tasks_variables
+	 */
+	public Vector<String> getAll_tasks_variables() {
+		return all_tasks_variables;
+	}
+	/**
+	 * @param all_tasks_variables the all_tasks_variables to set
+	 */
+	public void setAll_tasks_variables(Vector<String> all_tasks_variables) {
+		this.all_tasks_variables = all_tasks_variables;
+	}
+	/**
+	 * @return the condition
+	 */
+	public String getCondition() {
+		return condition;
+	}
+	/**
+	 * @param condition the condition to set
+	 */
+	public void setCondition(String condition) {
+		this.condition = condition;
+	}
+
+}

File src/TestClass.java

+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+
+import otherClasses.GenerateAllTasksVariables;
+import otherClasses.MakeJson;
+import otherClasses.PopulateBean;
+
+/**
+ * Class used for testing all the stuff written.
+ * @author The Best Pessimist
+ *
+ */
+public class TestClass {
+	
+	static Logger log = Logger.getLogger (MakeJson.class.getName());
+//	 this has to be put in every class where i want to use the logger
+
+	
+	public static void main(String args[]) throws Exception {
+		PropertyConfigurator.configure("logging.properties");
+		log.info("\nTesting started...");
+//		 this has to be put only one in the main function, so that logger knows
+//																		 its configuration
+
+		PopulateBean pb = new PopulateBean();
+		GenerateAllTasksVariables  ATV = new GenerateAllTasksVariables();
+		
+		
+		
+		
+		/*
+		InterpretGroovy ig = new InterpretGroovy();
+//		this is a string, so i can cancatenate other stuff as a parameter
+//		ig.interpretGroovy ("resource_load=677 \n  monetary_cost=7 \n" + pb.getGigaBean().getFrom_machine().getCondition());
+//		groovy interpreter is working!
+		
+		JSONObject jObj =  MakeJson.makeJson(pb.getGigaBean());
+//		System.out.println(jObj);
+//		creating json objects from bean works!
+
+*/
+
+		
+		
+		log.info("Exiting successfully the program...\n\n");
+	}
+
+}

File src/allTasksVariablesComputator/AllTasksVariablesComputator.java

+package allTasksVariablesComputator;
+
+import java.util.Vector;
+
+import mosaic.scheduler.platform.algorithms.util.AlgorithmUtil;
+import mosaic.scheduler.platform.algorithms.util.AlgorithmUtil.CostData;
+import mosaic.scheduler.platform.resources.Node;
+import mosaic.scheduler.platform.resources.Partition;
+
+
+/**
+ * Class for calculating some all_tasks_variables variables,
+ * that will be used in the groovy condition execution. 
+ * @author The Best Pessimist
+ */
+public class AllTasksVariablesComputator implements iAllTasksVariablesComputator{
+	
+	/**
+	 * Stores the nodes where the search will be done.
+	 */
+	private Vector <Node> allNodes;
+	
+	
+	/**
+	 * Private constructor.
+	 */
+	private AllTasksVariablesComputator() {}
+
+	
+	/**
+	 * Constructor.
+	 * @param allNodes Vector containing all the nodes
+	 */
+	public AllTasksVariablesComputator( Vector <Node> allNodes)
+	{
+		this.allNodes = allNodes;
+	}
+	
+
+	/**
+	 * Check interface for info.
+	 */
+	public MinMaxResource get_min_resource_load(int time)
+	{
+		MinMaxResource resource = new MinMaxResource();
+		int i = 0;
+		int nodeLoad = 0;
+		for(i = 0; i < allNodes.size() - 1; ++i)
+		{
+			nodeLoad = allNodes.elementAt(i).computeLoad(time, i);
+			if( nodeLoad < resource.getCost() )
+			{
+				resource.setCost(nodeLoad);
+				resource.setIndex(allNodes.elementAt(i).getID());
+			}
+		}
+		
+		return resource;
+	}
+	
+	/**
+	 * Check interface for info.
+	 */
+	public MinMaxResource get_max_resource_load(int time)
+	{
+
+		MinMaxResource resource = new MinMaxResource();
+		int i = 0;
+		int nodeLoad = 0;
+		for(i = 0; i < allNodes.size() - 1; ++i)
+		{
+			nodeLoad = allNodes.elementAt(i).computeLoad(time, i);
+			if( nodeLoad > resource.getCost() )
+			{
+				resource.setCost(nodeLoad);
+				resource.setIndex(allNodes.elementAt(i).getID());
+			}
+		}
+		
+		return resource;
+	}
+
+	
+	/**
+	 * Check interface for info.
+	 */
+	public MinMaxResource get_min_transport_cost (Partition partition)
+	{
+		MinMaxResource mmtc =  new AllTasksVariablesComputator(). new MinMaxResource();
+		mmtc.setCost(0);
+		Vector <CostData> relocationCosts = new Vector <CostData>();
+		relocationCosts = AlgorithmUtil.computePartitionRelocationCost (partition, allNodes);
+		mmtc.setIndex (relocationCosts.firstElement().getNode().getID());
+		mmtc.setCost(relocationCosts.firstElement().getCost());
+		return mmtc;
+	}
+	
+	
+	/**
+	 * Check interface for info.
+	 */
+	public Vector <MinMaxResource> get_min_transport_cost (Vector <Partition> partitionsVector)
+	{
+		Vector <MinMaxResource> moveCosts = new Vector < MinMaxResource>(); 
+		MinMaxResource aux = new MinMaxResource();
+		for (Partition partition: partitionsVector)
+		{
+			aux = get_min_transport_cost (partition);
+			moveCosts.add(aux);
+		}
+		
+		return moveCosts;
+	}
+
+
+	/**
+	 * Check interface for info.
+	 */
+	public MinMaxResource get_max_transportation_cost (Partition partition)
+	{
+		MinMaxResource mmtc = new MinMaxResource();
+		Vector <CostData> cost = new Vector <CostData> ();
+		cost = AlgorithmUtil.computePartitionRelocationCost(partition, allNodes);
+		mmtc.setCost(cost.lastElement().getCost());
+		mmtc.setIndex(cost.lastElement().getNode().getID());
+		return mmtc;
+	}
+	
+	
+	/**
+	 * Check interface for info.
+	 */
+	public Vector <MinMaxResource> get_max_transport_cost (Vector <Partition> partitionsVector)
+	{
+		Vector <MinMaxResource> vmmtc = new Vector <MinMaxResource>();
+		MinMaxResource aux = new MinMaxResource();
+		for (Partition partition: partitionsVector)
+		{
+			aux = get_max_transportation_cost(partition);
+			vmmtc.add(aux);		
+		}
+		return vmmtc;
+	}
+
+
+	/**
+	* Check interface for info.
+	 * Can not be computed with the methods currently available. 
+	 * @throws Exception 
+	 */
+	public void get_min_total_resource_execution_time() throws Exception
+	{
+		throw new Exception("I can not be computed with the methods currently available. Fix me! (oh, my ID too!)");
+//		nothing to do here...
+	}
+
+	
+	/**
+	 * Check interface for info.
+	 * Can not be computed with the methods currently available. 
+	 * @throws Exception 
+	 */
+	public void get_max_total_resource_execution_time() throws Exception
+	{
+		throw new Exception("I can not be computed with the methods currently available. Fix me! (oh, my ID too!)");
+//		nothing to do here...
+	}
+	
+	
+	/**
+	 * Class used as return object for the computation
+	 * of min/max transport cost node and it's ID.
+	 * @author The Best Pesimist
+	 *
+	 */
+	public class MinMaxResource
+	{
+		/*
+		 * Stores the cost resulted from the computation.
+		 */
+		private double cost = 0;
+		
+		/*
+		 * Stores the ID of the node resulted from the computation.
+		 */
+		private String index = "";
+
+		/**
+		 * @return the cost
+		 */
+		public double getCost() {
+			return cost;
+		}
+
+		/**
+		 * @param cost the cost to set
+		 */
+		public void setCost(double cost) {
+			this.cost = cost;
+		}
+
+		/**
+		 * @return the id
+		 */
+		public String getIndex() {
+			return index;
+		}
+
+		/**
+		 * @param id the id to set
+		 */
+		public void setIndex(String id) {
+			this.index = id;
+		}
+	}
+	
+	}

File src/allTasksVariablesComputator/iAllTasksVariablesComputator.java

+package allTasksVariablesComputator;
+
+import java.util.Vector;
+
+import allTasksVariablesComputator.AllTasksVariablesComputator.MinMaxResource;
+
+import mosaic.scheduler.platform.resources.Partition;
+
+
+/**
+ * The interface implementing All Tasks Variables Computator.
+ * @author The Best Pessimist
+ */
+public interface iAllTasksVariablesComputator {
+
+	/*
+	 * A bean named MinMaxResource is needed in order to return the data from the functions below.
+	 * It should contain a variable which stores the cost\load, and a string which stores the ID, along with it's getters and setters.
+	 */
+
+	/**
+	 * Return the node with the minimum resource load and its ID in a MinMaxResource bean. 
+	 * @param time the time when the load is calculated
+	 * @return the bean
+	 */
+	public MinMaxResource get_min_resource_load(int time);
+	
+	
+	/**
+	 * Return the node with the maximum resource load and its ID in a MinMaxResource bean.
+	 * @param time the time when the load is calculated
+	 * @return the bean
+	 */
+	public MinMaxResource get_max_resource_load(int time);
+	
+	
+	/**
+	 * Return minimum transportation cost for moving a partition to another node and the ID of the node.  
+	 * @param partition Partition to be moved
+	 * @return the cost and the ID in a MinMaxResource bean
+	 */
+	public MinMaxResource get_min_transport_cost (Partition partition);
+	
+	
+	/**
+	 * Returns a Vector of minimum costs  for the vector of partitions received as parameter.
+	 * @param partitions Vector of partitions
+	 * @return vector containing the costs and IDs in MinMaxTransportCost beans, respectively
+	 */
+	public Vector <MinMaxResource>  get_min_transport_cost (Vector <Partition> partitions);
+
+
+	/**
+	 * Returns maximum transport cost for moving a partition to another node, and the ID of the node.
+	 * @param partition the partition to be moved
+	 * @return a MinMaxResource bean containing the node ID and the cost for relocation
+	 */
+	public MinMaxResource get_max_transportation_cost (Partition partition);
+	
+	
+	/**
+	 * Returns a vector of maximum costs for the vector of partitions given as argument. 
+	 * @param partitionsVector argument for the function.
+	 * @return vector of maximum costs
+	 */
+	public Vector <MinMaxResource> get_max_transport_cost (Vector <Partition> partitionsVector);
+	
+//  	####################################################	
+	
+	/**
+	 * Can not be computed with the methods currently available. 
+	 * @throws Exception 
+	 */
+	public void get_min_total_resource_execution_time() throws Exception;
+	
+	/**
+	 * Can not be computed with the methods currently available. 
+	 * @throws Exception 
+	 */
+	public void get_max_total_resource_execution_time() throws Exception;
+	
+//	###################################################
+}

File src/fileIO/ReadFromFile.java

+package fileIO;
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStreamReader;
+
+/**
+ * 
+ * Class used to read from a text file.
+ * @author The Best Pessimist
+ *
+ */
+public class ReadFromFile {
+	
+	private String fileToUse;
+	private FileInputStream fis;
+	private InputStreamReader isr;
+	private BufferedReader infile;
+	
+	/**
+	 * Constructor. Just give the file path to read from.
+	 * It will be opened in text mode
+	 * @param aux The path to the file 
+	 * @throws FileNotFoundException In case the file is unavailable
+	 */
+	public ReadFromFile (String inputFile) throws FileNotFoundException
+	{
+		fileToUse = inputFile;
+		fis = new FileInputStream (fileToUse);
+		isr = new InputStreamReader (fis);
+		infile = new BufferedReader (isr);
+	}
+	
+
+	/**
+	 * The function is used to return the handle to the BufferedReader, in order to use it's
+	 * functions. 
+	 * @return Handle to the BufferedReader
+	 */
+	public BufferedReader use ()
+	{
+		return infile;
+	}
+	
+}

File src/mosaic/scheduler/platform/settings/system.properties.platform

+number_clouds = 1
+
+number_datacenters_per_cloud = 1
+
+
+###########################
+# Maximum number of nodes #
+######## Options ##########
+# -1 for unknown value    #
+# int otherwise           #
+###########################
+
+max_number_nodes = 20
+
+###############################
+# The type of nodes in use    #
+######## Options ##############
+# UNIFORM for uniform         #
+# UNRELATED for unrelated     #
+# HOMOGENEOUS for homogeneous #
+###############################
+
+node_type = HOMOGENEOUS
+
+###########################################
+# The variation of load on each node      #
+# Only if the maximum number of nodes     #
+# is known. Otherwise use a probabilistic #
+# method.								  #
+############## Options ####################
+# for uniform: values separated by ,      #
+# node_variation = "a,b,c"
+# for unrelated: values separated by , on #
+#    lines and ; for lines                #
+#    each line must have                  # 
+#       no_component_types values         # 
+# node_variation = "a,b;c,d;"             #
+# for homogeneous: -1                     # 
+# for custom values: -2                   #
+#	 these values need to be given        #
+#    inside the application               #
+#    NOT USED AT THE MOMENT               #
+###########################################
+
+node_variation = -1
+  
+#######################################  
+# The weight of CPU, memory & network #
+# for every node. Between 0 and 1     #
+# inclusively.                        #  
+#######################################
+  
+node_cpu_weight = 1
+node_memory_weight = 0
+node_network_weight =  0
+
+###################################
+# Maximum admissible load per node #
+###################################
+
+node_load_threshold = 40
+
+################################################
+# Number of component types in the application #
+################################################
+
+no_component_types = 3
+
+##############################################
+# The read/write rate of each component type #
+# No unit of measure given                   #
+##############################################
+
+component_read_rate = 100,50,50
+component_write_rate = 100,40,40
+
+########################################################
+# The component connection table as a dependency graph #
+# Each column is separated by , and lines by ;         #                    
+# Each line must have no_component_types column        #
+########################################################
+
+component_connection_table = 0,1,0;0,0,1;0,0,0
+
+################################################
+# The duration on any scale for the simulation #
+################################################
+
+time_span = 1
+
+#####################################
+# Method for generating web servers #
+# The server is the main component  #
+# after which all others scale      #
+########### Options: ################
+# POLYNOMIAL                        #
+# WEIBULL;shape,scale               #
+# PARETO;shape,minimumValue         # 
+#####################################
+
+web_server_generation_method = POLYNOMIAL  

File src/otherClasses/GenerateAllTasksVariables.java

+package otherClasses;
+
+import java.util.UUID;
+import java.util.Vector;
+
+import org.apache.log4j.Logger;
+
+import mosaic.scheduler.platform.resources.Component;
+import mosaic.scheduler.platform.resources.ComponentRequirementsList;
+import mosaic.scheduler.platform.resources.Node;
+import mosaic.scheduler.platform.resources.Partition;
+import mosaic.scheduler.platform.settings.SystemSettings;
+import mosaic.scheduler.simulator.resources.ComponentRequirements;
+
+public class GenerateAllTasksVariables {
+
+
+	private Vector <Partition> partitions = new Vector <Partition>();
+	private Vector <Node> allNodes = new Vector<Node>();	
+	
+	/**
+	 * The usual logger.
+	 */
+	static Logger log2 = Logger.getLogger(GenerateAllTasksVariables.class);
+	
+	
+	/**
+	 * Class which generates stuff. (nothing to do here)
+	 * @throws Exception 
+	 */
+	public GenerateAllTasksVariables() throws Exception
+	{
+		
+		/*
+		 * Below, i loaded a config file for SystemSettings. This had to be done in order to use marc's provided code.
+		 * (code borrowed from marc)
+		 */
+		SystemSettings.getSystemSettings().loadProperties("mosaic/scheduler/simulator/settings/system.properties");
+		for (int i=0; i < SystemSettings.getSystemSettings().getTime_span(); i++) {
+			ComponentRequirementsList crl  = ComponentRequirementsList.getComponentsRequirement();
+			crl.addComponentRequirement(i, new ComponentRequirements());
+		}
+		
+		
+		Node aNode = new Node (UUID.randomUUID().toString(), UUID.randomUUID().toString());
+		Node cNode = new Node (UUID.randomUUID().toString(), UUID.randomUUID().toString());
+
+		Partition aPartition = Partition.provide (aNode.getID());
+		Partition bPartition = Partition.provide (cNode.getID());
+		Partition cPartition = Partition.provide (cNode.getID());
+		Partition dPartition = Partition.provide (aNode.getID());
+		
+		Component aComponent = new Component(false, 0);		
+		Component bComponent = new Component( true , 1);
+		Component cComponent = new Component( true , 2);
+		Component dComponent = new Component( true , 3);
+		Component eComponent = new Component(false, 0);		
+		Component fComponent = new Component( true , 1);
+		Component gComponent = new Component( false , 4);
+		Component hComponent = new Component( true , 3);
+		
+		
+//	#######################################################
+		
+		
+		aPartition.addComponent (aComponent);
+		aPartition.addComponent(bComponent);
+		bPartition.addComponent(cComponent);
+		cPartition.addComponent(dComponent);
+		cPartition.addComponent(hComponent);
+		dPartition.addComponent(hComponent);
+		cPartition.addComponent(eComponent);
+		dPartition.addComponent(bComponent);
+		bPartition.addComponent(hComponent);
+		cPartition.addComponent(eComponent);
+		bPartition.addComponent(cComponent);
+		dPartition.addComponent(fComponent);
+		cPartition.addComponent(gComponent);
+		aPartition.addComponent(hComponent);
+
+//		######################################################
+		
+		aComponent.addConnection ("connected with tibi");
+		aComponent.addConnection ("connected with gogu");
+		bComponent.addConnection (aComponent.getID());
+		bComponent.addConnection (cComponent.getID());
+		
+//	#######################################################
+		
+		aNode.addPartition(aPartition);
+		aPartition.assignToNode(aNode.getID());
+		aNode.addPartition(cPartition);
+		cPartition.assignToNode(aNode.getID());
+		cNode.addPartition(dPartition);
+		dPartition.assignToNode(cNode.getID());
+		cNode.addPartition(bPartition);
+		bPartition.assignToNode(cNode.getID());
+		
+//		#######################################################
+
+//		for (int i = 0; i < SystemSettings.getSystemSettings().getTime_span(); ++i)
+//			System.out.println ("compute load: " + i + " " +  aPartition.computeLoad(i));
+		
+//		##################################################################
+		
+		partitions.add(cPartition);
+		partitions.add(bPartition);
+		
+//		################################################################
+
+		allNodes.add(cNode);
+		allNodes.add(aNode);
+
+		
+//		#########################################################
+
+/*
+		AllTasksVariablesComputator computeiT = new  AllTasksVariablesComputator(allNodes);
+		MinMaxResource mmtc = computeiT.get_min_transport_cost (cPartition);
+//		System.out.println ("\n\n" + mmtc.getCost() + "\n" + mmtc.getId());
+		
+		Vector <MinMaxResource> vmmtc = new Vector <MinMaxResource>();
+		vmmtc = computeiT.get_min_transport_cost (partitions);
+
+	*/
+	}
+
+
+	/**
+	 * @return the partitions
+	 */
+	public Vector<Partition> getPartitions() {
+		return partitions;
+	}
+
+
+	/**
+	 * @param partitions the partitions to set
+	 */
+	public void setPartitions(Vector<Partition> partitions) {
+		this.partitions = partitions;
+	}
+
+
+	/**
+	 * @return the allNodes
+	 */
+	public Vector<Node> getAllNodes() {
+		return allNodes;
+	}
+
+
+	/**
+	 * @param allNodes the allNodes to set
+	 */
+	public void setAllNodes(Vector<Node> allNodes) {
+		this.allNodes = allNodes;
+	}
+	
+	
+	
+	
+
+
+
+}

File src/otherClasses/InterpretGroovy.java

+package otherClasses;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.log4j.Logger;
+import groovy.lang.Binding;
+import groovy.lang.GroovyShell;
+import allTasksVariablesComputator.AllTasksVariablesComputator;
+
+public class InterpretGroovy {
+	
+	private static double configuration_file_value = 0;
+	static Logger log = Logger.getLogger(MakeJson.class.getName());
+	
+	
+	
+	@Deprecated
+	/**
+	 * Interpret the groovy code sent through the parameter
+	 * @ BETA!!!!!!!!!!!!!!	<- it has dummy values!
+	 * @author Lucian Stefanoaica 
+	 * @param condition String containing the groovy code to be evaluated.
+	 * @return Value of the evaluated groovy condition.
+	 * @Deprecated
+	 */
+	public static boolean interpretGroovy(String condition) throws Exception {
+		
+		
+		Boolean result = null;
+		try {
+			PopulateBean pb = new PopulateBean();
+			GenerateAllTasksVariables ATV = new GenerateAllTasksVariables();
+			AllTasksVariablesComputator ATVC = new AllTasksVariablesComputator(ATV.getAllNodes());
+			Binding binding = new Binding();
+			GroovyShell shell = new GroovyShell(binding);
+			for (String s : pb.getGigaBean().getFrom_machine().getSingle_task_variables()) {
+				
+				if (s.compareTo("resource_load") == 0)
+					throw new NotImplementedException();
+				
+				if (s.compareTo("monetary_cost") == 0)
+					throw new NotImplementedException();
+				
+				if (s.compareTo("transport_cost") == 0)
+					throw new NotImplementedException();
+			}
+			for (String s : pb.getGigaBean().getTo_machine().getSingle_task_variables()) {
+				
+				if (s.compareTo("resource_load") == 0)
+					throw new NotImplementedException();
+				
+				if (s.compareTo("monetary_cost") == 0)
+					throw new NotImplementedException();
+				
+				if (s.compareTo("transport_cost") == 0)
+					throw new NotImplementedException();
+			}
+			for (String s : pb.getGigaBean().getTo_machine().getAll_tasks_variables()) {
+			
+				if (s.compareTo("min_resource_load") == 0)
+					shell.setVariable("min_resource_load", ATVC.get_min_resource_load(0).getCost());
+				
+				if (s.compareTo("max_resource_load") == 0)
+					shell.setVariable("max_resource_load", ATVC.get_max_resource_load(0).getCost());
+				
+				if (s.compareTo("min_resource_load_id") == 0)
+					shell.setVariable("min_resource_load_id", ATVC.get_min_resource_load(0).getIndex());
+				
+				if (s.compareTo("max_resource_load_id") == 0)
+					shell.setVariable("max_resource_load_id", ATVC.get_max_resource_load(0).getIndex());
+				
+				if (s.compareTo("max_resource_load_threshold") == 0)
+					shell.setVariable("max_resource_load_threshold", configuration_file_value);	// TODO set with a fixed value taken from a configuration file.
+				
+				if (s.compareTo("min_resource_load_threshold") == 0)
+					shell.setVariable("min_resource_load_threshold", configuration_file_value);	// TODO set with a fixed value taken from a configuration file.
+				
+				if (s.compareTo("min_transport_cost") == 0)
+					shell.setVariable("min_transport_cost", ATVC.get_min_transport_cost(ATV.getPartitions()));
+				
+				if (s.compareTo("max_transport_cost") == 0)
+					shell.setVariable("max_transport_cost", ATVC.get_max_transport_cost(ATV.getPartitions()));	
+				
+				if (s.compareTo("min_transport_cost_resource_id") == 0)
+					shell.setVariable("min_transport_cost_resource_id", ATVC.get_min_transport_cost(ATV.getPartitions()).firstElement().getIndex());	//	TODO min_transport_cost_resource_id should be an array.
+				
+				if (s.compareTo("max_transport_cost_resource_id") == 0)
+					shell.setVariable("max_transport_cost_resource_id", ATVC.get_max_transport_cost(ATV.getPartitions()).firstElement().getIndex());	//	TODO max_transport_cost_resource_id should be an array.
+				
+				if (s.compareTo("min_total_resource_execution_time") == 0)
+					throw new NotImplementedException();
+				
+				if (s.compareTo("max_total_resource_execution_time") == 0)
+					throw new NotImplementedException();
+				
+				if (s.compareTo("min_total_resource_execution_time_id") == 0)
+					throw new NotImplementedException();
+				
+				if (s.compareTo("max_total_resource_execution_time_id") == 0)
+					throw new NotImplementedException();
+			}
+			result = (Boolean)shell.evaluate(condition);
+		}
+		catch(Exception e) {
+			log.fatal (e + "\nThe program will now exit.");
+			System.exit(-1337);
+		}
+		System.out.println(result);
+		return result;
+	}
+}

File src/otherClasses/MakeJson.java

+package otherClasses;
+import org.apache.log4j.Logger;
+import net.sf.json.JSONObject;
+
+/**
+ * This class will create the JSON object from a bean.
+ * @author The Best Pessimist
+ *
+ */
+public class MakeJson {
+
+	static Logger log = Logger.getLogger(InterpretGroovy.class.getClass());
+	
+	/**
+	 * Create the JSON object from a bean.
+	 * @author The Best Pessimist 
+	 * @param obj of type Bean.
+	 * @return JSONObject representing the bean.
+	 */
+	public static  JSONObject makeJson (Object obj)
+	{
+		JSONObject jObj = null;
+		try{
+			jObj = JSONObject.fromObject(obj);
+		}
+		catch (Exception ex)
+		{
+			log.fatal("invalid bean.\n" + ex.getMessage() + "\nThe program will now exit.");
+			System.exit(-1337);
+		}
+		return jObj;
+	}
+}

File src/otherClasses/PopulateBean.java

+package otherClasses;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.Vector;
+import org.apache.log4j.Logger;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONException;
+import net.sf.json.JSONObject;
+import fileIO.ReadFromFile;
+import Beans.FromMachineBean;
+import Beans.GigaBean;
+import Beans.ToMachineBean;
+
+/**
+ * assertions are made before parsing to the bean, because if i have different types, 
+ * then i will get who_knows_what values 
+ */
+
+/**
+ * 
+ * @author The Best Pessimist
+ * 
+ */
+
+public class PopulateBean {
+	private GigaBean gigaBean;
+	public static JSONObject jsonObject;
+	private Vector<String> singleNodeVariablesVerify = new Vector<String>();
+	private Vector<String> allNodesVariablesVerify = new Vector<String>();
+
+	private Logger log = Logger.getLogger(PopulateBean.class.getClass());
+//	this is used for the logger
+	
+	/**
+	 * Constructor
+	 * 
+	 * @throws Exception
+	 */
+	public PopulateBean() {
+		gigaBean = new GigaBean();
+		try {
+			this.jsonObject = parseJson();
+		} catch (JSONException jex) {
+			log.fatal("Invalid JSON string.\n" + jex.getMessage());
+			log.fatal("Exiting program...");
+			System.exit(-1);
+		}
+		// created the jsonObject
+
+		prepareVerifyVariables();
+
+		/*
+		 * in order to use the GigaBean object, i have to split the big json
+		 * object into 2 objects: 1 for the from-machine bean, and 1 for the
+		 * to-machine bean
+		 */
+		createFromMachine(jsonObject);
+		createToMachine(jsonObject);
+	}
+
+	
+	/**
+	 * Get the single node variables and the all nodes variables from the 2
+	 * files supplied in the docs folder.
+	 */
+	private void prepareVerifyVariables() {
+
+		try {
+			ReadFromFile inFile = new ReadFromFile(
+					"docs/single_task_variables.txt");
+			// read from the file
+
+			String aux = "";
+			while (inFile.use().ready()) {
+				aux += inFile.use().readLine();
+			}
+			String aux2[];
+			aux2 = aux.split("(\\s*)([,])(\\s*)");
+			// aici am regex care ma scapa de combinatiile spatiu virgula
+			// spatiu(nici unul sau mai multe)
+
+			for (String i : aux2)
+				singleNodeVariablesVerify.add(i);
+			// add the strings to the vector
+		} catch (IOException ioe) {
+			// In case no reading could be made from that particular file
+			log.error("Could not read the single_task_variables.txt file. "
+					+ ioe.getMessage() + "\nThe program will now exit.");
+			System.exit(-1);
+		}
+
+		// read the other file
+		try {
+			ReadFromFile inFile = new ReadFromFile(
+					"docs/all_tasks_variables.txt");
+			// read from the file
+
+			String aux = "";
+			while (inFile.use().ready()) {
+				aux += inFile.use().readLine();
+			}
+
+			String aux2[] = aux.split("(\\s*)([,])(\\s*)");
+			// aici am regex care ma scapa de combinatiile spatiu virgula
+			// spatiu(nici unul sau mai multe)
+
+			for (String i : aux2)
+				allNodesVariablesVerify.add(i);
+			// add the strings to the vector
+		} catch (IOException ioe) {
+			// In case no reading could be made from that particular file
+			log.error("Could not read the all_tasks_variables.txt file. "
+					+ ioe.getMessage() + "\nThe program will now exit.");
+			System.exit(-1);
+		}
+
+	}
+
+	
+	/**
+	 * Parses the JSON object from a file.
+	 * 
+	 * @(Must be modified!!!!)
+	 * @return a new JSONObject
+	 * @throws IOException
+	 */
+	private JSONObject parseJson() {
+		try {
+			ReadFromFile input = new ReadFromFile("docs/infile.json");
+			BufferedReader bufferedReader = input.use();
+			String aux = "";
+			while (bufferedReader.ready()) {
+				aux += (char) bufferedReader.read();
+			}
+
+			return new JSONObject().fromObject(aux);
+		} catch (IOException ioe) {
+			// In case the json can't be parsed.
+			log.fatal("Could not parse the json data file. " + ioe.getMessage()
+					+ "\nThe program will now exit.");
+			System.exit(-1337);
+			return null;
+			// this is unreachable code, but it has to be put in order to
+			// respect the function definition
+		}
+
+	}
+
+	
+	/**
+	 * creates the json object which will then be used to populate the
+	 * {@link FromMachineBean}
+	 * 
+	 * @throws Exception
+	 */
+	private void createFromMachine(JSONObject jsonObject) {
+		// do all the verifications first
+		assert jsonObject.containsKey("from_machine");
+		// assume i have the from-machine object
+		JSONObject fromMachine = jsonObject.getJSONObject("from_machine");
+		
+		if (fromMachine.isNullObject()) {
+			log.fatal("from_machine key not found in json."
+					+ "\nThe program will now exit.");
+			System.exit(-1);
+		}
+		boolean isToMachine = false;
+		checkArrays(fromMachine, isToMachine);
+		// assume i have the 2 arrays and they have correct data
+
+		// ###### all verifications completed at this point ###########
+
+		FromMachineBean fmb = new FromMachineBean();
+		fmb = (FromMachineBean) JSONObject.toBean(fromMachine,	FromMachineBean.class);
+		gigaBean.setFrom_machine(fmb);
+		// gigaBean has the from machine part!
+	}
+
+	
+	/**
+	 * creates the json object which will then be used to populate the
+	 * {@link ToMachineBean}
+	 * 
+	 * @param jsonObject
+	 *            The JSON object that contains the 2 arrays
+	 * @throws Exception
+	 *             The JSON arrays do not have valid data
+	 */
+	private void createToMachine(JSONObject jsonObject) {
+		// doing all the verifications first...
+		assert jsonObject.containsKey("to_machine");
+		// assuming there is the to-machine object
+		JSONObject toMachine = jsonObject.getJSONObject("to_machine");
+
+		if (toMachine.isNullObject()) {
+			log.fatal("to_machine key not found in json."
+					+ "\nThe program will now exit.");
+			System.exit(-1);
+		}
+		boolean isToMachine = true;
+		checkArrays(toMachine, isToMachine);
+
+		// assuming the 2 arrays exist and have good data
+
+		ToMachineBean tmb = (ToMachineBean) toMachine.toBean(toMachine,ToMachineBean.class);
+		gigaBean.setTo_machine(tmb);
+		// gigaBean has now the to-machine object
+	}
+
+	
+	/**
+	 * 
+	 * @param jObj
+	 *            The JSON object that contains the 2 arrays
+	 * @param isToMachine 
+	 * @throws Exception
+	 *             The JSON arrays do not have valid data
+	 */
+	private void checkArrays(JSONObject jObj, boolean isToMachine) {
+		// assume array single_task_variables exists
+		JSONArray array = jObj.getJSONArray("single_task_variables");
+
+		int i;
+		for (i = 0; i < array.size(); ++i)
+			if (!singleNodeVariablesVerify.contains(array.get(i).toString())) {
+				log.fatal("" + new Exception(	"Invalid single_task_variables! \nThe program will now exit.").getMessage());
+				System.exit(-1337);
+			}
+		// all data in this array is valid
+		
+		
+		if (isToMachine){
+			// assume the array all_tasks_variables exists
+			array = jObj.getJSONArray("all_tasks_variables");
+	
+			try {
+				for (i = 0; i < array.size(); ++i)
+					if (!allNodesVariablesVerify.contains(array.get(i).toString()))
+						throw (new Exception("Invalid all_tasks_variables!"));
+				// all data in the array is valid
+				
+			} catch (Exception e) {
+				log.fatal("Invalid data array. " + e.getMessage()
+						+ "\nThe program will now exit.");
+				System.exit(-1337);
+			}
+		}
+	}
+
+	
+	/**
+	 * @return the gigaBean
+	 */
+	public GigaBean getGigaBean() {
+		return gigaBean;
+	}
+
+	
+	/**
+	 * @param gigaBean
+	 *            the gigaBean to set
+	 */
+	public void setGigaBean(GigaBean gigaBean) {
+		this.gigaBean = gigaBean;
+	}
+
+}