allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [5/7] git commit: [#5697] Added short timeout for solr searches (default was 60s)
Date Tue, 29 Jan 2013 19:21:55 GMT
[#5697] Added short timeout for solr searches (default was 60s)

Signed-off-by: Cory Johns <johnsca@geek.net>


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

Branch: refs/heads/cj/5697
Commit: e15983a774aef28b13906f48362e66562de9d923
Parents: 9f6448e
Author: Cory Johns <johnsca@geek.net>
Authored: Mon Jan 28 23:40:37 2013 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Tue Jan 29 17:05:36 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/search.py                |    3 ++-
 Allura/allura/ext/search/search_main.py            |    2 +-
 Allura/allura/ext/user_profile/user_main.py        |    2 +-
 Allura/allura/lib/app_globals.py                   |    7 +++++--
 Allura/allura/lib/search.py                        |   14 ++++++++++----
 ForgeBlog/forgeblog/main.py                        |    3 ++-
 ForgeChat/forgechat/main.py                        |    3 ++-
 .../forgediscussion/controllers/root.py            |    3 ++-
 ForgeShortUrl/forgeshorturl/main.py                |    2 +-
 ForgeTracker/forgetracker/model/ticket.py          |    4 ++--
 ForgeTracker/forgetracker/tracker_main.py          |    6 +++---
 ForgeWiki/forgewiki/wiki_main.py                   |    2 +-
 12 files changed, 32 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/Allura/allura/controllers/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/search.py b/Allura/allura/controllers/search.py
index 2b9ed25..f7ecebf 100644
--- a/Allura/allura/controllers/search.py
+++ b/Allura/allura/controllers/search.py
@@ -28,7 +28,8 @@ class SearchController(BaseController):
         else:
             results = search.search(
                 q,
-                fq='is_history_b:%s' % history)
+                fq='is_history_b:%s' % history,
+                short_timeout=True)
             if results: count=results.hits
         return dict(q=q, history=history, results=results or [], count=count)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/Allura/allura/ext/search/search_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/search/search_main.py b/Allura/allura/ext/search/search_main.py
index f2ceeb7..2f9b240 100644
--- a/Allura/allura/ext/search/search_main.py
+++ b/Allura/allura/ext/search/search_main.py
@@ -61,7 +61,7 @@ class SearchController(BaseController):
                 for pid in pids )
             search_query = '%s AND is_history_b:%s AND (%s) AND -deleted_b:true' % (
                 q, history, project_match)
-            results = search.search(search_query, is_history_b=history)
+            results = search.search(search_query, is_history_b=history, short_timeout=True)
             if results: count=results.hits
         return dict(q=q, history=history, results=results or [], count=count)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/Allura/allura/ext/user_profile/user_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/user_profile/user_main.py b/Allura/allura/ext/user_profile/user_main.py
index f631fd5..6709493 100644
--- a/Allura/allura/ext/user_profile/user_main.py
+++ b/Allura/allura/ext/user_profile/user_main.py
@@ -72,7 +72,7 @@ class UserProfileController(BaseController):
     #     subs = Subscriptions.query.find({'user_id':user._id}).all()
     #     for sub in subs:
     #         for s in sub.subscriptions:
-    #             r = g.solr.search(s.artifact_index_id)
+    #             r = g.solr_short_timeout.search(s.artifact_index_id)
     #             print r.docs
     #     return dict(user=user)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 862a03c..736c297 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -71,12 +71,15 @@ class Globals(object):
         # Setup SOLR
         self.solr_server = config.get('solr.server')
         if asbool(config.get('solr.mock')):
-            self.solr = MockSOLR()
+            self.solr = self.solr_short_timeout = MockSOLR()
         elif self.solr_server:
             self.solr = Solr(self.solr_server, commit=asbool(config.get('solr.commit', True)),
-                    commitWithin=config.get('solr.commitWithin'))
+                    commitWithin=config.get('solr.commitWithin'), timeout=int(config.get('solr.long_timeout',
60)))
+            self.solr_short_timeout = Solr(self.solr_server, commit=asbool(config.get('solr.commit',
True)),
+                    commitWithin=config.get('solr.commitWithin'), timeout=int(config.get('solr.short_timeout',
10)))
         else: # pragma no cover
             self.solr = None
+            self.solr_short_timeout = None
         self.use_queue = asbool(config.get('use_queue', False))
 
         # Load login/logout urls; only used for SFX logins

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 7fe7388..11b5ed3 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -35,10 +35,13 @@ def solarize(obj):
     return doc
 
 @try_solr
-def search(q,**kw):
-    return g.solr.search(q, **kw)
+def search(q,short_timeout=False,**kw):
+    if short_timeout:
+        return g.solr_short_timeout.search(q, **kw)
+    else:
+        return g.solr.search(q, **kw)
 
