aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xexamples/example.py4
-rw-r--r--rumba/model.py47
2 files changed, 43 insertions, 8 deletions
diff --git a/examples/example.py b/examples/example.py
index 383dbf1..7fe130d 100755
--- a/examples/example.py
+++ b/examples/example.py
@@ -44,8 +44,8 @@ print(exp)
try:
exp.swap_in()
exp.bootstrap_prototype()
- c1 = Client("rinaperf", options = "-t perf -s 1000 -c 10000")
- s1 = Server("rinaperf", options = "-l", nodes = [a], clients = [c1])
+ c1 = ClientBinary("rinaperf", options = "-t perf -s 1000 -c 10000")
+ s1 = Server("rinaperf", arrival_rate=2, mean_duration=5, options = "-l", nodes = [a], clients = [c1])
sb = StoryBoard(exp, 3600, servers = [s1])
sb.start()
finally:
diff --git a/rumba/model.py b/rumba/model.py
index 97af536..36ac5c3 100644
--- a/rumba/model.py
+++ b/rumba/model.py
@@ -22,6 +22,8 @@
import abc
import random
+import time
+
import rumba.log as log
@@ -567,16 +569,50 @@ class Experiment:
# Undo the testbed (testbed-specific)
self.testbed.swap_out(self)
+
# Base class for client programs
#
# @ap: Application Process binary
# @options: Options to pass to the binary
#
-class Client:
- def __init__(self, ap, duration, options=None):
+class ClientBinary(object):
+ def __init__(self, ap, options=None):
self.ap = ap
self.options = options
- self.duration = duration # in seconds
+
+ def start_process(self, node, duration, start_time):
+ return ClientProcess(self.ap, node, duration, start_time, self.options)
+
+
+# Base class for client processes
+#
+# @ap: Application Process binary
+# @node: The node on which this process should run
+# @duration: The time (in seconds) this process should run
+# @start_time: The time at which this process is started.
+# @options: Options to pass to the binary
+#
+class ClientProcess(ClientBinary):
+ def __init__(self, ap, node, duration, start_time, options=None):
+ super(ClientProcess, self).__init__(ap, options=options)
+ self.node = node
+ self.duration = duration
+ self.start_time = start_time
+ self.run()
+ self.running = True
+
+ def run(self):
+ pass # TODO to be implemented
+
+ def stop(self):
+ pass # TODO to be implemented
+
+ def check(self, now):
+ if not self.running:
+ return
+ if now - self.start_time >= self.duration:
+ self.stop()
+
# Base class for server programs
#
@@ -623,12 +659,11 @@ class Server:
"""
pass
- def make_client(self):
+ def make_client_process(self):
"""Returns a client of this server"""
if len(self.clients) == 0:
raise Exception("Server %s has empty client list," % (self,))
- placeholder = 10 # TODO: Should be a sample from Exp(mean_duration)
- return Client(random.choice(self.clients), placeholder)
+ pass # TODO should return a ClientProcess
# Base class for ARCFIRE storyboards