提交 59a952dc 编写于 作者: M Matteo Merli 提交者: GitHub

Fixed problem in starting ZK server for standalone mode (#521)

上级 7c0b28fa
......@@ -31,15 +31,26 @@ import io.prometheus.client.Gauge;
*/
@Aspect
public class ZooKeeperServerAspect {
private static boolean metricsRegistered = false;
@Pointcut("execution(org.apache.zookeeper.server.ZooKeeperServer.new(..))")
public void processRequest() {
public void zkServerConstructorPointCut() {
}
@After("processRequest()")
public void timedProcessRequest(JoinPoint joinPoint) throws Throwable {
@After("zkServerConstructorPointCut()")
public void zkServerConstructor(JoinPoint joinPoint) throws Throwable {
// ZooKeeperServer instance was created
ZooKeeperServer zkServer = (ZooKeeperServer) joinPoint.getThis();
synchronized (ZooKeeperServerAspect.class) {
if (metricsRegistered) {
// We can only register the metrics a single time for the process
return;
}
metricsRegistered = true;
}
Gauge.build().name("zookeeper_server_znode_count").help("Number of z-nodes stored").create()
.setChild(new Gauge.Child() {
@Override
......@@ -80,5 +91,4 @@ public class ZooKeeperServerAspect {
}
}).register();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册