from round robin to best-fit

Hi all,

I am trying to develop a mechanism to know which machine can handle a user job (by providing his Requirements) for now I wrote this method but it is a Round robin, I am trying to modify it to a best-fit algorithm can anybody give me tips about how should I begin?

publicstatic String canDo(Resources userReq,Hashtable hash){

//getResourceInfo() is a method that store the machine name

//and thier resources(cpu,memory,disk) in a hashtable

Hashtable resourceInfo = connectData.getResourcesInfo();

Enumeration en = resourceInfo.keys();

String status ="";

String machineName;

Resources machineRec;

while(en.hasMoreElements()){

machineName = (String)en.nextElement();

status ="the following machine has been allocated to you: "+machineName;

//resourc

machineRec = (Resources)resourceInfo.get(machineName);

if(machineRec.getCpu().getCpuIdle()>=userReq.getCpu().getCpuIdle())

if(machineRec.getMemory().getFreeMemory()>=userReq.getMemory().getFreeMemory())

if(machineRec.getDisk().getFreeSpace()>=userReq.getDisk().getFreeSpace()){

break;

}

}

return status;

}

[1776 byte] By [kyotia] at [2007-11-26 13:45:42]
# 1
you mustn't have seen the replies here http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=1&t=016520
Michael_Dunna at 2007-7-8 1:20:25 > top of Java-index,Java Essentials,Java Programming...
# 2
I was trying to get as much thoughts as I could
kyotia at 2007-7-8 1:20:25 > top of Java-index,Java Essentials,Java Programming...