Skip to content

Commit

Permalink
Fixed problem in starting ZK server for standalone mode (apache#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat authored Jun 23, 2017
1 parent 7c0b28f commit 59a952d
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,26 @@
*/
@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
Expand Down Expand Up @@ -80,5 +91,4 @@ public double get() {
}
}).register();
}

}

0 comments on commit 59a952d

Please sign in to comment.