Changeset 481 for DCWoRMS/trunk/src


Ignore:
Timestamp:
10/08/12 10:23:45 (13 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/trunk/src
Files:
1 added
2 deleted
41 edited
3 copied
5 moved

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/src/example/globalplugin/BaseGlobalPlugin.java

    r478 r481  
    44import schedframe.PluginConfiguration; 
    55import schedframe.events.scheduling.SchedulingEventType; 
    6 import schedframe.scheduling.WorkloadUnitListImpl; 
     6import schedframe.scheduling.TaskListImpl; 
    77import schedframe.scheduling.manager.resources.ResourceManager; 
    88import schedframe.scheduling.plugin.SchedulingPluginConfiguration; 
     
    1111import schedframe.scheduling.queue.TaskQueue; 
    1212import schedframe.scheduling.queue.TaskQueueList; 
    13 import schedframe.scheduling.tasks.WorkloadUnit; 
     13import schedframe.scheduling.tasks.TaskInterface; 
    1414import schemas.StringValueWithUnit; 
    1515 
     
    2222        } 
    2323         
    24         public int placeJobsInQueues(WorkloadUnitListImpl newJobs, TaskQueueList queues, ResourceManager resourceManager, 
     24        public int placeTasksInQueues(TaskListImpl newTasks, TaskQueueList queues, ResourceManager resourceManager, 
    2525                        ModuleList moduleList) { 
    2626 
     
    2828                TaskQueue queue = queues.get(0); 
    2929 
    30                 for (int i = 0; i < newJobs.size(); i++) { 
    31                         WorkloadUnit task = newJobs.get(i); 
     30                for (int i = 0; i < newTasks.size(); i++) { 
     31                        TaskInterface<?> task = newTasks.get(i); 
    3232                        queue.add(task); 
    3333                } 
  • DCWoRMS/trunk/src/example/globalplugin/GridFCFSLoadBalancingPlugin.java

    r478 r481  
    1919import schedframe.scheduling.plugin.grid.ModuleList; 
    2020import schedframe.scheduling.plugin.grid.ResourceDiscovery; 
     21import schedframe.scheduling.queue.QueueDescription; 
    2122import schedframe.scheduling.queue.TaskQueue; 
    22 import schedframe.scheduling.queue.QueueDescription; 
    2323import schedframe.scheduling.queue.TaskQueueList; 
    2424import schedframe.scheduling.tasks.TaskInterface; 
     
    2929        private Log log = LogFactory.getLog(GridFCFSLoadBalancingPlugin.class); 
    3030         
    31         public SchedulingPlanInterface schedule(SchedulingEvent event, 
     31        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, 
    3232                        TaskQueueList queues,  
    3333                        JobRegistry jobRegistry, 
     
    8383         
    8484        private int findLeastLoadedResourceIdx(List<SchedulerDescription> availableResources){ 
    85                  
    8685                int resourceIdx = -1; 
    8786                long minLoad = Long.MAX_VALUE; 
     87                 
    8888                for(int i = 0; i < availableResources.size(); i++){ 
    8989                        SchedulerDescription sd = availableResources.get(i); 
  • DCWoRMS/trunk/src/example/localplugin/BaseLocalSchedulingPlugin.java

    r478 r481  
    1010import schedframe.resources.units.ResourceUnit; 
    1111import schedframe.resources.units.ResourceUnitName; 
    12 import schedframe.scheduling.WorkloadUnitListImpl; 
     12import schedframe.scheduling.TaskListImpl; 
    1313import schedframe.scheduling.manager.resources.ResourceManager; 
    1414import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
     
    2222import schedframe.scheduling.queue.TaskQueueList; 
    2323import schedframe.scheduling.tasks.TaskInterface; 
    24 import schedframe.scheduling.tasks.WorkloadUnit; 
    2524import schemas.StringValueWithUnit; 
    2625 
     
    4645        } 
    4746         
    48         public int placeJobsInQueues(WorkloadUnitListImpl newJobs, 
     47        public int placeTasksInQueues(TaskListImpl newTasks, 
    4948                        TaskQueueList queues,  
    5049                        ResourceManager resourceManager, ModuleList moduleList) { 
     
    5352                TaskQueue queue = queues.get(0); 
    5453 
    55                 for(int i = 0; i < newJobs.size(); i++){ 
    56                         WorkloadUnit task = newJobs.get(i); 
     54                for(int i = 0; i < newTasks.size(); i++){ 
     55                        TaskInterface<?> task = newTasks.get(i); 
    5756                        queue.add(task); 
    5857                } 
  • DCWoRMS/trunk/src/example/localplugin/FCFSCPUFreqScalingClusterLocalPlugin.java

    r478 r481  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.gssim.DCWormsTags; 
     4import gssim.schedframe.scheduling.Executable; 
    45 
    56import java.util.ArrayList; 
     
    2829import schedframe.scheduling.queue.TaskQueue; 
    2930import schedframe.scheduling.queue.TaskQueueList; 
    30 import schedframe.scheduling.tasks.SubmittedTask; 
    3131import schedframe.scheduling.tasks.TaskInterface; 
    3232import schedframe.scheduling.tasks.WorkloadUnit; 
     
    3939        } 
    4040 
    41         public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
     41        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
    4242                        ResourceManager resManager, ModuleList modules) { 
    4343 
     
    5858                                TaskInterface<?> task = (TaskInterface<?>) job; 
    5959                                // if status of the tasks in READY 
    60                                 if (task.getStatus() == Gridlet.READY) { 
     60                                if (task.getStatus() == DCWormsTags.READY) { 
    6161 
    6262                                        Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 
     
    7676                case TASK_FINISHED: 
    7777                        TaskFinishedEvent finEvent = (TaskFinishedEvent) event; 
    78                         SubmittedTask subTask = (SubmittedTask )jobRegistry.getSubmittedTask(finEvent.getJobId(), finEvent.getTaskId()); 
    79                         UsedResourceList<ResourceHistoryItem> usedResourcesList = subTask.getUsedResources(); 
     78                        Executable exec = (Executable) jobRegistry.getExecutable(finEvent.getJobId(), finEvent.getTaskId()); 
     79                        UsedResourceList<ResourceHistoryItem> usedResourcesList = exec.getUsedResources(); 
    8080                        ProcessingElements pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
    8181                        List<Processor> processors =  new ArrayList<Processor>(); 
     
    8989                case TASK_REQUESTED_TIME_EXPIRED: 
    9090                        TaskRequestedTimeExpiredEvent timExpEvent = (TaskRequestedTimeExpiredEvent) event; 
    91                          subTask = (SubmittedTask )jobRegistry.getSubmittedTask(timExpEvent.getJobId(), timExpEvent.getTaskId()); 
    92                         usedResourcesList = subTask.getUsedResources(); 
     91                        exec = (Executable) jobRegistry.getExecutable(timExpEvent.getJobId(), timExpEvent.getTaskId()); 
     92                        usedResourcesList = exec.getUsedResources(); 
    9393                        pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
    9494                        processors =  new ArrayList<Processor>(); 
     
    101101                                TaskInterface<?> task = (TaskInterface<?>) job; 
    102102                                // if status of the tasks in READY 
    103                                 if (task.getStatus() == Gridlet.READY) { 
     103                                if (task.getStatus() == DCWormsTags.READY) { 
    104104 
    105105                                        Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 
  • DCWoRMS/trunk/src/example/localplugin/FCFSClusterLocalPlugin.java

    r478 r481  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.gssim.DCWormsTags; 
    44 
    55import java.util.ArrayList; 
     
    5252                                TaskInterface<?> task = (TaskInterface<?>) job; 
    5353                                // if status of the tasks in READY 
    54                                 if (task.getStatus() == Gridlet.READY) { 
     54                                if (task.getStatus() == DCWormsTags.READY) { 
    5555                                         
    5656                                        /****************3 ways to schedule task****************/ 
  • DCWoRMS/trunk/src/example/localplugin/FCFSConsolidationClusterLocalPlugin.java

    r478 r481  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.gssim.DCWormsTags; 
    44 
    55import java.util.ArrayList; 
     
    3535        } 
    3636 
    37         public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
     37        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
    3838                        ResourceManager resManager, ModuleList modules) { 
    3939 
     
    5454                                TaskInterface<?> task = (TaskInterface<?>) job; 
    5555                                // if status of the tasks in READY 
    56                                 if (task.getStatus() == Gridlet.READY) { 
     56                                if (task.getStatus() == DCWormsTags.READY) { 
    5757 
    5858                                        Map<ResourceUnitName, ResourceUnit> choosenResources = null; 
  • DCWoRMS/trunk/src/example/localplugin/FCFSEnergyAwareClusterLocalPlugin.java

    r478 r481  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.gssim.DCWormsTags; 
    44 
    55import java.util.ArrayList; 
     
    2626        } 
    2727 
    28         public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
     28        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
    2929                        ResourceManager resManager, ModuleList modules) { 
    3030 
     
    4545                                TaskInterface<?> task = (TaskInterface<?>) job; 
    4646                                // if status of the tasks in READY 
    47                                 if (task.getStatus() == Gridlet.READY) { 
     47                                if (task.getStatus() == DCWormsTags.READY) { 
    4848 
    4949                                        String nodeName = chooseProviderForExecution(resourceManager, task); 
  • DCWoRMS/trunk/src/example/localplugin/FCFSNodePowerManagementClusterLocalPlugin.java

    r478 r481  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.gssim.DCWormsTags; 
    44 
    55import java.util.ArrayList; 
     
    3535        } 
    3636 
    37         public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
     37        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
    3838                        ResourceManager resManager, ModuleList modules) { 
    3939 
     
    5454                                TaskInterface<?> task = (TaskInterface<?>) job; 
    5555                                // if status of the tasks in READY 
    56                                 if (task.getStatus() == Gridlet.READY) { 
     56                                if (task.getStatus() == DCWormsTags.READY) { 
    5757 
    5858                                        Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 
  • DCWoRMS/trunk/src/example/localplugin/FCFSRandomClusterLocalPlugin.java

    r478 r481  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.gssim.DCWormsTags; 
    44 
    55import java.util.List; 
     
    4747                                TaskInterface<?> task = (TaskInterface<?>) job; 
    4848                                // if status of the tasks in READY 
    49                                 if (task.getStatus() == Gridlet.READY) { 
     49                                if (task.getStatus() == DCWormsTags.READY) { 
    5050                                        /*for(ResourceUnitName key:resManager.getSharedResourceUnits().keySet()){ 
    5151                                                System.out.println(key.getName()); 
  • DCWoRMS/trunk/src/example/localplugin/FCFS_BFLocalPlugin.java

    r478 r481  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.gssim.DCWormsTags; 
    44import schedframe.events.scheduling.SchedulingEvent; 
    55import schedframe.scheduling.manager.resources.ResourceManager; 
     
    3333                                 
    3434                                // if status of the tasks in READY 
    35                                 if (task.getStatus() == Gridlet.READY) { 
     35                                if (task.getStatus() == DCWormsTags.READY) { 
    3636                                        addToSchedulingPlan(plan, task); 
    3737                                } 
  • DCWoRMS/trunk/src/example/localplugin/RackLocalPlugin.java

    r478 r481  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.gssim.DCWormsTags; 
    44import schedframe.events.scheduling.SchedulingEvent; 
    55import schedframe.scheduling.manager.resources.ClusterResourceManager; 
     
    1919        } 
    2020 
    21         public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
     21        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
    2222                        ResourceManager resManager, ModuleList modules) { 
    2323 
     
    3939                                TaskInterface<?> task = (TaskInterface<?>) job; 
    4040                                // if status of the tasks in READY 
    41                                 if (task.getStatus() == Gridlet.READY) { 
     41                                if (task.getStatus() == DCWormsTags.READY) { 
    4242                                        System.out.println(resourceManager.getSchedulers().get(0).get_name()); 
    4343                                        String nodeName = resourceManager.getSchedulers().get(0).get_name(); 
  • DCWoRMS/trunk/src/gridsim/gssim/DCWormsTags.java

    r477 r481  
    66 * @author Marcin Krystek 
    77 */ 
    8 public class WormsTags extends GridSimTags { 
     8public class DCWormsTags extends GridSimTags { 
    99         
    1010        protected static final int GSSIMBASE = 600;  
     
    2828        public static final int TASK_REQUESTED_TIME_EXPIRED = GSSIMBASE + 6; 
    2929 
     30         
     31    public static final int CREATED = 0; 
     32 
     33    public static final int SUBMITTED = 1; 
     34     
     35    public static final int READY = 2; 
     36 
     37    public static final int QUEUED = 3; 
     38 
     39    public static final int INEXEC = 4; 
     40 
     41    public static final int SUCCESS = 5; 
     42 
     43    public static final int FAILED = 6; 
     44 
     45    public static final int CANCELED = 7; 
     46 
     47    public static final int PAUSED = 8; 
     48 
     49    public static final int RESUMED = 9; 
     50 
     51    public static final int FAILED_RESOURCE_UNAVAILABLE = 10; 
    3052 
    3153} 
  • DCWoRMS/trunk/src/gridsim/gssim/filter/ExecTaskFilter.java

    r477 r481  
    11package gridsim.gssim.filter; 
    22 
    3 import schedframe.scheduling.tasks.SubmittedTask; 
    43import eduni.simjava.Sim_event; 
    54import gridsim.filter.FilterResult; 
     5import gssim.schedframe.scheduling.Executable; 
    66 
    77/** 
     
    99 * 
    1010 */ 
    11 public class SubTaskFilter extends FilterResult { 
     11public class ExecTaskFilter extends FilterResult { 
    1212 
    13         public SubTaskFilter(int gridletID, int tag) { 
     13        public ExecTaskFilter(int gridletID, int tag) { 
    1414                super(gridletID, tag); 
    1515        } 
     
    2727                                Object obj = ev.get_data(); 
    2828 
    29                                 if (obj instanceof SubmittedTask) { 
     29                                if (obj instanceof Executable) { 
    3030 
    31                                         SubmittedTask subTask = (SubmittedTask) obj; 
     31                                        Executable exec = (Executable) obj; 
    3232 
    33                                         if (subTask.getGridletID() == eventID_) { 
     33                                        if (exec.getUniqueId() == eventID_) { 
    3434                                                result = true; 
    3535                                        } 
  • DCWoRMS/trunk/src/gssim/schedframe/scheduling/ExecTask.java

    r477 r481  
    1010        public boolean expectSpecificResource(ResourceParameterName resourceName);       
    1111        public Object getExpectedSpecificResource(ResourceParameterName resourceName); 
    12          
    13         //public void addToResPath(String resName); 
    14         //public String getResPath(); 
    15          
     12 
    1613        public void visitResource(String resName); 
    1714        public List<String> getVisitedResources(); 
  • DCWoRMS/trunk/src/gssim/schedframe/scheduling/Executable.java

    r480 r481  
    22 
    33 
    4 import gridsim.Gridlet; 
     4import gridsim.GridSim; 
     5import gridsim.gssim.DCWormsTags; 
    56 
    67import java.util.ArrayList; 
     
    910import java.util.Map; 
    1011 
     12import org.apache.commons.lang.ArrayUtils; 
    1113import org.joda.time.DateTime; 
    1214import org.joda.time.DateTimeUtilsExt; 
    1315import org.joda.time.ReadableDuration; 
    1416 
     17import schedframe.resources.computing.ComputingResource; 
     18import schedframe.resources.units.ProcessingElements; 
     19import schedframe.resources.units.StandardResourceUnitName; 
     20import schedframe.scheduling.ResourceHistoryItem; 
     21import schedframe.scheduling.UsedResourceList; 
    1522import schedframe.scheduling.WorkloadUnitHandler; 
    1623import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
     
    2532 * 
    2633 */ 
    27 public class Executable extends Gridlet implements ExecTask{ 
     34public class Executable implements ExecTask{ 
    2835 
    2936        protected Task task; 
    3037        protected String processesSetId; 
    3138         
     39        protected int status;  
     40        protected double length; 
     41        protected Map<ResourceParameterName, Object> specificResources; 
     42         
     43        protected String reservationId; 
     44        protected double completionPercentage; 
     45         
     46        protected int estimatedDuration; 
     47        //TO DO remove and benefit from visitedResources 
     48        protected String schedName; 
     49        protected UsedResourceList<ResourceHistoryItem> usedResources; 
     50        //TO DO consider removing 
    3251        protected List<String> visitedResources; 
    3352 
     53        protected double submissionTime; 
     54    protected double arrivalTime; 
     55        protected double execStartTime ; 
     56    protected double totalCompletionTime;  
     57        protected double finishTime;  
    3458         
    3559        public Executable(Task t){ 
    36                 super(0, 0, 0, 0); 
    3760                this.task = t; 
    38                 super.gridletID_ = (t.getJobId() + "_" + t.getId()).hashCode(); 
    39                 reservationId = null; 
     61                this.status = DCWormsTags.CREATED; 
     62                 
     63                this.usedResources = new UsedResourceList<ResourceHistoryItem>(); 
    4064                this.visitedResources = new ArrayList<String>(); 
    41                 setUserID(task.getSenderId()); 
     65                init(); 
    4266        } 
    4367         
    4468        public Executable(Task t, AbstractProcesses procesesSet){ 
    45                 super(0, 0, 0, 0); 
    4669                this.task = t; 
     70                this.status = DCWormsTags.CREATED; 
    4771                this.processesSetId = procesesSet.getId();  
    48                 super.gridletID_ = (t.getJobId() + "_" + t.getId() + "_" + processesSetId).hashCode(); 
     72                 
     73                this.usedResources = new UsedResourceList<ResourceHistoryItem>(); 
    4974                this.visitedResources = new ArrayList<String>(); 
    50                 setUserID(task.getSenderId()); 
    51         } 
    52          
    53         public DateTime getExecutionEndTime() throws NoSuchFieldException { 
    54                 return task.getExecutionEndTime(); 
    55         } 
    56  
    57         public DateTime getExecutionStartTime() throws NoSuchFieldException { 
    58                 return task.getExecutionStartTime(); 
    59         } 
    60  
    61         public ReadableDuration getExpectedDuration() throws NoSuchFieldException { 
    62                 return task.getExpectedDuration(); 
    63         } 
    64  
     75                init(); 
     76        } 
     77         
     78        protected void init() { 
     79                double currentTime =  DateTimeUtilsExt.getDateTimeAt(arrivalTime).getMillis() / 1000; 
     80                this.submissionTime =  currentTime; 
     81        this.totalCompletionTime = 0.0; 
     82         } 
     83         
     84        public int getUserId() { 
     85                return task.getSenderId(); 
     86        } 
     87        public String getUserDN() { 
     88                return task.getUserDN(); 
     89        } 
     90 
     91        public String getJobId() { 
     92                return task.getJobId(); 
     93        } 
     94         
     95        public String getTaskId(){ 
     96                return this.task.getId(); 
     97        } 
     98         
    6599        public String getId() { 
    66100                if(processesSetId == null) 
     
    69103                        return task.getId() + "_" + processesSetId; 
    70104        } 
    71  
    72         public String getJobId() { 
    73                 return task.getJobId(); 
     105         
     106        public String getProcessesId(){ 
     107                return this.processesSetId; 
     108        } 
     109         
     110    public int getUniqueId(){ 
     111        if(processesSetId == null){ 
     112                return (task.getJobId() + "_" + task.getId()).hashCode(); 
     113        } else { 
     114                return (task.getJobId() + "_" + task.getId() + "_" + processesSetId).hashCode(); 
     115        } 
     116    } 
     117     
     118        public List<AbstractProcesses> getProcesses() { 
     119                return task.getProcesses(); 
     120        } 
     121 
     122        public List<AbstractProcesses> getProcesses( 
     123                        AbstractProcessesGroup processGroup) { 
     124                return task.getProcesses(processGroup); 
     125        } 
     126 
     127        public List<AbstractProcessesGroup> getProcessesGroups() { 
     128                return task.getProcessesGroups(); 
     129        } 
     130 
     131        public org.qcg.broker.schemas.resreqs.Task getDescription() { 
     132                return task.getDescription(); 
     133        } 
     134 
     135        public String getDocument() throws Exception { 
     136                return task.getDocument(); 
     137        } 
     138         
     139        public long getLength() { 
     140                return task.getLength(); 
     141        } 
     142 
     143        public int getStatus() { 
     144                return status; 
     145        } 
     146         
     147        public boolean isFinished() 
     148    { 
     149                return task.isFinished(); 
     150    } 
     151         
     152        public void setStatus(int newStatus) throws Exception { 
     153                int prevStatus = status; 
     154             
     155        if (status == newStatus) { 
     156            return; 
     157        } 
     158 
     159        if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags.FAILED_RESOURCE_UNAVAILABLE) 
     160        { 
     161            throw new Exception("Gridlet.setGridletStatus() : Error - " + 
     162                    "Invalid integer range for Gridlet status."); 
     163        } 
     164 
     165        status = newStatus; 
     166        double currentTime = DateTimeUtilsExt.currentTimeMillis() / 1000; // time in seconds  
     167     
     168                 
     169                if (newStatus == DCWormsTags.SUCCESS || newStatus == DCWormsTags.CANCELED) { 
     170            finishTime = DateTimeUtilsExt.currentTimeMillis() / 1000; 
     171        } 
     172                 
     173                if(newStatus == DCWormsTags.SUBMITTED){ 
     174                         arrivalTime = GridSim.clock(); 
     175                } 
     176 
     177        if (prevStatus == DCWormsTags.INEXEC) 
     178        { 
     179 
     180            if (status == DCWormsTags.CANCELED || status == DCWormsTags.PAUSED || 
     181                status == DCWormsTags.SUCCESS) 
     182            { 
     183                totalCompletionTime += (currentTime -  execStartTime); 
     184            } 
     185        } 
     186 
     187        if (prevStatus == DCWormsTags.RESUMED && status == DCWormsTags.SUCCESS) 
     188        { 
     189            totalCompletionTime += (currentTime -  execStartTime); 
     190        } 
     191 
     192        if (status == DCWormsTags.INEXEC || 
     193            (prevStatus == DCWormsTags.PAUSED && status == DCWormsTags.RESUMED) ) 
     194        { 
     195                execStartTime = currentTime; 
     196                ProcessingElements pes = (ProcessingElements) getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
     197                for (ComputingResource resource : pes) { 
     198 
     199                        visitResource(resource.getName()); 
     200                        ComputingResource parent = resource.getParent(); 
     201 
     202                                List<String> visitedResource = getVisitedResources(); 
     203                        while (parent != null && !ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), parent.getName())) { 
     204                                visitResource(parent.getName()); 
     205                                parent = parent.getParent(); 
     206                        } 
     207                } 
     208        } 
     209        } 
     210         
     211        public void addSpecificResource(ResourceParameterName resourceName, Object value){ 
     212                if(this.specificResources == null) 
     213                        this.specificResources = new HashMap<ResourceParameterName, Object>(); 
     214                 
     215                this.specificResources.put(resourceName, value); 
     216        } 
     217 
     218        public boolean expectSpecificResource(ResourceParameterName resourceName){ 
     219                if(this.specificResources == null) 
     220                        return false; 
     221 
     222                return this.specificResources.containsKey(resourceName); 
     223        } 
     224         
     225        public Object getExpectedSpecificResource(ResourceParameterName resourceName){ 
     226                if(this.specificResources == null) 
     227                        return null; 
     228                 
     229                return this.specificResources.get(resourceName); 
     230        } 
     231         
     232        public void setReservationId(String reservationId){ 
     233                this.reservationId = reservationId; 
     234        } 
     235         
     236        public boolean requireReservation(){ 
     237                return (reservationId != null); 
     238        } 
     239         
     240        public String getReservationId(){ 
     241                return this.reservationId; 
     242        } 
     243         
     244        public double getCompletionPercentage() { 
     245                return completionPercentage; 
     246        } 
     247 
     248        public void setCompletionPercentage(double completionPercentage) { 
     249                this.completionPercentage = completionPercentage; 
     250        } 
     251 
     252        public void addUsedResources(ResourceHistoryItem usedResources){ 
     253                this.usedResources.add(usedResources); 
     254        } 
     255         
     256        public UsedResourceList<ResourceHistoryItem> getUsedResources(){ 
     257                return this.usedResources; 
     258        } 
     259         
     260    public void setSchedulerName(int resourceId) 
     261    { 
     262        this.schedName = GridSim.getEntityName(resourceId); 
     263    } 
     264 
     265    public String getSchedulerName() 
     266    { 
     267        return schedName; 
     268    } 
     269         
     270        public int getEstimatedDuration(){ 
     271                return this.estimatedDuration; 
     272        } 
     273         
     274        public void setEstimatedDuration(int value){ 
     275                this.estimatedDuration = value; 
     276        } 
     277 
     278        public boolean isRegistered() { 
     279                return task.isRegistered(); 
     280        } 
     281 
     282        public void register(JobRegistryImpl jobRegistry) { 
     283                task.register(jobRegistry); 
     284        } 
     285         
     286        public void visitResource(String resName){ 
     287                visitedResources.add(resName); 
     288        } 
     289         
     290        public List<String> getVisitedResources(){ 
     291                return visitedResources; 
     292        } 
     293         
     294        public ReadableDuration getExpectedDuration() throws NoSuchFieldException { 
     295                return task.getExpectedDuration(); 
    74296        } 
    75297 
     
    83305                return task.getParameterStringValue(parameterName); 
    84306        } 
     307         
     308        public double getCpuCntRequest() throws NoSuchFieldException{ 
     309                return getParameterDoubleValue(ResourceParameterName.CPUCOUNT); 
     310        } 
     311         
     312        public double getMemoryRequest() throws NoSuchFieldException{ 
     313                return getParameterDoubleValue(ResourceParameterName.MEMORY); 
     314        } 
     315         
     316        public DateTime getExecutionEndTime() throws NoSuchFieldException { 
     317                return task.getExecutionEndTime(); 
     318        } 
     319 
     320        public DateTime getExecutionStartTime() throws NoSuchFieldException { 
     321                return task.getExecutionStartTime(); 
     322        } 
    85323 
    86324        public DateTime getSubmissionTimeToBroker() { 
     
    88326        } 
    89327 
    90         public String getUserDN() { 
    91                 return task.getUserDN(); 
    92         } 
    93  
    94         public List<AbstractProcesses> getProcesses() { 
    95                 return task.getProcesses(); 
    96         } 
    97  
    98         public List<AbstractProcesses> getProcesses( 
    99                         AbstractProcessesGroup processGroup) { 
    100                 return task.getProcesses(processGroup); 
    101         } 
    102  
    103         public List<AbstractProcessesGroup> getProcessesGroups() { 
    104                 return task.getProcessesGroups(); 
    105         } 
    106  
    107         public org.qcg.broker.schemas.resreqs.Task getDescription() { 
    108                 return task.getDescription(); 
    109         } 
    110  
    111         public String getDocument() throws Exception { 
    112                 return task.getDocument(); 
    113         } 
    114          
    115         public void setReservationId(String reservationId){ 
    116                 this.reservationId = reservationId; 
    117         } 
    118          
    119         public String getProcessesId(){ 
    120                 return this.processesSetId; 
    121         } 
    122          
    123         public String getTaskId(){ 
    124                 return this.task.getId(); 
    125         } 
    126          
    127         public void addSpecificResource(ResourceParameterName resourceName, Object value){ 
    128                 if(this.chosenResources == null) 
    129                         this.chosenResources = new HashMap<ResourceParameterName, Object>(); 
    130                  
    131                 this.chosenResources.put(resourceName, value); 
    132         } 
    133  
    134328        public long getWorkloadLogWaitTime() { 
    135329                return task.getWorkloadLogWaitTime(); 
    136330        } 
    137          
    138          
    139         /*public void addToResPath(String resName){ 
    140                 task.addToResPath(resName); 
    141         } 
    142          
    143         public String getResPath(){ 
    144                 return task.getResPath(); 
    145         } 
    146         */ 
    147          
    148         public void visitResource(String resName){ 
    149                 visitedResources.add(resName); 
    150         } 
    151          
    152         public List<String> getVisitedResources(){ 
    153                 return visitedResources; 
    154         } 
    155          
    156          
    157         protected String reservationId; 
    158          
    159         public boolean requireReservation(){ 
    160                 return (reservationId != null); 
    161         } 
    162          
    163         public String getReservationId(){ 
    164                 return this.reservationId; 
    165         } 
    166          
    167          
     331 
     332    public double getExecStartTime() { 
     333        return execStartTime; 
     334    } 
     335 
     336    public double getFinishTime() { 
     337        return finishTime; 
     338    } 
     339 
     340    public double getSubmissionTime() { 
     341        return submissionTime; 
     342    } 
     343     
     344    public double getWaitingTime() 
     345    { 
     346        return execStartTime - submissionTime; 
     347    } 
     348 
     349     
     350    public void finalizeExecutable(){ 
     351 
     352    } 
     353     
     354        public void accept(WorkloadUnitHandler wuh) { 
     355                wuh.handleExecutable(this); 
     356        } 
     357     
    168358        public boolean equals(Object obj){ 
    169359                if(obj instanceof Executable){ 
     
    173363                return false; 
    174364        } 
    175          
    176         public void setGridletStatus(int newStatus) throws Exception { 
    177                 if(status_ == newStatus) 
    178                         return; 
    179                  
    180                 super.setGridletStatus(newStatus); 
    181                  
    182                 if (newStatus == Gridlet.SUCCESS || newStatus == Gridlet.CANCELED) { 
    183             finishTime_ = DateTimeUtilsExt.currentTimeMillis() / 1000; 
    184         } 
    185         } 
    186  
    187         /** 
    188          * @return the sum of the actual CPU time values for every gird resource,  
    189          * that this sub task has been executed on 
    190          */ 
    191         public double getTotalProcessingTime() { 
    192                 double totalProcessingTime = 0.0; 
    193                 for (Object resObj : resList_) { 
    194                         Resource res = (Resource) resObj; 
    195                         totalProcessingTime += res.actualCPUTime; 
    196                 } 
    197                 return totalProcessingTime; 
    198         } 
    199          
    200  
    201         protected Map<ResourceParameterName, Object> chosenResources; 
    202  
    203          
    204         /** 
    205          *  
    206          * @return length measured in instructions. 
    207          */ 
    208         public long getLength() { 
    209                 return Double.valueOf(getGridletLength()).longValue(); 
    210         } 
    211          
    212         /** 
    213          *  
    214          * @param length measured in instructions. 
    215          */ 
    216         public void setLength(long length){ 
    217                 setGridletLength(Long.valueOf(length).doubleValue()); 
    218         } 
    219          
    220         /** 
    221          *  
    222          * @return constant which represent current task status 
    223          */ 
    224         public int getStatus() { 
    225                 return getGridletStatus(); 
    226         } 
    227          
    228         /** 
    229          *  
    230          * @param status constant which describes current new task status 
    231          */ 
    232         public void setStatus(int status) throws Exception { 
    233                 setGridletStatus(status); 
    234         } 
    235          
    236         public double getCpuCntRequest() throws NoSuchFieldException{ 
    237                 return getParameterDoubleValue(ResourceParameterName.CPUCOUNT); 
    238         } 
    239          
    240         public double getMemoryRequest() throws NoSuchFieldException{ 
    241                 return getParameterDoubleValue(ResourceParameterName.MEMORY); 
    242         } 
    243          
    244         public boolean isFinished() 
    245     { 
    246         if (index_ == -1) { 
    247             return false; 
    248         } 
    249  
    250         boolean completed = false; 
    251  
    252         // if result is 0 or -ve then this Gridlet has finished 
    253         double finish = ( (Resource) resList_.get(index_) ).finishedSoFar; 
    254         double result = gridletLength_ - finish; 
    255         if (result <= 0.001) { 
    256             completed = true; 
    257         } 
    258  
    259         return completed; 
    260     } 
    261          
    262         public boolean expectSpecificResource(ResourceParameterName resourceName){ 
    263                 if(this.chosenResources == null) 
    264                         return false; 
    265  
    266                 return this.chosenResources.containsKey(resourceName); 
    267         } 
    268          
    269         public Object getExpectedSpecificResource(ResourceParameterName resourceName){ 
    270                 if(this.chosenResources == null) 
    271                         return null; 
    272                  
    273                 return this.chosenResources.get(resourceName); 
    274         } 
    275          
    276         public boolean isRegistered() { 
    277                 return task.isRegistered(); 
    278         } 
    279  
    280         public void register(JobRegistryImpl jobRegistry) { 
    281                 task.register(jobRegistry); 
    282  
    283         } 
    284          
    285         @Override 
    286         public void accept(WorkloadUnitHandler wuh) { 
    287                 wuh.handleExecutable(this); 
    288         } 
     365 
    289366} 
  • DCWoRMS/trunk/src/gssim/schedframe/scheduling/plugin/local/DCWormsTimeOperations.java

    r477 r481  
    55import schedframe.scheduling.plugin.local.TimeOperations; 
    66 
    7 public class WormsTimeOperations extends TimeOperations { 
     7public class DCWormsTimeOperations extends TimeOperations { 
    88 
    9         public WormsTimeOperations(){ 
     9        public DCWormsTimeOperations(){ 
    1010                this(0); 
    1111        } 
    1212         
    13         public WormsTimeOperations(long timeDelta){ 
     13        public DCWormsTimeOperations(long timeDelta){ 
    1414                super(timeDelta); 
    1515        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/ComputingResource.java

    r477 r481  
    22 
    33import gridsim.GridSimTags; 
    4 import gridsim.gssim.WormsTags; 
     4import gridsim.gssim.DCWormsTags; 
    55 
    66import java.util.ArrayList; 
     
    275275                        if(scheduler != null && (parent != null && scheduler != parent.getScheduler())/*scheduler.getResources().contains(this)*/){ 
    276276                                String src = event.getSource() != null ? event.getSource() : name; 
    277                                 scheduler.sendInternal(GridSimTags.SCHEDULE_NOW, WormsTags.UPDATE, src); 
     277                                scheduler.sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE, src); 
    278278                        } else if(parent != null) 
    279279                                parent.getEventHandler().handleSchedulingEvent(event); 
  • DCWoRMS/trunk/src/schedframe/resources/computing/ResourceFactory.java

    r477 r481  
    1111import schedframe.scheduling.policy.local.LocalManagementSystem; 
    1212import schedframe.scheduling.queue.TaskQueueList; 
    13 import simulator.WormsConstants; 
     13import simulator.DCWormsConstants; 
    1414 
    1515 
     
    4646                        } 
    4747                        case LS: { 
    48                                 ms = new LocalManagementSystem(id, WormsConstants.MANAGEMENT_SYSTEM, 
     48                                ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 
    4949                                                schedulingPlugin, execTimeEstimationPlugin, queues); 
    5050                                return new Scheduler(ms, type, managedResources); 
     
    5252 
    5353                default:{ 
    54                                 ms = new LocalManagementSystem(id, WormsConstants.MANAGEMENT_SYSTEM, 
     54                                ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 
    5555                                                schedulingPlugin, execTimeEstimationPlugin, queues); 
    5656                                return new Scheduler(ms, type, managedResources); 
  • DCWoRMS/trunk/src/schedframe/scheduling/Cluster.java

    r477 r481  
    1313import gridsim.GridSimTags; 
    1414import gridsim.IO_data; 
    15 import gridsim.gssim.WormsTags; 
     15import gridsim.gssim.DCWormsTags; 
    1616 
    1717public class Cluster extends Scheduler{ 
     
    2323        protected void processOtherRequest(Sim_event ev) { 
    2424                switch (ev.get_tag()) { 
    25                 case WormsTags.QUERY_RESOURCE_DESC: 
     25                case DCWormsTags.QUERY_RESOURCE_DESC: 
    2626                        SchedulerDescription desc = new SchedulerDescription(new LocalSystem(get_name(), null, null)); 
    2727                        Map<ResourceUnitName, List<ResourceUnit>> units = managementSystem.getResourceManager().getSharedResourceUnits(); 
     
    3030 
    3131                        IO_data data = new IO_data(desc, 0, ev.get_src()); 
    32                         send(ev.get_src(), GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
     32                        send(ev.get_src(), GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
    3333                        break; 
    3434 
  • DCWoRMS/trunk/src/schedframe/scheduling/GridResourceDiscovery.java

    r477 r481  
    55import gridsim.GridSimTags; 
    66import gridsim.IO_data; 
    7 import gridsim.gssim.WormsTags; 
     7import gridsim.gssim.DCWormsTags; 
    88 
    99import java.util.ArrayList; 
     
    5858                for(int i = 0; i < resourceList.size(); i++){ 
    5959                        int resourceId = resourceList.get(i).get_id(); 
    60                         gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC, null); 
     60                        gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC, null); 
    6161                } 
    6262                 
    6363                //filter only the query response messages 
    64                 Sim_type_p pred = new Sim_type_p(WormsTags.QUERY_RESOURCE_DESC_RESULT); 
     64                Sim_type_p pred = new Sim_type_p(DCWormsTags.QUERY_RESOURCE_DESC_RESULT); 
    6565                Sim_event ev = new Sim_event(); 
    6666                 
     
    8080                for(int i = 0; i < gridBroker.getChildren().size(); i++){ 
    8181                        int resourceId = gridBroker.getChildren().get(i).get_id(); 
    82                         gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC, null); 
     82                        gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC, null); 
    8383                } 
    8484                 
    8585                //filter only the query response messages 
    86                 Sim_type_p pred = new Sim_type_p(WormsTags.QUERY_RESOURCE_DESC_RESULT); 
     86                Sim_type_p pred = new Sim_type_p(DCWormsTags.QUERY_RESOURCE_DESC_RESULT); 
    8787                Sim_event ev = new Sim_event(); 
    8888                 
  • DCWoRMS/trunk/src/schedframe/scheduling/Scheduler.java

    r478 r481  
    88import gridsim.GridSimTags; 
    99import gridsim.IO_data; 
    10 import gridsim.gssim.WormsTags; 
     10import gridsim.gssim.DCWormsTags; 
    1111 
    1212import java.util.ArrayList; 
     
    2828import schedframe.scheduling.manager.resources.ManagedResources; 
    2929import schedframe.scheduling.policy.AbstractManagementSystem; 
     30import schedframe.scheduling.queue.QueueDescription; 
    3031import schedframe.scheduling.queue.TaskQueue; 
    31 import schedframe.scheduling.queue.QueueDescription; 
    3232import schedframe.scheduling.tasks.WorkloadUnit; 
    3333 
     
    117117                                if (obj != null) { 
    118118                                        int delay = (Integer) obj; 
    119                                         send(this.get_id(), delay, WormsTags.TIMER); 
     119                                        send(this.get_id(), delay, DCWormsTags.TIMER); 
    120120                                } 
    121121                        } 
     
    174174        protected void processOtherRequest(Sim_event ev) { 
    175175                switch (ev.get_tag()) { 
    176                 case WormsTags.QUERY_RESOURCE_DESC: 
     176                case DCWormsTags.QUERY_RESOURCE_DESC: 
    177177                        SchedulerDescription desc = new SchedulerDescription(new LocalSystem(get_name(), null, null)); 
    178178                        Map<ResourceUnitName, List<ResourceUnit>> units = managementSystem.getResourceManager().getSharedResourceUnits(); 
     
    181181 
    182182                        IO_data data = new IO_data(desc, 0, ev.get_src()); 
    183                         send(ev.get_src(), GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
     183                        send(ev.get_src(), GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
    184184                        break; 
    185185 
     
    271271        public List<QueueDescription> getQueuesDescription(){ 
    272272                List<QueueDescription> queues = new ArrayList<QueueDescription>(); 
    273                 for(TaskQueue queue: managementSystem.getAccessQueues()){ 
     273                for(TaskQueue queue: managementSystem.getQueues()){ 
    274274                        QueueDescription qd; 
    275275                        try { 
  • DCWoRMS/trunk/src/schedframe/scheduling/TaskList.java

    r478 r481  
    33import java.util.List; 
    44 
    5 import schedframe.scheduling.tasks.WorkloadUnit; 
     5import schedframe.scheduling.tasks.TaskInterface; 
    66 
    77 
    8 public interface WorkloadUnitList extends List<WorkloadUnit>{ 
     8public interface TaskList extends List<TaskInterface<?>>{ 
    99 
    1010} 
  • DCWoRMS/trunk/src/schedframe/scheduling/TaskListImpl.java

    r478 r481  
    33import java.util.ArrayList; 
    44 
    5 import schedframe.scheduling.tasks.WorkloadUnit; 
     5import schedframe.scheduling.tasks.TaskInterface; 
    66 
    77 
    8 public class WorkloadUnitListImpl extends ArrayList<WorkloadUnit> implements WorkloadUnitList { 
     8public class TaskListImpl extends ArrayList<TaskInterface<?>> implements TaskList { 
    99 
    1010        private static final long serialVersionUID = -3824600938144742457L; 
    1111 
    12         public WorkloadUnitListImpl(){ 
     12        public TaskListImpl(){ 
    1313                super(); 
    1414        } 
    1515         
    16         public WorkloadUnitListImpl(int initialSize){ 
     16        public TaskListImpl(int initialSize){ 
    1717                super(initialSize); 
    1818        }        
  • DCWoRMS/trunk/src/schedframe/scheduling/WorkloadUnitHandler.java

    r477 r481  
    22 
    33import schedframe.scheduling.tasks.Job; 
    4 import schedframe.scheduling.tasks.SubmittedTask; 
     4 
    55import schedframe.scheduling.tasks.TaskInterface; 
    66import gssim.schedframe.scheduling.ExecTask; 
     
    1313         
    1414        public void handleExecutable(ExecTask task); 
    15          
    16         public void handleSubmittedTask(SubmittedTask task); 
     15 
    1716} 
  • DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/AbstractJobRegistry.java

    r480 r481  
    1313 
    1414 
    15 public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job> */implements JobRegistry, Cloneable{ 
     15public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job>*/ implements JobRegistry, Cloneable{ 
    1616         
    1717        private static final long serialVersionUID = 8409060063583755824L; 
     18 
    1819         
    19         private static Log log = LogFactory.getLog(AbstractJobRegistry.class); 
    20          
    21         protected static final ConcurrentHashMap<String, Job> jobs = new ConcurrentHashMap<String, Job>(); 
     20        protected static final ConcurrentHashMap<String, JobInterface<?>> jobs = new ConcurrentHashMap<String, JobInterface<?>>(); 
    2221         
    2322        protected AbstractJobRegistry(){ 
    24                 //log.warn("Methods from JobRegistry interface are not implemented."); 
    2523        } 
    2624         
    2725        public boolean addJob(JobInterface<?> job) { 
    28                 jobs.put(job.getId(), (Job) job); 
     26                jobs.put(job.getId(), job); 
    2927                return true; 
    3028        } 
     
    3230        public boolean addTask(TaskInterface<?> task) { 
    3331                if(jobs.containsKey(task.getJobId())){ 
    34                         jobs.get(task.getJobId()).add((Task)task); 
     32                        getJob(task.getJobId()).add((Task)task); 
    3533                        return true; 
    3634                } else { 
     
    3937        } 
    4038 
    41         public Job getJob(String jobId){ 
     39        public JobInterface<?> getJobInfo(String jobId) { 
    4240                return jobs.get(jobId); 
    4341        } 
    44          
    45         public JobInterface<?> getJobInfo(String jobID) { 
    46                 return jobs.get(jobID); 
    47         } 
    4842 
    49         public TaskInterface<?> getTaskInfo(String jobID, String taskId) { 
     43        public TaskInterface<?> getTaskInfo(String jobId, String taskId) { 
    5044                Task task = null; 
    51                 Job job = jobs.get(jobID); 
     45                Job job = getJob(jobId); 
    5246                 
    5347                if(job == null) 
     
    5751                        task = job.getTask(taskId); 
    5852                } catch (NoSuchFieldException e) { 
    59                         log.error(e.getMessage()); 
    6053                } 
    6154                return task; 
    6255        } 
    6356         
    64         /*public List<JobInterface<?>> getActiveJobs() { 
    65                 log.error("getActiveJobs() not implemented."); 
    66                 return null; 
     57        public Job getJob(String jobId){ 
     58                return (Job)jobs.get(jobId); 
    6759        } 
    6860 
    69         public List<TaskInterface<?>> getActiveTasks() { 
    70                 log.error("getActiveTasks() not implemented."); 
    71                 return null; 
    72         }*/ 
    73  
    7461} 
  • DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/JobRegistry.java

    r477 r481  
    55import java.util.List; 
    66 
     7import schedframe.ExecutablesList; 
    78import schedframe.scheduling.tasks.JobInterface; 
    89import schedframe.scheduling.tasks.TaskInterface; 
     
    1112public interface JobRegistry { 
    1213 
    13         //public List<JobInterface<?>> getActiveJobs(); 
    14  
    15         //public List<TaskInterface<?>> getActiveTasks(); 
    16          
    1714        public JobInterface<?> getJobInfo(String jobId); 
    1815 
     
    3128 
    3229 
    33         //public List<SubmittedTask> getSubmittedTasks(); 
     30        public ExecutablesList getExecutableTasks();  
    3431         
    35         public ExecTask getSubmittedTask(String jobId, String taskId); 
     32        public ExecTask getExecutable(String jobId, String taskId); 
    3633 
    3734         
    38         public List<? extends TaskInterface<?>> getReadyTasks(List<JobInterface<?>> jobsList); 
     35        public List<? extends TaskInterface<?>> getAvailableTasks(List<JobInterface<?>> jobsList); 
    3936 
    4037} 
  • DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/JobRegistryImpl.java

    r477 r481  
    11package schedframe.scheduling.manager.tasks; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.gssim.DCWormsTags; 
    44import gssim.schedframe.scheduling.ExecTask; 
    5 import gssim.schedframe.scheduling.Executable; 
    65 
    76import java.util.ArrayList; 
    8 import java.util.Collections; 
    9 import java.util.HashMap; 
    107import java.util.List; 
    11 import java.util.Map; 
    128 
    139import org.apache.commons.lang.ArrayUtils; 
    1410import org.apache.commons.logging.Log; 
    1511import org.apache.commons.logging.LogFactory; 
    16 import org.joda.time.DateTime; 
    1712import org.qcg.broker.schemas.resreqs.ParentType; 
    1813import org.qcg.broker.schemas.resreqs.types.TaskStatesName; 
    1914 
    2015import qcg.shared.constants.BrokerConstants; 
    21 import schedframe.resources.units.ResourceUnit; 
    22 import schedframe.resources.units.ResourceUnitName; 
    23 import schedframe.scheduling.ResourceHistoryItem; 
    24 import schedframe.scheduling.plan.AllocationInterface; 
    25 import schedframe.scheduling.tasks.AbstractProcesses; 
     16import schedframe.ExecutablesList; 
    2617import schedframe.scheduling.tasks.JobInterface; 
    27 import schedframe.scheduling.tasks.SubmittedTask; 
    2818import schedframe.scheduling.tasks.Task; 
    29 import simulator.WormsConstants; 
    3019 
    3120public class JobRegistryImpl extends AbstractJobRegistry { 
     
    3726        private String context; 
    3827 
    39         //TO DO - change data structure 
    40         protected static final List<ExecTask> submittedTasks = Collections.synchronizedList(new ArrayList<ExecTask>());; 
    41         //protected static final List<ExecTaskInterface> submittedTasks = new CopyOnWriteArrayList<ExecTaskInterface>(); 
     28        //TO DO - consider data structure 
     29        protected static final ExecutablesList executables = new ExecutablesList(); 
     30        //protected static final List<ExecTask> executables = Collections.synchronizedList(new ArrayList<ExecTask>());; 
     31        //protected static final List<ExecTaskInterface> executables = new CopyOnWriteArrayList<ExecTaskInterface>(); 
    4232 
    43         public JobRegistryImpl(String context_) { 
    44                 context = context_; 
     33        public JobRegistryImpl(String context) { 
     34                this.context = context; 
    4535        } 
    4636 
    47         /*protected void setContext(String context_) { 
    48                 context = context_; 
    49         }*/ 
    50  
    51         public boolean addTask(ExecTask newTask) { 
    52                 if(getSubmittedTask(newTask.getJobId(), newTask.getId()) == null) 
    53                 { 
    54                         synchronized (submittedTasks)  { 
    55                                 submittedTasks.add(newTask); 
     37        public boolean addExecTask(ExecTask newTask) { 
     38                if(getExecutable(newTask.getJobId(), newTask.getId()) == null) { 
     39                        synchronized (executables)  { 
     40                                executables.add(newTask); 
    5641                        } 
    5742                        return true; 
     
    6045        } 
    6146 
     47        public ExecutablesList getExecutableTasks() { 
     48                return executables; 
     49        } 
    6250        public List<ExecTask> getTasks(int status) { 
    6351                List<ExecTask> taskList = new ArrayList<ExecTask>(); 
    64                 synchronized (submittedTasks)  { 
    65                         for (ExecTask task: submittedTasks) { 
     52                synchronized (executables)  { 
     53                        for (ExecTask task: executables) { 
    6654                                if (task.getStatus() == status) { 
    67                                         //SubmittedTask subTask = (SubmittedTask) task; 
    6855                                        List<String> visitedResource = task.getVisitedResources(); 
    69                                         if(ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), context)){ 
     56                                        if(ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), context)) { 
    7057                                                taskList.add(task); 
    7158                                        } 
    72                                         /*if(subTask.getVisitedResources().contains(context)){ 
    73                                                 taskList.add(subTask); 
    74                                         }*/ 
    7559                                } 
    7660                        } 
     
    8064 
    8165        public List<ExecTask> getQueuedTasks() { 
    82                 return getTasks(Gridlet.QUEUED); 
     66                return getTasks(DCWormsTags.QUEUED); 
    8367        } 
    8468         
    8569        public List<ExecTask> getRunningTasks() { 
    86                 return getTasks(Gridlet.INEXEC); 
     70                return getTasks(DCWormsTags.INEXEC); 
    8771        } 
    8872         
    8973        public List<ExecTask> getReadyTasks() { 
    90                 return getTasks(Gridlet.READY); 
     74                return getTasks(DCWormsTags.READY); 
    9175        } 
    9276         
    9377        public List<ExecTask> getFinishedTasks() { 
    94                 return getTasks(Gridlet.SUCCESS); 
     78                return getTasks(DCWormsTags.SUCCESS); 
    9579        } 
    9680         
    97          
    98         public List<ExecTask> getAllSubmittedTasks() { 
    99                 List<ExecTask> taskList; 
    100                 synchronized (submittedTasks)  { 
    101                         taskList = new ArrayList<ExecTask>(submittedTasks); 
    102                 } 
    103                 return taskList; 
    104         } 
    105  
    106         public List<SubmittedTask> getSubmittedTasks() { 
    107                 List<SubmittedTask> taskList = new ArrayList<SubmittedTask>(); 
    108                 synchronized (submittedTasks)  { 
    109                         for (ExecTask task : submittedTasks) { 
    110                                 SubmittedTask subTask = (SubmittedTask) task; 
    111                                 List<String> visitedResource = subTask.getVisitedResources(); 
    112                                 if(ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), context)){ 
    113                                         taskList.add(subTask); 
    114                                 } 
    115                                 /*if(subTask.getVisitedResources().contains(context)){ 
    116                                         taskList.add(subTask); 
    117                                 }*/ 
    118                         } 
    119                 } 
    120                 return taskList; 
    121         } 
    122          
    123         public ExecTask getSubmittedTask(String jobId, String taskId){ 
    124                 synchronized (submittedTasks)  { 
    125                         for (ExecTask task : submittedTasks) { 
     81        public ExecTask getExecutable(String jobId, String taskId){ 
     82                synchronized (executables)  { 
     83                        for (ExecTask task : executables) { 
    12684                                if (task.getJobId().compareTo(jobId) == 0 && task.getId().compareTo(taskId)==0) { 
    12785                                        return task; 
     
    13189                return null; 
    13290        } 
    133          
    13491 
    13592        @SuppressWarnings("unchecked") 
    136         public List<Task> getReadyTasks(List<JobInterface<?>> wuList) { 
    137                 List<Task> readyTasks = new ArrayList<Task>(); 
     93        public List<Task> getAvailableTasks(List<JobInterface<?>> wuList) { 
     94                List<Task> availableTasks = new ArrayList<Task>(); 
    13895                List<Task> waitingTasks = new ArrayList<Task>(); 
    13996                 
     
    143100                } 
    144101 
    145                 readyTasks.addAll(getPrecedenceConstrainedReadyTasks(waitingTasks)); 
    146                 return readyTasks; 
    147         } 
    148          
    149         public Executable getTaskExecutable(Integer executableId){ 
    150                 synchronized (submittedTasks)  { 
    151                         for (ExecTask task : submittedTasks) { 
    152                                 SubmittedTask subTask = (SubmittedTask) task; 
    153                                 Executable exec = (Executable)subTask.getGridlet(); 
    154                                 if (exec.getGridletID() == executableId) { 
    155                                         return exec; 
    156                                 } 
    157                         } 
    158                 } 
    159                 return null; 
    160         } 
    161          
    162         public List<Executable> getJobExecutables(String jobId){ 
    163                 List<Executable> list = new ArrayList<Executable>(); 
    164                 synchronized (submittedTasks)  { 
    165                         for(int i = 0; i < submittedTasks.size(); i++){ 
    166                                 SubmittedTask subTask = (SubmittedTask) submittedTasks.get(i); 
    167                                 Executable exec = (Executable)subTask.getGridlet(); 
    168                                  
    169                                 if(exec.getJobId().equals(jobId)) 
    170                                         list.add(exec); 
    171                         } 
    172                 } 
    173                 return list; 
    174         } 
    175          
    176         public JobRegistryImpl clone() { 
    177                 JobRegistryImpl jr = null; 
    178                 try { 
    179                         jr = (JobRegistryImpl) super.clone(); 
    180                 } catch (CloneNotSupportedException e) { 
    181                         // TODO Auto-generated catch block 
    182                         e.printStackTrace(); 
    183                 } 
    184  
    185                 return jr; 
    186         } 
    187  
    188         /*public AbstractExecutable getTaskExecutabls(String jobId, String taskId){ 
    189                 List<AbstractExecutable> list = new ArrayList<AbstractExecutable>(); 
    190                 synchronized (submittedTasks)  { 
    191                         for(int i = 0; i < size(); i++){ 
    192                                 SubmittedTask subTask = (SubmittedTask) submittedTasks.get(i); 
    193                                 AbstractExecutable exec = (AbstractExecutable)subTask.getGridlet(); 
    194                                  
    195                                 if(exec.getJobId().equals(jobId) && exec.getId().equals(taskId)) 
    196                                         return exec; 
    197                         } 
    198                 } 
    199                 return null; 
    200         }*/ 
    201          
    202          
    203         public Executable createExecutable(Task task, AllocationInterface allocation) { 
    204  
    205                 String refersTo = allocation.getProcessGroupId(); // null;//allocation.getRefersTo(); 
    206                 if(refersTo == null) 
    207                         refersTo = task.getId(); 
    208                          
    209                 Executable exec = null; 
    210  
    211                 if(refersTo.equals(task.getId())){ 
    212                         exec = new Executable(task); 
    213                 } else { 
    214                         List<AbstractProcesses> processes = task.getProcesses(); 
    215                         if(processes == null) { 
    216                                 try { 
    217                                         log.error("Allocation: " + allocation.getDocument() + "\nrefers to unknown task or processes set." + 
    218                                                         " Set correct value (task id or prcesses set id) for allocation refersTo attribute."); 
    219                                 } catch (Exception e) { 
    220                                         e.printStackTrace(); 
    221                                 } 
    222                         } 
    223                         boolean found = false; 
    224                         for(int j = 0; j < processes.size() && !found; j++){ 
    225                                 AbstractProcesses procesesSet = processes.get(j); 
    226                                 if(refersTo.equals(procesesSet.getId())){ 
    227                                         exec = new Executable(task, procesesSet); 
    228                                         found = true; 
    229                                 } 
    230                         } 
    231                         if(!found){ 
    232                                 log.error("Allocation refers to unknown proceses set."); 
    233                         } 
    234                 } 
    235                  
    236         //      exec.setUserID(task.getSenderId()); 
    237                 exec.setLength(task.getLength()); 
    238                 exec.setReservationId(allocation.getReservationId()); 
    239                          
    240                 /*HostInterface<?> host = allocation.getHost(); 
    241                 ComputingResourceTypeInterface<?> crt = host.getMachineParameters(); 
    242                 if(crt != null){ 
    243                         ComputingResourceTypeItemInterface<?> crti = crt.getComputingResourceTypeItem(0); 
    244                         if(crti != null){ 
    245                                 ParameterPropertyInterface<?> properties[] = crti.getHostParameter().getProperty(); 
    246                                 for(int p = 0; p < properties.length; p++){ 
    247                                         ParameterPropertyInterface<?> property = properties[p]; 
    248                                         if("chosenCPUs".equals(property.getName())){ 
    249                                                 Object cpuNames = property.getValue(); 
    250                                                 exec.addSpecificResource(ResourceParameterName.FREECPUS, cpuNames); 
    251                                         } 
    252                                 } 
    253                         } 
    254                 }*/ 
    255                 return exec; 
    256         } 
    257          
    258  
    259         public List<Executable> createExecutables(Task task) { 
    260  
    261                 List<AbstractProcesses> processes = task.getProcesses(); 
    262                  
    263                 List<Executable> executables = new ArrayList<Executable>(); 
    264  
    265                 if(processes == null || processes.size()==0){ 
    266                         Executable exec = new Executable(task); 
    267                         exec.setUserID(task.getSenderId()); 
    268                         exec.setLength(task.getLength()); 
    269                         executables.add(exec); 
    270                 } else { 
    271  
    272                         boolean found = false; 
    273                         for(int j = 0; j < processes.size() && !found; j++){ 
    274                                 AbstractProcesses procesesSet = processes.get(j); 
    275                                 Executable exec = new Executable(task, procesesSet); 
    276                                 exec.setUserID(task.getSenderId()); 
    277                                 exec.setLength(task.getLength()); 
    278                                 executables.add(exec); 
    279                         } 
    280                 } 
    281  
    282                 return  executables; 
     102                availableTasks.addAll(getPrecedenceConstrainedAvailableTasks(waitingTasks)); 
     103                return availableTasks; 
    283104        } 
    284105 
    285106 
    286         /**************************************/ 
    287         protected static Map<Integer, Map<String, Object>> history = new HashMap<Integer, Map<String,Object>>(); 
    288          
    289         public static Map<Integer, Map<String, Object>> getAllocationHistory(){ 
    290                 return history; 
    291         } 
    292          
    293         public void saveHistory (SubmittedTask submittedTask, int estimatedTime, Map<ResourceUnitName, ResourceUnit> choosenResources){ 
     107        private List<Task> getPrecedenceConstrainedAvailableTasks(List<Task> tasks){ 
    294108                 
    295                 /*submittedTask.setEstimatedDuration(estimatedTime); 
    296  
    297                 DateTime currentTime = new DateTime(); 
    298                 ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 
    299                 submittedTask.addUsedResources(resHistItem);*/ 
    300  
    301                 ResourceHistoryItem resHistItem = submittedTask.getUsedResources().getLast(); 
    302                 DateTime currentTime = new DateTime(); 
    303                 Map<String, Object> historyItem = new HashMap<String, Object>(); 
    304                 List<ResourceHistoryItem> list = new ArrayList<ResourceHistoryItem>(1); 
    305                 list.add(resHistItem); 
    306                 historyItem.put(WormsConstants.RESOURCES, list); 
    307                 historyItem.put(WormsConstants.START_TIME, currentTime); 
    308                 currentTime = currentTime.plusSeconds(estimatedTime); 
    309                 historyItem.put(WormsConstants.END_TIME, currentTime); 
    310  
    311                 history.put(Integer.valueOf(submittedTask.getGridletID()), historyItem); 
    312                 /*ProcessingElements pes = (ProcessingElements) choosenResources.get(ResourceParameterName.PROCESSINGELEMENTS); 
    313                 for (ComputingResource resource : pes) { 
    314                         //submittedTask.addToResPath(resource.getName()); 
    315                         submittedTask.visitResource(resource.getName()); 
    316                         ComputingResource parent = resource.getParent(); 
    317                         while (parent != null && !submittedTask.getResPath().contains(parent.getName() + "_")) { 
    318                                 submittedTask.addToResPath(parent.getName()); 
    319                                 parent = parent.getParent(); 
    320                         } 
    321                         while (parent != null && !submittedTask.getVisitedResources().contains(parent.getName() + "_")) { 
    322                                 submittedTask.visitResource(parent.getName()); 
    323                                 parent = parent.getParent(); 
    324                         } 
    325                 }*/ 
    326         } 
    327  
    328         private List<Task> getPrecedenceConstrainedReadyTasks(List<Task> tasks){ 
     109                List<Task> availableTasks = new ArrayList<Task>(); 
     110                int size = tasks.size(); 
    329111                 
    330                 List<Task> readyTasks = new ArrayList<Task>(); 
    331  
    332                 int size = tasks.size(); 
    333112                for(int i = 0; i < size; i++){ 
    334113                        int parCnt; 
    335                         int previousTaskReadyCnt = 0; 
     114                        int previousTaskSucceedCnt = 0; 
    336115                        Task task = tasks.get(i); 
    337116                        if(task.getStatus() != (int)BrokerConstants.TASK_STATUS_UNSUBMITTED) 
     
    341120                        } catch(Exception e){ 
    342121                                parCnt = 0; 
    343                                 //e.printStackTrace(); 
    344122                        } 
    345                         if(parCnt == 0) 
    346                         { 
    347                                 readyTasks.add(task); 
     123                        if(parCnt == 0){ 
     124                                availableTasks.add(task); 
    348125                        } 
    349                         else 
    350                         { 
     126                        else { 
    351127                                for(int j = 0; j < parCnt; j++){ 
    352128                                        ParentType par = task.getDescription().getWorkflow().getParent(j); 
     
    356132                                                } 
    357133                                        } 
    358                                         previousTaskReadyCnt++; 
     134                                        previousTaskSucceedCnt++; 
    359135                                } 
    360136                                 
    361                                 if(previousTaskReadyCnt == parCnt && task.getDescription().getWorkflow().getAnd() != null) 
    362                                         readyTasks.add(task); 
    363                                 else if(previousTaskReadyCnt > 0 && task.getDescription().getWorkflow().getOr() != null) 
    364                                         readyTasks.add(task); 
    365                                 else if (previousTaskReadyCnt == parCnt) 
    366                                         readyTasks.add(task); 
     137                                if(previousTaskSucceedCnt == parCnt && task.getDescription().getWorkflow().getAnd() != null) 
     138                                        availableTasks.add(task); 
     139                                else if(previousTaskSucceedCnt > 0 && task.getDescription().getWorkflow().getOr() != null) 
     140                                        availableTasks.add(task); 
     141                                else if (previousTaskSucceedCnt == parCnt) 
     142                                        availableTasks.add(task); 
    367143                        } 
    368144                }                
    369                 return readyTasks; 
     145                return availableTasks; 
    370146        } 
    371147         
     
    380156                return false; 
    381157        } 
     158 
    382159} 
  • DCWoRMS/trunk/src/schedframe/scheduling/plan/ScheduledTaskInterface.java

    r478 r481  
    44 
    55import schedframe.DescriptionContainer; 
    6 import schedframe.scheduling.tasks.WorkloadUnit; 
     6import schedframe.scheduling.tasks.TaskInterface; 
    77 
    88public interface ScheduledTaskInterface<T> extends DescriptionContainer<T> { 
     
    190190         
    191191 
    192         public ArrayList<AllocationInterface> getAllocations(); 
     192        public ArrayList<AllocationInterface<?>> getAllocations(); 
    193193         
    194         public WorkloadUnit getTask(); 
     194        public TaskInterface<?> getTask(); 
    195195 
    196196} 
  • DCWoRMS/trunk/src/schedframe/scheduling/plan/SchedulingPlanInterface.java

    r477 r481  
    9999 
    100100 
    101         public ArrayList<ScheduledTaskInterface> getTasks(); 
     101        public ArrayList<ScheduledTaskInterface<?>> getTasks(); 
    102102} 
  • DCWoRMS/trunk/src/schedframe/scheduling/plan/impl/ScheduledTask.java

    r478 r481  
    66import org.exolab.castor.xml.MarshalException; 
    77import org.exolab.castor.xml.ValidationException; 
     8import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 
    89 
    910import schedframe.scheduling.plan.AllocationInterface; 
    1011import schedframe.scheduling.plan.ScheduledTaskInterface; 
    1112import schedframe.scheduling.plan.ScheduledTimeInterface; 
    12 import schedframe.scheduling.tasks.WorkloadUnit; 
    13  
    14  
    15 import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 
     13import schedframe.scheduling.tasks.TaskInterface; 
    1614 
    1715public class ScheduledTask implements ScheduledTaskInterface<org.qcg.broker.schemas.schedulingplan.Task> { 
     
    2220        public ScheduledTask(){ 
    2321                t = new org.qcg.broker.schemas.schedulingplan.Task(); 
    24                 allocationList = new ArrayList<AllocationInterface>(); 
     22                allocationList = new ArrayList<AllocationInterface<?>>(); 
    2523        } 
    2624         
    2725        public ScheduledTask(org.qcg.broker.schemas.schedulingplan.Task value){ 
    2826                t = value; 
    29                 allocationList = new ArrayList<AllocationInterface>(); 
     27                allocationList = new ArrayList<AllocationInterface<?>>(); 
    3028        } 
    3129         
     
    178176         
    179177 
    180         protected WorkloadUnit task; 
    181         protected ArrayList<AllocationInterface> allocationList; 
     178        protected TaskInterface<?> task; 
     179        protected ArrayList<AllocationInterface<?>> allocationList; 
    182180 
    183         public ScheduledTask(WorkloadUnit task){ 
     181        public ScheduledTask(TaskInterface<?> task){ 
    184182                this(); 
    185183                this.task = task; 
    186184        } 
    187185 
    188         public ArrayList<AllocationInterface> getAllocations() { 
     186        public ArrayList<AllocationInterface<?>> getAllocations() { 
    189187                return this.allocationList; 
    190188        } 
    191189         
    192         public WorkloadUnit getTask(){ 
     190        public TaskInterface<?> getTask(){ 
    193191                return this.task; 
    194192        } 
  • DCWoRMS/trunk/src/schedframe/scheduling/plan/impl/SchedulingPlan.java

    r477 r481  
    1818        public SchedulingPlan(){ 
    1919                sp = new org.qcg.broker.schemas.schedulingplan.SchedulingPlan(); 
    20                 taskList = new ArrayList<ScheduledTaskInterface>(); 
     20                taskList = new ArrayList<ScheduledTaskInterface<?>>(); 
    2121        } 
    2222         
    2323        public SchedulingPlan(org.qcg.broker.schemas.schedulingplan.SchedulingPlan value){ 
    2424                sp = value; 
    25                 taskList = new ArrayList<ScheduledTaskInterface>(); 
     25                taskList = new ArrayList<ScheduledTaskInterface<?>>(); 
    2626        } 
    2727         
     
    106106 
    107107         
    108         protected ArrayList<ScheduledTaskInterface> taskList; 
     108        protected ArrayList<ScheduledTaskInterface<?>> taskList; 
    109109 
    110         public ArrayList<ScheduledTaskInterface> getTasks() { 
     110        public ArrayList<ScheduledTaskInterface<?>> getTasks() { 
    111111 
    112112                return this.taskList; 
  • DCWoRMS/trunk/src/schedframe/scheduling/plugin/SchedulingPlugin.java

    r477 r481  
    33import schedframe.Plugin; 
    44import schedframe.events.scheduling.SchedulingEvent; 
    5 import schedframe.scheduling.WorkloadUnitListImpl; 
     5import schedframe.scheduling.TaskListImpl; 
    66import schedframe.scheduling.manager.resources.ResourceManager; 
    77import schedframe.scheduling.manager.tasks.JobRegistry; 
     
    1212public interface SchedulingPlugin extends Plugin{ 
    1313 
    14         public int placeJobsInQueues(WorkloadUnitListImpl newJobs, 
     14        public int placeTasksInQueues(TaskListImpl newTasks, 
    1515                        TaskQueueList queues,  
    1616                        ResourceManager resourceManager, ModuleList modules); 
  • DCWoRMS/trunk/src/schedframe/scheduling/policy/AbstractManagementSystem.java

    r480 r481  
    1010import schedframe.PluginConfiguration; 
    1111import schedframe.events.scheduling.SchedulingEventType; 
    12 import schedframe.resources.units.StandardResourceUnitName; 
    1312import schedframe.scheduling.Scheduler; 
    1413import schedframe.scheduling.WorkloadUnitHandler; 
     
    1615import schedframe.scheduling.manager.resources.ResourceManager; 
    1716import schedframe.scheduling.manager.resources.ResourceManagerFactory; 
     17import schedframe.scheduling.manager.tasks.JobRegistry; 
    1818import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    19 import schedframe.scheduling.manager.tasks.JobRegistry; 
    2019import schedframe.scheduling.plan.AllocationInterface; 
    2120import schedframe.scheduling.plan.SchedulingPlanInterface; 
     
    2726import schedframe.scheduling.queue.TaskQueueList; 
    2827import schedframe.scheduling.tasks.Job; 
     28import schedframe.scheduling.tasks.TaskInterface; 
    2929import schedframe.scheduling.tasks.WorkloadUnit; 
    30 import simulator.WormsConstants; 
     30import simulator.DCWormsConstants; 
    3131import eduni.simjava.Sim_event; 
    3232import gridsim.GridSim; 
    3333import gridsim.GridSimTags; 
    34 import gridsim.Gridlet; 
    3534import gridsim.IO_data; 
    36 import gridsim.gssim.WormsTags; 
     35import gridsim.gssim.DCWormsTags; 
    3736import gssim.schedframe.scheduling.ExecTask; 
    3837import gssim.schedframe.scheduling.Executable; 
     
    4544        protected String name; 
    4645 
     46        protected TaskQueueList queues; 
    4747        protected ResourceManager resourceManager; 
    48  
    49         protected TaskQueueList queues; 
    50  
     48        protected JobRegistryImpl jobRegistry; 
     49        protected ModuleList moduleList; 
     50         
    5151        protected SchedulingPlugin schedulingPlugin; 
    52  
    5352        protected ExecutionTimeEstimationPlugin execTimeEstimationPlugin; 
    5453 
    55         protected ModuleList moduleList; 
    56          
    57         protected JobRegistryImpl jobRegistry; 
     54        protected Scheduler scheduler; 
    5855         
    5956 
     
    6764        } 
    6865         
     66        public void init(Scheduler sched, ManagedResources managedResources) { 
     67                scheduler = sched; 
     68                resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources); 
     69                scheduler.set_stat(DCWormsConstants.getResourcesStatisticsObject(queues.size())); 
     70                for(int i = 0; i < queues.size(); i++){ 
     71                        TaskQueue q = queues.get(i); 
     72                        if(q instanceof AbstractStatsSupportingQueue<?>){ 
     73                                AbstractStatsSupportingQueue<?> queue = (AbstractStatsSupportingQueue<?>) q; 
     74                                queue.setStats(scheduler.get_stat(), DCWormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME + "_" + Integer.toString(i)); 
     75                        } 
     76                } 
     77        } 
     78         
    6979        public void processEvent(Sim_event ev) { 
    7080                processOtherEvent(ev); 
     
    8191        } 
    8292         
     93         
    8394        public String getName() { 
    8495                return name; 
    85         } 
    86  
    87         public PluginConfiguration getSchedulingPluginConfiguration() { 
    88                 return schedulingPlugin.getConfiguration(); 
    8996        } 
    9097         
     
    106113                return jobRegistry; 
    107114        } 
     115         
     116        public Scheduler getScheduler() { 
     117                return scheduler; 
     118        } 
     119         
     120        public PluginConfiguration getSchedulingPluginConfiguration() { 
     121                return schedulingPlugin.getConfiguration(); 
     122        } 
    108123 
    109124        public boolean pluginSupportsEvent(int eventType){ 
     
    111126        } 
    112127 
    113         public abstract void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack); 
    114  
    115         public abstract void notifyCanceledWorkloadUnit(WorkloadUnit wu); 
    116  
    117         public abstract void notifyReturnedWorkloadUnit(WorkloadUnit wu); 
    118  
    119         protected abstract void executeSchedulingPlan(SchedulingPlanInterface decision); 
    120  
    121  
    122  
     128        public TaskQueueList getQueues(){ 
     129                return queues; 
     130        } 
     131         
     132        public Map<String, Integer> getQueuesSize() { 
     133                Map<String, Integer> queue_size = new HashMap<String, Integer>(); 
     134                for (TaskQueue queue : queues) { 
     135                        queue_size.put(queue.getName(), queue.size()); 
     136                } 
     137                return queue_size; 
     138        } 
     139         
    123140        //POPRAWIC  (ale co? bo teraz chyba jest ok) 
    124         protected void submitWorkloadUnit(WorkloadUnit wu, AllocationInterface allocation) { 
     141        protected void submitTask(TaskInterface<?> task, AllocationInterface<?> allocation) { 
    125142                String providerName = allocation.getProviderName(); 
    126143                if (providerName == null) { 
     
    128145                } 
    129146                //Executable exec = (Executable) wu; 
    130                 removeFromQueue(wu); 
    131                 scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, wu);  
    132         } 
    133          
    134         protected boolean sendCanceledWorkloadUnit(int tag, Executable task, int executableId, int destId) { 
    135                  
    136                 if (tag != GridSimTags.GRIDLET_CANCEL) { 
    137                         return false; 
    138                 } 
    139  
    140                 long taskSize = 0; 
    141                 if (task != null) { 
    142                         taskSize = task.getGridletOutputSize(); 
    143                 } 
    144  
    145                 // if no Gridlet found, then create a new Gridlet but set its status 
    146                 // to FAILED. Then, most importantly, set the resource parameters 
    147                 // because the user will search/filter based on a resource ID. 
    148                 else if (task == null) { 
    149                         try { 
    150                                 taskSize = 100; 
    151                                 task = jobRegistry.getTaskExecutable(executableId); 
    152                                 task.setGridletStatus(Gridlet.FAILED); 
    153                                 int cost = resourceManager.getSharedResourceUnits().get(StandardResourceUnitName.COST) != null ? resourceManager 
    154                                                 .getSharedResourceUnits().get(StandardResourceUnitName.COST).get(0).getAmount() 
    155                                                 : 1; 
    156                                 task.setResourceParameter(scheduler.get_id(), cost); 
    157                         } catch (Exception e) { 
    158                                 // empty ... 
    159                         } 
    160                 } 
    161                 scheduler.send(scheduler.getOutputPort(), GridSimTags.SCHEDULE_NOW, tag,  new IO_data(task, taskSize, destId)); 
    162  
    163                 return true; 
     147                removeFromQueue(task); 
     148                scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, task);        
    164149        } 
    165150 
     
    184169 
    185170        protected void sendExecutableReadyEvent(ExecTask exec) { 
    186  
    187                 /*if (wu instanceof JobInterface) { 
    188                         scheduler.sendInternal(Long.valueOf(0).doubleValue(), GssimTags.TASK_READY_FOR_EXECUTION, 
    189                                         wu); 
    190                         return; 
    191                 }*/ 
    192171 
    193172                long delay = 0; 
     
    202181                } 
    203182 
    204                 scheduler.sendInternal(Long.valueOf(delay).doubleValue(), WormsTags.TASK_READY_FOR_EXECUTION, 
     183                scheduler.sendInternal(Long.valueOf(delay).doubleValue(), DCWormsTags.TASK_READY_FOR_EXECUTION, 
    205184                                exec); 
    206185        } 
     
    214193                                if (obj != null) { 
    215194                                        int delay = (Integer) obj; 
    216                                         scheduler.sendInternal(delay, WormsTags.TIMER, null); 
     195                                        scheduler.sendInternal(delay, DCWormsTags.TIMER, null); 
    217196                                } 
    218197                        } 
     
    229208                return false; 
    230209        } 
    231  
    232         public TaskQueueList getAccessQueues(){ 
    233                 return queues; 
    234         } 
    235          
    236         public Map<String, Integer> getQueuesSize() { 
    237                 Map<String, Integer> queue_size = new HashMap<String, Integer>(); 
    238                 for (TaskQueue queue : queues) { 
    239                         queue_size.put(queue.getName(), queue.size()); 
    240                 } 
    241                 return queue_size; 
    242         } 
    243  
    244         public void init(Scheduler sched, ManagedResources managedResources) { 
    245                 scheduler = sched; 
    246                 resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources); 
    247                 scheduler.set_stat(WormsConstants.getResourcesStatisticsObject(queues.size())); 
    248                 for(int i = 0; i < queues.size(); i++){ 
    249                         TaskQueue q = queues.get(i); 
    250                         if(q instanceof AbstractStatsSupportingQueue<?>){ 
    251                                 AbstractStatsSupportingQueue<?> queue = (AbstractStatsSupportingQueue<?>) q; 
    252                                 queue.setStats(scheduler.get_stat(), WormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME + "_" + Integer.toString(i)); 
    253                         } 
    254                 } 
    255         } 
    256  
    257         protected Scheduler scheduler; 
    258  
    259         public Scheduler getScheduler() { 
    260                 return scheduler; 
    261         } 
    262210         
    263211        public abstract WorkloadUnitHandler getWorkloadUnitHandler(); 
     212         
     213        public abstract void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack); 
     214 
     215        public abstract void notifyReturnedWorkloadUnit(WorkloadUnit wu); 
     216 
     217        protected abstract void executeSchedulingPlan(SchedulingPlanInterface<?> decision); 
    264218 
    265219} 
  • DCWoRMS/trunk/src/schedframe/scheduling/policy/global/GlobalManagementSystem.java

    r480 r481  
    1212 
    1313import qcg.shared.constants.BrokerConstants; 
    14  
    15 import schedframe.events.scheduling.EventReason; 
    1614import schedframe.events.scheduling.SchedulingEvent; 
    1715import schedframe.events.scheduling.TaskArrivedEvent; 
    18 import schedframe.events.scheduling.TaskCanceledEvent; 
    1916import schedframe.events.scheduling.TimerEvent; 
    20 import schedframe.scheduling.Scheduler; 
    2117import schedframe.scheduling.WorkloadUnitHandler; 
    22 import schedframe.scheduling.WorkloadUnitListImpl; 
     18import schedframe.scheduling.TaskListImpl; 
    2319import schedframe.scheduling.plan.AllocationInterface; 
    2420import schedframe.scheduling.plan.ScheduledTaskInterface; 
     
    3127import schedframe.scheduling.tasks.Job; 
    3228import schedframe.scheduling.tasks.JobInterface; 
    33 import schedframe.scheduling.tasks.SubmittedTask; 
    3429import schedframe.scheduling.tasks.Task; 
    3530import schedframe.scheduling.tasks.TaskInterface; 
    3631import schedframe.scheduling.tasks.WorkloadUnit; 
    37  
    3832import eduni.simjava.Sim_event; 
    3933import gridsim.GridSim; 
    4034import gridsim.GridSimTags; 
    41 import gridsim.Gridlet; 
    4235import gridsim.IO_data; 
    43 import gridsim.gssim.WormsTags; 
     36import gridsim.gssim.DCWormsTags; 
    4437import gssim.schedframe.scheduling.ExecTask; 
    4538import gssim.schedframe.scheduling.Executable; 
     
    5447                super(providerId, entityName,  execTimeEstimationPlugin, queues); 
    5548 
    56                 /*schedulingPlugin = (GlobalSchedulingPlugin) InstanceFactory.createInstance( 
    57                                 schedulingPluginClassName, 
    58                                 GlobalSchedulingPlugin.class);*/ 
    5949                if(schedPlugin == null){ 
    6050                        throw new Exception("Can not create global scheduling plugin instance"); 
     
    6959                switch (tag) { 
    7060 
    71                 case WormsTags.TIMER: 
    72                         if (pluginSupportsEvent(WormsTags.TIMER)) { 
     61                case DCWormsTags.TIMER: 
     62                        if (pluginSupportsEvent(DCWormsTags.TIMER)) { 
    7363                                TimerEvent event = new  TimerEvent(); 
    74                                 SchedulingPlanInterface decision =  schedulingPlugin.schedule(event,  
     64                                SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event,  
    7565                                                queues,  getJobRegistry(), getResourceManager(), moduleList); 
    7666                                executeSchedulingPlan(decision); 
     
    114104         
    115105 
    116         protected void scheduleReadyTasks(Job job){ 
     106        protected void scheduleAvaialbleTasks(Job job){ 
    117107                List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    118108                jobsList.add(job); 
    119                 WorkloadUnitListImpl readyWorkloadUnits = new WorkloadUnitListImpl(); 
    120                 readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobsList)); 
    121                 schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues, getResourceManager(), moduleList); 
    122  
     109                TaskListImpl readyTasks = new TaskListImpl(); 
     110                readyTasks.addAll(jobRegistry.getAvailableTasks(jobsList)); 
     111                 
     112                schedulingPlugin.placeTasksInQueues(readyTasks, queues, getResourceManager(), moduleList); 
    123113                schedule(new TaskArrivedEvent()); 
    124114        } 
     
    126116        protected void schedule(SchedulingEvent schedulingEvent) { 
    127117 
    128                 try { 
    129                         SchedulingPlanInterface decision = schedulingPlugin.schedule( 
    130                                         schedulingEvent, queues, getJobRegistry(),  getResourceManager(), moduleList); 
    131                         if (decision == null) 
    132                                 return; 
    133  
     118                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule( 
     119                                schedulingEvent, queues, getJobRegistry(),  getResourceManager(), moduleList); 
     120                if (decision != null) 
    134121                        executeSchedulingPlan(decision); 
    135  
    136                 } catch (Exception e) { 
    137                         e.printStackTrace(); 
    138                 } 
    139122        } 
    140123         
     
    173156                        } 
    174157                        else { 
    175                                 scheduleReadyTasks(job); 
     158                                scheduleAvaialbleTasks(job); 
    176159                                /*List<JobInterface<?>> jobs = new ArrayList<JobInterface<?>>(); 
    177160                                jobs.add(jobRegistry.getJobInfo(job.getId())); 
     
    189172        } 
    190173 
    191         public void notifyCanceledWorkloadUnit(WorkloadUnit wu){; 
    192  
    193                 Executable task = (Executable) wu; 
    194                 String jobID = task.getJobId(); 
    195                 String taskID = task.getId(); 
    196                  
    197                 if(log.isDebugEnabled()) 
    198                         log.debug("Received canceled job" + jobID + "_" + taskID); 
    199                  
    200                 TaskInterface<?> ti = jobRegistry.getTaskInfo(jobID, taskID) ; 
    201                 try { 
    202  
    203                         ti.setStatus((int)BrokerConstants.JOB_STATUS_CANCELED); 
    204                          
    205                         TaskCanceledEvent event = new TaskCanceledEvent(jobID, taskID); 
    206                         event.setReason(EventReason.RESERVATION_EXCEEDED); 
    207                         schedule(event); 
    208                          
    209                 } catch (Exception e) { 
    210                         log.error("Exception during scheduling. " + e.getMessage()); 
    211                         e.printStackTrace(); 
    212                 } 
    213         } 
    214          
    215         protected void executeSchedulingPlan(SchedulingPlanInterface decision) { 
    216  
    217                 ArrayList<ScheduledTaskInterface> taskSchedulingDecisions = decision.getTasks(); 
     174        protected void executeSchedulingPlan(SchedulingPlanInterface<?> decision) { 
     175 
     176                ArrayList<ScheduledTaskInterface<?>> taskSchedulingDecisions = decision.getTasks(); 
    218177                for (int i = 0; i < taskSchedulingDecisions.size(); i++) { 
    219178 
    220                         try { 
    221                                 ScheduledTaskInterface taskDecision = taskSchedulingDecisions.get(i); 
    222          
    223                                 //log.info(decision.getDocument()); 
    224          
    225                                 String jobID = taskDecision.getJobId(); 
    226                                 String taskID = taskDecision.getTaskId(); 
    227                                  
    228                                 // Task allocations that were rejected because of lack of resources or which were canceled and  
    229                                 // not scheduled again are returned to the user. 
    230                                 if(taskDecision.getStatus() == AllocationStatus.REJECTED){ 
    231                                         Job job = jobRegistry.getJob(jobID); 
    232                                         scheduler.send(job.getSenderId(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_RETURN, job); 
    233                                         continue; 
    234                                 } 
    235                                  
    236                                 ArrayList<AllocationInterface> allocations = taskDecision.getAllocations(); 
    237  
    238                                 Task task = (Task) jobRegistry.getTaskInfo(jobID, taskID); 
    239                                 for (int j = 0; j < allocations.size(); j++) { 
    240  
    241                                         AllocationInterface allocation = allocations.get(j); 
    242                                         Executable exec = jobRegistry.createExecutable(task, allocation); 
    243                                         submitWorkloadUnit(exec, allocation); 
    244                                         task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED); 
    245                                 }                                                                
    246  
    247                         }catch (Exception e){ 
    248                                 e.printStackTrace(); 
    249                         } 
    250                 } 
    251         } 
    252  
    253         protected void submitWorkloadUnit(WorkloadUnit job, AllocationInterface allocation) { 
     179                        ScheduledTaskInterface<?> taskDecision = taskSchedulingDecisions.get(i); 
     180 
     181                        //log.info(decision.getDocument()); 
     182 
     183                        String jobID = taskDecision.getJobId(); 
     184                        String taskID = taskDecision.getTaskId(); 
     185                         
     186                        // Task allocations that were rejected because of lack of resources or which were canceled and  
     187                        // not scheduled again are returned to the user. 
     188                        if(taskDecision.getStatus() == AllocationStatus.REJECTED){ 
     189                                Job job = jobRegistry.getJob(jobID); 
     190                                scheduler.send(job.getSenderId(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_RETURN, job); 
     191                                continue; 
     192                        } 
     193                         
     194                        Task task = (Task) jobRegistry.getTaskInfo(jobID, taskID); 
     195                         
     196                        ArrayList<AllocationInterface<?>> allocations = taskDecision.getAllocations(); 
     197                        for (int j = 0; j < allocations.size(); j++) { 
     198 
     199                                AllocationInterface<?> allocation = allocations.get(j); 
     200                                Executable exec = createExecutable(task, allocation); 
     201                                submitTask(exec, allocation); 
     202                                task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED); 
     203                        }                                                                
     204                } 
     205        } 
     206 
     207        private Executable createExecutable(Task task, AllocationInterface<?> allocation) { 
     208 
     209                String refersTo = allocation.getProcessGroupId(); // null;//allocation.getRefersTo(); 
     210                if(refersTo == null) 
     211                        refersTo = task.getId(); 
     212                         
     213                Executable exec = null; 
     214 
     215                if(refersTo.equals(task.getId())){ 
     216                        exec = new Executable(task); 
     217                } else { 
     218                        List<AbstractProcesses> processes = task.getProcesses(); 
     219                        if(processes == null) { 
     220                                try { 
     221                                        log.error("Allocation: " + allocation.getDocument() + "\nrefers to unknown task or processes set." + 
     222                                                        " Set correct value (task id or prcesses set id) for allocation refersTo attribute."); 
     223                                } catch (Exception e) { 
     224                                        e.printStackTrace(); 
     225                                } 
     226                        } 
     227                        boolean found = false; 
     228                        for(int j = 0; j < processes.size() && !found; j++){ 
     229                                AbstractProcesses procesesSet = processes.get(j); 
     230                                if(refersTo.equals(procesesSet.getId())){ 
     231                                        exec = new Executable(task, procesesSet); 
     232                                        found = true; 
     233                                } 
     234                        } 
     235                        if(!found){ 
     236                                log.error("Allocation refers to unknown proceses set."); 
     237                        } 
     238                } 
     239 
     240                exec.setReservationId(allocation.getReservationId()); 
     241                         
     242                /*HostInterface<?> host = allocation.getHost(); 
     243                ComputingResourceTypeInterface<?> crt = host.getMachineParameters(); 
     244                if(crt != null){ 
     245                        ComputingResourceTypeItemInterface<?> crti = crt.getComputingResourceTypeItem(0); 
     246                        if(crti != null){ 
     247                                ParameterPropertyInterface<?> properties[] = crti.getHostParameter().getProperty(); 
     248                                for(int p = 0; p < properties.length; p++){ 
     249                                        ParameterPropertyInterface<?> property = properties[p]; 
     250                                        if("chosenCPUs".equals(property.getName())){ 
     251                                                Object cpuNames = property.getValue(); 
     252                                                exec.addSpecificResource(ResourceParameterName.FREECPUS, cpuNames); 
     253                                        } 
     254                                } 
     255                        } 
     256                }*/ 
     257                return exec; 
     258        } 
     259         
     260        protected void submitTask(TaskInterface<?> task, AllocationInterface<?> allocation) { 
    254261 
    255262                String providerName = allocation.getProviderName(); 
     
    257264                        return; 
    258265                } 
    259                 TaskInterface<?> task = (TaskInterface<?>) job; 
    260266                removeFromQueue(task); 
    261267                 
    262268                int resID = GridSim.getEntityId(providerName); 
    263                 IO_data data = new IO_data(job, 0, resID); 
     269                IO_data data = new IO_data(task, 0, resID); 
    264270                scheduler.send(scheduler.getOutputPort(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, data);   
    265271                 
    266272                //scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, job);                       
    267273                if(log.isDebugEnabled()) 
    268                         log.debug("Submitted job " + job.getId() + " to " + providerName); 
     274                        log.debug("Submitted job " + task.getId() + " to " + providerName); 
    269275 
    270276        } 
     
    274280                public void handleJob(Job job){ 
    275281 
    276                         jobRegistry.addJob(job); 
    277282                        if (log.isInfoEnabled()) 
    278283                                log.info("Received job " + job.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis())); 
    279284 
    280                         scheduleReadyTasks(job); 
     285                        jobRegistry.addJob(job); 
     286                        scheduleAvaialbleTasks(job); 
    281287                } 
    282288                 
     
    289295                } 
    290296 
    291                 public void handleSubmittedTask(SubmittedTask task) { 
    292                         throw new RuntimeException("Not implemented since it isn't expected that tasks are send directly to the global scheduler."); 
    293                 } 
    294297        } 
    295298 
     
    297300                return new GlobalWorkloadUnitHandler(); 
    298301        } 
    299          
    300302 
    301303 
  • DCWoRMS/trunk/src/schedframe/scheduling/policy/global/GridBroker.java

    r477 r481  
    1919public class GridBroker extends GlobalManagementSystem {  
    2020 
    21          
    2221        private static Log log = LogFactory.getLog(GridBroker.class); 
    2322 
     
    2726        public GridBroker(String name, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues) throws Exception { 
    2827                super(name, "BROKER",  schedulingPlugin, execTimeEstimationPlugin, queues); 
    29                  
    30                 //make use of plug-in interface 
    31                  
    32                 //Properties prop = new Properties(); 
    33                 //prop.put("plugin.name", name); 
    34                 //prop.put("plugin.utils.timeoperations", "gssim.scheduling.plugin.local.GssimTimeOperations"); 
    35                 //schedulingPlugin.init(prop); 
     28 
    3629                otherGridSchedulersIds = new HashSet<Integer>(); 
    37                  
    3830                moduleList = new ModuleListImpl(2); 
    39                 //this.moduleList.add(new GridResourceDiscovery(this.getScheduler())); 
    40                 //moduleList.add(new GridReservationManagerNew(this)); 
    41                  
    42                 if(log.isDebugEnabled()) 
    43                         log.debug(name + ": Creating a broker interface object"); 
    4431        } 
    4532 
    4633        public void init(Scheduler scheduler, ManagedResources managedResources) { 
    4734                super.init(scheduler, managedResources); 
    48                 //this.scheduler = scheduler; 
    49                 //this.resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources); 
    5035                this.moduleList.add((GridResourceDiscovery)resourceManager); 
    5136        } 
     
    5742                } 
    5843                return providerIds; 
    59                 //return GridSim.getGridResourceList(); 
    6044        } 
    6145 
  • DCWoRMS/trunk/src/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r480 r481  
    44import eduni.simjava.Sim_system; 
    55import gridsim.Accumulator; 
    6 import gridsim.GridSimTags; 
    7 import gridsim.Gridlet; 
    86import gridsim.ResourceCalendar; 
    9 import gridsim.gssim.WormsTags; 
    10 import gridsim.gssim.filter.SubTaskFilter; 
     7import gridsim.gssim.DCWormsTags; 
     8import gridsim.gssim.filter.ExecTaskFilter; 
    119import gssim.schedframe.scheduling.ExecTask; 
    1210import gssim.schedframe.scheduling.Executable; 
     
    2725import qcg.shared.constants.BrokerConstants; 
    2826import schedframe.ResourceController; 
    29 import schedframe.events.scheduling.EventReason; 
    3027import schedframe.events.scheduling.SchedulingEvent; 
    3128import schedframe.events.scheduling.SchedulingEventType; 
    3229import schedframe.events.scheduling.StartTaskExecutionEvent; 
    33 import schedframe.events.scheduling.TaskCanceledEvent; 
    3430import schedframe.events.scheduling.TaskFinishedEvent; 
    3531import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent; 
     
    4541import schedframe.scheduling.ResourceHistoryItem; 
    4642import schedframe.scheduling.Scheduler; 
     43import schedframe.scheduling.TaskListImpl; 
    4744import schedframe.scheduling.UsedResourceList; 
    4845import schedframe.scheduling.WorkloadUnitHandler; 
    49 import schedframe.scheduling.WorkloadUnitListImpl; 
    5046import schedframe.scheduling.manager.resources.LocalResourceManager; 
    5147import schedframe.scheduling.manager.resources.ManagedResources; 
     
    6359import schedframe.scheduling.tasks.Job; 
    6460import schedframe.scheduling.tasks.JobInterface; 
    65 import schedframe.scheduling.tasks.SubmittedTask; 
    6661import schedframe.scheduling.tasks.Task; 
    6762import schedframe.scheduling.tasks.TaskInterface; 
    6863import schedframe.scheduling.tasks.WorkloadUnit; 
    69 import simulator.WormsConstants; 
     64import simulator.DCWormsConstants; 
    7065import simulator.utils.DoubleMath; 
    7166 
     
    112107                switch (tag) { 
    113108 
    114                 case WormsTags.TIMER: 
     109                case DCWormsTags.TIMER: 
    115110                        if (pluginSupportsEvent(tag)) { 
    116111                                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TIMER); 
    117                                 SchedulingPlanInterface decision =  schedulingPlugin.schedule(event,  
     112                                SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event,  
    118113                                                queues,  getJobRegistry(), getResourceManager(), moduleList); 
    119114                                executeSchedulingPlan(decision); 
     
    123118                        break; 
    124119 
    125                 case WormsTags.TASK_READY_FOR_EXECUTION: 
     120                case DCWormsTags.TASK_READY_FOR_EXECUTION: 
    126121                         
    127122                        ExecTask data = (ExecTask) ev.get_data(); 
    128123                        try { 
    129                                 data.setStatus(Gridlet.READY); 
     124                                data.setStatus(DCWormsTags.READY); 
    130125                                if (pluginSupportsEvent(tag)) { 
    131126                                        SchedulingEvent event = new StartTaskExecutionEvent(data.getJobId(), data.getId()); 
    132                                         SchedulingPlanInterface decision =  schedulingPlugin.schedule(event, 
     127                                        SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event, 
    133128                                                        queues,  getJobRegistry(), getResourceManager(), moduleList); 
    134129                                        executeSchedulingPlan(decision); 
     
    139134                        break; 
    140135 
    141                 case WormsTags.TASK_EXECUTION_FINISHED: 
     136                case DCWormsTags.TASK_EXECUTION_FINISHED: 
    142137                        obj = ev.get_data(); 
    143                         ExecTask task = (ExecTask) obj; 
    144                         if (task.getStatus() == Gridlet.INEXEC) { 
    145                                 finalizeExecutable(task); 
    146                                 SubmittedTask subTask = (SubmittedTask)task; 
    147                                 sendFinishedWorkloadUnit((ExecTask)subTask.getGridlet()); 
     138                        ExecTask exec = (ExecTask) obj; 
     139                        if (exec.getStatus() == DCWormsTags.INEXEC) { 
     140                                finalizeExecutable(exec); 
     141 
     142                                sendFinishedWorkloadUnit(exec); 
    148143                                //task.setGridletStatus(Gridlet.SUCCESS); 
    149144                                //task.finalizeGridlet(); 
    150                                 log.debug(task.getJobId() + "_" + task.getId() + " finished execution on " + new DateTime()); 
    151                                 log.info(WormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
     145                                log.debug(exec.getJobId() + "_" + exec.getId() + " finished execution on " + new DateTime()); 
     146                                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
    152147                                /*UsedResourceList<ResourceHistoryItem> lastUsedList = task.getUsedResources(); 
    153148                                Map<ResourceUnitName, AbstractResourceUnit> lastUsed = lastUsedList.getLast() 
     
    163158                        } 
    164159                        if (pluginSupportsEvent(tag)) { 
    165                                 SchedulingEvent event = new TaskFinishedEvent(task.getJobId(), task.getId()); 
    166                                 SchedulingPlanInterface decision = schedulingPlugin.schedule(event, 
     160                                SchedulingEvent event = new TaskFinishedEvent(exec.getJobId(), exec.getId()); 
     161                                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 
    167162                                                queues, getJobRegistry(), getResourceManager(), moduleList); 
    168163                                executeSchedulingPlan(decision); 
    169164                        } 
    170                         Job job = jobRegistry.getJob(task.getJobId()); 
     165                        Job job = jobRegistry.getJob(exec.getJobId()); 
    171166                        if(!job.isFinished()){ 
    172167                                getWorkloadUnitHandler().handleJob(job); 
     
    174169 
    175170                        break; 
    176                 case WormsTags.TASK_REQUESTED_TIME_EXPIRED: 
     171                case DCWormsTags.TASK_REQUESTED_TIME_EXPIRED: 
    177172                        obj = ev.get_data(); 
    178                         task = (SubmittedTask) obj; 
     173                        exec = (Executable) obj; 
    179174                        if (pluginSupportsEvent(tag)) { 
    180                                 SchedulingEvent event = new TaskRequestedTimeExpiredEvent(task.getJobId(), task.getId()); 
    181                                 SchedulingPlanInterface decision = schedulingPlugin.schedule(event, 
     175                                SchedulingEvent event = new TaskRequestedTimeExpiredEvent(exec.getJobId(), exec.getId()); 
     176                                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 
    182177                                                queues, getJobRegistry(), getResourceManager(), moduleList); 
    183178                                executeSchedulingPlan(decision); 
     
    185180 
    186181                        break; 
    187                 case WormsTags.UPDATE: 
     182                case DCWormsTags.UPDATE: 
    188183                        updateProcessingTimes(ev); 
    189184                        break; 
     
    193188 
    194189        public void notifyReturnedWorkloadUnit(WorkloadUnit wu) { 
    195                 if (pluginSupportsEvent(WormsTags.TASK_EXECUTION_FINISHED)) { 
     190                if (pluginSupportsEvent(DCWormsTags.TASK_EXECUTION_FINISHED)) { 
    196191                        SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TASK_FINISHED); 
    197                         SchedulingPlanInterface decision =  schedulingPlugin.schedule(event, 
     192                        SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event, 
    198193                                        queues, getJobRegistry(), getResourceManager(), moduleList); 
    199194                        executeSchedulingPlan(decision); 
     
    203198                //} 
    204199        } 
    205  
    206         public void notifyCanceledWorkloadUnit(WorkloadUnit job) { 
    207  
    208                 if (!pluginSupportsEvent(GridSimTags.GRIDLET_CANCEL)) 
    209                         return; 
    210  
    211                 Executable executable = (Executable) job; 
    212                 String jobID = executable.getJobId(); 
    213  
    214                 SchedulingPlanInterface decision = null; 
    215  
    216                 try { 
    217                         executable.setStatus((int) BrokerConstants.JOB_STATUS_CANCELED); 
    218  
    219                         TaskCanceledEvent event = new TaskCanceledEvent(executable.getJobId(), executable.getTaskId()); 
    220                         event.setReason(EventReason.RESERVATION_EXCEEDED); 
    221                         decision = schedulingPlugin 
    222                                         .schedule(event, queues, getJobRegistry(), getResourceManager(), moduleList); 
    223  
    224                         if (decision == null) 
    225                                 return; 
    226  
    227                         executeSchedulingPlan(decision); 
    228  
    229                 } catch (Exception e) { 
    230                         log.error("Exception during scheduling. " + e.getMessage()); 
    231                         e.printStackTrace(); 
    232                 } 
    233         } 
    234          
    235         protected void executeSchedulingPlan(SchedulingPlanInterface decision) { 
    236  
    237                 ArrayList<ScheduledTaskInterface> taskSchedulingDecisions = decision.getTasks(); 
     200         
     201        protected void executeSchedulingPlan(SchedulingPlanInterface<?> decision) { 
     202 
     203                ArrayList<ScheduledTaskInterface<?>> taskSchedulingDecisions = decision.getTasks(); 
    238204                for (int i = 0; i < taskSchedulingDecisions.size(); i++) { 
    239                         try { 
    240                                 ScheduledTaskInterface taskDecision = taskSchedulingDecisions.get(i); 
    241  
    242                                 // not scheduled again are returned to the user. 
    243                                 if (taskDecision.getStatus() == AllocationStatus.REJECTED) { 
    244                                         continue; 
     205                        ScheduledTaskInterface<?> taskDecision = taskSchedulingDecisions.get(i); 
     206 
     207                        if (taskDecision.getStatus() == AllocationStatus.REJECTED) { 
     208                                continue; 
     209                        } 
     210 
     211                        ArrayList<AllocationInterface<?>> allocations = taskDecision.getAllocations(); 
     212 
     213                        TaskInterface<?> task = taskDecision.getTask(); 
     214                        for (int j = 0; j < allocations.size(); j++) { 
     215 
     216                                AllocationInterface<?> allocation = allocations.get(j); 
     217                                if (allocation.isProcessing()) { 
     218                                        ExecTask exec = (ExecTask) task;                                         
     219                                        executeTask(exec, allocation.getRequestedResources()); 
     220                                } else if(resourceManager.getSchedulerName(allocation.getProviderName()) != null){ 
     221                                        allocation.setProviderName(resourceManager.getSchedulerName(allocation.getProviderName())); 
     222                                        submitTask(task, allocation); 
     223                                } else { 
     224                                        ExecTask exec = (ExecTask) task; 
     225                                        executeTask(exec, chooseResourcesForExecution(allocation.getProviderName(), (ExecTask)task)); 
    245226                                } 
    246  
    247                                 ArrayList<AllocationInterface> allocations = taskDecision.getAllocations(); 
    248  
    249                                 WorkloadUnit task = taskDecision.getTask(); 
    250                                 for (int j = 0; j < allocations.size(); j++) { 
    251  
    252                                         AllocationInterface allocation = allocations.get(j); 
    253                                         if (allocation.isProcessing()) { 
    254                                                  
    255                                                 ExecTask exec = (ExecTask) task; 
    256                                                  
    257  
    258                                                 //Executable e = (Executable)task; 
    259                                                 /*SubmittedTask submittedTask = jobRegistry.getSubmittedTask(e.getJobId(), e.getId()); 
    260                                                 if(submittedTask == null) 
    261                                                 {       submittedTask = new SubmittedTask(e); 
    262                                                         jobRegistry.addTask(submittedTask); 
    263                                                 }*/ 
    264  
    265                                                 /*e.visitResource(scheduler.get_name()); 
    266                                                 Scheduler parentScheduler = scheduler.getParent(); 
    267                                                 while (parentScheduler != null && !e.getVisitedResources().contains(parentScheduler.get_name())) { 
    268                                                         e.visitResource(parentScheduler.get_name()); 
    269                                                         parentScheduler = parentScheduler.getParent(); 
    270                                                 }*/ 
    271                                                  
    272                                                                                                  
    273                                                 executeTask(exec, allocation.getRequestedResources()); 
    274                                         //} else if(GridSim.getEntityId(allocation.getProviderName()) != -1 || scheduler.getScheduler(allocation.getProviderName())!=null){ 
    275                                         } else if(resourceManager.getSchedulerName(allocation.getProviderName()) != null){ 
    276                                                 allocation.setProviderName(resourceManager.getSchedulerName(allocation.getProviderName())); 
    277                                                 submitWorkloadUnit(task, allocation); 
    278                                         } else { 
    279  
    280                                                 ExecTask exec = (ExecTask) task; 
    281                                                  
    282                                                         //Executable exec = jobRegistry.createExecutable(t, allocation); 
    283                                                         //exec.setResourceParameter(scheduler.get_id(), 1); 
    284                                                 /*e.visitResource(scheduler.get_name()); 
    285                                                 Scheduler parentScheduler = scheduler.getParent(); 
    286                                                 while (parentScheduler != null && !e.getVisitedResources().contains(parentScheduler.get_name())) { 
    287                                                         e.visitResource(parentScheduler.get_name()); 
    288                                                         parentScheduler = parentScheduler.getParent(); 
    289                                                 }*/ 
    290                                                 executeTask(exec, chooseResourcesForExecution(allocation.getProviderName(), (ExecTask)task)); 
    291                                         } 
    292                                 } 
    293  
    294                         } catch (Exception e) { 
    295                                 e.printStackTrace(); 
    296                         } 
     227                        } 
     228 
    297229                } 
    298230        } 
    299231 
    300232        protected void executeTask(ExecTask task, Map<ResourceUnitName, ResourceUnit> choosenResources) { 
    301         //      Executable exec = (Executable) task; 
    302          
    303                 SubmittedTask submittedTask = (SubmittedTask)task; 
     233 
     234                Executable exec = (Executable)task; 
    304235                boolean allocationStatus = getAllocationManager().allocateResources(choosenResources); 
    305236                if(allocationStatus == false) 
    306237                        return; 
    307238                removeFromQueue(task); 
    308                 //SubmittedTask submittedTask = (SubmittedTask)task; 
    309                 /* submittedTask = jobRegistry.getSubmittedTask(exec.getJobId(), exec.getId()); 
    310                 if(submittedTask == null) 
    311                 {       submittedTask = new SubmittedTask(exec); 
    312                         jobRegistry.addTask(submittedTask); 
    313                 }*/ 
    314                 double completionPercentage = (submittedTask.getLength() - submittedTask.getRemainingGridletLength())/submittedTask.getLength(); 
     239                //double completionPercentage = (submittedTask.getLength() - submittedTask.getRemainingGridletLength())/submittedTask.getLength(); 
    315240                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION); 
    316241                int time = Double.valueOf( 
    317                                 execTimeEstimationPlugin.execTimeEstimation(event, task, choosenResources, completionPercentage)).intValue(); 
     242                                execTimeEstimationPlugin.execTimeEstimation(event, task, choosenResources, exec.getCompletionPercentage())).intValue(); 
    318243                log.debug(task.getJobId() + "_" + task.getId() + " starts executing on " + new DateTime() 
    319244                                + " will finish after " + time); 
     
    322247                        return; 
    323248 
    324                 submittedTask.setEstimatedDuration(time); 
     249                exec.setEstimatedDuration(time); 
    325250                DateTime currentTime = new DateTime(); 
    326251                ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 
    327                 submittedTask.addUsedResources(resHistItem); 
    328                 submittedTask.setFinishTime(currentTime.getMillis() / 1000); 
    329                  
    330                 jobRegistry.saveHistory(submittedTask, time, choosenResources); 
    331                  
    332                 scheduler.sendInternal(time, WormsTags.TASK_EXECUTION_FINISHED, 
    333                                 submittedTask); 
     252                exec.addUsedResources(resHistItem); 
     253 
     254                scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, 
     255                                exec); 
    334256 
    335257                try { 
    336                         long expectedDuration = submittedTask.getExpectedDuration().getMillis() / 1000; 
    337                         scheduler.sendInternal(expectedDuration, WormsTags.TASK_REQUESTED_TIME_EXPIRED, submittedTask); 
     258                        long expectedDuration = exec.getExpectedDuration().getMillis() / 1000; 
     259                        scheduler.sendInternal(expectedDuration, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec); 
    338260                } catch (NoSuchFieldException e) { 
    339                         double t = submittedTask.getEstimatedDuration(); 
    340                         scheduler.sendInternal(t, WormsTags.TASK_REQUESTED_TIME_EXPIRED, submittedTask); 
    341                 } 
    342                  
    343                 submittedTask.setGridletStatus(Gridlet.INEXEC); 
    344                 log.info(WormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
     261                        double t = exec.getEstimatedDuration(); 
     262                        scheduler.sendInternal(t, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec); 
     263                } 
     264                 
     265                try { 
     266                        exec.setStatus(DCWormsTags.INEXEC); 
     267                } catch (Exception e1) { 
     268                        // TODO Auto-generated catch block 
     269                        e1.printStackTrace(); 
     270                } 
     271                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
    345272                 
    346273                PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE); 
     
    348275                        ProcessingElements pes = (ProcessingElements) peUnit; 
    349276                        for (ComputingResource resource : pes) { 
    350                                 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, submittedTask)); 
     277                                resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
    351278                        } 
    352279                } else { 
     
    357284                                 
    358285                        } 
    359                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, submittedTask)); 
     286                        resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
    360287                } 
    361288                /*ProcessingElements pes = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE); 
     
    371298        } 
    372299         
    373         public void finalizeExecutable(ExecTask exec){ 
    374                  
    375                 SubmittedTask subTask = (SubmittedTask)exec; 
    376                 subTask.setGridletStatus(Gridlet.SUCCESS); 
    377                 subTask.finalizeGridlet(); 
    378                 UsedResourceList<ResourceHistoryItem> lastUsedList = subTask.getUsedResources(); 
     300        public void finalizeExecutable(ExecTask execTask){ 
     301                 
     302                Executable exec = (Executable)execTask; 
     303                try { 
     304                        exec.setStatus(DCWormsTags.SUCCESS); 
     305                } catch (Exception e1) { 
     306                        // TODO Auto-generated catch block 
     307                        e1.printStackTrace(); 
     308                } 
     309                exec.finalizeExecutable(); 
     310                UsedResourceList<ResourceHistoryItem> lastUsedList = exec.getUsedResources(); 
    379311                Map<ResourceUnitName, ResourceUnit> lastUsed = lastUsedList.getLast() 
    380312                                .getResourceUnits(); 
     
    385317                        ProcessingElements pes = (ProcessingElements) peUnit; 
    386318                        for (ComputingResource resource : pes) { 
    387                                 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask)); 
     319                                resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
    388320                        } 
    389321                } else { 
     
    394326                                 
    395327                        } 
    396                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask)); 
     328                        resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
    397329                } 
    398330                /*ProcessingElements pes = (ProcessingElements) lastUsed.get(StandardResourceUnitName.PE); 
     
    400332                        resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask)); 
    401333                }*/ 
    402                 SubTaskFilter filter = new SubTaskFilter(subTask.getGridletID(), WormsTags.TASK_REQUESTED_TIME_EXPIRED); 
     334                ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_REQUESTED_TIME_EXPIRED); 
    403335                scheduler.sim_cancel(filter, null); 
    404336                 
    405                 Executable executable = (Executable) subTask.getGridlet(); 
    406                 Job job = jobRegistry.getJob(executable.getJobId()); 
     337 
     338                Job job = jobRegistry.getJob(exec.getJobId()); 
    407339 
    408340                Task task = null; 
    409341                try { 
    410                         task = job.getTask(executable.getTaskId()); 
     342                        task = job.getTask(exec.getTaskId()); 
    411343                } catch (NoSuchFieldException e) { 
    412344                        e.printStackTrace(); 
    413345                } 
    414                 if(executable.getProcessesId() == null){ 
     346                if(exec.getProcessesId() == null){ 
    415347                        try { 
    416                                 task.setStatus(executable.getStatus()); 
     348                                task.setStatus(exec.getStatus()); 
    417349                        } catch (Exception e) { 
    418350                                e.printStackTrace(); 
     
    422354                        for(int i = 0; i < processesList.size(); i++){ 
    423355                                AbstractProcesses processes = processesList.get(i); 
    424                                 if(processes.getId().equals(executable.getProcessesId())){ 
    425                                         processes.setStatus(executable.getStatus()); 
     356                                if(processes.getId().equals(exec.getProcessesId())){ 
     357                                        processes.setStatus(exec.getStatus()); 
    426358                                        break; 
    427359                                } 
     
    441373                while (iter.hasNext()) { 
    442374                        ExecTask task = iter.next(); 
    443                         SubmittedTask subTask = (SubmittedTask)task; 
    444                         UsedResourceList<ResourceHistoryItem> usedResourcesList = subTask.getUsedResources(); 
     375                        Executable exec = (Executable)task; 
     376                        UsedResourceList<ResourceHistoryItem> usedResourcesList = exec.getUsedResources(); 
    445377                        ResourceUnit unit = usedResourcesList.getLast().getResourceUnits() 
    446378                                        .get(StandardResourceUnitName.PE); 
    447379 
    448380                        double load = getMIShare(timeSpan, (PEUnit) unit); 
    449                         subTask.updateGridletFinishedSoFar(load); 
     381                        exec.setCompletionPercentage(100 * timeSpan/exec.getEstimatedDuration()); 
    450382                        addTotalLoad(load); 
    451383                } 
     
    471403                updateProcessingProgress(); 
    472404                for (ExecTask task : jobRegistry.getRunningTasks()) { 
    473                         SubmittedTask subTask = (SubmittedTask)task; 
    474                         List<String> visitedResource = subTask.getVisitedResources(); 
     405                        Executable exec = (Executable)task; 
     406                        List<String> visitedResource = exec.getVisitedResources(); 
    475407                        String originResource = ev.get_data().toString(); 
    476408                        if(!ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), originResource)){ 
     
    478410                        } 
    479411                         
    480                         Map<ResourceUnitName, ResourceUnit> choosenResources = subTask.getUsedResources().getLast().getResourceUnits(); 
    481                         double completionPercentage = (task.getLength() - subTask.getRemainingGridletLength())/task.getLength(); 
     412                        Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getUsedResources().getLast().getResourceUnits(); 
     413                        //double completionPercentage = (task.getLength() - subTask.getRemainingGridletLength())/task.getLength(); 
    482414                        double time = execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED),  
    483                                         task, choosenResources, completionPercentage); 
     415                                        task, choosenResources, exec.getCompletionPercentage()); 
    484416 
    485417                        /*if(!subTask.getVisitedResources().contains(ev.get_data().toString())) { 
     
    487419                        }*/ 
    488420                        //check if the new estimated end time is equal to the previous one; if yes the continue without update 
    489                         if( DoubleMath.subtract((subTask.getExecStartTime() + subTask.getEstimatedDuration()), (new DateTime().getMillis()/1000 + time)) == 0.0){ 
     421                        if( DoubleMath.subtract((exec.getExecStartTime() + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + time)) == 0.0){ 
    490422                                continue; 
    491423                        } 
    492                         SubTaskFilter filter = new SubTaskFilter(subTask.getGridletID(), WormsTags.TASK_EXECUTION_FINISHED); 
     424                        ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED); 
    493425                        scheduler.sim_cancel(filter, null); 
    494                         scheduler.sendInternal(time, WormsTags.TASK_EXECUTION_FINISHED, task); 
     426                        scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, task); 
    495427 
    496428                } 
     
    577509                        } 
    578510 
    579                         /*try { 
    580                                 List<? extends ComputingResource> processingElements = resourceManager.getResourcesOfType(StandardResourceType.Processor); 
    581                                 List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(); 
    582                                 int peSize = processingElements.size(); 
    583                                 for (int i = 0; i < peSize && cpuRequest > 0; i++) { 
    584                                         if (processingElements.get(i).getStatus() == ResourceStatus.FREE) { 
    585                                                 choosenResources.add(processingElements.get(i)); 
    586                                                 cpuRequest--; 
    587                                         } 
    588                                 } 
    589                                 if (cpuRequest > 0) 
    590                                 {        
    591                                         return null; 
    592                                 } 
    593                                 processingUnits = new ProcessingElements(choosenResources); 
    594                         } catch (Exception e) { 
    595          
    596                                 List<ResourceUnit> procResUnit = resourceManager.getDistributedResourceUnits(StandardResourceUnitName.PE); 
    597  
    598                                 for(ResourceUnit resUnit: procResUnit){ 
    599                                         if (resUnit.getFreeAmount() >= cpuRequest) 
    600                                         {        
    601                                                 processingUnits = new PEUnit(resUnit.getResourceId(), cpuRequest, cpuRequest); 
    602                                                 break; 
    603                                         }  
    604                                 } 
    605                         }*/ 
    606511                        map.put(StandardResourceUnitName.PE, choosenPEUnits.get(0)); 
    607512                } 
    608                 /*int memoryRequest; 
    609                 try { 
    610                         memoryRequest = Double.valueOf(task.getMemoryRequest()).intValue(); 
    611                 } catch (NoSuchFieldException e) { 
    612                         memoryRequest = 0; 
    613                 } 
    614                 if (memoryRequest != 0) { 
    615                         List<ResourceUnit> resUnit = resourceManager.getSharedResourceUnits().get(StandardResourceUnitName.MEMORY); 
    616  
    617                         Memory memory = null; 
    618                         for (ResourceUnit memUnit : resUnit) { 
    619                                 Memory m = (Memory) memUnit; 
    620  
    621                                 if (m.getFreeAmount() >= memoryRequest) {        
    622                                         System.out.println(m.getResourceId()+ ";"+m.getAmount()+";"+m.getFreeAmount()); 
    623                                         memory = new Memory(m, memoryRequest, memoryRequest); 
    624                                 } 
    625                         } 
    626                         if(memory == null) 
    627                                 return null; 
    628                         map.put(StandardResourceUnitName.MEMORY, memory); 
    629                 }*/ 
     513 
    630514                return  map; 
    631515        } 
    632  
    633  
    634          
    635         public void notifySubmittedWorkloadUnit(WorkloadUnit job, boolean ack) { 
     516         
     517        public void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack) { 
    636518                updateProcessingProgress(); 
    637                 registerWorkloadUnit(job); 
     519                registerWorkloadUnit(wu); 
    638520        } 
    639521 
     
    654536                        List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    655537                        jobsList.add(job); 
    656                         WorkloadUnitListImpl readyTasks = new WorkloadUnitListImpl(); 
    657                         for(Task task: jobRegistry.getReadyTasks(jobsList)){ 
     538                        TaskListImpl readyTasks = new TaskListImpl(); 
     539                        for(Task task: jobRegistry.getAvailableTasks(jobsList)){ 
    658540                                task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED); 
    659541                                readyTasks.add(task); 
     
    667549                public void handleTask(TaskInterface<?> ti){ 
    668550                        Task task = (Task)ti; 
    669                          
    670                         if(task.getProcesses() == null){ 
     551                        List<AbstractProcesses> processes = task.getProcesses(); 
     552 
     553                        if(processes == null || processes.size() == 0){ 
    671554                                Executable exec = new Executable(task); 
    672                                 exec.setUserID(task.getSenderId()); 
    673                                 exec.setLength(task.getLength()); 
    674555                                registerWorkloadUnit(exec); 
    675556                        } else { 
    676                                 List<AbstractProcesses> processesList = task.getProcesses(); 
    677                                 for(int i = 0; i < processesList.size(); i++){   
    678                                         AbstractProcesses processes = processesList.get(i); 
    679                                         Executable exec = new Executable(task, processes); 
    680                                         exec.setUserID(task.getSenderId()); 
    681                                         exec.setLength(task.getLength()); 
     557                                for(int j = 0; j < processes.size(); j++){ 
     558                                        AbstractProcesses procesesSet = processes.get(j); 
     559                                        Executable exec = new Executable(task, procesesSet); 
    682560                                        registerWorkloadUnit(exec); 
    683561                                } 
     
    701579                        } 
    702580                         
    703                         exec.setResourceParameter(scheduler.get_id(), 1); 
    704                         SubmittedTask subTask = new SubmittedTask(exec); 
    705                         jobRegistry.addTask(subTask); 
    706                         WorkloadUnitListImpl newTasks = new WorkloadUnitListImpl(); 
    707                         newTasks.add(subTask); 
    708                  
    709                         schedulingPlugin.placeJobsInQueues(newTasks, queues, getResourceManager(), moduleList); 
    710  
    711                         if (subTask.getStatus() == Gridlet.QUEUED) { 
     581                        exec.setSchedulerName(scheduler.get_id()); 
     582                        jobRegistry.addExecTask(exec); 
     583                        TaskListImpl newTasks = new TaskListImpl(); 
     584                        newTasks.add(exec); 
     585                 
     586                        schedulingPlugin.placeTasksInQueues(newTasks, queues, getResourceManager(), moduleList); 
     587 
     588                        if (exec.getStatus() == DCWormsTags.QUEUED) { 
    712589                                sendExecutableReadyEvent(exec); 
    713                         } 
    714                 } 
    715                  
    716                 public void handleSubmittedTask(SubmittedTask task){ 
    717  
    718                         task.visitResource(scheduler.get_name()); 
    719                         Scheduler parentScheduler = scheduler.getParent(); 
    720                         while (parentScheduler != null && !task.getVisitedResources().contains(parentScheduler.get_name())) { 
    721                                 task.visitResource(parentScheduler.get_name()); 
    722                                 parentScheduler = parentScheduler.getParent(); 
    723                         } 
    724  
    725                         jobRegistry.addTask(task); 
    726                         WorkloadUnitListImpl newTasks = new WorkloadUnitListImpl(); 
    727                         newTasks.add(task); 
    728                  
    729                         schedulingPlugin.placeJobsInQueues(newTasks, queues, getResourceManager(), moduleList); 
    730  
    731                         if (task.getStatus() == Gridlet.QUEUED) { 
    732                                 sendExecutableReadyEvent(task); 
    733590                        } 
    734591                } 
  • DCWoRMS/trunk/src/schedframe/scheduling/queue/TaskQueue.java

    r478 r481  
    11package schedframe.scheduling.queue; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.gssim.DCWormsTags; 
    44import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
    55 
    66import org.joda.time.DateTime; 
    77 
    8 import schedframe.scheduling.tasks.WorkloadUnit; 
     8import schedframe.scheduling.tasks.TaskInterface; 
    99 
    10 public class TaskQueue extends AbstractStatsSupportingQueue<WorkloadUnit> implements Queue<WorkloadUnit>{ 
    11  
     10public class TaskQueue extends AbstractStatsSupportingQueue<TaskInterface<?>> implements Queue<TaskInterface<?>>{ 
    1211 
    1312        private static final long serialVersionUID = 6576299222910508209L; 
     
    1716        protected boolean supportReservation; 
    1817         
    19          
    2018        public TaskQueue (boolean supportReservation){ 
    21                 name = "Queue"; 
    22                 priority = 0; 
     19                this.name = "Queue"; 
     20                this.priority = 0; 
    2321                this.supportReservation = supportReservation; 
    24  
    2522        } 
    2623         
    27         public boolean add(WorkloadUnit wu){ 
     24        public boolean add(TaskInterface<?> task){ 
    2825                try { 
    29                         wu.setStatus(Gridlet.QUEUED); 
     26                        task.setStatus(DCWormsTags.QUEUED); 
    3027                } catch(Exception e){ 
    3128                        throw new RuntimeException(e); 
    3229                } 
    33                 //updateStats(); 
    34                 return super.add(wu); 
     30                return super.add(task); 
    3531        } 
    3632         
    37         public void add(int pos, WorkloadUnit wu){ 
     33        public void add(int pos, TaskInterface<?> task){ 
    3834                try { 
    39                         wu.setStatus(Gridlet.QUEUED); 
     35                        task.setStatus(DCWormsTags.QUEUED); 
    4036                } catch(Exception e){ 
    4137                        throw new RuntimeException(e); 
    4238                } 
    43                 //updateStats(); 
    44                  super.add(pos, wu); 
     39                 super.add(pos, task); 
    4540        } 
    4641         
    4742        public DateTime getArrivalTime(int pos) throws IndexOutOfBoundsException { 
    48                 //return get(pos).getSubmissionTimeToBroker(); 
    49                 return null; 
     43                return get(pos).getSubmissionTimeToBroker(); 
    5044        } 
    5145 
     
    6963                return supportReservation; 
    7064        } 
    71          
    72          
    73         /*public boolean contains (WorkloadUnitInterface<?> wu) { 
    74                 for(int i = 0; i< size();i++){ 
    75                         try { 
    76                                 if(get(i).getId().equals(wu.getId())) 
    77                                         return true; 
    78                         } catch (NoSuchFieldException e) { 
    79                                 return false; 
    80                         } 
    81                 } 
    82                 return false; 
    83         } 
    84          
    85         public boolean remove (WorkloadUnitInterface<?> wu) { 
    86                 boolean found = false; 
    87                 int index = 0; 
    88                 for(int i = 0; i< size() && !found;i++){ 
    89                         try { 
    90                                 if(get(i).getId().equals(wu.getId())) 
    91                                 { 
    92                                         found = true; 
    93                                         index = i; 
    94                                 } 
    95                                  
    96                         } catch (NoSuchFieldException e) { 
    97                                 return false; 
    98                         } 
    99                 } 
    100                 remove(index); 
    101                 return true; 
    102         }*/ 
    10365} 
  • DCWoRMS/trunk/src/schedframe/scheduling/tasks/Job.java

    r480 r481  
    178178        } 
    179179         
    180         public int getUserID(){ 
     180        public int getUserId(){ 
    181181                return this.senderId; 
    182182        } 
  • DCWoRMS/trunk/src/schedframe/scheduling/tasks/Processes.java

    r480 r481  
    199199 
    200200        @Override 
    201         public int getUserID() { 
     201        public int getUserId() { 
    202202                // TODO Auto-generated method stub 
    203203                return 0; 
  • DCWoRMS/trunk/src/schedframe/scheduling/tasks/Task.java

    r480 r481  
    471471 
    472472        @Override 
    473         public int getUserID() { 
     473        public int getUserId() { 
    474474                // TODO Auto-generated method stub 
    475475                return 0; 
  • DCWoRMS/trunk/src/schedframe/scheduling/tasks/TaskInterface.java

    r480 r481  
    8888         */ 
    8989        public long getLength(); 
    90          
    91         /** 
    92          *  
    93          * @param length measured in instructions. 
    94          */ 
    95         public void setLength(long length); 
    96          
     90 
    9791        /** 
    9892         *  
  • DCWoRMS/trunk/src/schedframe/scheduling/tasks/WorkloadUnit.java

    r480 r481  
    88        public String getId(); 
    99         
    10         public int getUserID(); 
     10        public int getUserId(); 
    1111         
    1212        public int getStatus(); 
  • DCWoRMS/trunk/src/simulator/DCWormsConstants.java

    r477 r481  
    33import eduni.simjava.Sim_stat; 
    44 
    5 public class WormsConstants { 
     5public class DCWormsConstants { 
    66 
    77        public static final String START_TIME="start_time"; 
  • DCWoRMS/trunk/src/simulator/DCWormsUsers.java

    r477 r481  
    77import gridsim.Gridlet; 
    88import gridsim.IO_data; 
     9import gridsim.gssim.DCWormsTags; 
    910import gridsim.net.InfoPacket; 
    1011import gssim.schedframe.scheduling.utils.JobDescription; 
     
    3132import simulator.workload.WorkloadLoader; 
    3233 
    33 public class WormsUsers extends GridSim implements GenericUser { 
     34public class DCWormsUsers extends GridSim implements GenericUser { 
    3435 
    3536        /**A job generator, which produces jobs and tasks. These jobs are then sent by this entity */ 
     
    5455        protected boolean error; 
    5556         
    56         private static Log log = LogFactory.getLog(WormsUsers.class); 
     57        private static Log log = LogFactory.getLog(DCWormsUsers.class); 
    5758         
    5859        /** 
     
    6364         * @throws Exception if any occurs (see {@link GridSim#GridSim(String, double)}) 
    6465         */ 
    65         public WormsUsers(String name, String destinationName, WorkloadLoader workload) throws Exception { 
    66                 super(name, WormsConstants.DEFAULT_BAUD_RATE); 
     66        public DCWormsUsers(String name, String destinationName, WorkloadLoader workload) throws Exception { 
     67                super(name, DCWormsConstants.DEFAULT_BAUD_RATE); 
    6768                this.workloadLoader = workload; 
    6869                destName = destinationName; 
     
    259260                for (JobInterface<?> job : returnedJobs) { 
    260261                        for (TaskInterface<?> task: job.getTask()) { 
    261                                 if(task.getStatus() == Gridlet.SUCCESS) 
     262                                if(task.getStatus() == DCWormsTags.SUCCESS) 
    262263                                        result++; 
    263264                        } 
  • DCWoRMS/trunk/src/simulator/DataCenterWorkloadSimulator.java

    r477 r481  
    2626import simulator.reader.ResourceReader; 
    2727import simulator.stats.AccumulatedStatistics; 
    28 import simulator.stats.implementation.WormsStatistics; 
     28import simulator.stats.implementation.DCWormsStatistics; 
    2929import simulator.utils.LogErrStream; 
    3030import simulator.workload.WorkloadLoader; 
     
    4040 * {@link #main(String[])} method used to invoke the program. This class also 
    4141 * provides second possibility to start the simulator, namely one may use the 
    42  * {@link #performSimulation(ConfigurationOptions, WormsStatistics)} method. 
     42 * {@link #performSimulation(ConfigurationOptions, DCWormsStatistics)} method. 
    4343 * In this case, the input parameter, describing the simulation options, must be 
    4444 * earlier prepared. The results of the simulation can be acquired using the 
     
    269269                rc.setInitList(null); 
    270270                 
    271                 WormsUsers wl = new WormsUsers("Users", 
     271                DCWormsUsers wl = new DCWormsUsers("Users", 
    272272                                rc.getScheduler().get_name(), workload); 
    273273                 
     
    275275                long stopSimulation = System.currentTimeMillis(); 
    276276 
    277                 WormsStatistics stats = new WormsStatistics(simulationIdentifier, 
     277                DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier, 
    278278                                options, wl, statsOutputPath, rc); 
    279279                accumulatedStatistics.add(stats); 
  • DCWoRMS/trunk/src/simulator/stats/AccumulatedStatistics.java

    r477 r481  
    1010import java.util.List; 
    1111 
    12 import simulator.stats.implementation.WormsStatistics; 
     12import simulator.stats.implementation.DCWormsStatistics; 
    1313import gridsim.Accumulator; 
    1414 
  • DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java

    r477 r481  
    4949import org.jfree.data.xy.XYSeriesCollection; 
    5050import org.jfree.ui.TextAnchor; 
    51 import org.joda.time.DateTime; 
    5251import org.joda.time.DateTimeUtilsExt; 
    5352 
     53import schedframe.ExecutablesList; 
    5454import schedframe.ResourceController; 
    5555import schedframe.exceptions.ResourceException; 
     
    6969import schedframe.scheduling.ResourceHistoryItem; 
    7070import schedframe.scheduling.Scheduler; 
     71import schedframe.scheduling.manager.tasks.JobRegistry; 
    7172import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    7273import schedframe.scheduling.tasks.Job; 
    7374import schedframe.scheduling.tasks.JobInterface; 
    7475import simulator.ConfigurationOptions; 
     76import simulator.DCWormsConstants; 
    7577import simulator.DataCenterWorkloadSimulator; 
    7678import simulator.GenericUser; 
    77 import simulator.WormsConstants; 
    7879import simulator.stats.GSSAccumulator; 
    7980import simulator.stats.SimulationStatistics; 
     
    9091import gssim.schedframe.scheduling.Executable; 
    9192 
    92 public class WormsStatistics implements SimulationStatistics { 
    93  
    94         private Log log = LogFactory.getLog(WormsStatistics.class); 
     93public class DCWormsStatistics implements SimulationStatistics { 
     94 
     95        private Log log = LogFactory.getLog(DCWormsStatistics.class); 
    9596 
    9697        protected static float ALPHA = 0.5f; 
     
    9899 
    99100        //protected static final int BITS = 8; 
    100         //protected static final int MILLI_SEC = 1000; 
     101        protected static final int MILLI_SEC = 1000; 
    101102 
    102103        protected static final String RAW_TASKS_STATISTICS_OUTPUT_FILE_NAME = "Tasks.txt"; 
     
    117118        protected String simulationIdentifier; 
    118119        protected ConfigurationOptions configuration; 
    119  
    120120 
    121121        protected GSSAccumulatorsStats accStats; 
     
    129129        protected long endSimulationTime; 
    130130         
    131          
    132131        //RESOURCES 
    133132        protected Timetable ganttDiagramPeTimetable; 
     
    140139        protected Map<String, TimetableEventGroup> taskGanttMap; 
    141140         
    142          
    143141        //TASKS 
    144142        protected int numOfdelayedTasks = 0; 
     
    151149        protected HashMap<String, List<String>> task_processorsMap; 
    152150 
    153  
    154151        protected JobRegistryImpl jr; 
    155152 
    156153         
    157         public WormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users, 
     154        public DCWormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users, 
    158155                        String outputFolderName, ResourceController resourceController) { 
    159156                this.simulationIdentifier = simulationIdentifier; 
     
    188185                gatherResourceStatistics(); 
    189186                e = System.currentTimeMillis(); 
    190                 log.info("time in sec: " + ((e - s) / 1000)); 
     187                log.info("time in sec: " + ((e - s) / MILLI_SEC)); 
    191188                 
    192189                log.info("gatherTaskStatistics"); 
     
    194191                gatherTaskStatistics(); 
    195192                e = System.currentTimeMillis(); 
    196                 log.info("time in sec: " + ((e - s) / 1000)); 
     193                log.info("time in sec: " + ((e - s) / MILLI_SEC)); 
    197194 
    198195                log.info("saveSimulationStatistics"); 
     
    200197                saveSimulationStatistics(); 
    201198                e = System.currentTimeMillis(); 
    202                 log.info("time in sec: " + ((e - s) / 1000)); 
     199                log.info("time in sec: " + ((e - s) / MILLI_SEC)); 
    203200        } 
    204201 
     
    299296                        energyStatsFile = null; 
    300297                } 
    301                  
    302                 basicResStats = gatherPEStats(JobRegistryImpl.getAllocationHistory()); 
     298                JobRegistry jr = new JobRegistryImpl("stats"); 
     299                basicResStats = gatherPEStats(jr.getExecutableTasks()); 
    303300                peStatsPostProcessing(basicResStats); 
    304301                basicResLoad = calculatePELoad( basicResStats); 
     
    342339                                                energyUsage = gatherResourceEnergyStats(resource); 
    343340                                                energyUsage.setMeanUsage(calculateEnergyLoad(energyUsage)); 
    344                                                 energyUsage.setSumUsage(energyUsage.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * 1000)); 
     341                                                energyUsage.setSumUsage(energyUsage.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
    345342                                                 
    346343                                                EnergyExtension een = (EnergyExtension )(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     
    428425                                        for(String key: energyCategoryStats.keySet()){ 
    429426                                                GSSAccumulator acc = energyCategoryStats.get(key); 
    430                                                 energyStatsFile.println(key + "- mean: "  + acc.getMean()+ " sum: " +acc.getMean() * (endSimulationTime-startSimulationTime) / (3600 * 1000) * acc.getCount()); 
     427                                                energyStatsFile.println(key + "- mean: "  + acc.getMean()+ " sum: " +acc.getMean() * (endSimulationTime-startSimulationTime) / (3600 * MILLI_SEC) * acc.getCount()); 
    431428                                        } 
    432429                                        energyStatsFile.println("\n\n"); 
     
    462459                        String measure = (String) info[0]; 
    463460                        if (measure 
    464                                         .startsWith(WormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) { 
     461                                        .startsWith(DCWormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) { 
    465462                                return stats.average(measure); 
    466463                        } 
     
    492489                } 
    493490        } 
    494         private Map<String, List<ResStat>> gatherPEStats(Map<Integer, Map<String, Object>> history) { 
    495  
     491        private Map<String, List<ResStat>> gatherPEStats( ExecutablesList executables) { 
     492 
     493                 
    496494                Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 
    497                  
    498                 for (Integer executableId : history.keySet()) { 
    499  
    500                         Map<String, Object> historyItem = (Map<String, Object>) history.get(executableId); 
    501                         List<ResourceHistoryItem> resHistItemList = (List<ResourceHistoryItem>) historyItem.get(WormsConstants.RESOURCES); 
     495                //Map<Integer, Map<String, Object>> history 
     496                 
     497                for (ExecTask execTask:executables) { 
     498                        Executable exec = (Executable) execTask; 
     499 
     500                        List<ResourceHistoryItem> resHistItemList = exec.getUsedResources(); 
    502501                        Map<ResourceUnitName, ResourceUnit> res = resHistItemList.get(resHistItemList.size() - 1).getResourceUnits(); 
    503502                        ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 
     
    507506                                for(ComputingResource pe: pes){ 
    508507                                        String peName = pe.getName(); 
    509                                         long startDate = ((DateTime) historyItem.get(WormsConstants.START_TIME)).getMillis(); 
    510                                         long endDate = ((DateTime) historyItem.get(WormsConstants.END_TIME)).getMillis(); 
    511                                         JobRegistryImpl jr = new JobRegistryImpl("stats"); 
    512                                         ExecTask execTask = jr.getTaskExecutable(executableId); 
     508                                        long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC; 
     509                                        long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 
     510 
     511 
    513512                                        String uniqueTaskID = execTask.getJobId() + "_" + execTask.getId(); 
    514513                                         
     
    535534                        } else if (resUnit instanceof PEUnit){ 
    536535                                PEUnit peUnit = (PEUnit) resUnit ; 
    537                          
    538536                        } 
    539537 
     
    629627                                                 
    630628                                        ///     System.out.println(resource.getName() + ":"+new DateTime(pu.getTimestamp())+";"+pu.getValue()); 
    631                                                 power = power + (pu.getTimestamp() - lastTime) * lastPower/ (3600 * 1000); 
     629                                                power = power + (pu.getTimestamp() - lastTime) * lastPower/ (3600 * MILLI_SEC); 
    632630                                                lastPower = pu.getValue(); 
    633631                                                lastTime = pu.getTimestamp(); 
     
    10261024 
    10271025                        //List<TaskInterface> execList = JobRegistry.getInstance("COMPUTING_GRID_0#BROKER").getAllSubmittedTasks(); 
    1028                         List<Executable> execList = jr.getJobExecutables(job.getId()); 
     1026                        List<Executable> execList = jr.getExecutableTasks().getJobExecutables(job.getId()); 
    10291027                        List<TaskStats> taskStatsList = new ArrayList<TaskStats>(); 
    10301028 
     
    11431141                String uniqueTaskID = task.getJobId() + "_" + task.getId(); 
    11441142 
    1145                 String resIDlist[] = task.getAllResourceName(); 
    1146                 String resID = resIDlist[resIDlist.length - 1]; 
    1147  
    1148                 long execStartTime = Double.valueOf(task.getExecStartTime()).longValue() * 1000; 
    1149                 long execEndTime = Double.valueOf(task.getFinishTime()).longValue() * 1000; 
     1143                String resID = task.getSchedulerName(); 
     1144 
     1145                long execStartTime = Double.valueOf(task.getExecStartTime()).longValue() * MILLI_SEC; 
     1146                long execEndTime = Double.valueOf(task.getFinishTime()).longValue() * MILLI_SEC; 
    11501147 
    11511148                TaskSeries taskRes = ganttDiagramTaskSeriesCollection.getSeries(resID); 
     
    11651162                String uniqueTaskID = task.getJobId() + "_" + task.getId(); 
    11661163 
    1167                 String resIDlist[] = task.getAllResourceName(); 
    1168                 String resID = resIDlist[resIDlist.length - 1]; 
    1169  
    1170                 long execStartTime = Double.valueOf(task.getExecStartTime()).longValue() * 1000; 
    1171                 long execEndTime = Double.valueOf(task.getFinishTime()).longValue() * 1000; 
     1164                String resID = task.getSchedulerName(); 
     1165 
     1166                long execStartTime = Double.valueOf(task.getExecStartTime()).longValue() * MILLI_SEC; 
     1167                long execEndTime = Double.valueOf(task.getFinishTime()).longValue() * MILLI_SEC; 
    11721168 
    11731169                TaskSeries waitRes = ganttDiagramWaitingTimeSeriesCollection.getSeries(resID); 
     
    11771173                } 
    11781174 
    1179                 long sub = Double.valueOf(task.getSubmissionTime()).longValue() * 1000; 
     1175                long sub = Double.valueOf(task.getSubmissionTime()).longValue() * MILLI_SEC; 
    11801176                org.jfree.data.gantt.Task wait_exec = new org.jfree.data.gantt.Task(uniqueTaskID, new Date(sub), new Date( 
    11811177                                execEndTime)); 
  • DCWoRMS/trunk/src/simulator/stats/implementation/TaskStats.java

    r480 r481  
    4949 
    5050        public String getResName() { 
    51                 String resNames[] = this.task.getAllResourceName(); 
    52                 String resName = ""; 
    53                 for (int i = 0; i < resNames.length; i++) { 
    54                         resName += resNames[i]; 
    55                         if (resNames.length > 1) 
    56                                 resName += " "; 
    57                 } 
     51                String resName = this.task.getSchedulerName(); 
     52 
    5853                return resName; 
    5954        } 
  • DCWoRMS/trunk/src/simulator/workload/generator/impl/QcgJobGenerator.java

    r477 r481  
    5858import org.xml.sax.InputSource; 
    5959 
    60 import simulator.WormsConstants; 
     60import simulator.DCWormsConstants; 
    6161import simulator.utils.GSSimXML; 
    6262import simulator.utils.XsltTransformations; 
     
    259259                         
    260260                        //initially - a standard value 
    261                         taskCountToBeGenerated = WormsConstants.DEFAULT_TASK_COUNT_IN_SINGLE_JOB;  
     261                        taskCountToBeGenerated = DCWormsConstants.DEFAULT_TASK_COUNT_IN_SINGLE_JOB;  
    262262                         
    263263                        try { 
Note: See TracChangeset for help on using the changeset viewer.