-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert "workers" collection to mongoengine
This patch converts the `workers` collection to mongoengine. It also moves some functionality into tasks.py that previously lived in the worker manager. One thing to note, it appears that the existing workers collection did not have a `_ns` field. Thus, I did not add this into the new collection. This commit includes a fix to CriteriaQuerySet's `update()` method which was incorrectly firing the `post_save()` hook on TaskStatus objects, even when the Document was not a task status. A spec file requirement for `python-blinker` was also added to support mongoengine signals. Additionally, a small unrelated flake8 fixup to test_users.py was added. fixes #88
- Loading branch information
Showing
26 changed files
with
386 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import logging | ||
|
||
from mongoengine import Document, StringField, DateTimeField | ||
|
||
from pulp.server.db.model.base import CriteriaQuerySet | ||
|
||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class Worker(Document): | ||
""" | ||
Represents a worker. | ||
This inherits from mongoengine.Document and defines the schema for the documents | ||
in the worker collection. | ||
:ivar name: worker name, in the form of "worker_type@hostname" | ||
:type name: basestring | ||
:ivar last_heartbeat: A timestamp of the last heartbeat from the Worker | ||
:type last_heartbeat: datetime.datetime | ||
""" | ||
name = StringField(primary_key=True) | ||
last_heartbeat = DateTimeField() | ||
|
||
meta = {'collection': 'workers', | ||
'indexes': [], # this is a small collection that does not need an index | ||
'allow_inheritance': False, | ||
'queryset_class': CriteriaQuerySet} | ||
|
||
@property | ||
def queue_name(self): | ||
""" | ||
This property is a convenience for getting the queue_name that Celery assigns to this | ||
Worker. | ||
:return: The name of the queue that this Worker is uniquely subcribed to. | ||
:rtype: basestring | ||
""" | ||
return "%(name)s.dq" % {'name': self.name} |
Oops, something went wrong.