DocumentStoreStats implements DocumentStoreStatsCollector, DocumentStoreStatsMBean { @Override public void doneFindUncached(long timeTakenNanos, Collection<? extends Document> collection, String key, boolean docFound, boolean isSlaveOk) { if (collection == Collection.NODES){ TimerStats timer; if (docFound) { timer = findNodesTimer; } else { timer = findNodesMissingTimer; findNodesMissing.mark(); } timer.update(timeTakenNanos, TimeUnit.NANOSECONDS); if (isSlaveOk){ findNodesSlave.mark(); } else { findNodesPrimary.mark(); } if (Utils.isPreviousDocId(key)){ findSplitNodes.mark(); } } perfLog(timeTakenNanos, "findUncached on key={}, isSlaveOk={}", key, isSlaveOk); } 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 doneFindUncached() throws Exception{ stats.doneFindUncached(100, Collection.NODES, "0:/", true, false); assertEquals(1, getMeter(DocumentStoreStats.NODES_FIND_PRIMARY).getCount()); assertEquals(100, getTimer(DocumentStoreStats.NODES_FIND_TIMER).getSnapshot().getMax()); assertEquals(0, getMeter(DocumentStoreStats.NODES_FIND_SLAVE).getCount()); stats.doneFindUncached(100, Collection.NODES, "0:/", true, true); assertEquals(1, getMeter(DocumentStoreStats.NODES_FIND_PRIMARY).getCount()); assertEquals(1, getMeter(DocumentStoreStats.NODES_FIND_SLAVE).getCount()); stats.doneFindUncached(100, Collection.NODES, "2:p/foo", true, false); assertEquals(2, getMeter(DocumentStoreStats.NODES_FIND_PRIMARY).getCount()); assertEquals(1, getMeter(DocumentStoreStats.NODES_FIND_SPLIT).getCount()); stats.doneFindUncached(100, Collection.SETTINGS, "0:/", true, false); assertEquals(2, getMeter(DocumentStoreStats.NODES_FIND_PRIMARY).getCount()); }