Example usage for io.netty.util.concurrent SingleThreadEventExecutor pendingTasks

List of usage examples for io.netty.util.concurrent SingleThreadEventExecutor pendingTasks

Introduction

In this page you can find the example usage for io.netty.util.concurrent SingleThreadEventExecutor pendingTasks.

Prototype

public int pendingTasks() 

Source Link

Document

Return the number of tasks that are pending for processing.

Usage

From source file:com.englishtown.vertx.metrics.VertxEventLoopGauges.java

License:Open Source License

protected void register(Vertx vertx, Container container, MetricRegistry registry) {

    if (vertx instanceof VertxInternal) {
        VertxInternal vertxInternal = (VertxInternal) vertx;
        int count = 0;

        for (EventExecutor ee : vertxInternal.getEventLoopGroup()) {
            if (ee instanceof SingleThreadEventExecutor) {
                final SingleThreadEventExecutor executor = (SingleThreadEventExecutor) ee;
                try {
                    registry.register(name(Utils.DEFAULT_METRIC_PREFIX, this.getClass().getSimpleName(),
                            "executor-" + count++, "pendingTasks"), new Gauge<Integer>() {
                                @Override
                                public Integer getValue() {
                                    return executor.pendingTasks();
                                }/*from ww  w. ja  v  a 2s  . c  o  m*/
                            });
                } catch (IllegalArgumentException e) {
                    // Assume this is due to multiple instances
                }
            }
        }

    } else {
        container.logger().warn("Vertx is not an instance of VertxInternal, cannot access event loops.");
    }

}