Search in sources :

Example 1 with ServerThreadViewSetter

use of org.neo4j.metrics.source.server.ServerThreadViewSetter in project neo4j by neo4j.

the class EnterpriseNeoServer method createWebServer.

@Override
protected WebServer createWebServer() {
    Jetty9WebServer webServer = (Jetty9WebServer) super.createWebServer();
    webServer.setJettyCreatedCallback((jetty) -> {
        ThreadPool threadPool = jetty.getThreadPool();
        assert threadPool != null;
        try {
            ServerThreadViewSetter setter = database.getGraph().getDependencyResolver().resolveDependency(ServerThreadViewSetter.class);
            setter.set(new ServerThreadView() {

                @Override
                public int allThreads() {
                    return threadPool.getThreads();
                }

                @Override
                public int idleThreads() {
                    return threadPool.getIdleThreads();
                }
            });
        } catch (UnsatisfiedDependencyException ex) {
        // nevermind, metrics are likely not enabled
        }
    });
    return webServer;
}
Also used : ServerThreadView(org.neo4j.metrics.source.server.ServerThreadView) UnsatisfiedDependencyException(org.neo4j.kernel.impl.util.UnsatisfiedDependencyException) ThreadPool(org.eclipse.jetty.util.thread.ThreadPool) Jetty9WebServer(org.neo4j.server.web.Jetty9WebServer) ServerThreadViewSetter(org.neo4j.metrics.source.server.ServerThreadViewSetter)

Aggregations

ThreadPool (org.eclipse.jetty.util.thread.ThreadPool)1 UnsatisfiedDependencyException (org.neo4j.kernel.impl.util.UnsatisfiedDependencyException)1 ServerThreadView (org.neo4j.metrics.source.server.ServerThreadView)1 ServerThreadViewSetter (org.neo4j.metrics.source.server.ServerThreadViewSetter)1 Jetty9WebServer (org.neo4j.server.web.Jetty9WebServer)1