aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rumba/model.py40
-rwxr-xr-xsetup.py16
2 files changed, 38 insertions, 18 deletions
diff --git a/rumba/model.py b/rumba/model.py
index 46a2351..ce4e938 100644
--- a/rumba/model.py
+++ b/rumba/model.py
@@ -30,9 +30,17 @@ logger = log.get_logger(__name__)
try:
from numpy.random import poisson
+ from numpy.random import exponential
+ logger.debug("Using numpy for faster and better random variables.")
except ImportError:
from rumba.recpoisson import poisson
+ def exponential(mean_duration):
+ return random.expovariate(1.0 / mean_duration)
+
+ logger.debug("Falling back to simple implementations.")
+ # PROBLEM! These logs will almost never be printed...
+
# Represents generic testbed info
#
@@ -717,15 +725,12 @@ class ClientProcess(Client):
self.ap, self.node.name, self.duration
)
- script = r'nohup "$@" > /dev/null & echo "$!"'
opt_str = self.options if self.options is not None else ""
- cmds = ["echo '%s' > startup.sh && chmod a+x startup.sh"
- % (script,),
- "./startup.sh %s %s" % (self.ap, opt_str)]
+ cmd = "./startup.sh %s %s" % (self.ap, opt_str)
self.running = True
- self.pid = ssh_support.execute_commands(self.testbed,
- self.node.ssh_config,
- cmds)
+ self.pid = ssh_support.execute_command(self.testbed,
+ self.node.ssh_config,
+ cmd)
def stop(self):
logger.debug(
@@ -807,20 +812,21 @@ class Server:
"""Returns a client of this server"""
if len(self.clients) == 0:
raise Exception("Server %s has empty client list." % (self,))
- duration = random.expovariate(1.0 / self.mean_duration)
+ duration = exponential(self.mean_duration)
return random.choice(self.clients)\
.start_process(duration=duration)
def run(self):
for node in self.nodes:
opt_str = self.options if self.options is not None else ""
- script = r'nohup "$@" > /dev/null & echo "$!"'
+ logfile = "%s.log" % self.ap
+ script = r'nohup "$@" > %s & echo "$!"' % logfile
cmds = ["echo '%s' > startup.sh && chmod a+x startup.sh"
% (script,),
"./startup.sh %s %s" % (self.ap, opt_str)]
logger.debug(
- 'Starting server %s on node %s.',
- self.ap, node.name
+ 'Starting server %s on node %s with logfile %s.',
+ self.ap, node.name, logfile
)
self.pids[node] = (ssh_support.execute_commands(self.testbed,
node.ssh_config,
@@ -843,13 +849,14 @@ class Server:
#
# @experiment: Experiment to use as input
# @duration: Duration of the whole storyboard
+# @testbed: The testbed the experiment is run on.
# @servers: App servers available in the network
#
class StoryBoard:
DEFAULT_INTERVAL = 2.5 # in seconds (may be a float)
- def __init__(self, experiment, duration, servers=None):
+ def __init__(self, experiment, duration, testbed, servers=None):
self.experiment = experiment
self.duration = duration
if servers is None:
@@ -858,6 +865,7 @@ class StoryBoard:
self.client_nodes = [c for c in experiment.nodes if c.client]
self.active_clients = []
self.start_time = None
+ self.testbed = testbed
def add_server(self, server):
self.servers.append(server)
@@ -867,6 +875,14 @@ class StoryBoard:
def start(self):
self.start_time = time.time()
+ script = r'nohup "$@" > /dev/null & echo "$!"'
+ for node in self.client_nodes:
+ logger.debug("Writing utility startup script on client nodes.")
+ ssh_support.execute_command(
+ self.testbed,
+ node.ssh_config,
+ "echo '%s' > startup.sh && chmod a+x startup.sh" % (script,)
+ )
try:
for server in self.servers:
server.run()
diff --git a/setup.py b/setup.py
index f00e934..366f36c 100755
--- a/setup.py
+++ b/setup.py
@@ -1,10 +1,13 @@
#!/usr/bin/env python
-from setuptools import setup
-from codecs import open
-from os import path
+import setuptools
-setup(
+INSTALL_REQUIRES = ["paramiko", "wheel", "wget",
+ 'repoze.lru; python_version<"3.2"']
+EXTRAS_REQUIRE = {"NumpyAcceleration": ["numpy"]}
+
+
+setuptools.setup(
name="Rumba",
version="0.4",
url="https://gitlab.com/arcfire/rumba",
@@ -14,6 +17,7 @@ setup(
license="LGPL",
description="Rumba measurement framework for RINA",
packages=["rumba", "rumba.testbeds", "rumba.prototypes"],
- install_requires=["paramiko", "wheel", "wget"],
- scripts = ['tools/rumba-access']
+ install_requires=INSTALL_REQUIRES,
+ extras_require=EXTRAS_REQUIRE,
+ scripts=['tools/rumba-access']
)