本文整理汇总了Java中io.dropwizard.setup.Bootstrap.getMetricRegistry方法的典型用法代码示例。如果您正苦于以下问题:Java Bootstrap.getMetricRegistry方法的具体用法?Java Bootstrap.getMetricRegistry怎么用?Java Bootstrap.getMetricRegistry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.dropwizard.setup.Bootstrap
的用法示例。
在下文中一共展示了Bootstrap.getMetricRegistry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import io.dropwizard.setup.Bootstrap; //导入方法依赖的package包/类
@Override
protected void run(Bootstrap<EmoConfiguration> bootstrap, Namespace namespace, EmoConfiguration configuration)
throws Exception {
String serviceName = namespace.getString("service");
CuratorFramework curator = configuration.getZooKeeperConfiguration().newCurator();
curator.start();
ZooKeeperHostDiscovery hostDiscovery = new ZooKeeperHostDiscovery(curator, serviceName, bootstrap.getMetricRegistry());
for (ServiceEndPoint endPoint : hostDiscovery.getHosts()) {
System.out.println(endPoint.getId());
}
hostDiscovery.close();
curator.close();
}
示例2: run
import io.dropwizard.setup.Bootstrap; //导入方法依赖的package包/类
@Override
protected final void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {
final Environment environment = new Environment(bootstrap.getApplication().getName(),
bootstrap.getObjectMapper(),
bootstrap.getValidatorFactory().getValidator(),
bootstrap.getMetricRegistry(),
bootstrap.getClassLoader());
configuration.getMetricsFactory().configure(environment.lifecycle(),
bootstrap.getMetricRegistry());
bootstrap.run(configuration, environment);
href = namespace.getString("href");
try {
cleanupAsynchronously();
} catch (Exception e) {
cleanup();
throw e;
}
application.run(configuration, environment);
}
示例3: run
import io.dropwizard.setup.Bootstrap; //导入方法依赖的package包/类
@Override
protected void run(Bootstrap<EmoConfiguration> bootstrap, Namespace namespace, EmoConfiguration config)
throws Exception {
String host = namespace.getString("host");
int limit = namespace.getInt("limit");
String subscription = namespace.getString("subscription");
String apiKey = namespace.getString("api_key");
Set<String> tables = Sets.newHashSet(namespace.<String>getList("table"));
List<String> keys = namespace.getList("key");
Set<String> keySet = keys != null ? Sets.newHashSet(keys) : null;
System.out.println("Connecting...");
URI uri = URI.create(host).resolve(DatabusClient.SERVICE_PATH + "/_raw");
MetricRegistry metricRegistry = bootstrap.getMetricRegistry();
Client client = createDefaultJerseyClient(config.getHttpClientConfiguration(), metricRegistry, "");
QueueService databus = QueueServiceAuthenticator.proxied(new QueueClient(uri, new JerseyEmoClient(client)))
.usingCredentials(apiKey);
for (;;) {
List<Message> events = databus.peek(subscription, 5000);
List<String> ids = Lists.newArrayList();
for (Message event : events) {
//noinspection unchecked
Map<String, String> coord = (Map<String, String>) checkNotNull(event.getPayload());
String table = checkNotNull(coord.get("table"));
String key = checkNotNull(coord.get("key"));
if (tables.contains(table) && (keySet == null || keySet.contains(key))) {
ids.add(event.getId());
if (--limit <= 0) {
break;
}
}
}
if (ids.isEmpty()) {
System.out.println("All matching events of the first " + events.size() + " have been purged.");
break;
}
System.out.println("Purging " + ids.size() + " events...");
databus.acknowledge(subscription, ids);
if (limit == 0) {
System.out.println("Limit reached.");
break;
}
}
}