def setUp(self): super(ProcessEvaluatorTestCase, self).setUp() scheduler = SchedulerFactory.getScheduler("FiFo", timeslice=10) scheduler.initialize("A") scheduler.run() self.evaluator = ProcessEvaluator()
def setUp(self): super(StrategyEvaluatorComplexTestCase, self).setUp() scheduler = SchedulerFactory.getScheduler("FiFo", timeslice=10) scheduler.initialize("A") scheduler.run() self.evaluator = StrategyEvaluator()
def post(self, strategy, quantum=4, ts=10): #import pdb; pdb.set_trace() # parse process syntax args = self.parser.parse_args() processDescription = args.get("syntax") init_p = args.get("initial_process") # trying to parse the syntax parseSyntax(processDescription) # here comes the critical section: creating the Scheduler environmet including Singletons. try: # generate scheduler scheduler = SchedulerFactory.getScheduler(str(strategy), quantum=quantum, timeslice=ts) # run scheduler scheduler.initialize(init_p) scheduler.run() # generate JSON json_result = JsonSerializer().generateData() except Exception as e: # pass the exceptions to the api - it will translate it to json-requests raise e finally: # we make sure that even after an exception, all Singletons get destroyed. ProcessManager._drop() SystemTimer._drop() return json_result, 200
def main(): """ REPL-environment CLI-Client :return: """ print welcome while True: # read-eval-print-loop syntax = read_loop() # read try: parseSyntax(syntax) # eval except Exception as e: print 'Something went wrong:', e.message print 'try it again!' # print else: print 'sucessfully read syntax' # print print syntax.strip() break # prozesse sind erzeugt - process manager ist initialisiert. weiter im text.... init_process = raw_input("Welcher Prozess soll zuerst laufen? [%s]:" % " oder ".join([p.process.name for p in ProcessManager().jobs])) # welcher scheduler soll verwendet werden? while True: requested_scheduler = raw_input("Welchen Scheduler soll ich verwenden? ") q = input("initial process quantum: ") ts = input("initial process timeslice: ") try: scheduler = SchedulerFactory.getScheduler(requested_scheduler, timeslice=ts, quantum=q) except Exception as e: print 'something went wrong:', e print 'try one of these:', SchedulerFactory.getPossibleChoices() else: scheduler.initialize(init_process) scheduler.run() print_scheduler_results() print_process_results() break
def test_factory_possible_choices(self): choices = SchedulerFactory.getPossibleChoices() print choices self.assertIn('FiFo'.lower(), choices)
def test_factory_02(self): ml_snd_RR = SchedulerFactory.getScheduler('MLsecondRR', timeslice=20, quantum=2) self.assertIsInstance(ml_snd_RR, Scheduler, 'exptected type %s, got an instance of type %s instead' % (Scheduler, type(ml_snd_RR)) )
def test_factory_01(self): fifo_scheduler = SchedulerFactory.getScheduler('FiFo') self.assertIsInstance(fifo_scheduler, Scheduler)
def get(self): possible_scheds = SchedulerFactory.getPossibleChoices() options = {"installed scheduler": possible_scheds} return jsonify(options)
def setUp(self): super(JSONSerializerTestCase, self).setUp() fifoscheduler = SchedulerFactory.getScheduler("FiFo") fifoscheduler.initialize("A") fifoscheduler.run()