Package ClusterShell :: Module Event
[hide private]
[frames] | no frames]

Source Code for Module ClusterShell.Event

  1  # 
  2  # Copyright (C) 2007-2015 CEA/DAM 
  3  # Copyright (C) 2015 Stephane Thiell <sthiell@stanford.edu> 
  4  # 
  5  # This file is part of ClusterShell. 
  6  # 
  7  # ClusterShell is free software; you can redistribute it and/or 
  8  # modify it under the terms of the GNU Lesser General Public 
  9  # License as published by the Free Software Foundation; either 
 10  # version 2.1 of the License, or (at your option) any later version. 
 11  # 
 12  # ClusterShell is distributed in the hope that it will be useful, 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 15  # Lesser General Public License for more details. 
 16  # 
 17  # You should have received a copy of the GNU Lesser General Public 
 18  # License along with ClusterShell; if not, write to the Free Software 
 19  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 
 20   
 21  """ 
 22  ClusterShell Event handling. 
 23   
 24  This module contains the base class **EventHandler** which defines a simple 
 25  interface through methods to handle events coming from ClusterShell I/O Engine 
 26  clients. Events are generated by Worker, EngineTimer or EnginePort objects. 
 27  """ 
 28   
29 -class EventHandler(object):
30 """ClusterShell EventHandler interface. 31 32 Derived class should implement the following methods to listen for Worker, 33 EngineTimer or EnginePort chosen events. 34 """ 35
36 - def ev_start(self, worker):
37 """ 38 Called to indicate that a worker has just started. 39 40 :param worker: :class:`.Worker` object 41 """
42
43 - def ev_pickup(self, worker):
44 """ 45 Called to indicate that a worker command for a specific node (or key) 46 has just started. Called for each node. 47 48 :param worker: :class:`.Worker` object 49 50 Available worker attributes: 51 52 * :attr:`.Worker.current_node` - node (or key) 53 """
54
55 - def ev_read(self, worker):
56 """ 57 Called to indicate that a worker has data to read from a specific 58 node (or key). 59 60 :param worker: :class:`.Worker` object 61 62 Available worker attributes: 63 64 * :attr:`.Worker.current_node` - node (or key) 65 * :attr:`.Worker.current_msg` - read message 66 """
67
68 - def ev_error(self, worker):
69 """ 70 Called to indicate that a worker has error to read on stderr from 71 a specific node (or key). 72 73 :param worker: :class:`.Worker` object 74 75 Available worker attributes: 76 77 * :attr:`.Worker.current_node` - node (or key) 78 * :attr:`.Worker.current_errmsg` - read error message 79 """
80
81 - def ev_written(self, worker, node, sname, size):
82 """ 83 Called to indicate that some writing has been done by the worker to a 84 node on a given stream. This event is only generated when ``write()`` 85 is previously called on the worker. 86 87 This handler may be called very often depending on the number of target 88 nodes, the amount of data to write and the block size used by the 89 worker. 90 91 Note: up to ClusterShell 1.6, this event handler wasn't implemented. To 92 properly handle ev_written after 1.6, the method signature must consist 93 of the following parameters: 94 95 :param worker: :class:`.Worker` object 96 :param node: node (or) key 97 :param sname: stream name 98 :param size: amount of bytes that has just been written to node/stream 99 associated with this event 100 """
101
102 - def ev_hup(self, worker):
103 """ 104 Called to indicate that a worker command for a specific node (or key) 105 has just finished. Called for each node. 106 107 :param worker: :class:`.Worker` object 108 109 Available worker attributes: 110 111 * :attr:`.Worker.current_node` - node (or key) 112 * :attr:`.Worker.current_rc` - command return code 113 """
114
115 - def ev_timeout(self, worker):
116 """ 117 Called to indicate that a worker has timed out (worker timeout only). 118 119 :param worker: :class:`.Worker` object 120 """
121
122 - def ev_close(self, worker):
123 """ 124 Called to indicate that a worker has just finished (it may already 125 have failed on timeout). 126 127 :param worker: :class:`.Worker` object 128 """
129
130 - def ev_msg(self, port, msg):
131 """ 132 Called to indicate that a message has been received on an EnginePort. 133 134 Used to deliver messages reliably between tasks. 135 136 :param port: EnginePort object on which a message has been received 137 :param msg: the message object received 138 """
139
140 - def ev_timer(self, timer):
141 """ 142 Called to indicate that a timer is firing. 143 144 :param timer: :class:`.EngineTimer` object that is firing 145 """
146
147 - def _ev_routing(self, worker, arg):
148 """ 149 Routing event (private). Called to indicate that a (meta)worker has just 150 updated one of its route path. You can safely ignore this event. 151 """
152