Java 类com.codahale.metrics.jetty9.InstrumentedHandler 实例源码

项目:dcos-commons    文件:SchedulerApiServer.java   
public SchedulerApiServer(SchedulerConfig schedulerConfig, Collection<Object> resources) {
    this.port = schedulerConfig.getApiServerPort();
    this.server = JettyHttpContainerFactory.createServer(
            UriBuilder.fromUri("http://0.0.0.0/").port(this.port).build(),
            new ResourceConfig(MultiPartFeature.class).registerInstances(new HashSet<>(resources)),
            false /* don't start yet. wait for start() call below. */);
    this.startTimeout = schedulerConfig.getApiServerInitTimeout();

    ServletContextHandler context = new ServletContextHandler();

    // Metrics + Prometheus
    Metrics.configureMetricsEndpoints(context, "/v1/metrics", "/v1/metrics/prometheus");

    // Resources
    ResourceConfig resourceConfig = new ResourceConfig(MultiPartFeature.class)
            .registerInstances(new HashSet<>(resources));
    ServletHolder resourceHolder = new ServletHolder(new ServletContainer(resourceConfig));
    context.addServlet(resourceHolder, "/*");

    final InstrumentedHandler handler = new InstrumentedHandler(Metrics.getRegistry());
    handler.setHandler(context);
    server.setHandler(handler);
}
项目:flux    文件:ContainerModule.java   
/**
 * Creates the Jetty server instance for the Flux API endpoint.
 * @param port where the service is available.
 * @return Jetty Server instance
 */
@Named("APIJettyServer")
@Provides
@Singleton
Server getAPIJettyServer(@Named("Api.service.port") int port,
                         @Named("APIResourceConfig")ResourceConfig resourceConfig,
                         @Named("Api.service.acceptors") int acceptorThreads,
                         @Named("Api.service.selectors") int selectorThreads,
                         @Named("Api.service.workers") int maxWorkerThreads,
                         ObjectMapper objectMapper, MetricRegistry metricRegistry) throws URISyntaxException, UnknownHostException {
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(objectMapper);
    resourceConfig.register(provider);
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMaxThreads(maxWorkerThreads);
    Server server = new Server(threadPool);
    ServerConnector http = new ServerConnector(server, acceptorThreads, selectorThreads);
    http.setPort(port);
    server.addConnector(http);
    ServletContextHandler context = new ServletContextHandler(server, "/*");
    ServletHolder servlet = new ServletHolder(new ServletContainer(resourceConfig));
    context.addServlet(servlet, "/*");

    final InstrumentedHandler handler = new InstrumentedHandler(metricRegistry);
    handler.setHandler(context);
    server.setHandler(handler);

    server.setStopAtShutdown(true);
    return server;
}
项目:Poseidon    文件:Poseidon.java   
private Handler getPoseidonHandler() {
    ServletContextHandler servletContextHandler = new ServletContextHandler();
    servletContextHandler.setContextPath("/");
    servletContextHandler.addServlet(new ServletHolder(getPoseidonServlet()), "/*");

    addFilters(servletContextHandler);

    InstrumentedHandler instrumentedHandler = new InstrumentedHandler(Metrics.getRegistry());
    instrumentedHandler.setHandler(servletContextHandler);
    return instrumentedHandler;
}
项目:factoryfx    文件:InstrumentedJettyServer.java   
@Override
protected List<Handler> additionalHandlers(){
    metricRegistry= new MetricRegistry();
    return Arrays.asList(new InstrumentedHandler(metricRegistry,"monitoring example"));
}