jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1186713 - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/ jackrabbit-core/s...
Date Thu, 20 Oct 2011 10:19:59 GMT
Author: jukka
Date: Thu Oct 20 10:19:58 2011
New Revision: 1186713

URL: http://svn.apache.org/viewvc?rev=1186713&view=rev
Log:
JCR-3117: Stats for the PersistenceManager

Use AtomicLong counters and the TimeSeries mechanism for PM stats

Removed:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/stats/PersistenceManagerStat.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/PersistenceManagerStatCore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/PersistenceManagerStatImpl.java
Modified:
    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/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PMContext.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/RepositoryStatisticsImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java

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=1186713&r1=1186712&r2=1186713&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
Thu Oct 20 10:19:58 2011
@@ -24,8 +24,13 @@ package org.apache.jackrabbit.api.stats;
 public interface RepositoryStatistics {
 
     enum Type {
-        SESSION_READ_COUNTER(true), 
-        SESSION_READ_DURATION(true), 
+        BUNDLE_READ_COUNTER(true),
+        BUNDLE_READ_DURATION(true),
+        BUNDLE_WRITE_COUNTER(true),
+        BUNDLE_WRITE_DURATION(true),
+        BUNDLE_CACHE_COUNTER(true),
+        SESSION_READ_COUNTER(true),
+        SESSION_READ_DURATION(true),
         SESSION_WRITE_COUNTER(true),
         SESSION_WRITE_DURATION(true),
         SESSION_LOGIN_COUNTER(true),

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=1186713&r1=1186712&r2=1186713&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Thu Oct 20 10:19:58 2011
@@ -1332,11 +1332,7 @@ public class RepositoryImpl extends Abst
         try {
             PersistenceManager pm = pmConfig
                     .newInstance(PersistenceManager.class);
-            PMContext pmContext = new PMContext(homeDir, fs,
-                    context.getRootNodeId(), context.getNamespaceRegistry(),
-                    context.getNodeTypeRegistry(), context.getDataStore());
-            pmContext.setPersistenceManagerStatCore(context.getStatManager()
-                    .getPersistenceManagerStatCore());
+            PMContext pmContext = new PMContext(homeDir, fs, context);
             pm.init(pmContext);
             return pm;
         } catch (Exception e) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PMContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PMContext.java?rev=1186713&r1=1186712&r2=1186713&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PMContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/PMContext.java
Thu Oct 20 10:19:58 2011
@@ -20,11 +20,12 @@ import java.io.File;
 
 import javax.jcr.NamespaceRegistry;
 
+import org.apache.jackrabbit.core.RepositoryContext;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.core.stats.PersistenceManagerStatCore;
+import org.apache.jackrabbit.core.stats.RepositoryStatisticsImpl;
 
 /**
  * A <code>PMContext</code> is used to provide context information for a
@@ -64,32 +65,26 @@ public class PMContext {
      */
     private final DataStore dataStore;
 
-    /**
-     * PersistenceManagerStatCore stats object for the PM.
-     */
-    private PersistenceManagerStatCore persistenceManagerStatCore;
+    /** Repository statistics collector. */
+    private final RepositoryStatisticsImpl stats;
 
     /**
      * Creates a new <code>PMContext</code>.
      *
      * @param homeDir the physical home directory
      * @param fs the virtual jackrabbit filesystem
-     * @param rootNodeId id of the root node
-     * @param nsReg        namespace registry
-     * @param ntReg        node type registry
+     * @param context repository component context
      */
     public PMContext(File homeDir,
                      FileSystem fs,
-                     NodeId rootNodeId,
-                     NamespaceRegistry nsReg,
-                     NodeTypeRegistry ntReg,
-                     DataStore dataStore) {
+                     RepositoryContext context) {
         this.physicalHomeDir = homeDir;
         this.fs = fs;
-        this.rootNodeId = rootNodeId;
-        this.nsReg = nsReg;
-        this.ntReg = ntReg;
-        this.dataStore = dataStore;
+        this.rootNodeId = context.getRootNodeId();
+        this.nsReg = context.getNamespaceRegistry();
+        this.ntReg = context.getNodeTypeRegistry();
+        this.dataStore = context.getDataStore();
+        this.stats = context.getRepositoryStatistics();
     }
 
 
@@ -144,17 +139,14 @@ public class PMContext {
         return dataStore;
     }
 
+
     /**
-     * Returns the PersistenceManagerStatCore stats object for the PM.
-     * 
-     * @return the PersistenceManagerStatCore stats object for the PM.
+     * Returns the repository statistics collector.
+     *
+     * @return repository statistics
      */
-    public PersistenceManagerStatCore getPersistenceManagerStatCore() {
-        return persistenceManagerStatCore;
+    public RepositoryStatisticsImpl getRepositoryStatistics() {
+        return stats;
     }
 
-    public void setPersistenceManagerStatCore(
-            PersistenceManagerStatCore persistenceManagerStatCore) {
-        this.persistenceManagerStatCore = persistenceManagerStatCore;
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=1186713&r1=1186712&r2=1186713&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
Thu Oct 20 10:19:58 2011
@@ -23,9 +23,11 @@ import static org.apache.jackrabbit.spi.
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
 
 import javax.jcr.PropertyType;
 
+import org.apache.jackrabbit.api.stats.RepositoryStatistics;
 import org.apache.jackrabbit.core.cache.Cache;
 import org.apache.jackrabbit.core.cache.CacheAccessListener;
 import org.apache.jackrabbit.core.cache.ConcurrentCache;
@@ -49,7 +51,7 @@ import org.apache.jackrabbit.core.state.
 import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
-import org.apache.jackrabbit.core.stats.PersistenceManagerStatCore;
+import org.apache.jackrabbit.core.stats.RepositoryStatisticsImpl;
 import org.apache.jackrabbit.core.util.StringIndex;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
@@ -133,8 +135,20 @@ public abstract class AbstractBundlePers
     /** default size of the bundle cache */
     private long bundleCacheSize = 8 * 1024 * 1024;
 
-    /** statistics object */
-    private PersistenceManagerStatCore pmStatCore;
+    /** Counter of read operations. */
+    private AtomicLong readCounter;
+
+    /** Counter of write operations. */
+    private AtomicLong writeCounter;
+
+    /** Duration of read operations. */
+    private AtomicLong readDuration;
+
+    /** Duration of write operations. */
+    private AtomicLong writeDuration;
+
+    /** Counter of bundle cache accesses. */
+    private AtomicLong cacheCounter;
 
     /**
      * Returns the size of the bundle cache in megabytes.
@@ -398,7 +412,19 @@ public abstract class AbstractBundlePers
         bundles = new ConcurrentCache<NodeId, NodePropBundle>(context.getHomeDir().getName()
+ "BundleCache");
         bundles.setMaxMemorySize(bundleCacheSize);
         bundles.setAccessListener(this);
-        pmStatCore = context.getPersistenceManagerStatCore();
+
+        // statistics
+        RepositoryStatisticsImpl stats = context.getRepositoryStatistics();
+        cacheCounter = stats.getCounter(
+                RepositoryStatistics.Type.BUNDLE_CACHE_COUNTER);
+        readCounter = stats.getCounter(
+                RepositoryStatistics.Type.BUNDLE_READ_COUNTER);
+        readDuration = stats.getCounter(
+                RepositoryStatistics.Type.BUNDLE_READ_DURATION);
+        writeCounter = stats.getCounter(
+                RepositoryStatistics.Type.BUNDLE_WRITE_COUNTER);
+        writeDuration = stats.getCounter(
+                RepositoryStatistics.Type.BUNDLE_WRITE_DURATION);
     }
 
     /**
@@ -675,17 +701,7 @@ public abstract class AbstractBundlePers
             return bundle;
         }
         // cache miss
-        if (pmStatCore != null && pmStatCore.isEnabled()) {
-            long t = System.currentTimeMillis();
-            try {
-                return getBundleCacheMiss(id);
-            } finally {
-                t = System.currentTimeMillis() - t;
-                pmStatCore.onReadCacheMiss(t);
-            }
-        } else {
-            return getBundleCacheMiss(id);
-        }
+        return getBundleCacheMiss(id);
     }
 
     /**
@@ -700,7 +716,11 @@ public abstract class AbstractBundlePers
      */
     private NodePropBundle getBundleCacheMiss(NodeId id)
             throws ItemStateException {
+        long time = System.nanoTime();
         NodePropBundle bundle = loadBundle(id);
+        readDuration.addAndGet(System.nanoTime() - time);
+        readCounter.incrementAndGet();
+
         if (bundle != null) {
             bundle.markOld();
             bundles.put(id, bundle, bundle.getSize());
@@ -729,15 +749,12 @@ public abstract class AbstractBundlePers
      * @throws ItemStateException if an error occurs
      */
     private void putBundle(NodePropBundle bundle) throws ItemStateException {
-
-        long time = System.currentTimeMillis();
+        long time = System.nanoTime();
         storeBundle(bundle);
+        writeDuration.addAndGet(System.nanoTime() - time);
+        writeCounter.incrementAndGet();
+
         bundle.markOld();
-        log.debug("stored bundle {} in {} ms", new Object[] { bundle.getId(),
-                System.currentTimeMillis() - time });
-        if (pmStatCore != null && pmStatCore.isEnabled()) {
-            pmStatCore.onBundleWrite(System.currentTimeMillis() - time);
-        }
 
         // only put to cache if already exists. this is to ensure proper
         // overwrite and not creating big contention during bulk loads
@@ -765,7 +782,7 @@ public abstract class AbstractBundlePers
 
     public void cacheAccessed(long accessCount) {
         logCacheStats();
-        pmStatCore.cacheAccessed(accessCount);
+        cacheCounter.addAndGet(accessCount);
     }
 
     private void logCacheStats() {

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=1186713&r1=1186712&r2=1186713&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
Thu Oct 20 10:19:58 2011
@@ -48,6 +48,10 @@ public class RepositoryStatisticsImpl im
         getOrCreateRecorder(Type.SESSION_READ_DURATION);
         getOrCreateRecorder(Type.SESSION_WRITE_COUNTER);
         getOrCreateRecorder(Type.SESSION_WRITE_DURATION);
+        getOrCreateRecorder(Type.BUNDLE_READ_COUNTER);
+        getOrCreateRecorder(Type.BUNDLE_READ_DURATION);
+        getOrCreateRecorder(Type.BUNDLE_WRITE_COUNTER);
+        getOrCreateRecorder(Type.BUNDLE_WRITE_DURATION);
     }
 
     public synchronized Iterator<Entry<Type, TimeSeries>> iterator() {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java?rev=1186713&r1=1186712&r2=1186713&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/stats/StatManager.java
Thu Oct 20 10:19:58 2011
@@ -30,7 +30,6 @@ public class StatManager {
 
     public static String ALL_STATS_ENABLED_PROPERTY = "org.apache.jackrabbit.api.stats.ALL";
     public static String QUERY_STATS_ENABLED_PROPERTY = "org.apache.jackrabbit.api.stats.QueryStat";
-    public static String PM_STATS_ENABLED_PROPERTY = "org.apache.jackrabbit.api.stats.PersistenceManagerStat";
 
     private static final Logger log = LoggerFactory
             .getLogger(StatManager.class);
@@ -38,8 +37,6 @@ public class StatManager {
     /* STAT OBJECTS */
     private final QueryStatCore queryStat = new QueryStatImpl();
 
-    private final PersistenceManagerStatCore pmStat = new PersistenceManagerStatImpl();
-
     public StatManager() {
         init();
     }
@@ -48,17 +45,13 @@ public class StatManager {
         boolean allEnabled = getBoolean(ALL_STATS_ENABLED_PROPERTY);
         queryStat.setEnabled(allEnabled
                 || getBoolean(QUERY_STATS_ENABLED_PROPERTY));
-        pmStat.setEnabled(allEnabled || getBoolean(PM_STATS_ENABLED_PROPERTY));
         log.debug(
-                "Started StatManager. QueryStat is enabled {}, PersistenceManagerStat is
enabled {}",
-                new Object[] { queryStat.isEnabled(), pmStat.isEnabled() });
+                "Started StatManager. QueryStat is enabled {}",
+                new Object[] { queryStat.isEnabled() });
     }
 
     public QueryStatCore getQueryStat() {
         return queryStat;
     }
 
-    public PersistenceManagerStatCore getPersistenceManagerStatCore() {
-        return pmStat;
-    }
 }



Mime
View raw message