chenboat commented on a change in pull request #5336:
URL: https://github.com/apache/incubator-pinot/pull/5336#discussion_r422427031



##########
File path: 
pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/PeerServerSegmentFetcher.java
##########
@@ -0,0 +1,149 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.common.utils.fetcher;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import org.apache.commons.configuration.Configuration;
+import org.apache.helix.HelixAdmin;
+import org.apache.helix.HelixManager;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.InstanceConfig;
+import org.apache.pinot.common.utils.CommonConstants;
+import org.apache.pinot.common.utils.LLCSegmentName;
+import org.apache.pinot.common.utils.StringUtil;
+import org.apache.pinot.common.utils.helix.HelixHelper;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.plugin.PluginManager;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This segment fetcher downloads the segment by first discovering the server 
having the segment through external view
+ * of a Pinot table and then downloading the segment from the peer server 
using a configured http or https fetcher. By
+ * default, HttpSegmentFetcher is used.
+ * The format fo expected segment address uri is
+ *    server:///segment_name
+ * Note the host component is empty.
+ * To use this segment fetcher, servers need to put "server" in their segment 
fetcher protocol.
+ */
+public class PeerServerSegmentFetcher extends BaseSegmentFetcher {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(PeerServerSegmentFetcher.class);
+  private static final String PEER_2_PEER_PROTOCOL = "server";
+  private static final String DOWNLOADER_CLASS = ".downloader.class";
+  private HelixManager _helixManager;
+  private String _helixClusterName;
+  private HttpSegmentFetcher _httpSegmentFetcher;
+
+  public PeerServerSegmentFetcher(Configuration config, HelixManager 
helixManager, String helixClusterName) {
+    _helixManager = helixManager;
+    _helixClusterName = helixClusterName;
+    String segmentDownloaderClass = config.getString(PEER_2_PEER_PROTOCOL + 
DOWNLOADER_CLASS);
+    try {
+      _httpSegmentFetcher = 
PluginManager.get().createInstance(segmentDownloaderClass);

Review comment:
       The config I use now passed in the fetcher class (mainly for ease of 
testing). I can pass in scheme (http or https) too together with the class. But 
let us put this config choice in a broader discussion we had offline so that we 
plan everything in one discussion.




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to