|
70 | 70 | import org.apache.hadoop.fs.azurebfs.constants.HttpHeaderConfigurations;
|
71 | 71 | import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
|
72 | 72 | import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AzureBlobFileSystemException;
|
73 |
| -import org.apache.hadoop.fs.azurebfs.contracts.exceptions.ConcurrentWriteOperationDetectedException; |
74 | 73 | import org.apache.hadoop.fs.azurebfs.contracts.exceptions.FileSystemOperationUnhandledException;
|
75 | 74 | import org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidAbfsRestOperationException;
|
76 | 75 | import org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidFileSystemPropertyException;
|
@@ -762,53 +761,8 @@ private AbfsRestOperation conditionalCreateOverwriteFile(final String relativePa
|
762 | 761 | final TracingContext tracingContext) throws IOException {
|
763 | 762 | AbfsRestOperation op;
|
764 | 763 | AbfsClient createClient = getClientHandler().getIngressClient();
|
765 |
| - try { |
766 |
| - // Trigger a create with overwrite=false first so that eTag fetch can be |
767 |
| - // avoided for cases when no pre-existing file is present (major portion |
768 |
| - // of create file traffic falls into the case of no pre-existing file). |
769 |
| - op = createClient.createPath(relativePath, true, false, permissions, |
770 |
| - isAppendBlob, null, contextEncryptionAdapter, tracingContext); |
771 |
| - |
772 |
| - } catch (AbfsRestOperationException e) { |
773 |
| - if (e.getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { |
774 |
| - // File pre-exists, fetch eTag |
775 |
| - try { |
776 |
| - op = getClient().getPathStatus(relativePath, false, tracingContext, null); |
777 |
| - } catch (AbfsRestOperationException ex) { |
778 |
| - if (ex.getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { |
779 |
| - // Is a parallel access case, as file which was found to be |
780 |
| - // present went missing by this request. |
781 |
| - throw new ConcurrentWriteOperationDetectedException( |
782 |
| - "Parallel access to the create path detected. Failing request " |
783 |
| - + "to honor single writer semantics"); |
784 |
| - } else { |
785 |
| - throw ex; |
786 |
| - } |
787 |
| - } |
788 |
| - |
789 |
| - String eTag = extractEtagHeader(op.getResult()); |
790 |
| - |
791 |
| - try { |
792 |
| - // overwrite only if eTag matches with the file properties fetched befpre |
793 |
| - op = createClient.createPath(relativePath, true, true, permissions, |
794 |
| - isAppendBlob, eTag, contextEncryptionAdapter, tracingContext); |
795 |
| - } catch (AbfsRestOperationException ex) { |
796 |
| - if (ex.getStatusCode() == HttpURLConnection.HTTP_PRECON_FAILED) { |
797 |
| - // Is a parallel access case, as file with eTag was just queried |
798 |
| - // and precondition failure can happen only when another file with |
799 |
| - // different etag got created. |
800 |
| - throw new ConcurrentWriteOperationDetectedException( |
801 |
| - "Parallel access to the create path detected. Failing request " |
802 |
| - + "to honor single writer semantics"); |
803 |
| - } else { |
804 |
| - throw ex; |
805 |
| - } |
806 |
| - } |
807 |
| - } else { |
808 |
| - throw e; |
809 |
| - } |
810 |
| - } |
811 |
| - |
| 764 | + op = createClient.conditionalCreateOverwriteFile(relativePath, statistics, |
| 765 | + permissions, isAppendBlob, contextEncryptionAdapter, tracingContext); |
812 | 766 | return op;
|
813 | 767 | }
|
814 | 768 |
|
|
0 commit comments