aboutsummaryrefslogtreecommitdiff
path: root/rumba/model.py
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2017-05-11 10:51:26 +0200
committerMarco Capitani <m.capitani@nextworks.it>2017-05-11 10:51:26 +0200
commitea1a4462a8b7a2fb7404e4652e0806795ba96863 (patch)
treec89faa5691dad770c20b07c08ad1ad6f589b73c0 /rumba/model.py
parent43d3dbafc78172030dee2545b25d4fe5a05d1eba (diff)
downloadrumba-ea1a4462a8b7a2fb7404e4652e0806795ba96863.tar.gz
rumba-ea1a4462a8b7a2fb7404e4652e0806795ba96863.zip
Storyboard: added modifications to API to example.py
Diffstat (limited to 'rumba/model.py')
-rw-r--r--rumba/model.py47
1 files changed, 41 insertions, 6 deletions
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