1 | package de.uka.ipd.sdq.scheduler.factory; |
2 | |
3 | import scheduler.configuration.MultipleQueueConfiguration; |
4 | import scheduler.configuration.SingleQueueConfiguration; |
5 | import scheduler.configuration.util.ConfigurationSwitch; |
6 | import de.uka.ipd.sdq.scheduler.loaddistribution.IInstanceSelector; |
7 | import de.uka.ipd.sdq.scheduler.loaddistribution.IProcessSelector; |
8 | import de.uka.ipd.sdq.scheduler.loaddistribution.balancers.AbstractLoadBalancer; |
9 | import de.uka.ipd.sdq.scheduler.queueing.IQueueingStrategy; |
10 | import de.uka.ipd.sdq.scheduler.queueing.IRunQueue; |
11 | import de.uka.ipd.sdq.scheduler.queueing.strategies.MultipleQueuesStrategy; |
12 | import de.uka.ipd.sdq.scheduler.queueing.strategies.SingleQueueStrategy; |
13 | import de.uka.ipd.sdq.scheduler.resources.active.SimActiveResource; |
14 | import de.uka.ipd.sdq.scheduler.strategy.impl.AbstractScheduler; |
15 | |
16 | public class QueueingConfigurationSwitch extends ConfigurationSwitch<IQueueingStrategy> { |
17 | |
18 | |
19 | private IInstanceSelector instance_selector; |
20 | private IRunQueue runqueue_prototype; |
21 | private SimActiveResource resource; |
22 | private SchedulingFactory factory; |
23 | |
24 | public QueueingConfigurationSwitch(IRunQueue runqueue_prototype, IInstanceSelector instance_selector, SchedulingFactory factory, SimActiveResource resource){ |
25 | this.instance_selector = instance_selector; |
26 | this.runqueue_prototype = runqueue_prototype; |
27 | this.factory = factory; |
28 | this.resource = resource; |
29 | } |
30 | |
31 | @Override |
32 | public IQueueingStrategy caseMultipleQueueConfiguration( |
33 | MultipleQueueConfiguration configuration) { |
34 | AbstractLoadBalancer load_balancer = (AbstractLoadBalancer)factory.createLoadBalancer(configuration.getLoadBalancing()); |
35 | MultipleQueuesStrategy strategy = new MultipleQueuesStrategy(resource.getInstanceList(), runqueue_prototype, instance_selector, load_balancer, configuration.isInFrontWhenBalancing()); |
36 | load_balancer.setQueueHolder(strategy); |
37 | return strategy; |
38 | } |
39 | |
40 | @Override |
41 | public IQueueingStrategy caseSingleQueueConfiguration(SingleQueueConfiguration configuration) { |
42 | IProcessSelector processSelector = factory.createProcessSelector(configuration.getProcessSelection()); |
43 | return new SingleQueueStrategy(runqueue_prototype, processSelector, instance_selector); |
44 | } |
45 | } |