1 | package simulator.factory; |
---|
2 | |
---|
3 | import simulator.RandomNumbers; |
---|
4 | import simulator.hostspec.CpuCount; |
---|
5 | import simulator.hostspec.CpuLoad; |
---|
6 | import simulator.hostspec.CpuSpeed; |
---|
7 | import simulator.hostspec.DiskFree; |
---|
8 | import simulator.hostspec.DiskTotal; |
---|
9 | import simulator.hostspec.MemoryFree; |
---|
10 | import simulator.hostspec.MemoryTotal; |
---|
11 | import simulator.hostspec.ResourcesConfiguration; |
---|
12 | import simulator.hostspec.SwapFree; |
---|
13 | import simulator.hostspec.SwapTotal; |
---|
14 | import simulator.hostspec.RandParams; |
---|
15 | |
---|
16 | /** |
---|
17 | * |
---|
18 | * @author Marcin Krystek |
---|
19 | * |
---|
20 | */ |
---|
21 | public class ResourcesRandomNumbersFactory { |
---|
22 | |
---|
23 | public RandomNumbers initRandomNumbers(ResourcesConfiguration resConfig){ |
---|
24 | RandomNumbers randNumbers = new RandomNumbers(); |
---|
25 | |
---|
26 | simulator.hostspec.SingleResource singleRes = resConfig.getSingleResource(); |
---|
27 | if(singleRes != null) { |
---|
28 | CpuCount cpuCount = singleRes.getCpuCount(); |
---|
29 | addRandomNumbers(randNumbers, cpuCount, SingleResourceFactory.CPU_COUNT); |
---|
30 | |
---|
31 | CpuSpeed cpuSpeed = singleRes.getCpuSpeed(); |
---|
32 | addRandomNumbers(randNumbers, cpuSpeed, SingleResourceFactory.CPU_SPEED); |
---|
33 | |
---|
34 | CpuLoad cpuLoad = singleRes.getCpuLoad(); |
---|
35 | addRandomNumbers(randNumbers, cpuLoad, SingleResourceFactory.CPU_LOAD); |
---|
36 | |
---|
37 | MemoryTotal memoryTotal = singleRes.getMemoryTotal(); |
---|
38 | addRandomNumbers(randNumbers, memoryTotal, SingleResourceFactory.MEMORY_TOTAL); |
---|
39 | |
---|
40 | MemoryFree memoryFree = singleRes.getMemoryFree(); |
---|
41 | addRandomNumbers(randNumbers, memoryFree, SingleResourceFactory.MEMORY_FREE); |
---|
42 | |
---|
43 | SwapTotal swapTotal = singleRes.getSwapTotal(); |
---|
44 | addRandomNumbers(randNumbers, swapTotal, SingleResourceFactory.SWAP_TOTAL); |
---|
45 | |
---|
46 | SwapFree swapFree = singleRes.getSwapFree(); |
---|
47 | addRandomNumbers(randNumbers, swapFree, SingleResourceFactory.SWAP_FREE); |
---|
48 | |
---|
49 | DiskTotal diskTotal = singleRes.getDiskTotal(); |
---|
50 | addRandomNumbers(randNumbers, diskTotal, SingleResourceFactory.DISK_TOTAL); |
---|
51 | |
---|
52 | DiskFree diskFree = singleRes.getDiskFree(); |
---|
53 | addRandomNumbers(randNumbers, diskFree, SingleResourceFactory.DISK_FREE); |
---|
54 | } |
---|
55 | |
---|
56 | simulator.hostspec.QueueingSystem queueSystem = resConfig.getQueueingSystem(); |
---|
57 | |
---|
58 | if(queueSystem != null){ |
---|
59 | simulator.hostspec.QueuesGroup queueGroup = queueSystem.getQueuesGroup(); |
---|
60 | |
---|
61 | randNumbers.addRandomGenerator( |
---|
62 | queueGroup.getDistribution().getType(), |
---|
63 | queueGroup.hasAvg(), |
---|
64 | queueGroup.getAvg(), |
---|
65 | queueGroup.getStdev(), |
---|
66 | queueGroup.hasMin(), |
---|
67 | queueGroup.getMin(), |
---|
68 | queueGroup.hasMax(), |
---|
69 | queueGroup.getMax(), |
---|
70 | queueGroup.hasSeed(), |
---|
71 | queueGroup.getSeed(), |
---|
72 | QueueingSystemFactory.QUEUE_GROUP); |
---|
73 | |
---|
74 | simulator.hostspec.Queue queue = queueGroup.getQueue(); |
---|
75 | randNumbers.addRandomGenerator( |
---|
76 | queue.getDistribution().getType(), |
---|
77 | queue.hasAvg(), |
---|
78 | queue.getAvg(), |
---|
79 | queue.getStdev(), |
---|
80 | queue.hasMin(), |
---|
81 | queue.getMin(), |
---|
82 | queue.hasMax(), |
---|
83 | queue.getMax(), |
---|
84 | queue.hasSeed(), |
---|
85 | queue.getSeed(), |
---|
86 | QueueingSystemFactory.QUEUE); |
---|
87 | |
---|
88 | simulator.hostspec.Priority priority = queue.getPriority(); |
---|
89 | addRandomNumbers(randNumbers, priority, QueueingSystemFactory.PRIORITY); |
---|
90 | |
---|
91 | simulator.hostspec.MaxJobs maxJobs = queue.getMaxJobs(); |
---|
92 | addRandomNumbers(randNumbers, maxJobs, QueueingSystemFactory.MAX_JOBS); |
---|
93 | |
---|
94 | simulator.hostspec.MaxRunning maxRunning = queue.getMaxRunning(); |
---|
95 | addRandomNumbers(randNumbers, maxRunning, QueueingSystemFactory.MAX_RUNNING); |
---|
96 | |
---|
97 | simulator.hostspec.MaxPending maxPending = queue.getMaxPending(); |
---|
98 | addRandomNumbers(randNumbers, maxPending, QueueingSystemFactory.MAX_PENDING); |
---|
99 | |
---|
100 | simulator.hostspec.QueueResourcesCollective resCollective = queueGroup.getQueueResourcesCollective(); |
---|
101 | simulator.hostspec.NodeTotalMemory totalMemory = resCollective.getNodeTotalMemory(); |
---|
102 | addRandomNumbers(randNumbers, totalMemory, QueueingSystemFactory.NODE_TOTAL_MEMORY); |
---|
103 | |
---|
104 | simulator.hostspec.TotalCpus totalCpus = resCollective.getTotalCpus(); |
---|
105 | addRandomNumbers(randNumbers, totalCpus, QueueingSystemFactory.TOTAL_CPUS); |
---|
106 | } |
---|
107 | |
---|
108 | return randNumbers; |
---|
109 | } |
---|
110 | |
---|
111 | public static void addRandomNumbers(RandomNumbers rn, RandParams rp, String name) { |
---|
112 | rn.addRandomGenerator(rp.getDistribution().getType(), rp.hasAvg(), rp.getAvg(), rp.getStdev(), rp.hasMin(), rp.getMin(), rp.hasMax(), rp.getMax(), rp.hasSeed(), rp.getSeed(), name); |
---|
113 | } |
---|
114 | } |
---|