]> git.somenet.org - pub/jan/lsdc.git/blob - src/at/ac/tuwien/lsdc/federation/Federation.java
change build.xml clean ..
[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.sched.SchedulerB;
7 import at.ac.tuwien.lsdc.types.Application;
8
9 /**
10  * Cloudpartners management. Class to be used to ask cloudpartners to take one
11  * of our APPs over to their infrastructure.
12  * 
13  * @author jan
14  * 
15  */
16 public class Federation {
17         /**
18          * Logger.
19          */
20         private static final Logger LOG = LoggerFactory.getLogger(SchedulerB.class);
21
22         private int numPartners;
23         public final static int fak = 100;
24         public final static int th = 30;
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                 for (int i = 0; i < numPartners; i++) {
40                         if (Math.random() * fak < th)
41                                 return true;
42                 }
43                 return false;
44         }
45
46 }