incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/2] git commit: [#5105] introduce a new "task" db for monq_task collection
Date Thu, 11 Oct 2012 15:43:51 GMT
Updated Branches:
  refs/heads/db/5105 fbf1157bb -> fc974fa89 (forced update)


[#5105] introduce a new "task" db for monq_task collection


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/fc974fa8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/fc974fa8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/fc974fa8

Branch: refs/heads/db/5105
Commit: fc974fa89870e750e7970a98e1899d87d2244982
Parents: a7e8be9
Author: Dave Brondsema <dbrondsema@geek.net>
Authored: Thu Oct 11 14:55:40 2012 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Thu Oct 11 15:31:27 2012 +0000

----------------------------------------------------------------------
 Allura/allura/command/show_models.py |   16 ++++++++--------
 Allura/allura/model/__init__.py      |    1 +
 Allura/allura/model/monq_model.py    |    7 ++++---
 Allura/allura/model/session.py       |    2 ++
 Allura/development.ini               |    3 +++
 Allura/test.ini                      |    1 +
 6 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fc974fa8/Allura/allura/command/show_models.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/show_models.py b/Allura/allura/command/show_models.py
index 95558ec..7dc1c0a 100644
--- a/Allura/allura/command/show_models.py
+++ b/Allura/allura/command/show_models.py
@@ -111,9 +111,8 @@ class EnsureIndexCommand(base.Command):
     def command(self):
         from allura import model as M
         self.basic_setup()
-        # Collect indexes by collection name
-        main_indexes = defaultdict(list)
-        project_indexes = defaultdict(list)
+        main_indexes = defaultdict(lambda: defaultdict(list))  # by db, then collection name
+        project_indexes = defaultdict(list)  # by collection name
         base.log.info('Collecting indexes...')
         for m in Mapper.all_mappers():
             mgr = m.collection.m
@@ -124,15 +123,16 @@ class EnsureIndexCommand(base.Command):
                 continue
             base.log.info('... for class %s', cls)
             if session(cls) in (
-                M.main_orm_session, M.repository_orm_session):
-                idx = main_indexes[cname]
+                M.main_orm_session, M.repository_orm_session, M.task_orm_session):
+                idx = main_indexes[session(cls)][cname]
             else:
                 idx = project_indexes[cname]
             idx.extend(mgr.indexes)
         base.log.info('Updating indexes for main DB')
-        db = M.main_doc_session.db
-        for name, indexes in main_indexes.iteritems():
-            self._update_indexes(db[name], indexes)
+        for odm_session, db_indexes in main_indexes.iteritems():
+            db = odm_session.impl.db
+            for name, indexes in db_indexes.iteritems():
+                self._update_indexes(db[name], indexes)
         base.log.info('Updating indexes for project DBs')
         configured_dbs = set()
         for projects in utils.chunked_find(M.Project):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fc974fa8/Allura/allura/model/__init__.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/__init__.py b/Allura/allura/model/__init__.py
index a329e34..5ce734e 100644
--- a/Allura/allura/model/__init__.py
+++ b/Allura/allura/model/__init__.py
@@ -22,6 +22,7 @@ from .types import ACE, ACL, EVERYONE, ALL_PERMISSIONS, DENY_ALL
 from .session import main_doc_session, main_orm_session
 from .session import project_doc_session, project_orm_session
 from .session import artifact_orm_session, repository_orm_session
+from .session import task_orm_session
 from .session import ArtifactSessionExtension
 
 import repo

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fc974fa8/Allura/allura/model/monq_model.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/monq_model.py b/Allura/allura/model/monq_model.py
index 9964fc8..a9b2278 100644
--- a/Allura/allura/model/monq_model.py
+++ b/Allura/allura/model/monq_model.py
@@ -13,10 +13,11 @@ from ming import schema as S
 from ming.orm import session, FieldProperty
 from ming.orm.declarative import MappedClass
 
-from .session import main_orm_session
+from .session import task_orm_session
 
 log = logging.getLogger(__name__)
 
+
 class MonQTask(MappedClass):
     '''Task to be executed by the taskd daemon.
 
@@ -40,7 +41,7 @@ class MonQTask(MappedClass):
     states = ('ready', 'busy', 'error', 'complete')
     result_types = ('keep', 'forget')
     class __mongometa__:
-        session = main_orm_session
+        session = task_orm_session
         name = 'monq_task'
         indexes = [
             [
@@ -236,7 +237,7 @@ class MonQTask(MappedClass):
             raise
         finally:
             self.time_stop = datetime.utcnow()
-            main_orm_session.flush(self)
+            session(self).flush(self)
             if restore_context:
                 c.project = old_cproject
                 c.app = old_capp

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fc974fa8/Allura/allura/model/session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index 11c3ff2..f3d5e22 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -68,8 +68,10 @@ class ArtifactSessionExtension(SessionExtension):
 
 main_doc_session = Session.by_name('main')
 project_doc_session = Session.by_name('project')
+task_doc_session = Session.by_name('task')
 main_orm_session = ThreadLocalORMSession(main_doc_session)
 project_orm_session = ThreadLocalORMSession(project_doc_session)
+task_orm_session = ThreadLocalORMSession(task_doc_session)
 artifact_orm_session = ThreadLocalORMSession(
     doc_session=project_doc_session,
     extensions = [ ArtifactSessionExtension ])

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fc974fa8/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 0d835b7..cd67320 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -130,8 +130,11 @@ activitystream.timeline_collection = timelines
 activitystream.enabled = false
 
 # Ming setup
+# These don't necessarily have to be separate databases, they could
+# be all in the same database if desired
 ming.main.uri = mongodb://127.0.0.1:27017/allura
 ming.project.uri = mongodb://127.0.0.1:27017/project-data
+ming.task.uri = mongodb://127.0.0.1:27017/task
 ming.zarkov.uri = mongodb://127.0.0.1:27017/zarkov
 
 # Zarkov host setting, requires the zarkov and gevent libraries.

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fc974fa8/Allura/test.ini
----------------------------------------------------------------------
diff --git a/Allura/test.ini b/Allura/test.ini
index 6b37100..fa951e2 100644
--- a/Allura/test.ini
+++ b/Allura/test.ini
@@ -27,6 +27,7 @@ base_url = http://localhost/
 # ming.main.master = mongo://127.0.0.1:27018/allura
 ming.main.uri = mim:///allura
 ming.project.uri = mim:///project-data
+ming.task.uri = mim:///task
 
 # ActivityStream
 activitystream.master = mim://


Mime
View raw message