package test.local.db.loader; import java.text.ParseException; /** * * @author Marcin Krystek * */ public class RawResourcesReader extends StatsReader { public RawResourcesReader(StatsParser p) { super(p); } public String getResourceName(){ return this.values[0]; } public int getMemory(){ return getAsInt(1); } public int getCpus(){ return getAsInt(2); } public int getCpuSpeed(){ return getAsInt(3); } public double getQueueLength(){ return getAsDouble(4); } public Load[] getCpuLoad(){ String load = this.values[5]; if(load == null) return null; return prepareLoad(load); } public Load[] getReservationLoad(){ String load = this.values[6]; if(load == null) return null; return prepareLoad(load); } protected Load[] prepareLoad(String arg){ String cpuList[] = arg.split(":"); Load result[] = new Load[cpuList.length]; for(int i = 0; i < cpuList.length; i++){ Load cpuLoad = new Load(); String cpuDesc[] = cpuList[i].split(" "); cpuLoad.cpuName = cpuDesc[0]; try { cpuLoad.value = this.format.parse(cpuDesc[1]).doubleValue(); } catch (ParseException e) { e.printStackTrace(); cpuLoad.value = -1.0; } result[i] = cpuLoad; } return result; } public class Load{ public String cpuName; public double value; public String toString(){ return cpuName + " " + value; } } }