nishantmonu51 commented on a change in pull request #7537:  Avoid file rename 
when pushing segments with HDFSDataPusher
URL: https://github.com/apache/incubator-druid/pull/7537#discussion_r297746694
 
 

 ##########
 File path: 
extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusher.java
 ##########
 @@ -107,55 +106,28 @@ public DataSegment push(final File inDir, final 
DataSegment segment, final boole
         fullyQualifiedStorageDirectory.get(),
         storageDir
     );
+    final String uniquePrefix = useUniquePath ? 
DataSegmentPusher.generateUniquePath() + "_" : "";
 
-    Path tmpIndexFile = new Path(StringUtils.format(
-        "%s/%s/%s/%s_index.zip",
+    final Path outIndexFile = new Path(StringUtils.format(
+        "%s/%s/%d_%sindex.zip",
         fullyQualifiedStorageDirectory.get(),
-        segment.getDataSource(),
-        UUIDUtils.generateUuid(),
-        segment.getShardSpec().getPartitionNum()
+        storageDir,
+        segment.getShardSpec().getPartitionNum(),
+        uniquePrefix
     ));
-    FileSystem fs = tmpIndexFile.getFileSystem(hadoopConfig);
-
-    fs.mkdirs(tmpIndexFile.getParent());
-    log.info("Compressing files from[%s] to [%s]", inDir, tmpIndexFile);
+    FileSystem fs = outIndexFile.getFileSystem(hadoopConfig);
+    // Create parent if it does not exist, recreation is not an error
+    fs.mkdirs(outIndexFile.getParent());
+    log.info("Compressing files from[%s] to [%s]", inDir, outIndexFile);
 
     final long size;
-    final DataSegment dataSegment;
-    try {
-      try (FSDataOutputStream out = fs.create(tmpIndexFile)) {
-        size = CompressionUtils.zip(inDir, out);
-      }
-
-      final String uniquePrefix = useUniquePath ? 
DataSegmentPusher.generateUniquePath() + "_" : "";
-      final Path outIndexFile = new Path(StringUtils.format(
-          "%s/%s/%d_%sindex.zip",
-          fullyQualifiedStorageDirectory.get(),
-          storageDir,
-          segment.getShardSpec().getPartitionNum(),
-          uniquePrefix
-      ));
-
-      dataSegment = segment.withLoadSpec(makeLoadSpec(outIndexFile.toUri()))
-                           .withSize(size)
-                           
.withBinaryVersion(SegmentUtils.getVersionFromDir(inDir));
-
-      // Create parent if it does not exist, recreation is not an error
-      fs.mkdirs(outIndexFile.getParent());
-      copyFilesWithChecks(fs, tmpIndexFile, outIndexFile);
-    }
-    finally {
-      try {
-        if (fs.exists(tmpIndexFile.getParent()) && 
!fs.delete(tmpIndexFile.getParent(), true)) {
-          log.error("Failed to delete temp directory[%s]", 
tmpIndexFile.getParent());
-        }
-      }
-      catch (IOException ex) {
-        log.error(ex, "Failed to delete temp directory[%s]", 
tmpIndexFile.getParent());
-      }
+    try (FSDataOutputStream out = fs.create(outIndexFile)) {
 
 Review comment:
   done, have set overwrite to false.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to