本文整理汇总了Java中com.codahale.metrics.Timer.Context.close方法的典型用法代码示例。如果您正苦于以下问题:Java Context.close方法的具体用法?Java Context.close怎么用?Java Context.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codahale.metrics.Timer.Context
的用法示例。
在下文中一共展示了Context.close方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequest
import com.codahale.metrics.Timer.Context; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
Context context = timer.time();
try {
handler.handleRequest(exchange);
} finally {
context.close();
}
}
示例2: testLookup
import com.codahale.metrics.Timer.Context; //导入方法依赖的package包/类
public Deferred<EnumMap<UniqueIdType, Map<String, String>>> testLookup(final TSDBMetricMeta meta) {
final Context ctx = resolveUidsTimer.time();
final EnumMap<UniqueIdType, Map<String, String>> map = new EnumMap<UniqueIdType, Map<String, String>>(UniqueIdType.class);
final TSDBMetricMeta m = metricMetas.get(meta.getTsuid());
map.put(UniqueIdType.METRIC, Collections.singletonMap(m.getMetricName(), m.getMetricUid()));
map.put(UniqueIdType.TAGK, m.getTagKeyUids());
map.put(UniqueIdType.TAGV, m.getTagValueUids());
ctx.close();
return Deferred.fromResult(map);
}
示例3: doGet
import com.codahale.metrics.Timer.Context; //导入方法依赖的package包/类
@Override
protected final void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
log(req);
Context context = getTimer(req).time();
try {
get(req, resp);
} finally {
context.close();
}
}
示例4: doPost
import com.codahale.metrics.Timer.Context; //导入方法依赖的package包/类
@Override
protected final void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
log(req);
Context context = getTimer(req).time();
try {
post(req, resp);
} finally {
context.close();
}
}
示例5: doPut
import com.codahale.metrics.Timer.Context; //导入方法依赖的package包/类
@Override
protected final void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
log(req);
Context context = getTimer(req).time();
try {
put(req, resp);
} finally {
context.close();
}
}
示例6: doDelete
import com.codahale.metrics.Timer.Context; //导入方法依赖的package包/类
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
log(req);
Context context = getTimer(req).time();
try {
delete(req, resp);
} finally {
context.close();
}
}
示例7: onClose
import com.codahale.metrics.Timer.Context; //导入方法依赖的package包/类
@Override
protected void onClose(CloseReason closereason) {
edm.countOpened.ifPresent(Counter::dec);
Context ctx = (Context) getJsrSession().getUserProperties().get(this.getClass().getName());
if (ctx != null)
ctx.close();
super.onClose(closereason);
}
示例8: rebalanceCurrentCluster
import com.codahale.metrics.Timer.Context; //导入方法依赖的package包/类
public synchronized void rebalanceCurrentCluster(List<LiveInstance> liveInstances) {
Context context = _rebalanceTimer.time();
LOGGER.info("AutoRebalanceLiveInstanceChangeListener.onLiveInstanceChange() wakes up!");
try {
_numLiveInstances.inc(liveInstances.size() - _numLiveInstances.getCount());
if (!_helixManager.isLeader()) {
LOGGER.info("Not leader, do nothing!");
return;
}
if (!_helixMirrorMakerManager.isAutoBalancingEnabled()) {
LOGGER.info("Is leader, but auto-balancing is disabled, do nothing!");
return;
}
if (liveInstances.isEmpty()) {
LOGGER.info("No live instances, do nothing!");
return;
}
final Map<String, Set<TopicPartition>> instanceToTopicPartitionMap =
HelixUtils.getInstanceToTopicPartitionsMap(_helixManager);
Set<TopicPartition> unassignedTopicPartitions =
HelixUtils.getUnassignedPartitions(_helixManager);
if (instanceToTopicPartitionMap.isEmpty() && unassignedTopicPartitions.isEmpty()) {
LOGGER.info("No topic got assigned yet, do nothing!");
return;
}
Set<InstanceTopicPartitionHolder> newAssignment =
rescaleInstanceToTopicPartitionMap(liveInstances, instanceToTopicPartitionMap,
unassignedTopicPartitions);
if (newAssignment == null) {
LOGGER.info("No Live Instances got changed, do nothing!");
return;
}
LOGGER.info("Trying to fetch IdealStatesMap from current assignment!");
Map<String, IdealState> idealStatesFromAssignment =
HelixUtils.getIdealStatesFromAssignment(newAssignment);
LOGGER.info("Trying to assign new IdealStatesMap!");
assignIdealStates(_helixManager, idealStatesFromAssignment);
_helixMirrorMakerManager.updateCurrentServingInstance();
_rebalanceRate.mark();
} finally {
context.close();
}
}