Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/CoolEmAllStringSerializer.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/CoolEmAllStringSerializer.java	(revision 1096)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/CoolEmAllStringSerializer.java	(revision 1096)
@@ -0,0 +1,244 @@
+package simulator.stats.implementation.out;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.StandardResourceType;
+import simulator.stats.implementation.ResourceAirFlowStats;
+import simulator.stats.implementation.ResourcePowerStats;
+import simulator.stats.implementation.ResourceTemperatureStats;
+import simulator.stats.implementation.ResourceUsageStats;
+
+public class CoolEmAllStringSerializer extends StringSerializer {
+
+	private Log log = LogFactory.getLog(CoolEmAllStringSerializer.class);
+
+	public Object visit(ResourceUsageStats resourceUsageStats) {
+		Map<Long, Double> resourceUsage = resourceUsageStats.getHistory();
+		String cpuMetricName = "CPU_Load";
+		int mapSize = resourceUsage.size();
+		/*
+		 * FIXME:
+		 * Integer.MAX_VALUE = 2147483647. We assume, that each line contains 
+		 * max 30 signs - this gives max 71582788 lines. If resourceUsage map
+		 * contains more elements then we have a problem, because content of
+		 * resourceUsage map will not fit in the buffer.
+		 * This will need further attention in the future.
+		 */
+		int maxSize = (Integer.MAX_VALUE / 30 ) - 1;
+		if(mapSize >= maxSize){
+			log.error("Resource usage data is to long to fit in the buffer.");
+			return null;
+		}
+		
+		int size = 30 * resourceUsage.size();
+		
+		StringBuffer buffer = null;
+
+		if(printedHeaders.add(resourceUsageStats.getUsageType())) {
+			buffer = new StringBuffer(size + 42);
+		} else {
+			buffer = new StringBuffer(size);
+		}
+		
+		if(resourceUsageStats.getResourceType().equals(StandardResourceType.Processor) || resourceUsageStats.getResourceType().equals(CoolEmAllResourceType.Processor)){
+			for (Long timestamp : resourceUsage.keySet()) {
+				
+				buffer.append(cpuMetricName);
+				buffer.append(fieldSeparator);
+				buffer.append(resourceUsageStats.getResourceName());
+				buffer.append(fieldSeparator);
+				Double value = resourceUsage.get(timestamp);
+				buffer.append(timestamp);
+				buffer.append(fieldSeparator);
+				//buffer.append(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT
+				//		.format(value));
+				buffer.append(value);
+				buffer.append(fieldSeparator);
+				buffer.append(System.getProperty("line.separator"));
+			}
+		}
+
+		int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));
+		if(lastIdx != -1){
+			//buffer.deleteCharAt(lastIdx);	
+		}
+
+		return buffer.toString();
+	}
+
+	public Object visit(ResourcePowerStats resourceEnergyStats) {
+		Map<Long, Double> resourceEnergy = resourceEnergyStats.getHistory();
+		String nodeMetricName = "RECS_Power";
+		int mapSize = resourceEnergy.size();
+		/*
+		 * FIXME:
+		 * Integer.MAX_VALUE = 2147483647. We assume, that each line contains 
+		 * max 30 signs - this gives max 71582788 lines. If resourceUsage map
+		 * contains more elements then we have a problem, because content of
+		 * resourceUsage map will not fit in the buffer.
+		 * This will need further attention in the future.
+		 */
+		int maxSize = (Integer.MAX_VALUE / 30 ) - 1;
+		if(mapSize >= maxSize){
+			log.error("Resource usage data is to long to fit in the buffer.");
+			return null;
+		}
+		
+		int size = 30 * resourceEnergy.size();
+		
+		StringBuffer buffer = null;
+
+		if(printedHeaders.add(resourceEnergyStats.getUsageType())) {
+			buffer = new StringBuffer(size + 42);
+		} else {
+			buffer = new StringBuffer(size);
+		}
+		
+		if(resourceEnergyStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceEnergyStats.getResourceType().equals(CoolEmAllResourceType.Node)){
+			for (Long timestamp : resourceEnergy.keySet()) {
+				
+				buffer.append(nodeMetricName);
+				buffer.append(fieldSeparator);
+				buffer.append(resourceEnergyStats.getResourceName());
+				buffer.append(fieldSeparator);
+				Double value = resourceEnergy.get(timestamp);
+				buffer.append(timestamp);
+				buffer.append(fieldSeparator);
+				//buffer.append(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT
+				//		.format(value));
+				buffer.append(value);
+				buffer.append(fieldSeparator);
+				buffer.append(System.getProperty("line.separator"));
+			}
+		}
+
+		int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));
+		if(lastIdx != -1){
+			//buffer.deleteCharAt(lastIdx);
+		}
+
+		return buffer.toString();
+	}
+
+	public Object visit(ResourceAirFlowStats resourceAirFlowStats) {
+		Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getHistory();
+		String nodeMetricName = "RECS_Airflow";
+		int mapSize = resourceAirFlow.size();
+		/*
+		 * FIXME:
+		 * Integer.MAX_VALUE = 2147483647. We assume, that each line contains 
+		 * max 30 signs - this gives max 71582788 lines. If resourceUsage map
+		 * contains more elements then we have a problem, because content of
+		 * resourceUsage map will not fit in the buffer.
+		 * This will need further attention in the future.
+		 */
+		int maxSize = (Integer.MAX_VALUE / 30 ) - 1;
+		if(mapSize >= maxSize){
+			log.error("Resource usage data is to long to fit in the buffer.");
+			return null;
+		}
+		
+		int size = 30 * resourceAirFlow.size();
+		
+		StringBuffer buffer = null;
+
+		if(printedHeaders.add(resourceAirFlowStats.getUsageType())) {
+			buffer = new StringBuffer(size + 42);
+		} else {
+			buffer = new StringBuffer(size);
+		}
+		
+		if(resourceAirFlowStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceAirFlowStats.getResourceType().equals(CoolEmAllResourceType.Node)){
+			for (Long timestamp : resourceAirFlow.keySet()) {
+				
+				buffer.append(nodeMetricName);
+				buffer.append(fieldSeparator);
+				buffer.append(resourceAirFlowStats.getResourceName());
+				buffer.append(fieldSeparator);
+				Double value = resourceAirFlow.get(timestamp);
+				buffer.append(timestamp);
+				buffer.append(fieldSeparator);
+				//buffer.append(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT
+				//		.format(value));
+				buffer.append(value);
+				buffer.append(fieldSeparator);
+				buffer.append(System.getProperty("line.separator"));
+			}
+		}
+
+		int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));
+		if(lastIdx != -1){
+			//buffer.deleteCharAt(lastIdx);
+		}
+
+		return buffer.toString();
+	}
+	
+	public Object visit(ResourceTemperatureStats resourceTemperatureStats) {
+		Map<Long, Double> resourceTemperature = resourceTemperatureStats.getHistory();
+		String nodeMetricName = "RECS_Temperature";
+		String cpuMetricName = "CPU_Temp";
+		int mapSize = resourceTemperature.size();
+		/*
+		 * FIXME:
+		 * Integer.MAX_VALUE = 2147483647. We assume, that each line contains 
+		 * max 30 signs - this gives max 71582788 lines. If resourceUsage map
+		 * contains more elements then we have a problem, because content of
+		 * resourceUsage map will not fit in the buffer.
+		 * This will need further attention in the future.
+		 */
+		int maxSize = (Integer.MAX_VALUE / 30 ) - 1;
+		if(mapSize >= maxSize){
+			log.error("Resource temperature data is to long to fit in the buffer.");
+			return null;
+		}
+		
+		int size = 30 * resourceTemperature.size();
+		
+		StringBuffer buffer = null;
+
+		if(printedHeaders.add(resourceTemperatureStats.getUsageType())) {
+			buffer = new StringBuffer(size + 42);
+		} else {
+			buffer = new StringBuffer(size);
+		}
+		
+		if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node) || 
+				resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){
+			String metricName = null;
+			if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node)){
+				metricName = nodeMetricName;
+			} else if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){
+				metricName = cpuMetricName;
+			}
+			for (Long timestamp : resourceTemperature.keySet()) {
+				
+				buffer.append(metricName);
+				buffer.append(fieldSeparator);
+				buffer.append(resourceTemperatureStats.getResourceName());
+				buffer.append(fieldSeparator);
+				Double value = resourceTemperature.get(timestamp);
+				buffer.append(timestamp);
+				buffer.append(fieldSeparator);
+				//buffer.append(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT
+				//		.format(value));
+				buffer.append(value);
+				buffer.append(fieldSeparator);
+				buffer.append(System.getProperty("line.separator"));
+			}
+		}
+		
+		int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));
+		if(lastIdx != -1){
+			//buffer.deleteCharAt(lastIdx);	
+		}
+
+		return buffer.toString();
+	}
+
+
+}
