source: xssim/branches/tpiontek/src/test/rewolucja/scheduling/implementation/LocalManagementSystem.java @ 262

Revision 262, 20.4 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
RevLine 
[104]1package test.rewolucja.scheduling.implementation;
2
3import eduni.simjava.Sim_event;
4import eduni.simjava.Sim_system;
5import gridsim.Accumulator;
6import gridsim.GridSimTags;
7import gridsim.Gridlet;
8import gridsim.ResourceCalendar;
9import gridsim.gssim.GssimConstants;
10import gridsim.gssim.GssimTags;
11import gridsim.gssim.ResourceHistoryItem;
12import gridsim.gssim.SubmittedTask;
13import gridsim.gssim.filter.SubTaskFilter;
14import grms.shared.constants.BrokerConstants;
15import gssim.schedframe.scheduling.AbstractExecutable;
16import gssim.schedframe.scheduling.ExecTaskInterface;
17import gssim.schedframe.scheduling.Executable;
18
19import java.util.ArrayList;
20import java.util.HashMap;
21import java.util.Iterator;
22import java.util.List;
23import java.util.Map;
24import java.util.Properties;
25
26import org.apache.commons.logging.Log;
27import org.apache.commons.logging.LogFactory;
28import org.joda.time.DateTime;
29import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus;
30
[262]31import schedframe.resources.PowerState;
[104]32import schedframe.resources.units.ResourceUnit;
33import schedframe.scheduling.events.SchedulingEvent;
34import schedframe.scheduling.events.SchedulingEventReason;
35import schedframe.scheduling.events.SchedulingEventType;
36import schedframe.scheduling.events.StartTaskExecutionEvent;
37import schedframe.scheduling.events.TaskCanceledEvent;
38import schedframe.scheduling.events.TaskFinishedEvent;
[142]39import schedframe.scheduling.events.TaskRequestedTimeExpiredEvent;
[104]40import schedframe.scheduling.plugin.SchedulingPluginConfiguration;
41import schedframe.scheduling.plugin.estimation.ExecTimeEstimationPlugin;
42import schedframe.scheduling.plugin.grid.ModuleListImpl;
43import schedframe.scheduling.plugin.grid.ModuleType;
44import schedframe.scheduling.plugin.local.LocalSchedulingPlugin;
45import schedframe.scheduling.utils.ResourceParameterName;
46import simulator.utils.DoubleMath;
47import simulator.utils.InstanceFactory;
48import test.rewolucja.GSSIMJobInterface;
49import test.rewolucja.energy.EnergyEvent;
50import test.rewolucja.energy.EnergyEventType;
51import test.rewolucja.resources.ProcessingElements;
52import test.rewolucja.resources.ResourceStatus;
53import test.rewolucja.resources.ResourceType;
54import test.rewolucja.resources.description.ExecResourceDescription;
55import test.rewolucja.resources.exception.ResourceException;
[232]56import test.rewolucja.resources.logical.base.LogicalResource;
[104]57import test.rewolucja.resources.manager.factory.ResourceManagerFactory;
58import test.rewolucja.resources.manager.implementation.ResourceManager;
59import test.rewolucja.resources.manager.interfaces.ResourceManagerInterface;
60import test.rewolucja.resources.manager.utils.ResourceManagerUtils;
61import test.rewolucja.resources.physical.base.ComputingResource;
[175]62import test.rewolucja.scheduling.UsedResourceList;
[104]63import test.rewolucja.scheduling.plan.AllocationInterfaceNew;
64import test.rewolucja.scheduling.plan.ScheduledTaskInterfaceNew;
65import test.rewolucja.scheduling.plan.SchedulingPlanInterfaceNew;
66import test.rewolucja.task.JobList;
67
68public class LocalManagementSystem extends ManagementSystem {
69
70        private Log log = LogFactory.getLog(LocalManagementSystem.class);
71
72        protected double lastUpdateTime;
73
74        protected Accumulator accTotalLoad_;
75
76        public LocalManagementSystem(String providerId, String entityName, String schedulingPluginClassName,
77                        ExecTimeEstimationPlugin execTimeEstimationPlugin, ExecResourceDescription resourceDescription)
78                        throws Exception {
79
80                super(providerId, entityName, schedulingPluginClassName, execTimeEstimationPlugin, resourceDescription);
81
82                schedulingPlugin = (LocalSchedulingPlugin) InstanceFactory.createInstance(schedulingPluginClassName, LocalSchedulingPlugin.class);
83                if (schedulingPlugin == null) {
84                        throw new Exception("Can not create local scheduling plugin instance.");
85                }
86
87                accTotalLoad_ = new Accumulator();
88                moduleList = new ModuleListImpl(1);
89
90        }
91
92        public void init(LogicalResource logRes) {
93                logicalResource = logRes;
94                resourceManager = (ResourceManager) ResourceManagerFactory.createResourceManager(logicalResource);
95                double load = 0;
96                accTotalLoad_.add(load);
97        }
98
99        public void processEvent(Sim_event ev) {
100
101                updateProcessingProgress();
102
103                int tag = ev.get_tag();
104                Object obj;
105
106                switch (tag) {
107
108                case GssimTags.TIMER:
109                        if (pluginSupportsEvent(tag)) {
110                                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TIMER);
111                                SchedulingPlanInterfaceNew decision =  schedulingPlugin.schedule(event,
112                                                queues,  getJobRegistry(), getResourceManager(), moduleList);
113                                executeSchedulingPlan(decision);
114                        }
115                        sendTimerEvent();
116
117                        break;
118
119                case GssimTags.TASK_READY_FOR_EXECUTION:
120                        Executable data = (Executable) ev.get_data();
121
122                        try {
123                                data.setGridletStatus(Gridlet.READY);
124                                if (pluginSupportsEvent(tag)) {
125                                        SchedulingEvent event = new StartTaskExecutionEvent(data.getJobId(), data.getId());
126                                        SchedulingPlanInterfaceNew decision =  schedulingPlugin.schedule(event,
127                                                        queues,  getJobRegistry(), getResourceManager(), moduleList);
128                                        executeSchedulingPlan(decision);
129
130                                }
131                        } catch (Exception e) {
132                                e.printStackTrace();
133                        }
134                        break;
135
136                case GssimTags.TASK_EXECUTION_FINISHED:
137                        obj = ev.get_data();
138                        SubmittedTask task = (SubmittedTask) obj;
139                        if (task.getStatus() == Gridlet.INEXEC) {
140                                task.setGridletStatus(Gridlet.SUCCESS);
141                                task.finalizeGridlet();
142                                log.debug(task.getJobId() + "_" + task.getId() + " finished execution on " + new DateTime());
143                                log.info(GssimConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size()));
[175]144                                UsedResourceList<ResourceHistoryItem> lastUsedList = task.getUsedResources();
145                                Map<ResourceParameterName, ResourceUnit> lastUsed = lastUsedList.getLast()
[104]146                                                .getResourceUnits();
147                                getAllocationManager().freeResources(lastUsed);
148                                ProcessingElements pes = (ProcessingElements) lastUsed.get(ResourceParameterName.PROCESSINGELEMENTS);
149                                for (ComputingResource resource : pes) {
150                                        resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, task));
151                                }
[239]152                                SubTaskFilter filter = new SubTaskFilter(task.getGridletID(), GssimTags.TASK_REQUESTED_TIME_EXPIRED);
153                                logicalResource.sim_cancel(filter, null);
[104]154                                super.sendFinishJob((AbstractExecutable) task.getGridlet());
155                        }
156
157                        if (pluginSupportsEvent(tag)) {
158                                SchedulingEvent event = new TaskFinishedEvent(task.getJobId(), task.getId());
159                                SchedulingPlanInterfaceNew decision = schedulingPlugin.schedule(event,
160                                                queues, getJobRegistry(), getResourceManager(), moduleList);
161                                executeSchedulingPlan(decision);
162                        }
163
164                        break;
165                case GssimTags.TASK_REQUESTED_TIME_EXPIRED:
166                        obj = ev.get_data();
[142]167                        task = (SubmittedTask) obj;
[104]168                        if (pluginSupportsEvent(tag)) {
[142]169                                SchedulingEvent event = new TaskRequestedTimeExpiredEvent(task.getJobId(), task.getId());
[104]170                                SchedulingPlanInterfaceNew decision = schedulingPlugin.schedule(event,
171                                                queues, getJobRegistry(), getResourceManager(), moduleList);
172                                executeSchedulingPlan(decision);
173                        }
174
175                        break;
176                case GssimTags.UPDATE:
177                        updateProcessingTimes(ev);
178                        break;
[262]179                case GssimTags.START:
180                case GssimTags.SHUTDOWN:
181                        changeResourcePowerState(ev);
182                        if (pluginSupportsEvent(tag)) {
183                                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.POWER_STATE_CHANGED);
184                                SchedulingPlanInterfaceNew decision = schedulingPlugin.schedule(event,
185                                                queues, getJobRegistry(), getResourceManager(), moduleList);
186                                executeSchedulingPlan(decision);
187                        }
188                        break;
[104]189                }
190        }
191       
192        public void notifySubmittedJob(GSSIMJobInterface<?> job, boolean ack) {
193                if (job instanceof AbstractExecutable) {
194                        AbstractExecutable executable = (AbstractExecutable) job;
195                        // int cost =
196                        // this.resourceManager.getResourceCharacteristic().getResUnits() !=
197                        // null ?
198                        // this.resourceManager.getResourceCharacteristic().getResUnits().get(ResourceParameterName.COST).getAmount()
199                        // : 1;
200                        executable.setResourceParameter(logicalResource.get_id(), 1);
201
202                        updateProcessingProgress();
203                        JobList newTasks = new JobList();
204                        SubmittedTask submittedTask = jobRegistry.getSubmittedTask(executable.getJobId(), executable.getId());
205                        if(submittedTask == null)
206                        {       submittedTask = new SubmittedTask((Executable) executable);
207                                jobRegistry.addTask(submittedTask);
208                        }
[133]209
210                        //submittedTask.addToResPath(logicalRes.get_name());
211                        submittedTask.visitResource(logicalResource.get_name());
212                        LogicalResource logicalRes = logicalResource.getParent();
213                        /*while (logicalRes != null && !submittedTask.getResPath().contains(logicalRes.get_name())) {
[104]214                                submittedTask.addToResPath(logicalRes.get_name());
215                                logicalRes = logicalRes.getParent();
[133]216                        }*/
217                        while (logicalRes != null && !submittedTask.getVisitedResources().contains(logicalRes.get_name())) {
218                                submittedTask.visitResource(logicalRes.get_name());
219                                logicalRes = logicalRes.getParent();
[104]220                        }
221                        newTasks.add(submittedTask);
222                        schedulingPlugin.placeJobsInQueues(newTasks, queues, getResourceManager(), moduleList);
223
224                        if (job.getStatus() == Gridlet.QUEUED) {
225                                sendJobReadyEvent(job);
226                        }
227                }
228        }
229
230        public void notifyReturnedJob(GSSIMJobInterface<?> job) {
231                if (pluginSupportsEvent(GssimTags.TASK_EXECUTION_FINISHED)) {
232                        SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TASK_FINISHED);
233                        SchedulingPlanInterfaceNew decision =  schedulingPlugin.schedule(event,
234                                        queues, getJobRegistry(), getResourceManager(), moduleList);
235                        executeSchedulingPlan(decision);
236                }
237                if(logicalResource.getParent() != null){
238                        sendFinishJob((AbstractExecutable)job);
239                }
240        }
241
242        public void notifyCanceledJob(GSSIMJobInterface<?> job) {
243
244                if (!pluginSupportsEvent(GridSimTags.GRIDLET_CANCEL))
245                        return;
246
247                Executable executable = (Executable) job;
248                String jobID = executable.getJobId();
249
250                SchedulingPlanInterfaceNew decision = null;
251
252                try {
253
254                        executable.setStatus((int) BrokerConstants.JOB_STATUS_CANCELED);
255
256                        TaskCanceledEvent event = new TaskCanceledEvent(executable.getJobId(), executable.getTaskId());
257                        event.setReason(SchedulingEventReason.RESERVATION_EXCEEDED);
258                        decision = schedulingPlugin
259                                        .schedule(event, queues, getJobRegistry(), getResourceManager(), moduleList);
260
261                        if (decision == null)
262                                return;
263
264                        executeSchedulingPlan(decision);
265
266                } catch (Exception e) {
267                        log.error("Exception during scheduling. " + e.getMessage());
268                        e.printStackTrace();
269                }
270        }
271       
272        protected void executeSchedulingPlan(SchedulingPlanInterfaceNew decision) {
273
274                ArrayList<ScheduledTaskInterfaceNew> taskSchedulingDecisions = decision.getTasks();
275                for (int i = 0; i < taskSchedulingDecisions.size(); i++) {
276                        try {
277                                ScheduledTaskInterfaceNew taskDecision = taskSchedulingDecisions.get(i);
278
279                                // not scheduled again are returned to the user.
280                                if (taskDecision.getStatus() == AllocationStatus.REJECTED) {
281                                        continue;
282                                }
283
284                                ArrayList<AllocationInterfaceNew> allocations = taskDecision.getAllocations();
285
286                                GSSIMJobInterface<?> task = taskDecision.getTask();
287                                for (int j = 0; j < allocations.size(); j++) {
288
289                                        AllocationInterfaceNew allocation = allocations.get(j);
290                                        if (allocation.isProcessing()) {
291                                                executeTask(task, allocation.getRequestedResources());
292                                        //} else if(GridSim.getEntityId(allocation.getProviderName()) != -1 || logicalResource.getLogicalResource(allocation.getProviderName())!=null){
293                                        } else if(resourceManager.getResourceProvider(allocation.getProviderName()) != null){
294                                                allocation.setProviderName(resourceManager.getResourceProvider(allocation.getProviderName()));
295                                                submitJob(task, allocation);
296                                        } else {
297                                                executeTask(task, chooseResourcesForExecution(allocation.getProviderName(), (ExecTaskInterface)task));
298                                        }
299                                }
300
301                        } catch (Exception e) {
302                                e.printStackTrace();
303                        }
304                }
305        }
306
307        protected void executeTask(GSSIMJobInterface<?> job, Map<ResourceParameterName, ResourceUnit> choosenResources) {
308                ExecTaskInterface task = (ExecTaskInterface) job;
309                SubmittedTask submittedTask = (SubmittedTask) task;
310
311                boolean allocationStatus = getAllocationManager().allocateResources(choosenResources);
312                if(allocationStatus == false)
313                        return;
314                removeFromQueue(task);
315                double completionPercentage = (submittedTask.getLength() - submittedTask.getRemainingGridletLength())/submittedTask.getLength();
316                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION);
317                int time = Double.valueOf(
318                                forecastFinishTimePlugin.execTimeEstimation(event, choosenResources, task, completionPercentage)).intValue();
319                log.debug(task.getJobId() + "_" + task.getId() + " starts executing on " + new DateTime()
320                                + " will finish after " + time);
321
322                if (time < 0.0)
323                        return;
324               
[133]325                submittedTask.setEstimatedDuration(time);
326                DateTime currentTime = new DateTime();
327                ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime);
328                submittedTask.addUsedResources(resHistItem);
329                submittedTask.setFinishTime(currentTime.getMillis() / 1000);
330               
[104]331                jobRegistry.saveHistory(submittedTask, time, choosenResources);
332               
333                logicalResource.sendInternal(time, GssimTags.TASK_EXECUTION_FINISHED,
334                                submittedTask);
335
336                try {
337                        long expectedDuration = submittedTask.getExpectedDuration().getMillis() / 1000;
338                        logicalResource.sendInternal(expectedDuration, GssimTags.TASK_REQUESTED_TIME_EXPIRED, submittedTask);
339                } catch (NoSuchFieldException e) {
340                        double t = submittedTask.getEstimatedDuration();
341                        logicalResource.sendInternal(t, GssimTags.TASK_REQUESTED_TIME_EXPIRED, submittedTask);
342                }
343               
[133]344                submittedTask.setGridletStatus(Gridlet.INEXEC);
345                log.info(GssimConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size()));
346               
[104]347                ProcessingElements pes = (ProcessingElements) choosenResources.get(ResourceParameterName.PROCESSINGELEMENTS);
348                for (ComputingResource resource : pes) {
349                        resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, submittedTask));
350                }
351
[133]352                /*for(ExecTaskInterface etask : jobRegistry.getRunningTasks()){
353                        System.out.println(etask.getJobId());
354                        for(String taskId: etask.getVisitedResources())
355                                System.out.println("====="+taskId);
356                }*/
[104]357
358        }
359       
360        protected void updateProcessingProgress() {
361                double timeSpan = DoubleMath.subtract(Sim_system.clock(), lastUpdateTime);
362                if (timeSpan <= 0.0) {
363                        // don't update when nothing changed
364                        return;
365                }
366                lastUpdateTime = Sim_system.clock();
367                Iterator<ExecTaskInterface> iter = jobRegistry.getRunningTasks().iterator();
368                while (iter.hasNext()) {
369                        ExecTaskInterface task = iter.next();
370                        SubmittedTask subTask = (SubmittedTask)task;
[175]371                        UsedResourceList<ResourceHistoryItem> usedResourcesList = subTask.getUsedResources();
372                        ResourceUnit unit = usedResourcesList.getLast().getResourceUnits()
[104]373                                        .get(ResourceParameterName.PROCESSINGELEMENTS);
374
375                        double load = getMIShare(timeSpan, (ProcessingElements) unit);
376                        subTask.updateGridletFinishedSoFar(load);
377                        addTotalLoad(load);
378                }
379        }
380
381        private double getMIShare(double timeSpan, ProcessingElements pes) {
382                double localLoad;
383                ResourceCalendar resCalendar = (ResourceCalendar) moduleList.getModule(ModuleType.RESOURCE_CALENDAR);
384                if (resCalendar == null)
385                        localLoad = 0;
386                else
387                        // 1 - localLoad_ = available MI share percentage
388                        localLoad = resCalendar.getCurrentLoad();
389
390                int speed = pes.getSpeed();
391                int cnt = pes.getAmount();
392
393                double totalMI = speed * cnt * timeSpan * (1 - localLoad);
394                return totalMI;
395        }
396
397        protected void updateProcessingTimes(Sim_event ev) {
398                updateProcessingProgress();
399                for (ExecTaskInterface task : jobRegistry.getRunningTasks()) {
400                        SubmittedTask subTask = (SubmittedTask)task;
[175]401                        Map<ResourceParameterName, ResourceUnit> choosenResources = subTask.getUsedResources().getLast().getResourceUnits();
[104]402                        double completionPercentage = (task.getLength() - subTask.getRemainingGridletLength())/task.getLength();
403                        double time = forecastFinishTimePlugin.execTimeEstimation(null, choosenResources, task,
404                                        completionPercentage);
[133]405                        /*if(!subTask.getResPath().contains(ev.get_data().toString())) {
406                                continue;*/
407                        if(!subTask.getVisitedResources().contains(ev.get_data().toString())) {
[104]408                                continue;
[142]409                        }// else if( DoubleMath.subtract(subTask.getEstimatedDuration(), (time + lastUpdateTime)) == 0.0 || completionPercentage == 0){
410                        else if( DoubleMath.subtract((subTask.getExecStartTime()+subTask.getEstimatedDuration()), (new DateTime().getMillis()/1000 + time)) == 0.0){
[104]411                                continue;
412                        }
413                        SubTaskFilter filter = new SubTaskFilter(subTask.getGridletID(), GssimTags.TASK_EXECUTION_FINISHED);
414                        logicalResource.sim_cancel(filter, null);
415                        logicalResource.sendInternal(time, GssimTags.TASK_EXECUTION_FINISHED, task);
416
417                }
418        }       
419
420        public boolean pluginSupportsEvent(int eventType) {
421                SchedulingPluginConfiguration config = (SchedulingPluginConfiguration) schedulingPlugin.getConfiguration();
422                if (config == null)
423                        return false;
424
425                Map<SchedulingEventType, Object> servedEvent = config.getServedEvents();
426                if (servedEvent == null)
427                        return false;
428
429                switch (eventType) {
430
431                case GssimTags.TIMER:
432                        return servedEvent.containsKey(SchedulingEventType.TIMER);
433
434                case GssimTags.GRIDLET_SUBMIT:
435                        return servedEvent.containsKey(SchedulingEventType.TASK_ARRIVED);
436
437                case GssimTags.TASK_READY_FOR_EXECUTION:
438                        return servedEvent.containsKey(SchedulingEventType.START_TASK_EXECUTION);
439                case GssimTags.TASK_EXECUTION_FINISHED:
440                        return servedEvent.containsKey(SchedulingEventType.TASK_FINISHED);
441                case GssimTags.GRIDLET_CANCEL:
442                        return servedEvent.containsKey(SchedulingEventType.TASK_CANCELED);
443                case GssimTags.GRIDLET_RESUME:
444                        return servedEvent.containsKey(SchedulingEventType.TASK_ARRIVED);
445
446                case GssimTags.GRIDRESOURCE_FAILURE:
447                        return servedEvent.containsKey(SchedulingEventType.RESOURCE_FAILED);
448
449
450                case GssimTags.TASK_REQUESTED_TIME_EXPIRED:
451                        return servedEvent.containsKey(SchedulingEventType.TASK_REQUESTED_TIME_EXPIRED);
452
[262]453                case GssimTags.START:
454                        return true;
455                case GssimTags.SHUTDOWN:
456                        return true;
[104]457                default:
458                        return false;
459                }
460        }
461
462        public double calculateTotalLoad(int size) {
463                // background load, defined during initialization
464                double load;
465                ResourceCalendar resCalendar = (ResourceCalendar) moduleList.getModule(ModuleType.RESOURCE_CALENDAR);
466                if (resCalendar == null)
467                        load = 0;
468                else
469                        load = resCalendar.getCurrentLoad();
470
471                double numberOfPE;
472                try {
473                        numberOfPE = resourceManager.getResourcesOfType(ResourceType.CPU).size();
474                } catch (Exception e) {
475                        numberOfPE = 1;
476                }
477                double tasksPerPE = (double) size / numberOfPE;
478                load += Math.min(1.0 - load, tasksPerPE);
479
480                return load;
481        }
482
483        public Accumulator getTotalLoad() {
484                return accTotalLoad_;
485        }
486
487        protected void addTotalLoad(double load) {
488                accTotalLoad_.add(load);
489        }
490       
491        private HashMap<ResourceParameterName, ResourceUnit> chooseResourcesForExecution(String resourceName,
492                        ExecTaskInterface task) {
493
494                ResourceManagerInterface resourceManager = this.resourceManager;
495                if(resourceName != null){
496                        ComputingResource resource = null;
497                        try {
498                                resource = resourceManager.getResourceByName(resourceName);
499                        } catch (ResourceException e) {
500                                return null;
501                        }
502
503                        resourceManager = new ResourceManager(resource);
504                }
505                HashMap<ResourceParameterName, ResourceUnit> map = new HashMap<ResourceParameterName, ResourceUnit>();
506
507                List<ComputingResource> choosenResources = null;
508                int cpuRequest;
509                try {
510                        cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
511                } catch (NoSuchFieldException e) {
512                        cpuRequest = 1;
513                }
514
515                if (cpuRequest != 0) {
516                        List<? extends ComputingResource> processingElements = null;
517                        try {
518                                Properties properties = new Properties();
519                                properties.setProperty("type", ResourceType.CPU.toString());
520                                processingElements = resourceManager.filterResources(properties);
521                        } catch (Exception e) {
522                                e.printStackTrace();
523                        }
524
525                        choosenResources = new ArrayList<ComputingResource>();
526
527                        for (int i = 0; i < processingElements.size() && cpuRequest > 0; i++) {
528                                if (processingElements.get(i).getStatus() == ResourceStatus.FREE) {
529                                        choosenResources.add(processingElements.get(i));
530                                        cpuRequest--;
531                                }
532                        }
533                        if (cpuRequest > 0)
534                        {       
535                                return null;
536                        }
537                       
538                        ProcessingElements result = new ProcessingElements(ResourceManagerUtils.getCommonParent(choosenResources).getName());
539                        result.addAll(choosenResources);
540                        map.put(ResourceParameterName.PROCESSINGELEMENTS, result);
541                }
542                return  map;
543        }
544
[262]545        private void changeResourcePowerState(Sim_event ev) {
546                String resName = (String)ev.get_data();
547                ComputingResource resource = null;
548                try {
549                        resource = resourceManager.getResourceByName(resName);
550                } catch (ResourceException e) {
551                        return;
552                }
553                switch(ev.get_tag()){
554                case GssimTags.START:
555                        resource.getPowerInterface().setPowerState(PowerState.ON);
556                        break;
557                case GssimTags.SHUTDOWN:
558                        resource.getPowerInterface().setPowerState(PowerState.OFF);
559                        break;
560                default: break;
561                       
562                }
563               
564        }
[104]565}
Note: See TracBrowser for help on using the repository browser.