mcvsubbu commented on a change in pull request #3541: Adding pluggable storage 
support for realtime upload
URL: https://github.com/apache/incubator-pinot/pull/3541#discussion_r236452700
 
 

 ##########
 File path: 
pinot-controller/src/main/java/com/linkedin/pinot/controller/api/resources/LLCSegmentCompletionHandlers.java
 ##########
 @@ -300,27 +303,48 @@ private String uploadSegment(FormDataMultiPart 
multiPart, String instanceId, Str
       FormDataBodyPart bodyPart = map.get(name).get(0);
 
       FileUploadPathProvider provider = new 
FileUploadPathProvider(_controllerConf);
-      File tmpFile = new File(provider.getFileUploadTmpDir(), name + "." + 
UUID.randomUUID().toString());
-      tmpFile.deleteOnExit();
 
+      String tmpFilePath = StringUtil.join("/", 
provider.getFileUploadTmpDirURI().toString(), name + "." + 
UUID.randomUUID().toString());
+      java.net.URI tmpFileURI = ControllerConf.getUriFromPath(tmpFilePath);
+
+      PinotFS pinotFS = PinotFSFactory.create(tmpFileURI.getScheme());
+
+      File localTmpFile = new File(provider.getFileUploadTmpDir(), name + "." 
+ UUID.randomUUID().toString());
+      localTmpFile.deleteOnExit();
+
+      // Copy multipart to local
       try (InputStream inputStream = bodyPart.getValueAs(InputStream.class);
-          OutputStream outputStream = new FileOutputStream(tmpFile)) {
+          OutputStream outputStream = new FileOutputStream(localTmpFile)) {
         IOUtils.copyLarge(inputStream, outputStream);
       }
 
+      // If remote, will need to copy tmp file to remote storage
 
 Review comment:
   The existing logic is:
   
   Pull the bytes off off http post stream and store it to tmpFile
   if (splitcommit) {
     target = uniqueFileName
   } else {
     target = finalSegmentDestination
   }
   move tmpFile to target
   
   Can we do the same in the new logic?
   
   Also, since we are using 'copy' operation now, we need to delete tmpFile.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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