/
Driver.py
70 lines (61 loc) · 1.95 KB
/
Driver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'''
Created on Jun 4, 2013
@author: sivabalan
'''
from proj.tasks import add1,add,add2
from celery.task.control import inspect
from celery import chord
import json,sys
from random import randint
from scheduler.Scheduler import Scheduler
from scheduler.FCFSScheduler import FCFSScheduler
from scheduler.RandomizedScheduler import RandomizedScheduler
import cPickle
def main():
loop = []
# count1 = 0
# count2 = 0
#code to generate 300 tasks of random types
# for x in xrange(300):
# opertn = randint(0,2)
# if opertn == 0:
# temp = add.s((randint(0,100)),(randint(0,100)))
# print temp
# count = count + 1
# count1 = count1 + 1
# loop.append(temp)
# elif opertn == 1:
# temp = add1.s((randint(0,100)),(randint(0,100)))
# print temp
# count = count + 1
# count2 = count2 + 1
# loop.append(temp)
# else:
# temp = add2.s((randint(0,100)),(randint(0,100)))
# print temp
# loop.append(temp)
# print " add ",count1," add1 ",count2
# code to generate 300 tasks of same type
count1 = 0
for x in xrange(300):
temp = add.s((randint(0,100)),(randint(0,100)))
print temp
count1 = count1+1
loop.append(temp)
FILE = open("tasks1.txt", 'w')
cPickle.dump(loop, FILE)
FILE.close()
FILE = open("tasks1.txt", 'r')
taskslist = cPickle.load(FILE)
FILE.close()
print "Task list"
print taskslist
schedulertype = sys.argv[0]
# print "total add tasks ",count1
if schedulertype == "FCFS":
schedulerObj = FCFSScheduler(["wnode1","wnode2","wnode3"])
else:
schedulerObj = RandomizedScheduler(["wnode1","wnode2","wnode3"])
schedulerObj.assignTasks("client1",taskslist)
if __name__ == "__main__":
main()