Revision 7f30777b
b/daemons/ganeti-noded | ||
---|---|---|
48 | 48 |
queue_lock = None |
49 | 49 |
|
50 | 50 |
|
51 |
def _RequireJobQueueLock(fn): |
|
52 |
"""Decorator for job queue manipulating functions. |
|
53 |
|
|
54 |
""" |
|
55 |
def wrapper(*args, **kwargs): |
|
56 |
# Locking in exclusive, blocking mode because there could be several |
|
57 |
# children running at the same time. |
|
58 |
# TODO: Implement nonblocking locking with retries? |
|
59 |
queue_lock.Exclusive(blocking=True) |
|
60 |
try: |
|
61 |
return fn(*args, **kwargs) |
|
62 |
finally: |
|
63 |
queue_lock.Unlock() |
|
64 |
return wrapper |
|
65 |
|
|
66 |
|
|
51 | 67 |
class NodeDaemonRequestHandler(http.HTTPRequestHandler): |
52 | 68 |
"""The server implementation. |
53 | 69 |
|
... | ... | |
538 | 554 |
new_file_storage_dir) |
539 | 555 |
|
540 | 556 |
@staticmethod |
557 |
@_RequireJobQueueLock |
|
541 | 558 |
def perspective_jobqueue_update(params): |
542 | 559 |
"""Update job queue. |
543 | 560 |
|
544 | 561 |
""" |
545 | 562 |
(file_name, content) = params |
546 |
|
|
547 |
# Locking in exclusive, blocking mode because there could be several |
|
548 |
# children running at the same time. |
|
549 |
# TODO: Implement nonblocking locking with retries? |
|
550 |
queue_lock.Exclusive(blocking=True) |
|
551 |
try: |
|
552 |
return backend.JobQueueUpdate(file_name, content) |
|
553 |
finally: |
|
554 |
queue_lock.Unlock() |
|
563 |
return backend.JobQueueUpdate(file_name, content) |
|
555 | 564 |
|
556 | 565 |
@staticmethod |
557 | 566 |
def perspective_jobqueue_purge(params): |
Also available in: Unified diff