DocumentStoreStats implements DocumentStoreStatsCollector, DocumentStoreStatsMBean { @Override public void doneFindAndModify(long timeTakenNanos, Collection<? extends Document> collection, String key, boolean newEntry, boolean success, int retryCount) { if (collection == Collection.NODES){ if (success) { if (newEntry) { createNodeUpsertMeter.mark(); createNodeUpsertTimer.update(timeTakenNanos, TimeUnit.NANOSECONDS); } else { updateNodeMeter.mark(); updateNodeTimer.update(timeTakenNanos, TimeUnit.NANOSECONDS); } if (retryCount > 0){ updateNodeRetryCountMeter.mark(retryCount); } } else { updateNodeRetryCountMeter.mark(retryCount); updateNodeFailureMeter.mark(); } } perfLog(timeTakenNanos, "findAndModify [{}]", key); } 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 doneFindAndModify() throws Exception{ 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, true, 0); assertEquals(1, getMeter(DocumentStoreStats.NODES_UPDATE).getCount()); assertEquals(100, getTimer(DocumentStoreStats.NODES_UPDATE_TIMER).getSnapshot().getMax()); }
@Test public void doneFindAndModifyRetryAndFailure() throws Exception{ stats.doneFindAndModify(100, Collection.NODES, "foo", true, false, 3); assertEquals(1, getMeter(DocumentStoreStats.NODES_UPDATE_FAILURE).getCount()); assertEquals(3, getMeter(DocumentStoreStats.NODES_UPDATE_RETRY_COUNT).getCount()); stats.doneFindAndModify(100, Collection.NODES, "foo", true, true, 2); assertEquals(5, getMeter(DocumentStoreStats.NODES_UPDATE_RETRY_COUNT).getCount()); }