ankitsultana commented on code in PR #12960:
URL: https://github.com/apache/pinot/pull/12960#discussion_r1605379781


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/generator/BaseTaskGenerator.java:
##########
@@ -131,4 +140,44 @@ public void generateTasks(List<TableConfig> tableConfigs, 
List<PinotTaskConfig>
   public String getMinionInstanceTag(TableConfig tableConfig) {
     return TaskGeneratorUtils.extractMinionInstanceTag(tableConfig, 
getTaskType());
   }
+
+  @Override
+  public boolean isAllowDownloadFromServer(TableConfig tableConfig) {
+    return 
TaskGeneratorUtils.extractMinionAllowDownloadFromServer(tableConfig, 
getTaskType());
+  }
+
+  public List<URI> getSegmentServerURIs(TableConfig tableConfig, String 
segmentName) {
+    String peerDownloadScheme = 
tableConfig.getValidationConfig().getPeerSegmentDownloadScheme();
+    List<URI> segmentServerURIs = PeerServerSegmentFinder.getPeerServerURIs(
+        
_clusterInfoAccessor.getPinotHelixResourceManager().getHelixZkManager(),
+        tableConfig.getTableName(), segmentName, peerDownloadScheme);
+    Collections.shuffle(segmentServerURIs);
+    return segmentServerURIs;
+  }
+
+  public Map<String, String> getBaseTaskConfigs(TableConfig tableConfig, 
List<String> segmentNames) {
+    Map<String, String> baseConfigs = new HashMap<>();
+    baseConfigs.put(MinionConstants.TABLE_NAME_KEY, 
tableConfig.getTableName());
+    baseConfigs.put(MinionConstants.SEGMENT_NAME_KEY, 
StringUtils.join(segmentNames,
+          MinionConstants.SEGMENT_NAME_SEPARATOR));
+    Map<String, List<String>> segmentServerUriMap = new HashMap<>();
+    if (isAllowDownloadFromServer(tableConfig)) {
+      segmentServerUriMap = segmentNames.stream()
+          .collect(Collectors.toMap(
+              segmentName -> segmentName,
+              segmentName -> getSegmentServerURIs(tableConfig, segmentName)

Review Comment:
   `getSegmentServerURIs` incurs a call to fetch the EV, so we will end up 
making the same call num-segment times. Maybe we can refactor 
`PeerServerSegmentFinder` so it can take in a list of segments by default? We 
could still keep the existing top-level method `getPeerServerURIs` which can 
simply delegate to the more general method.



##########
pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/BaseTaskExecutor.java:
##########
@@ -101,4 +109,26 @@ private void addTaskMeterMetrics(MinionMeter meter, long 
unitCount, String table
     _minionMetrics.addMeteredTableValue(tableName, meter, unitCount);
     _minionMetrics.addMeteredTableValue(tableName, taskType, meter, unitCount);
   }
+
+  protected void downloadSegmentToLocal(String tableNameWithType, String 
segmentName, String deepstoreURL,
+      Map<String, List<String>> segmentServiceUrisList, File 
tarredSegmentFile, String crypterName)
+      throws Exception {
+    LOGGER.info("Downloading segment from {} to {}", deepstoreURL, 
tarredSegmentFile.getAbsolutePath());
+    try {
+      // download from deepstore first
+      SegmentFetcherFactory.fetchAndDecryptSegmentToLocal(deepstoreURL, 
tarredSegmentFile, crypterName);
+    } catch (Exception e) {
+      LOGGER.error("Segment download failed from deepstore for {}, 
crypter:{}", deepstoreURL, crypterName, e);
+      if (!segmentServiceUrisList.isEmpty()) {
+        LOGGER.info("Trying to download form servers for segment {} post 
deepstore download failed", segmentName);

Review Comment:
   nit: `form` ==> `from`



-- 
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]

Reply via email to