jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1240068 - in /jackrabbit/branches/2.4: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java
Date Fri, 03 Feb 2012 10:34:33 GMT
Author: jukka
Date: Fri Feb  3 10:34:32 2012
New Revision: 1240068

URL: http://svn.apache.org/viewvc?rev=1240068&view=rev
Log:
2.4: Merged revision 1240053 (JCr-3225)

Modified:
    jackrabbit/branches/2.4/   (props changed)
    jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java

Propchange: jackrabbit/branches/2.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb  3 10:34:32 2012
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1221447,1221579,1221593,1221789,1221818,1225179,1225191,1225196,1225207,1225525,1225528,1226452,1226472,1226515,1226750,1226863,1227171,1227240,1227590,1227593,1227615,1228058,1228149,1228155,1228160,1230507,1230681,1230688,1231204,1232035,1232100,1232404,1232831,1232920,1232922,1233069,1233344,1233446,1233468,1233471,1234807,1235192,1235375,1235423,1236709,1236775,1236819-1236821
+/jackrabbit/trunk:1221447,1221579,1221593,1221789,1221818,1225179,1225191,1225196,1225207,1225525,1225528,1226452,1226472,1226515,1226750,1226863,1227171,1227240,1227590,1227593,1227615,1228058,1228149,1228155,1228160,1230507,1230681,1230688,1231204,1232035,1232100,1232404,1232831,1232920,1232922,1233069,1233344,1233446,1233468,1233471,1234807,1235192,1235375,1235423,1236709,1236775,1236819-1236821,1240053

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java?rev=1240068&r1=1240067&r2=1240068&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java
Fri Feb  3 10:34:32 2012
@@ -115,16 +115,19 @@ public class QueryStatImpl implements Qu
         final QueryStatDtoImpl qs = new QueryStatDtoImpl(language, statement,
                 durationMs);
         slowQueries.offer(qs);
-        Iterator<QueryStatDtoImpl> iterator = popularQueries.iterator();
-        while (iterator.hasNext()) {
-            QueryStatDtoImpl qsdi = iterator.next();
-            if (qsdi.equals(qs)) {
-                qs.setOccurrenceCount(qsdi.getOccurrenceCount() + 1);
-                iterator.remove();
-                break;
+
+        synchronized (popularQueries) {
+            Iterator<QueryStatDtoImpl> iterator = popularQueries.iterator();
+            while (iterator.hasNext()) {
+                QueryStatDtoImpl qsdi = iterator.next();
+                if (qsdi.equals(qs)) {
+                    qs.setOccurrenceCount(qsdi.getOccurrenceCount() + 1);
+                    iterator.remove();
+                    break;
+                }
             }
+            popularQueries.offer(qs);
         }
-        popularQueries.offer(qs);
     }
 
     public void clearSlowQueriesQueue() {
@@ -142,11 +145,17 @@ public class QueryStatImpl implements Qu
     }
 
     public QueryStatDto[] getPopularQueries() {
-        QueryStatDtoImpl[] top = popularQueries
-                .toArray(new QueryStatDtoImpl[popularQueries.size()]);
+        QueryStatDtoImpl[] top = new QueryStatDtoImpl[0];
+        int size = 0;
+        int maxSize = 0;
+        synchronized (popularQueries) {
+            top = popularQueries.toArray(new QueryStatDtoImpl[popularQueries
+                    .size()]);
+            size = popularQueries.size();
+            maxSize = popularQueries.getMaxSize();
+        }
         Arrays.sort(top, Collections.reverseOrder(comparatorOccurrence));
-        int retSize = Math.min(popularQueries.size(),
-                popularQueries.getMaxSize() / POPULAR_QUEUE_MULTIPLIER);
+        int retSize = Math.min(size, maxSize / POPULAR_QUEUE_MULTIPLIER);
         QueryStatDto[] retval = new QueryStatDto[retSize];
         for (int i = 0; i < retSize; i++) {
             top[i].setPosition(i + 1);



Mime
View raw message