wirybeaver commented on code in PR #17521:
URL: https://github.com/apache/pinot/pull/17521#discussion_r2970739160


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/replication/RealtimeSegmentCopier.java:
##########
@@ -0,0 +1,177 @@
+/**
+ * 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.controller.helix.core.replication;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
+import org.apache.pinot.common.exception.HttpErrorStatusException;
+import org.apache.pinot.common.utils.FileUploadDownloadClient;
+import org.apache.pinot.common.utils.SimpleHttpResponse;
+import org.apache.pinot.common.utils.http.HttpClient;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.api.resources.CopyTablePayload;
+import org.apache.pinot.spi.filesystem.PinotFS;
+import org.apache.pinot.spi.filesystem.PinotFSFactory;
+import org.apache.pinot.spi.utils.retry.RetryPolicies;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Copies a realtime segment from source to destination.
+ */
+public class RealtimeSegmentCopier implements SegmentCopier {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(RealtimeSegmentCopier.class);
+  private static final String SEGMENT_UPLOAD_ENDPOINT_TEMPLATE = 
"/segments?tableName=%s";
+
+  private final String _destinationDeepStoreUri;
+  private final HttpClient _httpClient;
+
+  public RealtimeSegmentCopier(ControllerConf controllerConf) {
+    this(controllerConf, HttpClient.getInstance());
+  }
+
+  public RealtimeSegmentCopier(ControllerConf controllerConf, HttpClient 
httpClient) {
+    _destinationDeepStoreUri = controllerConf.getDataDir();
+    _httpClient = httpClient;
+  }
+
+
+  /**
+   * Copies a segment to the destination cluster.
+   *
+   * This method performs the following steps:
+   * 1. Get the source segment URI from ZK metadata.
+   * 2. Copy the segment from the source deep store to the destination deep 
store.
+   * 3. Upload the segment to the destination controller.
+   *
+   * @param tableNameWithType Table name with type suffix
+   * @param segmentName Segment name
+   * @param copyTablePayload Payload for copying a table
+   * @param segmentZKMetadata ZK metadata for the segment
+   */
+  @Override
+  public void copy(String tableNameWithType, String segmentName, 
CopyTablePayload copyTablePayload,
+      Map<String, String> segmentZKMetadata) {
+    if (!tableNameWithType.endsWith("_REALTIME")) {
+      throw new IllegalArgumentException("Table name must end with _REALTIME");
+    }
+    String tableName = tableNameWithType.substring(0, 
tableNameWithType.lastIndexOf("_REALTIME"));
+    try {
+      // 1. Get the the source segment uri
+      String downloadUrl = segmentZKMetadata.get("segment.download.url");

Review Comment:
   Done — using `CommonConstants.Segment.DOWNLOAD_URL`.



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/CopyTablePayload.java:
##########
@@ -40,6 +61,14 @@ public class CopyTablePayload {
    * MUST NOT contain the tenant type suffix, i.e. _REALTIME or _OFFLINE.
    */
   private String _serverTenant;
+  private Integer _backfillParallism;

Review Comment:
   Done — fixed to `backfillParallelism` throughout (field, JSON property, 
getter).



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