jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1195423 - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/ jackrabbit-core/s...
Date Mon, 31 Oct 2011 11:53:40 GMT
Author: alexparvulescu
Date: Mon Oct 31 11:53:40 2011
New Revision: 1195423

URL: http://svn.apache.org/viewvc?rev=1195423&view=rev
Log:
JCR-3133 Query Stats should use the TimeSeries mechanism

Removed:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/util/CachingOpsPerSecondDto.java
Modified:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/QueryStat.java
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java

Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/QueryStat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/QueryStat.java?rev=1195423&r1=1195422&r2=1195423&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/QueryStat.java
(original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/QueryStat.java
Mon Oct 31 11:53:40 2011
@@ -44,10 +44,6 @@ public interface QueryStat {
      */
     void clearSlowQueriesQueue();
 
-    double getQueriesPerSecond();
-
-    double getAvgQueryTime();
-
     /** -- GENERAL OPS -- **/
 
     /**

Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java?rev=1195423&r1=1195422&r2=1195423&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java
(original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/RepositoryStatistics.java
Mon Oct 31 11:53:40 2011
@@ -42,7 +42,10 @@ public interface RepositoryStatistics {
         SESSION_WRITE_DURATION(true),
         SESSION_WRITE_AVERAGE(false),
         SESSION_LOGIN_COUNTER(true),
-        SESSION_COUNT(false);
+        SESSION_COUNT(false),
+        QUERY_COUNT(true),
+        QUERY_DURATION(true),
+        QUERY_AVERAGE(true);
 
         private final boolean resetValueEachSecond;
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java?rev=1195423&r1=1195422&r2=1195423&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
Mon Oct 31 11:53:40 2011
@@ -33,8 +33,10 @@ import javax.jcr.query.InvalidQueryExcep
 import javax.jcr.query.QueryResult;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.api.stats.RepositoryStatistics.Type;
 import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.session.SessionOperation;
+import org.apache.jackrabbit.core.stats.RepositoryStatisticsImpl;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.slf4j.Logger;
@@ -122,21 +124,27 @@ public class QueryImpl extends AbstractQ
      */
     public QueryResult execute() throws RepositoryException {
         checkInitialized();
-        long time = System.currentTimeMillis();
+        long time = System.nanoTime();
         QueryResult result = sessionContext.getSessionState().perform(
                 new SessionOperation<QueryResult>() {
                     public QueryResult perform(SessionContext context)
                             throws RepositoryException {
                         return query.execute(offset, limit);
                     }
+
                     public String toString() {
                         return "query.execute(" + statement + ")";
                     }
                 });
-        time = System.currentTimeMillis() - time;
-        log.debug("executed in {} ms. ({})", time, statement);
+        time = System.nanoTime() - time;
+        final long timeMs = time / 1000;
+        log.debug("executed in {} ms. ({})", timeMs, statement);
+        RepositoryStatisticsImpl statistics = sessionContext
+                .getRepositoryContext().getRepositoryStatistics();
+        statistics.getCounter(Type.QUERY_COUNT).incrementAndGet();
+        statistics.getCounter(Type.QUERY_DURATION).addAndGet(time);
         sessionContext.getRepositoryContext().getStatManager().getQueryStat()
-                .logQuery(language, statement, time);
+                .logQuery(language, statement, timeMs);
         return result;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java?rev=1195423&r1=1195422&r2=1195423&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java
Mon Oct 31 11:53:40 2011
@@ -30,12 +30,14 @@ import javax.jcr.query.qom.Ordering;
 import javax.jcr.query.qom.QueryObjectModel;
 import javax.jcr.query.qom.Source;
 
+import org.apache.jackrabbit.api.stats.RepositoryStatistics.Type;
 import org.apache.jackrabbit.commons.query.QueryObjectModelBuilderRegistry;
 import org.apache.jackrabbit.core.query.lucene.LuceneQueryFactory;
 import org.apache.jackrabbit.core.query.lucene.SearchIndex;
 import org.apache.jackrabbit.core.query.lucene.join.QueryEngine;
 import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.session.SessionOperation;
+import org.apache.jackrabbit.core.stats.RepositoryStatisticsImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.BindVariableValueImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.DefaultTraversingQOMTreeVisitor;
 import org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelTree;
@@ -117,7 +119,7 @@ public class QueryObjectModelImpl extend
     }
 
     public QueryResult execute() throws RepositoryException {
-        long time = System.currentTimeMillis();
+        long time = System.nanoTime();
         final QueryResult result = sessionContext.getSessionState().perform(
                 new SessionOperation<QueryResult>() {
                     public QueryResult perform(SessionContext context)
@@ -127,12 +129,17 @@ public class QueryObjectModelImpl extend
                         return engine.execute(getColumns(), getSource(),
                                 getConstraint(), getOrderings(), offset, limit);
                     }
+
                     public String toString() {
                         return "query.execute(" + statement + ")";
                     }
                 });
-        time = System.currentTimeMillis() - time;
-        log.debug("executed in {} ms. ({})", time, statement);
+        time = System.nanoTime() - time;
+        log.debug("executed in {} ms. ({})", time / 1000, statement);
+        RepositoryStatisticsImpl statistics = sessionContext
+                .getRepositoryContext().getRepositoryStatistics();
+        statistics.getCounter(Type.QUERY_COUNT).incrementAndGet();
+        statistics.getCounter(Type.QUERY_DURATION).addAndGet(time);
         sessionContext.getRepositoryContext().getStatManager().getQueryStat()
                 .logQuery(language, statement, time);
         return result;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java?rev=1195423&r1=1195422&r2=1195423&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/QueryStatImpl.java
Mon Oct 31 11:53:40 2011
@@ -20,7 +20,6 @@ import java.util.Comparator;
 import java.util.PriorityQueue;
 
 import org.apache.jackrabbit.api.stats.QueryStatDto;
-import org.apache.jackrabbit.core.stats.util.CachingOpsPerSecondDto;
 
 /**
  * Default {@link QueryStatCore} implementation
@@ -35,8 +34,6 @@ public class QueryStatImpl implements Qu
     private PriorityQueue<QueryStatDto> queries = new PriorityQueue<QueryStatDto>(
             queueSize + 1, comparator);
 
-    private CachingOpsPerSecondDto qps = new CachingOpsPerSecondDto();
-
     private boolean enabled = false;
 
     public QueryStatImpl() {
@@ -76,7 +73,6 @@ public class QueryStatImpl implements Qu
             if (queries.size() > queueSize) {
                 queries.remove();
             }
-            qps.onOp(durationMs);
         }
     }
 
@@ -93,12 +89,4 @@ public class QueryStatImpl implements Qu
     public QueryStatDto[] getSlowQueries() {
         return queries.toArray(new QueryStatDto[queries.size()]);
     }
-
-    public double getQueriesPerSecond() {
-        return qps.getOpsPerSecond();
-    }
-
-    public double getAvgQueryTime() {
-        return qps.getOpAvgTime();
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java?rev=1195423&r1=1195422&r2=1195423&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java
Mon Oct 31 11:53:40 2011
@@ -42,21 +42,21 @@ public class RepositoryStatisticsImpl im
         getOrCreateRecorder(Type.SESSION_COUNT);
         getOrCreateRecorder(Type.SESSION_LOGIN_COUNTER);
 
-        TimeSeries src = getOrCreateRecorder(Type.SESSION_READ_COUNTER);
-        TimeSeries srd = getOrCreateRecorder(Type.SESSION_READ_DURATION);
-        avg.put(Type.SESSION_READ_AVERAGE, new TimeSeriesAverage(srd, src));
-
-        TimeSeries swc = getOrCreateRecorder(Type.SESSION_WRITE_COUNTER);
-        TimeSeries swd = getOrCreateRecorder(Type.SESSION_WRITE_DURATION);
-        avg.put(Type.SESSION_WRITE_AVERAGE, new TimeSeriesAverage(swd, swc));
-
-        TimeSeries brc = getOrCreateRecorder(Type.BUNDLE_CACHE_MISS_COUNTER);
-        TimeSeries brd = getOrCreateRecorder(Type.BUNDLE_CACHE_MISS_DURATION);
-        avg.put(Type.BUNDLE_CACHE_MISS_AVERAGE, new TimeSeriesAverage(brd, brc));
-
-        TimeSeries bwc = getOrCreateRecorder(Type.BUNDLE_WRITE_COUNTER);
-        TimeSeries bwd = getOrCreateRecorder(Type.BUNDLE_WRITE_DURATION);
-        avg.put(Type.BUNDLE_WRITE_AVERAGE, new TimeSeriesAverage(bwd, bwc));
+        createAvg(Type.SESSION_READ_COUNTER, Type.SESSION_READ_DURATION,
+                Type.SESSION_READ_AVERAGE);
+        createAvg(Type.SESSION_WRITE_COUNTER, Type.SESSION_WRITE_DURATION,
+                Type.SESSION_WRITE_AVERAGE);
+        createAvg(Type.BUNDLE_CACHE_MISS_COUNTER,
+                Type.BUNDLE_CACHE_MISS_DURATION, Type.BUNDLE_CACHE_MISS_AVERAGE);
+        createAvg(Type.BUNDLE_WRITE_COUNTER, Type.BUNDLE_WRITE_DURATION,
+                Type.BUNDLE_WRITE_AVERAGE);
+        createAvg(Type.QUERY_COUNT, Type.QUERY_DURATION, Type.QUERY_AVERAGE);
+
+    }
+
+    private void createAvg(Type count, Type duration, Type avgTs) {
+        avg.put(avgTs, new TimeSeriesAverage(getOrCreateRecorder(duration),
+                getOrCreateRecorder(count)));
     }
 
     public RepositoryStatisticsImpl(ScheduledExecutorService executor) {



Mime
View raw message