DocumentStoreStats implements DocumentStoreStatsCollector, DocumentStoreStatsMBean { @Override public void doneCreate(long timeTakenNanos, Collection<? extends Document> collection, List<String> ids, boolean insertSuccess) { if (collection == Collection.NODES && insertSuccess){ for (String id : ids){ createNodeMeter.mark(); if (Utils.isPreviousDocId(id)){ createSplitNodeMeter.mark(); } } createNodeTimer.update(timeTakenNanos / ids.size(), TimeUnit.NANOSECONDS); } else if (collection == Collection.JOURNAL){ createJournal.mark(ids.size()); createJournalTimer.update(timeTakenNanos, TimeUnit.NANOSECONDS); } perfLog(timeTakenNanos, "create"); } 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 doneCreate_Journal() throws Exception{ stats.doneCreate(100, Collection.JOURNAL, of("a", "b"), true); assertEquals(2, getMeter(DocumentStoreStats.JOURNAL_CREATE).getCount()); assertEquals(100, getTimer(DocumentStoreStats.JOURNAL_CREATE_TIMER).getSnapshot().getMax()); }