chenboat commented on a change in pull request #7556:
URL: https://github.com/apache/pinot/pull/7556#discussion_r727392927
##########
File path:
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
##########
@@ -2862,6 +2864,13 @@ public TableStats getTableStats(String
tableNameWithType) {
return new TableStats(creationTime);
}
+ // Return the list of live brokers serving a table. Each entry is of the
following format:
+ // Broker_hostname_port (e.g., broker_12.34.56.78_1234)
+ public List<String> getLiveBrokersForTable(String tableNameWithType) {
+ ExternalViewReader externalViewReader = new ExternalViewReader(new
ZkClient(_helixZkURL));
+ Map<String, List<String>> tableToBrokersMap =
externalViewReader.getTableWithTypeToRawBrokerInstanceIdsMap();
+ return tableToBrokersMap == null ? null :
tableToBrokersMap.get(tableNameWithType);
Review comment:
Returning empty map.
##########
File path:
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
##########
@@ -2862,6 +2864,13 @@ public TableStats getTableStats(String
tableNameWithType) {
return new TableStats(creationTime);
}
+ // Return the list of live brokers serving a table. Each entry is of the
following format:
+ // Broker_hostname_port (e.g., broker_12.34.56.78_1234)
+ public List<String> getLiveBrokersForTable(String tableNameWithType) {
+ ExternalViewReader externalViewReader = new ExternalViewReader(new
ZkClient(_helixZkURL));
+ Map<String, List<String>> tableToBrokersMap =
externalViewReader.getTableWithTypeToRawBrokerInstanceIdsMap();
+ return tableToBrokersMap == null ? null :
tableToBrokersMap.get(tableNameWithType);
Review comment:
Revised to return empty map.
##########
File path:
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/ExternalViewReader.java
##########
@@ -87,7 +87,18 @@ protected ByteArrayInputStream getInputStream(byte[]
brokerResourceNodeData) {
return new ByteArrayInputStream(brokerResourceNodeData);
}
+ // Return a map from tablename (without type) to live brokers (of format
host:port).
public Map<String, List<String>> getTableToBrokersMap() {
+ return getTableToBrokersMapFromExternalView(false, true);
+
Review comment:
done.
##########
File path:
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/ExternalViewReader.java
##########
@@ -87,7 +87,18 @@ protected ByteArrayInputStream getInputStream(byte[]
brokerResourceNodeData) {
return new ByteArrayInputStream(brokerResourceNodeData);
}
+ // Return a map from tablename (without type) to live brokers (of format
host:port).
public Map<String, List<String>> getTableToBrokersMap() {
+ return getTableToBrokersMapFromExternalView(false, true);
+
+ }
+
+ // Return a map from tablename (with type) to live brokers (of raw instance
format broker_host_port).
+ public Map<String, List<String>> getTableWithTypeToRawBrokerInstanceIdsMap()
{
+ return getTableToBrokersMapFromExternalView(true, false);
+ }
+
+ private Map<String, List<String>>
getTableToBrokersMapFromExternalView(boolean tableWithType, boolean
useUrlFormat) {
Map<String, Set<String>> brokerUrlsMap = new HashMap<>();
try {
byte[] brokerResourceNodeData =
_zkClient.readData("/EXTERNALVIEW/brokerResource", true);
Review comment:
done.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]