Skip to content

Commit

Permalink
[STATS] [DOC] Add @statsdoc annotation for bookie state manager 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 bookie state manager stats.

*Changes*

- convert bookie state manager stats to use StatsDoc for documenting metrics

Master Issue: apache#1785




Reviewers: Enrico Olivelli <eolivelli@gmail.com>

This closes apache#1876 from sijie/bookie_state_stats
  • Loading branch information
sijie authored Dec 12, 2018
1 parent e5cf9d4 commit d82163f
Showing 1 changed file with 16 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.BOOKIE_SCOPE;
import static org.apache.bookkeeper.bookie.BookKeeperServerStats.CATEGORY_SERVER;
import static org.apache.bookkeeper.bookie.BookKeeperServerStats.SERVER_STATUS;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
Expand All @@ -42,6 +44,7 @@
import org.apache.bookkeeper.stats.Gauge;
import org.apache.bookkeeper.stats.NullStatsLogger;
import org.apache.bookkeeper.stats.StatsLogger;
import org.apache.bookkeeper.stats.annotations.StatsDoc;
import org.apache.bookkeeper.util.DiskChecker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -50,6 +53,11 @@
* An implementation of StateManager.
*/
@Slf4j
@StatsDoc(
name = BOOKIE_SCOPE,
category = CATEGORY_SERVER,
help = "Bookie state manager related stats"
)
public class BookieStateManager implements StateManager {
private static final Logger LOG = LoggerFactory.getLogger(BookieStateManager.class);
private final ServerConfiguration conf;
Expand All @@ -73,7 +81,11 @@ public class BookieStateManager implements StateManager {
private ShutdownHandler shutdownHandler;
private final Supplier<RegistrationManager> rm;
// Expose Stats
private final StatsLogger statsLogger;
@StatsDoc(
name = SERVER_STATUS,
help = "Bookie status (1: up, 0: readonly, -1: unregistered)"
)
private final Gauge<Number> serverStatusGauge;

public BookieStateManager(ServerConfiguration conf,
StatsLogger statsLogger,
Expand All @@ -98,13 +110,12 @@ public BookieStateManager(ServerConfiguration conf,
List<File> statusDirs,
Supplier<String> bookieIdSupplier) throws IOException {
this.conf = conf;
this.statsLogger = statsLogger;
this.rm = rm;
this.statusDirs = statusDirs;
// ZK ephemeral node for this Bookie.
this.bookieId = bookieIdSupplier.get();
// 1 : up, 0 : readonly, -1 : unregistered
statsLogger.registerGauge(SERVER_STATUS, new Gauge<Number>() {
this.serverStatusGauge = new Gauge<Number>() {
@Override
public Number getDefaultValue() {
return 0;
Expand All @@ -120,7 +131,8 @@ public Number getSample() {
return 1;
}
}
});
};
statsLogger.registerGauge(SERVER_STATUS, serverStatusGauge);
}

private boolean isRegistrationManagerDisabled() {
Expand Down

0 comments on commit d82163f

Please sign in to comment.