Skip to content

Commit

Permalink
[STATS] [DOC] Add @statsdoc annotation for entrylogger stats
Browse files Browse the repository at this point in the history
Descriptions of the changes in this PR:

*Motivation*

As part of [BP-36](apache#1785),
this PR is to document the entrylogger stats.

*Changes*

- convert entrylogger stats to use StatsDoc for documenting metrics

Master Issue: apache#1785




Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Jia Zhai <None>

This closes apache#1871 from sijie/document_ledgerstorage_stats
  • Loading branch information
sijie authored Dec 12, 2018
1 parent 2c59032 commit e5cf9d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

package org.apache.bookkeeper.bookie;

import static org.apache.bookkeeper.bookie.BookKeeperServerStats.CATEGORY_SERVER;
import static org.apache.bookkeeper.bookie.BookKeeperServerStats.ENTRYLOGGER_SCOPE;
import static org.apache.bookkeeper.bookie.BookKeeperServerStats.ENTRYLOGS_PER_LEDGER;
import static org.apache.bookkeeper.bookie.BookKeeperServerStats.NUM_LEDGERS_HAVING_MULTIPLE_ENTRYLOGS;
import static org.apache.bookkeeper.bookie.BookKeeperServerStats.NUM_OF_WRITE_ACTIVE_LEDGERS;
Expand Down Expand Up @@ -61,6 +63,7 @@
import org.apache.bookkeeper.stats.Counter;
import org.apache.bookkeeper.stats.OpStatsLogger;
import org.apache.bookkeeper.stats.StatsLogger;
import org.apache.bookkeeper.stats.annotations.StatsDoc;
import org.apache.bookkeeper.util.IOUtils;
import org.apache.bookkeeper.util.MathUtils;
import org.apache.bookkeeper.util.collections.ConcurrentLongHashMap;
Expand Down Expand Up @@ -115,11 +118,37 @@ private void setEntryLogWithDirInfo(BufferedLogChannelWithDirInfo entryLogWithDi
}
}

@StatsDoc(
name = ENTRYLOGGER_SCOPE,
category = CATEGORY_SERVER,
help = "EntryLogger related stats"
)
class EntryLogsPerLedgerCounter {

@StatsDoc(
name = NUM_OF_WRITE_ACTIVE_LEDGERS,
help = "Number of write active ledgers"
)
private final Counter numOfWriteActiveLedgers;
@StatsDoc(
name = NUM_OF_WRITE_LEDGERS_REMOVED_CACHE_EXPIRY,
help = "Number of write ledgers removed after cache expiry"
)
private final Counter numOfWriteLedgersRemovedCacheExpiry;
@StatsDoc(
name = NUM_OF_WRITE_LEDGERS_REMOVED_CACHE_MAXSIZE,
help = "Number of write ledgers removed due to reach max cache size"
)
private final Counter numOfWriteLedgersRemovedCacheMaxSize;
@StatsDoc(
name = NUM_LEDGERS_HAVING_MULTIPLE_ENTRYLOGS,
help = "Number of ledgers having multiple entry logs"
)
private final Counter numLedgersHavingMultipleEntrylogs;
@StatsDoc(
name = ENTRYLOGS_PER_LEDGER,
help = "The distribution of number of entry logs per ledger"
)
private final OpStatsLogger entryLogsPerLedger;
/*
* ledgerIdEntryLogCounterCacheMap cache will be used to store count of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ public class EntryLogger {
@VisibleForTesting
static final int UNINITIALIZED_LOG_ID = -0xDEAD;

// Expose Stats
private final StatsLogger statsLogger;

static class BufferedLogChannel extends BufferedChannel {
private final long logId;
private final EntryLogMetadata entryLogMetadata;
Expand Down Expand Up @@ -375,7 +372,6 @@ public EntryLogger(ServerConfiguration conf,
this.recentlyCreatedEntryLogsStatus = new RecentEntryLogsStatus(logId + 1);
this.entryLoggerAllocator = new EntryLoggerAllocator(conf, ledgerDirsManager, recentlyCreatedEntryLogsStatus,
logId);
this.statsLogger = statsLogger;
if (entryLogPerLedgerEnabled) {
this.entryLogManager = new EntryLogManagerForEntryLogPerLedger(conf, ledgerDirsManager,
entryLoggerAllocator, listeners, recentlyCreatedEntryLogsStatus, statsLogger);
Expand Down

0 comments on commit e5cf9d4

Please sign in to comment.