1 package at.ac.tuwien.lsdc.federation;
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
6 import at.ac.tuwien.lsdc.JobGenerator;
7 import at.ac.tuwien.lsdc.SchedSimulator;
8 import at.ac.tuwien.lsdc.sched.AbstractScheduler;
9 import at.ac.tuwien.lsdc.sched.SchedulerB;
10 import at.ac.tuwien.lsdc.types.Application;
13 * Cloudpartners management. Class to be used to ask cloudpartners to take one
14 * of our APPs over to their infrastructure.
19 public class Federation {
23 private static final Logger LOG = LoggerFactory.getLogger(SchedulerB.class);
25 private int numPartners;
27 public Federation(int numPartners) {
28 this.numPartners = numPartners;
32 * Try to outsource app.
35 * Application to outsource.
36 * @return true, if application can be outsourced.
38 public boolean askToOutsource(Application app) {
39 if ((Math.random() * 100) < (10 * numPartners)) {
40 LOG.info("Outsource:" + app);
47 * Try to insource app.
49 * @return application to be insourced.
51 public Application askToInsource() {
57 long timestamp = AbstractScheduler.getCurrentTime() + JobGenerator.randomInt(1, 3);
59 if ((Math.random() * 100) < (10 * numPartners)) {
60 LOG.info("Insource app ");
61 switch (SchedSimulator.getScenario()) {
63 size = JobGenerator.randomInt(20, 100);
64 ram = JobGenerator.randomInt(30, 50);
65 cpu = JobGenerator.randomInt(50, 100);
66 duration = JobGenerator.randomInt(1, 50);
67 return new Application(timestamp, size, ram, cpu, duration);
69 size = JobGenerator.randomInt(150, 500);
70 ram = JobGenerator.randomInt(100, 700);
71 cpu = JobGenerator.randomInt(100, 400);
72 duration = JobGenerator.randomInt(1, 50);
73 return new Application(timestamp, size, ram, cpu, duration);
75 size = JobGenerator.randomInt(20, 500);
76 ram = JobGenerator.randomInt(30, 700);
77 cpu = JobGenerator.randomInt(50, 400);
78 duration = JobGenerator.randomInt(1, 50);
79 return new Application(timestamp, size, ram, cpu, duration);