You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2016/01/15 11:58:59 UTC
svn commit: r1724773 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/document/
main/java/org/apache/jackrabbit/oak/plugins/document/mongo/
test/java/org/apache/jackrabbit/oak/plugins/document/
Author: chetanm
Date: Fri Jan 15 10:58:59 2016
New Revision: 1724773
URL: http://svn.apache.org/viewvc?rev=1724773&view=rev
Log:
OAK-3791 - Time measurements for DocumentStore methods
Change the method signature in prepration for support for RDB. For findAndModify case in RDB 2 more stats are possible i.e. retry count and success of update op
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStats.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsCollector.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsIT.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStats.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStats.java?rev=1724773&r1=1724772&r2=1724773&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStats.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStats.java Fri Jan 15 10:58:59 2016
@@ -168,10 +168,10 @@ public class DocumentStoreStats implemen
@Override
public void doneQuery(long timeTakenNanos, Collection collection, String fromKey, String toKey,
- String indexedProperty, int resultSize, long lockTime, boolean isSlaveOk) {
+ boolean indexedProperty, int resultSize, long lockTime, boolean isSlaveOk) {
if (collection == Collection.NODES){
//Distinguish between query done with filter and without filter
- TimerStats timer = indexedProperty != null ? queryNodesWithFilterTimer : queryNodesTimer;
+ TimerStats timer = indexedProperty ? queryNodesWithFilterTimer : queryNodesTimer;
timer.update(timeTakenNanos, TimeUnit.NANOSECONDS);
//Number of nodes read
@@ -223,8 +223,10 @@ public class DocumentStoreStats implemen
}
@Override
- public void doneFindAndModify(long timeTakenNanos, Collection collection, String key, boolean newEntry) {
+ public void doneFindAndModify(long timeTakenNanos, Collection collection, String key, boolean newEntry,
+ boolean success, int retryCount) {
if (collection == Collection.NODES){
+ //TODO Meter for success and retryCount
if (newEntry){
createNodeUpsertMeter.mark();
createNodeUpsertTimer.update(timeTakenNanos, TimeUnit.NANOSECONDS);
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsCollector.java?rev=1724773&r1=1724772&r2=1724773&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsCollector.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsCollector.java Fri Jan 15 10:58:59 2016
@@ -21,8 +21,6 @@ package org.apache.jackrabbit.oak.plugin
import java.util.List;
-import javax.annotation.Nullable;
-
public interface DocumentStoreStatsCollector {
/**
* Called when a document with given key is found from the cache
@@ -44,17 +42,17 @@ public interface DocumentStoreStatsColle
/**
* Called when query with given parameters is performed
- * @param timeTakenNanos watch for determining time taken
+ * @param timeTakenNanos watch for determining time taken
* @param collection the collection
* @param fromKey the start value (excluding)
* @param toKey the end value (excluding)
- * @param indexedProperty the name of the indexed property (optional)
+ * @param indexedProperty true if indexProperty was specified
* @param resultSize number of documents found for given query
* @param lockTime time in millis to acquire any lock. If no lock was required then its -1
* @param isSlaveOk true if find was performed against a secondary instance
*/
void doneQuery(long timeTakenNanos, Collection collection, String fromKey, String toKey,
- @Nullable String indexedProperty, int resultSize, long lockTime, boolean isSlaveOk);
+ boolean indexedProperty, int resultSize, long lockTime, boolean isSlaveOk);
/**
* Called when a document is created in the given collection
@@ -76,10 +74,13 @@ public interface DocumentStoreStatsColle
/**
* Called when a update operation was completed which affected single
* document.
- * @param timeTakenNanos watch for determining time taken
+ * @param timeTakenNanos watch for determining time taken
* @param collection the collection
* @param key collection which got updated or inserted
* @param newEntry true if the document was newly created due to given operation
+ * @param success true if the update was success
+ * @param retryCount number of retries done to get the update
*/
- void doneFindAndModify(long timeTakenNanos, Collection collection, String key, boolean newEntry);
+ void doneFindAndModify(long timeTakenNanos, Collection collection, String key,
+ boolean newEntry, boolean success, int retryCount);
}
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java?rev=1724773&r1=1724772&r2=1724773&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java Fri Jan 15 10:58:59 2016
@@ -607,7 +607,7 @@ public class MongoDocumentStore implemen
lock.unlock();
}
stats.doneQuery(watch.elapsed(TimeUnit.NANOSECONDS), collection, fromKey, toKey,
- indexedProperty, resultSize, lockTime, isSlaveOk);
+ indexedProperty != null , resultSize, lockTime, isSlaveOk);
}
}
@@ -781,7 +781,8 @@ public class MongoDocumentStore implemen
if (lock != null) {
lock.unlock();
}
- stats.doneFindAndModify(watch.elapsed(TimeUnit.NANOSECONDS), collection, updateOp.getId(), newEntry);
+ stats.doneFindAndModify(watch.elapsed(TimeUnit.NANOSECONDS), collection, updateOp.getId(),
+ newEntry, true, 0);
}
}
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsIT.java?rev=1724773&r1=1724772&r2=1724773&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsIT.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsIT.java Fri Jan 15 10:58:59 2016
@@ -33,9 +33,9 @@ import org.junit.rules.TestName;
import static java.util.Collections.singletonList;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
+import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -99,9 +99,9 @@ public class DocumentStoreStatsIT extend
ds.query(Collection.NODES, base, base + "A", 5);
verify(stats).doneQuery(anyLong(), eq(Collection.NODES), eq(base), eq(base + "A"),
- isNull(String.class), //indexedProperty
+ eq(false), //indexedProperty
eq(5) , // resultSize
- eq(0L), //lockTime
+ anyLong(), //lockTime
eq(false) //isSlaveOk
);
}
@@ -144,7 +144,7 @@ public class DocumentStoreStatsIT extend
up.max("_modified", 122L);
ds.findAndUpdate(Collection.NODES, up);
- verify(coll).doneFindAndModify(anyLong(), eq(Collection.NODES), eq(id), eq(false));
+ verify(coll).doneFindAndModify(anyLong(), eq(Collection.NODES), eq(id), eq(false), eq(true), anyInt());
}
private void configureStatsCollector(DocumentStoreStatsCollector stats) {
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java?rev=1724773&r1=1724772&r2=1724773&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java Fri Jan 15 10:58:59 2016
@@ -81,22 +81,22 @@ public class DocumentStoreStatsTest {
@Test
public void doneQuery_Nodes() throws Exception{
- stats.doneQuery(100, Collection.NODES, "foo", "bar", null, 5, -1, false);
+ stats.doneQuery(100, Collection.NODES, "foo", "bar", false, 5, -1, false);
assertEquals(5, getMeter(DocumentStoreStats.NODES_QUERY_FIND_READ_COUNT).getCount());
assertEquals(1, getMeter(DocumentStoreStats.NODES_QUERY_PRIMARY).getCount());
- stats.doneQuery(100, Collection.NODES, "foo", "bar", null, 7, -1, true);
+ stats.doneQuery(100, Collection.NODES, "foo", "bar", false, 7, -1, true);
assertEquals(1, getMeter(DocumentStoreStats.NODES_QUERY_SLAVE).getCount());
assertEquals(12, getMeter(DocumentStoreStats.NODES_QUERY_FIND_READ_COUNT).getCount());
- stats.doneQuery(100, Collection.NODES, "foo", "bar", null, 7, 1000, false);
+ stats.doneQuery(100, Collection.NODES, "foo", "bar", false, 7, 1000, false);
assertEquals(2, getMeter(DocumentStoreStats.NODES_QUERY_PRIMARY).getCount());
assertEquals(1, getMeter(DocumentStoreStats.NODES_QUERY_LOCK).getCount());
}
@Test
public void doneQuery_Journal() throws Exception{
- stats.doneQuery(100, Collection.JOURNAL, "foo", "bar", null, 5, -1, false);
+ stats.doneQuery(100, Collection.JOURNAL, "foo", "bar", false, 5, -1, false);
assertEquals(5, getMeter(DocumentStoreStats.JOURNAL_QUERY).getCount());
assertEquals(1, getTimer(DocumentStoreStats.JOURNAL_QUERY_TIMER).getCount());
}
@@ -110,11 +110,11 @@ public class DocumentStoreStatsTest {
@Test
public void doneFindAndModify() throws Exception{
- stats.doneFindAndModify(100, Collection.NODES, "foo", true);
+ stats.doneFindAndModify(100, Collection.NODES, "foo", true, true, 0);
assertEquals(1, getMeter(DocumentStoreStats.NODES_CREATE_UPSERT).getCount());
assertEquals(100, getTimer(DocumentStoreStats.NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax());
- stats.doneFindAndModify(100, Collection.NODES, "foo", false);
+ stats.doneFindAndModify(100, Collection.NODES, "foo", false, true, 0);
assertEquals(1, getMeter(DocumentStoreStats.NODES_UPDATE).getCount());
assertEquals(100, getTimer(DocumentStoreStats.NODES_UPDATE_TIMER).getSnapshot().getMax());
}
@@ -130,24 +130,24 @@ public class DocumentStoreStatsTest {
customLogs.starting();
//No logs untill debug enabled
- stats.doneFindAndModify(100, Collection.NODES, "foo", true);
+ stats.doneFindAndModify(100, Collection.NODES, "foo", true, true, 0);
assertEquals(0, customLogs.getLogs().size());
- stats.doneFindAndModify(TimeUnit.SECONDS.toNanos(10), Collection.NODES, "foo", true);
+ stats.doneFindAndModify(TimeUnit.SECONDS.toNanos(10), Collection.NODES, "foo", true, true, 0);
assertEquals(0, customLogs.getLogs().size());
//Change level to DEBUG - Now threshold rule applies
enableLevel(logName, Level.DEBUG);
- stats.doneFindAndModify(100, Collection.NODES, "foo", true);
+ stats.doneFindAndModify(100, Collection.NODES, "foo", true, true, 0);
assertEquals(0, customLogs.getLogs().size());
- stats.doneFindAndModify(TimeUnit.SECONDS.toNanos(10), Collection.NODES, "foo", true);
+ stats.doneFindAndModify(TimeUnit.SECONDS.toNanos(10), Collection.NODES, "foo", true, true, 0);
assertEquals(1, customLogs.getLogs().size());
//With trace level everything is logged
enableLevel(logName, Level.TRACE);
- stats.doneFindAndModify(100, Collection.NODES, "foo", true);
+ stats.doneFindAndModify(100, Collection.NODES, "foo", true, true, 0);
assertEquals(2, customLogs.getLogs().size());
customLogs.finished();