DocumentStoreStats implements DocumentStoreStatsCollector, DocumentStoreStatsMBean { @Override public void doneQuery(long timeTakenNanos, Collection<? extends Document> collection, String fromKey, String toKey, boolean indexedProperty, int resultSize, long lockTime, boolean isSlaveOk) { if (collection == Collection.NODES){ TimerStats timer = indexedProperty ? queryNodesWithFilterTimer : queryNodesTimer; timer.update(timeTakenNanos, TimeUnit.NANOSECONDS); queryNodesResult.mark(resultSize); if (isSlaveOk){ queryNodesSlave.mark(); } else { queryNodesPrimary.mark(); } if (lockTime > 0){ queryNodesLock.mark(); queryNodesLockTimer.update(lockTime, TimeUnit.NANOSECONDS); } } else if (collection == Collection.JOURNAL){ queryJournal.mark(resultSize); queryJournalTimer.update(timeTakenNanos, TimeUnit.NANOSECONDS); } perfLog(timeTakenNanos, "query for children from [{}] to [{}], lock:{}", fromKey, toKey, lockTime); } DocumentStoreStats(StatisticsProvider provider); @Override void doneFindCached(Collection<? extends Document> collection, String key); @Override void doneFindUncached(long timeTakenNanos, Collection<? extends Document> collection, String key,
                                 boolean docFound, boolean isSlaveOk); @Override void doneQuery(long timeTakenNanos, Collection<? extends Document> collection, String fromKey, String toKey,
                          boolean indexedProperty, int resultSize, long lockTime, boolean isSlaveOk); @Override void doneCreate(long timeTakenNanos, Collection<? extends Document> collection, List<String> ids, boolean insertSuccess); @Override void doneCreateOrUpdate(long timeTakenNanos,
                                   Collection<? extends Document> collection,
                                   List<String> ids); @Override void doneFindAndModify(long timeTakenNanos, Collection<? extends Document> collection, String key, boolean newEntry,
                                  boolean success, int retryCount); @Override void doneRemove(long timeTakenNanos,
                           Collection<? extends Document> collection,
                           int removeCount); @Override long getNodesFindCount(); @Override long getNodesFindQueryCount(); @Override long getNodesFindMissingCount(); @Override long getNodesReadByQueryCount(); @Override long getNodesCreateCount(); @Override long getNodesUpdateCount(); @Override long getNodesRemoveCount(); @Override long getJournalCreateCount(); @Override long getJournalReadCount(); @Override CompositeData getFindCachedNodesHistory(); @Override CompositeData getFindSplitNodesHistory(); @Override CompositeData getFindNodesFromPrimaryHistory(); @Override CompositeData getFindNodesFromSlaveHistory(); @Override CompositeData getFindNodesMissingHistory(); @Override CompositeData getQueryNodesFromSlaveHistory(); @Override CompositeData getQueryNodesFromPrimaryHistory(); @Override CompositeData getQueryNodesLockHistory(); @Override CompositeData getQueryJournalHistory(); @Override CompositeData getCreateJournalHistory(); @Override CompositeData getCreateNodesHistory(); @Override CompositeData getUpdateNodesHistory(); @Override CompositeData getUpdateNodesRetryHistory(); @Override CompositeData getUpdateNodesFailureHistory(); @Override CompositeData getRemoveNodesHistory(); static final int PERF_LOG_THRESHOLD; }
@Test public void doneQuery_Nodes() throws Exception{ 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", 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", 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", false, 5, -1, false); assertEquals(5, getMeter(DocumentStoreStats.JOURNAL_QUERY).getCount()); assertEquals(1, getTimer(DocumentStoreStats.JOURNAL_QUERY_TIMER).getCount()); }