-def search_artifact(atype, q, history=False, rows=10, **kw):
+def search_artifact(atype, q, history=False, rows=10, short_timeout=False, **kw):
     """Performs SOLR search.
 
     Raises ValueError if SOLR returns an error.
@@ -56,7 +59,10 @@ def search_artifact(atype, q, history=False, rows=10, **kw):
     if not history:
         fq.append('is_history_b:False')
     try:
-        return g.solr.search(q, fq=fq, rows=rows, **kw)
+        if short_timeout:
+            return g.solr_short_timeout.search(q, fq=fq, rows=rows, **kw)
+        else:
+            return g.solr.search(q, fq=fq, rows=rows, **kw)
     except pysolr.SolrError, e:
         raise ValueError('Error running search query: %s' % e.message)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index b2cf875..4a7bfe8 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -201,7 +201,8 @@ class RootController(BaseController):
                     'state_s:published',
                     'is_history_b:%s' % history,
                     'project_id_s:%s' % c.project._id,
-                    'mount_point_s:%s'% c.app.config.options.mount_point ])
+                    'mount_point_s:%s'% c.app.config.options.mount_point ],
+                short_timeout=True)
             if results: count=results.hits
         return dict(q=q, history=history, results=results or [], count=count)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/ForgeChat/forgechat/main.py
----------------------------------------------------------------------
diff --git a/ForgeChat/forgechat/main.py b/ForgeChat/forgechat/main.py
index 4f2122f..f5b1f6f 100644
--- a/ForgeChat/forgechat/main.py
+++ b/ForgeChat/forgechat/main.py
@@ -132,7 +132,8 @@ class RootController(BaseController):
                 fq=[
                     'is_history_b:%s' % history,
                     'project_id_s:%s' % c.project._id,
-                    'mount_point_s:%s'% c.app.config.options.mount_point ])
+                    'mount_point_s:%s'% c.app.config.options.mount_point ],
+                short_timeout=True)
             if results: count=results.hits
         return dict(q=q, history=history, results=results or [], count=count)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 6cb1b3b..8bc3627 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -130,7 +130,8 @@ class RootController(BaseController, DispatchIndex):
                     'is_history_b:%s' % history,
                     'project_id_s:%s' % c.project._id,
                     'mount_point_s:%s'% c.app.config.options.mount_point,
-                    '-deleted_b:true'])
+                    '-deleted_b:true'],
+                short_timeout=True)
             if results: count=results.hits
         c.search_results = self.W.search_results
         if results is not None:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/ForgeShortUrl/forgeshorturl/main.py
----------------------------------------------------------------------
diff --git a/ForgeShortUrl/forgeshorturl/main.py b/ForgeShortUrl/forgeshorturl/main.py
index 38bd3cc..41d9adc 100644
--- a/ForgeShortUrl/forgeshorturl/main.py
+++ b/ForgeShortUrl/forgeshorturl/main.py
@@ -167,7 +167,7 @@ class RootController(BaseController):
                     'type_s:%s' % ShortUrl.type_s]
             if not has_access(c.app, 'view_private'):
                 query.append('private_b:False')
-            results = search(q, fq=query)
+            results = search(q, fq=query, short_timeout=True)
 
             if results:
                 count = results.hits

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index a985afe..633af86 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -120,7 +120,7 @@ class Globals(MappedClass):
         self._bin_counts_data = []
         for b in Bin.query.find(dict(
                 app_config_id=self.app_config_id)):
-            r = search_artifact(Ticket, b.terms, rows=0)
+            r = search_artifact(Ticket, b.terms, rows=0, with_timeout=False)
             hits = r is not None and r.hits or 0
             self._bin_counts_data.append(dict(summary=b.summary, hits=hits))
         self._bin_counts_expire = \
@@ -684,7 +684,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
         try:
             if q:
                 matches = search_artifact(
-                    cls, q,
+                    cls, q, short_timeout=True,
                     rows=limit, sort=refined_sort, start=start, fl='ticket_num_i', **kw)
             else:
                 matches = None

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 796eb19..db5473f 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -529,7 +529,7 @@ class RootController(BaseController):
                                     # rows by default, so give it a high upper
                                     # bound to make sure we get all tickets
                                     # for this milestone
-                                    r = search_artifact(TM.Ticket, q, rows=10000)
+                                    r = search_artifact(TM.Ticket, q, rows=10000, short_timeout=False)
                                     ticket_numbers = [match['ticket_num_i'] for match in
r.docs]
                                     tickets = TM.Ticket.query.find(dict(
                                         app_config_id=c.app.config._id,
@@ -914,7 +914,7 @@ class BinController(BaseController):
         try:
             # Test the search by running it
             with h.push_config(c, app=self.app):
-                search_artifact(TM.Ticket, bin.terms, rows=0)
+                search_artifact(TM.Ticket, bin.terms, rows=0, short_timeout=True)
         except ValueError, e:
             # Search threw an error.
             # Save the error on the bin object for displaying
@@ -987,7 +987,7 @@ class BinController(BaseController):
                         bin.terms = bin_form['terms']
                         try:
                             with h.push_config(c, app=self.app):
-                                search_artifact(TM.Ticket, bin.terms, rows=0)
+                                search_artifact(TM.Ticket, bin.terms, rows=0, short_timeout=True)
                         except ValueError, e:
                             # Search threw an error.
                             # Save the error on the bin object for displaying

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e15983a7/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 2857819..42a1d98 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -303,7 +303,7 @@ class RootController(BaseController, DispatchIndex):
             q = ''
         else:
             results = search(
-                q, rows=limit, start=start,
+                q, short_timeout=True, rows=limit, start=start,
                 fq=[
                     'is_history_b:%s' % history,
                     'project_id_s:%s' % c.project._id,


Mime
View raw message