本文整理匯總了Java中com.codahale.metrics.servlets.PingServlet類的典型用法代碼示例。如果您正苦於以下問題:Java PingServlet類的具體用法?Java PingServlet怎麽用?Java PingServlet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PingServlet類屬於com.codahale.metrics.servlets包,在下文中一共展示了PingServlet類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: evaluateWeb
import com.codahale.metrics.servlets.PingServlet; //導入依賴的package包/類
private void evaluateWeb()
throws Exception {
if (!runPerServiceMode(web)) {
return;
}
// Load balancers should hit the ping servlet, exposed on the main port to reflect main connection pool issues
_environment.servlets().addServlet("/ping", new PingServlet());
// Serve static assets
_environment.jersey().register(FaviconResource.class);
// Add a filter to provide finer 5xx metrics than the default DropWizard metrics include.
//noinspection unchecked
_environment.jersey().getResourceConfig().getContainerResponseFilters()
.add(new ServerErrorResponseMetricsFilter(_environment.metrics()));
}
示例2: registerMetricsServlets
import com.codahale.metrics.servlets.PingServlet; //導入依賴的package包/類
private void registerMetricsServlets(final ServletContextHandler context) {
context.addEventListener(new ExampleHealthCheckServletContextListener());
context.addEventListener(new ExampleMetricsServletContextListener());
context.addServlet(AdminServlet.class, "/admin");
context.addServlet(HealthCheckServlet.class, "/admin/healthcheck");
context.addServlet(MetricsServlet.class, "/admin/metrics");
context.addServlet(PingServlet.class, "/admin/ping");
context.addServlet(ThreadDumpServlet.class, "/admin/threads");
}
示例3: configure
import com.codahale.metrics.servlets.PingServlet; //導入依賴的package包/類
@Override
protected void configure() {
// NOTE: AdminServletModule (metrics-guice integration) generates invalid links, so wire up servlets ourselves
final Clock clock = Clock.defaultClock();
bind(Clock.class).toInstance(clock);
final JsonFactory jsonFactory = new JsonFactory(new ObjectMapper());
bind(JsonFactory.class).toInstance(jsonFactory);
install(new ServletModule()
{
@Override
protected void configureServlets() {
bind(MetricsServlet.class);
bind(HealthCheckServlet.class);
serve(MOUNT_POINT + "/ping").with(new PingServlet());
serve(MOUNT_POINT + "/threads").with(new ThreadDumpServlet());
serve(MOUNT_POINT + "/data").with(MetricsServlet.class);
serve(MOUNT_POINT + "/healthcheck").with(HealthCheckServlet.class);
// record metrics for all webapp access
filter("/*").through(new InstrumentedFilter());
bind(SecurityFilter.class);
// configure security
filter(MOUNT_POINT + "/*").through(SecurityFilter.class);
}
});
// require permission to use endpoints
install(new FilterChainModule()
{
@Override
protected void configure() {
addFilterChain(MOUNT_POINT + "/**",
NexusAuthenticationFilter.NAME,
AnonymousFilter.NAME,
PermissionsFilter.config("nexus:metrics:read"));
}
});
log.info("Metrics support configured");
}