aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2017-05-10 18:09:56 +0200
committerMarco Capitani <m.capitani@nextworks.it>2017-05-10 18:09:56 +0200
commit43d3dbafc78172030dee2545b25d4fe5a05d1eba (patch)
treec1a25ba34145653bcd112c4b42d87ba14f0a875f
parenta34a5d7ec2e6aa59a0a0aa0daba62f7738a1749a (diff)
downloadrumba-43d3dbafc78172030dee2545b25d4fe5a05d1eba.tar.gz
rumba-43d3dbafc78172030dee2545b25d4fe5a05d1eba.zip
Storyboard: additions to the model
Means of distributions and other required fields.
-rw-r--r--rumba/model.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/rumba/model.py b/rumba/model.py
index 91f33a6..97af536 100644
--- a/rumba/model.py
+++ b/rumba/model.py
@@ -20,6 +20,7 @@
# MA 02110-1301 USA
import abc
+import random
import rumba.log as log
@@ -572,20 +573,23 @@ class Experiment:
# @options: Options to pass to the binary
#
class Client:
- def __init__(self, ap, options=None):
+ def __init__(self, ap, duration, options=None):
self.ap = ap
self.options = options
+ self.duration = duration # in seconds
# Base class for server programs
#
# @ap: Application Process binary
+# @arrival_rate: Average requests/s to be received by this server
# @options: Options to pass to the binary
# @max_clients: Maximum number of clients to serve
# @clients: Client binaries that will use this server
# @nodes: Specific nodes to start this server on
#
class Server:
- def __init__(self, ap, options=None, max_clients=None,
+ def __init__(self, ap, arrival_rate, mean_duration,
+ options=None, max_clients=None,
clients=None, nodes=None):
self.ap = ap
self.options = options
@@ -594,6 +598,8 @@ class Server:
clients = list()
self.clients = clients
self.nodes = nodes
+ self.arrival_rate = arrival_rate # mean requests/s
+ self.mean_duration = mean_duration # in seconds
def add_client(self, client):
self.clients.append(client)
@@ -607,6 +613,24 @@ class Server:
def del_node(self, node):
self.nodes.remove(node)
+ def get_new_clients(self, interval):
+ """
+ Returns a list of clients of size appropriate to the server's rate.
+
+ The list's size should be a sample from Poisson(arrival_rate) over
+ interval seconds.
+ Hence, the average size should be interval * arrival_rate.
+ """
+ pass
+
+ def make_client(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)
+
+
# Base class for ARCFIRE storyboards
#
# @experiment: Experiment to use as input