Jackie-Jiang commented on a change in pull request #4245: Make
ControllerLeadershipManager thread-safe and register it to PARTICIPANT
HelixManager
URL: https://github.com/apache/incubator-pinot/pull/4245#discussion_r288322881
##########
File path:
pinot-controller/src/main/java/org/apache/pinot/controller/ControllerLeadershipManager.java
##########
@@ -18,50 +18,66 @@
*/
package org.apache.pinot.controller;
+import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import javax.annotation.concurrent.ThreadSafe;
import org.apache.helix.HelixManager;
-import org.apache.helix.api.listeners.ControllerChangeListener;
import org.apache.pinot.common.metrics.ControllerGauge;
import org.apache.pinot.common.metrics.ControllerMetrics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Single place for listening on controller changes
- * This should be created at controller startup and everyone who wants to
listen to controller changes should subscribe
+ * Single place for listening on controller changes.
+ * This should be created at controller startup and everyone who wants to
listen to controller changes should subscribe.
*/
+@ThreadSafe
public class ControllerLeadershipManager {
-
private static final Logger LOGGER =
LoggerFactory.getLogger(ControllerLeadershipManager.class);
- private HelixManager _helixManager;
- private ControllerMetrics _controllerMetrics;
- private volatile boolean _amILeader = false;
+ private final HelixManager _helixManager;
+ private final ControllerMetrics _controllerMetrics;
- private Map<String, LeadershipChangeSubscriber> _subscribers = new
ConcurrentHashMap<>();
+ private Map<String, LeadershipChangeSubscriber> _subscribers = new
HashMap<>();
+ private boolean _amILeader = false;
Review comment:
It does not need to be as the methods are synchronized
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]