]> git.somenet.org - pub/jan/lsdc.git/blob - src/at/ac/tuwien/lsdc/federation/Federation.java
fix strange methods in Physical & Virtual Machine
[pub/jan/lsdc.git] / src / at / ac / tuwien / lsdc / federation / Federation.java
1 package at.ac.tuwien.lsdc.federation;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5
6 import at.ac.tuwien.lsdc.JobGenerator;
7 import at.ac.tuwien.lsdc.SchedSimulator;
8 import at.ac.tuwien.lsdc.sched.SchedulerB;
9 import at.ac.tuwien.lsdc.types.Application;
10
11 /**
12  * Cloudpartners management. Class to be used to ask cloudpartners to take one
13  * of our APPs over to their infrastructure.
14  * 
15  * @author jan
16  * 
17  */
18 public class Federation {
19         /**
20          * Logger.
21          */
22         private static final Logger LOG = LoggerFactory.getLogger(SchedulerB.class);
23
24         private int numPartners;
25
26         public Federation(int numPartners) {
27                 this.numPartners = numPartners;
28         }
29
30         /**
31          * Try to outsource app.
32          * 
33          * @param app
34          *            Application to outsource.
35          * @return true, if application can be outsourced.
36          */
37         public boolean askToOutsource(Application app) {
38                 LOG.info("askToOutsource():" + app);
39                 if ((Math.random() * 100) < (10 * numPartners))
40                         return true;
41                 return false;
42         }
43
44         /**
45          * Try to insource app.
46          * 
47          * @return application to be insourced.
48          */
49         @SuppressWarnings("unused")
50         public Application askToInsource() {
51                 LOG.info("askToOutsource()");
52                 int size;
53                 int ram;
54                 int cpu;
55                 int duration;
56
57                 if ((Math.random() * 100) < (10 * numPartners) && false)
58                         switch (SchedSimulator.getScenario()) {
59                                 case A :
60                                         size = JobGenerator.randomInt(20, 100);
61                                         ram = JobGenerator.randomInt(30, 50);
62                                         cpu = JobGenerator.randomInt(50, 100);
63                                         duration = JobGenerator.randomInt(1, 50);
64                                         return new Application(0, size, ram, cpu, duration);
65                                 case B :
66                                         size = JobGenerator.randomInt(150, 500);
67                                         ram = JobGenerator.randomInt(100, 700);
68                                         cpu = JobGenerator.randomInt(100, 400);
69                                         duration = JobGenerator.randomInt(1, 50);
70                                         return new Application(0, size, ram, cpu, duration);
71                                 default :
72                                         size = JobGenerator.randomInt(20, 500);
73                                         ram = JobGenerator.randomInt(30, 700);
74                                         cpu = JobGenerator.randomInt(50, 400);
75                                         duration = JobGenerator.randomInt(1, 50);
76                                         return new Application(0, size, ram, cpu, duration);
77                         }
78                 return null;
79         }
80 }