mcvsubbu commented on a change in pull request #4553: Refactor
ControllerLeaderLocator
URL: https://github.com/apache/incubator-pinot/pull/4553#discussion_r324280388
##########
File path:
pinot-core/src/main/java/org/apache/pinot/server/realtime/ControllerLeaderLocator.java
##########
@@ -80,45 +84,111 @@ public static ControllerLeaderLocator getInstance() {
/**
* Locates the controller leader so that we can send LLC segment completion
requests to it.
- * Checks the {@link
ControllerLeaderLocator::_cachedControllerLeaderInvalid} flag and fetches the
leader from helix if cached value is invalid
+ * Checks the {@link
ControllerLeaderLocator::_cachedControllerLeaderInvalid} flag and fetches the
leaders to {@link ControllerLeaderLocator::_cachedControllerLeaderMap} from
helix if cached value is invalid
* @param rawTableName table name without type.
* @return The host-port pair of the current controller leader.
*/
public synchronized Pair<String, Integer> getControllerLeader(String
rawTableName) {
+ int partitionId = LeadControllerUtils.getPartitionIdForTable(rawTableName);
if (!_cachedControllerLeaderInvalid) {
- return _controllerLeaderHostPort;
+ return _cachedControllerLeaderMap.get(partitionId);
}
- Pair<String, Integer> leaderForTable = getLeaderForTable(rawTableName);
- if (leaderForTable == null) {
- LOGGER.warn("Failed to find a leader for Table: {}", rawTableName);
+ // No controller leader cached, fetches a fresh copy of external view and
then gets the leader for the given table.
+ boolean success = refreshControllerLeaderMap();
+ if (success) {
+ _cachedControllerLeaderInvalid = false;
Review comment:
Can we set this variable inside the methods that refreshes?
Also, can we log appropriate failures in the methods as well (we can log
additional information of what exactly happened). The log in this method seems
to be redundant (other than the benefit that we can look for one string to
check success/failure)
----------------------------------------------------------------
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]