@@ -177,7 +177,13 @@ public software.amazon.awssdk.services.s3.model.UploadPartResponse uploadPart(
177177
178178 /** Creates default PutObjectOptions for Hadoop 3.4.2. */
179179 private static org .apache .hadoop .fs .s3a .impl .PutObjectOptions createDefaultPutObjectOptions () {
180- return org .apache .hadoop .fs .s3a .impl .PutObjectOptions .keepingDirs ();
180+ org .apache .hadoop .fs .s3a .impl .PutObjectOptions options = org .apache .hadoop .fs .s3a .impl .PutObjectOptions .keepingDirs ();
181+
182+ // Log conditional write configuration
183+ LOG .info ("=== CONDITIONAL WRITES: Creating PutObjectOptions with keepingDirs() - Hadoop 3.4.2 ===" );
184+ LOG .info ("=== PutObjectOptions details: {} ===" , options .toString ());
185+
186+ return options ;
181187 }
182188
183189 /**
@@ -413,11 +419,18 @@ private static void validateOutputFile(File file) {
413419 public String startMultiPartUpload (String key ) throws IOException {
414420 validateKey (key );
415421 try {
422+ LOG .info ("=== CONDITIONAL WRITES: Initiating multipart upload for key: {} ===" , key );
423+
416424 // Hadoop 3.4.2 uses AWS SDK v2 and requires PutObjectOptions
417- String uploadId =
418- s3accessHelper .initiateMultiPartUpload (key , createDefaultPutObjectOptions ());
425+ org .apache .hadoop .fs .s3a .impl .PutObjectOptions putObjectOptions = createDefaultPutObjectOptions ();
426+ LOG .info ("=== CONDITIONAL WRITES: Using PutObjectOptions: {} ===" , putObjectOptions );
427+
428+ String uploadId = s3accessHelper .initiateMultiPartUpload (key , putObjectOptions );
429+
430+ LOG .info ("=== CONDITIONAL WRITES: Multipart upload initiated successfully. UploadId: {} ===" , uploadId );
419431 return uploadId ;
420432 } catch (Exception e ) {
433+ LOG .error ("=== CONDITIONAL WRITES: Failed to initiate multipart upload for key: {} - Error: {} ===" , key , e .getMessage ());
421434 throw e ;
422435 }
423436 }
@@ -481,6 +494,10 @@ public UploadPartResult uploadPart(
481494 public PutObjectResult putObject (String key , File inputFile ) throws IOException {
482495 validateKey (key );
483496 validateInputFile (inputFile );
497+
498+ LOG .info ("=== CONDITIONAL WRITES: Putting object for key: {}, file size: {} bytes ===" ,
499+ key , inputFile .length ());
500+
484501 // Hadoop 3.4.2 uses AWS SDK v2 with different put object API
485502 // Create AWS SDK v2 PutObjectRequest with correct bucket name
486503 software .amazon .awssdk .services .s3 .model .PutObjectRequest putRequest =
@@ -493,6 +510,8 @@ public PutObjectResult putObject(String key, File inputFile) throws IOException
493510 // Create PutObjectOptions
494511 org .apache .hadoop .fs .s3a .impl .PutObjectOptions putObjectOptions =
495512 createDefaultPutObjectOptions ();
513+
514+ LOG .info ("=== CONDITIONAL WRITES: Using PutObjectOptions for putObject: {} ===" , putObjectOptions );
496515
497516 // Note: For Hadoop 3.4.2, the putObject API with BlockUploadData is designed for
498517 // block-based uploads from memory. For file-based uploads, it's more appropriate
@@ -532,6 +551,9 @@ public PutObjectResult putObject(String key, File inputFile) throws IOException
532551 result .setSSECustomerAlgorithm (response .sseCustomerAlgorithm ());
533552 }
534553
554+ LOG .info ("=== CONDITIONAL WRITES: PutObject completed successfully for key: {}, ETag: {} ===" ,
555+ key , result .getETag ());
556+
535557 return result ;
536558
537559 } catch (software .amazon .awssdk .core .exception .SdkException e ) {
@@ -572,6 +594,12 @@ public CompleteMultipartUploadResult commitMultiPartUpload(
572594 .build ())
573595 .collect (java .util .stream .Collectors .toList ());
574596
597+ LOG .info ("=== CONDITIONAL WRITES: Completing multipart upload for key: {}, uploadId: {}, parts: {} ===" ,
598+ destKey , uploadId , partETags .size ());
599+
600+ org .apache .hadoop .fs .s3a .impl .PutObjectOptions putObjectOptions = createDefaultPutObjectOptions ();
601+ LOG .info ("=== CONDITIONAL WRITES: Using PutObjectOptions for completion: {} ===" , putObjectOptions );
602+
575603 // Use the new completeMPUwithRetries API
576604 software .amazon .awssdk .services .s3 .model .CompleteMultipartUploadResponse response =
577605 s3accessHelper .completeMPUwithRetries (
@@ -580,7 +608,10 @@ public CompleteMultipartUploadResult commitMultiPartUpload(
580608 completedParts ,
581609 length ,
582610 errorCount ,
583- createDefaultPutObjectOptions ());
611+ putObjectOptions );
612+
613+ LOG .info ("=== CONDITIONAL WRITES: Multipart upload completed successfully for key: {}, ETag: {} ===" ,
614+ destKey , response .eTag ());
584615
585616 // Convert AWS SDK v2 response to AWS SDK v1 response
586617 CompleteMultipartUploadResult result = new CompleteMultipartUploadResult ();
0 commit comments