Changeset 453
- Timestamp:
- 05/12/08 14:06:31
(8 months ago)
- Author:
- mgoldman
- Message:
Add server auto-download log logic.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r452 |
r453 |
|
| 58 | 58 | def service_client(self): |
|---|
| 59 | 59 | pass |
|---|
| | 60 | |
|---|
| | 61 | ### |
|---|
| | 62 | ### Auxillary functions to handle specific tasks. |
|---|
| | 63 | ### |
|---|
| | 64 | ### The functions that query agents should be updated to create the |
|---|
| | 65 | ### message for a specific client only. The sending to specific (or all) |
|---|
| | 66 | ### clients should be handled by the function self.comm() |
|---|
| | 67 | ### |
|---|
| | 68 | ### Querys against the server itself should continue to to return the msg |
|---|
| | 69 | ### to be sent back to the manager. |
|---|
| 60 | 70 | |
|---|
| 61 | 71 | def updatep(self, (mgr, info), msg, clientid=None): |
|---|
| … | … | |
| 242 | 252 | |
|---|
| 243 | 253 | def comm(self, func, msg, (mgr, info)): |
|---|
| | 254 | ''' |
|---|
| | 255 | This function takes a function that "personalizes" a message for |
|---|
| | 256 | a particular client |
|---|
| | 257 | The message to personalize, |
|---|
| | 258 | and a manager and info. |
|---|
| | 259 | Also, it takes a targetid. |
|---|
| | 260 | |
|---|
| | 261 | The functions sends messages to the targets in the original message |
|---|
| | 262 | and returns a list of their result pairs. ''' |
|---|
| 244 | 263 | target = msg.targets |
|---|
| 245 | 264 | msg.targets = None |
|---|
| … | … | |
| 254 | 273 | tlist = targetexpand(target) |
|---|
| 255 | 274 | for t in tlist: |
|---|
| 256 | | self.clients.send_key(func((mgr, info), deepcopy(msg)), t) |
|---|
| | 275 | self.clients.send_key(func((mgr, info), deepcopy(msg), t), t) |
|---|
| 257 | 276 | res = [] |
|---|
| 258 | 277 | for t in tlist: |
|---|
| … | … | |
| 271 | 290 | return [self.service_manager(m) for m in self.manager.accept_and_wait(timeout)] |
|---|
| 272 | 291 | |
|---|
| | 292 | def updatelogs(self): |
|---|
| | 293 | ''' Updates server side logs for all known clients. ''' |
|---|
| | 294 | msg = protocol.Message() |
|---|
| | 295 | msg.msg = "log" |
|---|
| | 296 | msg.type = "query" |
|---|
| | 297 | msg.body = "UPDATE" |
|---|
| | 298 | # Call the comm function to send the messages and collect the results |
|---|
| | 299 | # first function just returns the message, pass in the message and |
|---|
| | 300 | # None for the manager and info since we aren't going to use it. |
|---|
| | 301 | res = self.comm(lambda *x: msg, msg, (None, None)) |
|---|
| | 302 | # FIXME: Put in code here to store the messages in the storage subsytem |
|---|
| | 303 | |
|---|
| | 304 | |
|---|
| 273 | 305 | |
|---|
| 274 | 306 | if __name__ == "__main__": |
|---|
| 275 | 307 | m = Master() |
|---|
| | 308 | cntr = 0 |
|---|
| 276 | 309 | while True: |
|---|
| 277 | 310 | print "sheep" |
|---|
| 278 | 311 | m.run2(5) |
|---|
| | 312 | if(cntr % 12 == 0): |
|---|
| | 313 | m.updatelogs() |
|---|
| | 314 | cntr += 1 |
|---|
Download in other formats:
* Generating other formats may take time.