Source:
<code>public static List<URI> getPeerServerURIs(String segmentName, String downloadScheme, HelixManager helixManager) { LLCSegmentName llcSegmentName = new LLCSegmentName(segmentName); String tableNameWithType = TableNameBuilder.forType(TableType.REALTIME).tableNameWithType(llcSegmentName.getTableName()); HelixAdmin helixAdmin = helixManager.getClusterManagmentTool(); String clusterName = helixManager.getClusterName(); if (clusterName == null) { _logger.error("ClusterName not found"); return ListUtils.EMPTY_LIST; } ExternalView externalViewForResource = HelixHelper.getExternalViewForResource(helixAdmin, clusterName, tableNameWithType); if (externalViewForResource == null) { _logger.warn("External View not found for table {}", tableNameWithType); return ListUtils.EMPTY_LIST; } List<URI> onlineServerURIs = new ArrayList<>(); <START> for (String segment : externalViewForResource.getPartitionSet()) { <END> if (!segmentName.equals(segment)) { continue; } Map<String, String> instanceToStateMap = externalViewForResource.getStateMap(segmentName); for (Map.Entry<String, String> instanceState : instanceToStateMap.entrySet()) { if ("ONLINE".equals(instanceState.getValue())) { String instanceId = instanceState.getKey(); _logger.info("Found ONLINE server for segment {}.", instanceId, segmentName); InstanceConfig instanceConfig = helixAdmin.getInstanceConfig(clusterName, instanceId); String hostName = instanceConfig.getHostName(); int port = getServerAdminPort(helixAdmin, clusterName, instanceId); try { onlineServerURIs.add(new URI(StringUtil .join("/", downloadScheme + "://" + hostName + ":" + port, "segments", tableNameWithType, segmentName))); } catch (URISyntaxException e) { _logger.warn("Error in uri syntax: ", e); } } } } return onlineServerURIs; }</code><technical_language>looping here? get statemap for a segment? ExternalView.getStateMap(segmentName) returns a Map<String, String> iterate on</technical_language>

Target:
public static List<URI> getPeerServerURIs(String segmentName, String downloadScheme, HelixManager helixManager) { LLCSegmentName llcSegmentName = new LLCSegmentName(segmentName); String tableNameWithType = TableNameBuilder.forType(TableType.REALTIME).tableNameWithType(llcSegmentName.getTableName()); HelixAdmin helixAdmin = helixManager.getClusterManagmentTool(); String clusterName = helixManager.getClusterName(); if (clusterName == null) { _logger.error("ClusterName not found"); return ListUtils.EMPTY_LIST; } ExternalView externalViewForResource = HelixHelper.getExternalViewForResource(helixAdmin, clusterName, tableNameWithType); if (externalViewForResource == null) { _logger.warn("External View not found for table {}", tableNameWithType); return ListUtils.EMPTY_LIST; } List<URI> onlineServerURIs = new ArrayList<>(); Map<String, String> instanceToStateMap = externalViewForResource.getStateMap(segmentName); for (Map.Entry<String, String> instanceState : instanceToStateMap.entrySet()) { if ("ONLINE".equals(instanceState.getValue())) { String instanceId = instanceState.getKey(); _logger.info("Found ONLINE server for segment {}.", instanceId, segmentName); InstanceConfig instanceConfig = helixAdmin.getInstanceConfig(clusterName, instanceId); String hostName = instanceConfig.getHostName(); int port = getServerAdminPort(helixAdmin, clusterName, instanceId); try { onlineServerURIs.add(new URI(StringUtil .join("/", downloadScheme + "://" + hostName + ":" + port, "segments", tableNameWithType, segmentName))); } catch (URISyntaxException e) { _logger.warn("Error in uri syntax: ", e); } } } return onlineServerURIs; }