From 97419cc12557220de42fca8a9e99c9f05d66783d Mon Sep 17 00:00:00 2001 From: Jan Vales Date: Thu, 13 Jun 2013 16:42:56 +0200 Subject: [PATCH] federation now has askToInsource(). --- .../ac/tuwien/lsdc/federation/Federation.java | 48 ++++++++++++++++--- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/src/at/ac/tuwien/lsdc/federation/Federation.java b/src/at/ac/tuwien/lsdc/federation/Federation.java index 78cf678..ad60a6b 100644 --- a/src/at/ac/tuwien/lsdc/federation/Federation.java +++ b/src/at/ac/tuwien/lsdc/federation/Federation.java @@ -3,6 +3,8 @@ package at.ac.tuwien.lsdc.federation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.ac.tuwien.lsdc.JobGenerator; +import at.ac.tuwien.lsdc.SchedSimulator; import at.ac.tuwien.lsdc.sched.SchedulerB; import at.ac.tuwien.lsdc.types.Application; @@ -20,8 +22,6 @@ public class Federation { private static final Logger LOG = LoggerFactory.getLogger(SchedulerB.class); private int numPartners; - public final static int fak = 100; - public final static int th = 30; public Federation(int numPartners) { this.numPartners = numPartners; @@ -31,16 +31,50 @@ public class Federation { * Try to outsource app. * * @param app - * Application to outsource. + * Application to outsource. * @return true, if application can be outsourced. */ public boolean askToOutsource(Application app) { LOG.info("askToOutsource():" + app); - for (int i = 0; i < numPartners; i++) { - if (Math.random() * fak < th) - return true; - } + if ((Math.random() * 100) < (10 * numPartners)) + return true; return false; } + /** + * Try to insource app. + * + * @return application to be insourced. + */ + @SuppressWarnings("unused") + public Application askToInsource() { + LOG.info("askToOutsource()"); + int size; + int ram; + int cpu; + int duration; + + if ((Math.random() * 100) < (10 * numPartners) && false) + switch (SchedSimulator.getScenario()) { + case A : + size = JobGenerator.randomInt(20, 100); + ram = JobGenerator.randomInt(30, 50); + cpu = JobGenerator.randomInt(50, 100); + duration = JobGenerator.randomInt(1, 50); + return new Application(0, size, ram, cpu, duration); + case B : + size = JobGenerator.randomInt(150, 500); + ram = JobGenerator.randomInt(100, 700); + cpu = JobGenerator.randomInt(100, 400); + duration = JobGenerator.randomInt(1, 50); + return new Application(0, size, ram, cpu, duration); + default : + size = JobGenerator.randomInt(20, 500); + ram = JobGenerator.randomInt(30, 700); + cpu = JobGenerator.randomInt(50, 400); + duration = JobGenerator.randomInt(1, 50); + return new Application(0, size, ram, cpu, duration); + } + return null; + } } -- 2.43.0