Ignore:
Timestamp:
02/02/16 11:41:11 (9 years ago)
Author:
wojtekp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/example/globalplugin/GridFCFSRandomPlugin.java

    r1449 r1562  
    11package example.globalplugin; 
    22 
     3import java.util.Comparator; 
    34import java.util.List; 
    45import java.util.Random; 
     
    1819import schedframe.scheduling.queue.TaskQueueList; 
    1920import schedframe.scheduling.tasks.TaskInterface; 
    20 import schedframe.scheduling.tasks.WorkloadUnit; 
    2121 
    2222public class GridFCFSRandomPlugin extends BaseGlobalPlugin { 
     
    4949                // order of the resources on this list is not determined 
    5050                List<SchedulerDescription> availableResources = resources.getResources(null); 
     51                availableResources.sort(new SchedulerDescriptionComparator()); 
    5152                int resourceIdx = -1; 
    5253                 
     
    5758                        resourceIdx = rand.nextInt(availableResources.size()); 
    5859                        SchedulerDescription sd = availableResources.get(resourceIdx); 
    59                          
    6060                        Allocation allocation = new Allocation(); 
    6161                        allocation.setProcessesCount(1); 
     
    7575 
    7676} 
     77 
     78class SchedulerDescriptionComparator implements Comparator<SchedulerDescription>{ 
     79 
     80        @Override 
     81        public int compare(SchedulerDescription o1, SchedulerDescription o2) { 
     82                return(o1.getProvider().getProviderId().compareTo(o2.getProvider().getProviderId())); 
     83        } 
     84} 
Note: See TracChangeset for help on using the changeset viewer.