Github user merlimat commented on a diff in the pull request:
https://github.com/apache/incubator-pulsar/pull/521#discussion_r123651694
--- Diff:
pulsar-zookeeper/src/main/java/com/yahoo/pulsar/zookeeper/ZooKeeperServerAspect.java
---
@@ -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) {
--- End diff --
so, the variable is only read/written within the mutex and there is no need
to use volatile, because the mutex implies here a full memory barrier, so all
variables needs to be committed to memory and the execution cannot be reordered
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---