[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22744 - in gnunet-planetlab/gplmt: . contrib
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22744 - in gnunet-planetlab/gplmt: . contrib |
Date: |
Wed, 18 Jul 2012 14:11:54 +0200 |
Author: wachs
Date: 2012-07-18 14:11:54 +0200 (Wed, 18 Jul 2012)
New Revision: 22744
Modified:
gnunet-planetlab/gplmt/Notifications.py
gnunet-planetlab/gplmt/Tasks.py
gnunet-planetlab/gplmt/Worker.py
gnunet-planetlab/gplmt/contrib/current.nodes
gnunet-planetlab/gplmt/gplmt.py
Log:
changes
Modified: gnunet-planetlab/gplmt/Notifications.py
===================================================================
--- gnunet-planetlab/gplmt/Notifications.py 2012-07-18 11:58:26 UTC (rev
22743)
+++ gnunet-planetlab/gplmt/Notifications.py 2012-07-18 12:11:54 UTC (rev
22744)
@@ -20,17 +20,30 @@
#
# GNUnet Planetlab deployment and automation toolset
#
-# Notifications
+# Notifications
class Notification:
def __init__(self, logger):
assert (None != logger)
self.logger = logger
- def tasklist_started (self, tasks):
- print "Tasklist '" + tasks.name + "' started"
- def tasklist_completed (self, tasks):
- print "Tasklist '" + tasks.name + "' completed"
- def task_started (self, tasks):
- print "Task '" + tasks.name + "' started"
- def task_completed (self, tasks):
- print "Task '" + tasks.name + "' completed"
\ No newline at end of file
+ def tasklist_started (self, node, tasks):
+ assert (0)
+ def tasklist_completed (self, node, tasks):
+ assert (0)
+ def task_started (self, node, tasks):
+ assert (0)
+ def task_completed (self, node, tasks):
+ assert (0)
+
+class SimpleNotification (Notification):
+ def __init__(self, logger):
+ assert (None != logger)
+ self.logger = logger
+ def tasklist_started (self, node, tasks):
+ print node + " : Tasklist '" + tasks.name + "' started"
+ def tasklist_completed (self, node, tasks):
+ print node + " : Tasklist '" + tasks.name + "' completed"
+ def task_started (self, node, task):
+ print node + " : Task '" + task.name + "' started"
+ def task_completed (self, node, task):
+ print node + " : Task '" + task.name + "' completed"
\ No newline at end of file
Modified: gnunet-planetlab/gplmt/Tasks.py
===================================================================
--- gnunet-planetlab/gplmt/Tasks.py 2012-07-18 11:58:26 UTC (rev 22743)
+++ gnunet-planetlab/gplmt/Tasks.py 2012-07-18 12:11:54 UTC (rev 22744)
@@ -157,9 +157,9 @@
def load (self):
self.logger.log ("Loading nodes file '" + self.filename + "'")
try:
- root = ElementTree.parse (self.filename).getroot()
- if (None != root.attrib.get("name")):
- self.name = root.attrib.get("name")
+ root = ElementTree.parse (self.filename).getroot()
+ if (None != root.attrib.get("name")):
+ self.name = root.attrib.get("name")
except IOError:
print "File " + self.filename + " not found"
return False
@@ -170,6 +170,8 @@
t = Tasks (self.filename, self.logger)
# Create a copy of the task list as described in
# http://docs.python.org/library/copy.html
+ t.filename = self.filename
+ t.name = self.name
t.l = self.l[:]
return t
def get (self):
Modified: gnunet-planetlab/gplmt/Worker.py
===================================================================
--- gnunet-planetlab/gplmt/Worker.py 2012-07-18 11:58:26 UTC (rev 22743)
+++ gnunet-planetlab/gplmt/Worker.py 2012-07-18 12:11:54 UTC (rev 22744)
@@ -20,33 +20,36 @@
#
# GNUnet Planetlab deployment and automation toolset
#
-# Nodes
+# Worker
import threading
import time
exitFlag = 0
+glogger = None
-
class NodeWorkerThread (threading.Thread):
- def __init__(self, threadID, name, tasks, notifications):
+ def __init__(self, threadID, node, tasks, notifications):
threading.Thread.__init__(self)
self.threadID = threadID
- self.name = name
+ self.node = node
self.tasks = tasks
self.notifications = notifications
def run(self):
- print "Starting " + self.name
+ glogger.log (self.node + " : Starting tasklist " + self.tasks.name)
task = self.tasks.get()
while (None != task):
if (task.__class__.__name__ == "Task"):
- print self.name + " : Running task " + task.name
+ glogger.log (self.node + " : Running task " + task.name)
+ self.notifications.task_started (self.node, task)
elif (task.__class__.__name__ == "Taskset"):
- print self.name + " : Running task set"
+ glogger.log (self.node + " : Running task set")
task = self.tasks.get()
time.sleep(1)
- print "Exiting " + self.name
+ self.notifications.tasklist_completed (self.node, self.tasks)
+ glogger.log (self.node + " : All tasks done for " + self.node)
+
class NodeWorker:
@@ -62,20 +65,26 @@
self.notifications = notifications
def start (self):
self.logger.log ("Starting execution for node " + self.node)
- self.notifications.tasklist_started (self.tasks)
+ self.notifications.tasklist_started (self.node, self.tasks)
self.thread = NodeWorkerThread (1, self.node, self.tasks,
self.notifications)
self.thread.start()
class Worker:
def __init__(self, logger, nodes, tasks, notifications):
+ global glogger;
assert (None != logger)
assert (None != nodes)
assert (None != tasks)
assert (None != notifications)
+ assert (hasattr(notifications, 'tasklist_started'))
+ assert (hasattr(notifications, 'tasklist_completed'))
+ assert (hasattr(notifications, 'task_started'))
+ assert (hasattr(notifications, 'task_completed'))
self.logger = logger
self.nodes = nodes
self.tasks = tasks
self.notifications = notifications
+ glogger = logger;
def start (self):
self.logger.log ("Starting execution")
for n in self.nodes.nodes:
Modified: gnunet-planetlab/gplmt/contrib/current.nodes
===================================================================
--- gnunet-planetlab/gplmt/contrib/current.nodes 2012-07-18 11:58:26 UTC
(rev 22743)
+++ gnunet-planetlab/gplmt/contrib/current.nodes 2012-07-18 12:11:54 UTC
(rev 22744)
@@ -1,3 +1,3 @@
-dmmuy.de
-dmmy.de
-asddas.de
\ No newline at end of file
+abc.de
+def.at
+ghi.tv
\ No newline at end of file
Modified: gnunet-planetlab/gplmt/gplmt.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt.py 2012-07-18 11:58:26 UTC (rev 22743)
+++ gnunet-planetlab/gplmt/gplmt.py 2012-07-18 12:11:54 UTC (rev 22744)
@@ -122,7 +122,7 @@
sys.exit(2)
# Set up notifications
- notifications = Notifications.Notification (main.logger)
+ notifications = Notifications.SimpleNotification (main.logger)
# Start execution
worker = Worker.Worker (main.logger, nodes, tasks, notifications)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22744 - in gnunet-planetlab/gplmt: . contrib,
gnunet <=