npawar commented on a change in pull request #6740:
URL: https://github.com/apache/incubator-pinot/pull/6740#discussion_r610161942



##########
File path: 
pinot-plugins/pinot-segment-uploader/pinot-segment-uploader-default/src/main/java/org/apache/pinot/plugin/segmentuploader/SegmentUploaderDefault.java
##########
@@ -0,0 +1,100 @@
+/**
+ * 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.plugin.segmentuploader;
+
+import com.google.common.base.Preconditions;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.core.util.IngestionUtils;
+import org.apache.pinot.spi.auth.AuthContext;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.filesystem.PinotFS;
+import org.apache.pinot.spi.ingestion.batch.BatchConfig;
+import org.apache.pinot.spi.ingestion.batch.BatchConfigProperties;
+import org.apache.pinot.spi.ingestion.batch.spec.Constants;
+import org.apache.pinot.spi.ingestion.segment.uploader.SegmentUploader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Default implementation of {@link SegmentUploader} with support for all push 
modes
+ * The configs for push are fetched from batchConfigMaps of tableConfig
+ */
+public class SegmentUploaderDefault implements SegmentUploader {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(SegmentUploaderDefault.class);
+
+  private String _tableNameWithType;
+  private BatchConfig _batchConfig;
+
+  @Override
+  public void init(TableConfig tableConfig)
+      throws Exception {
+    _tableNameWithType = tableConfig.getTableName();
+
+    Preconditions.checkState(
+        tableConfig.getIngestionConfig() != null && 
tableConfig.getIngestionConfig().getBatchIngestionConfig() != null
+            && CollectionUtils
+            
.isNotEmpty(tableConfig.getIngestionConfig().getBatchIngestionConfig().getBatchConfigMaps()),
+        "Must provide ingestionConfig->batchIngestionConfig->batchConfigMaps 
in tableConfig for table: %s",
+        _tableNameWithType);
+    Preconditions
+        
.checkState(tableConfig.getIngestionConfig().getBatchIngestionConfig().getBatchConfigMaps().size()
 == 1,
+            "batchConfigMaps must contain only 1 BatchConfig for table: %s", 
_tableNameWithType);
+    _batchConfig = new BatchConfig(_tableNameWithType,
+        
tableConfig.getIngestionConfig().getBatchIngestionConfig().getBatchConfigMaps().get(0));
+
+    
Preconditions.checkState(StringUtils.isNotBlank(_batchConfig.getPushControllerURI()),
+        "Must provide: %s in batchConfigs for table: %s", 
BatchConfigProperties.PUSH_CONTROLLER_URI,
+        _tableNameWithType);
+
+    LOGGER.info("Initialized {} for table: {}", 
SegmentUploaderDefault.class.getName(), _tableNameWithType);
+  }
+
+  @Override
+  public void uploadSegment(URI segmentTarURI, @Nullable AuthContext 
authContext)
+      throws Exception {
+    IngestionUtils
+        .uploadSegment(_tableNameWithType, _batchConfig, 
Collections.singletonList(segmentTarURI), authContext);
+    LOGGER.info("Successfully uploaded segment: {} to table: {}", 
segmentTarURI, _tableNameWithType);
+  }
+
+  @Override
+  public void uploadSegments(URI segmentDir, @Nullable AuthContext authContext)

Review comment:
       Yes agreed. It also made me uncomfortable that the only visual 
difference between the 2 methods was an 's' at the end




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