Browse Source

HADOOP-15506. Upgrade Azure Storage Sdk version to 7.0.0 and update corresponding code blocks.
Contributed by Esfandiar Manii.

(cherry picked from commit d901be679554eb6b323f3bc6e8de267d85dd2e06)
(cherry picked from commit baac7c2b285454d71d0371505fb7a3403a548176)
(cherry picked from commit df338f2e1a19ed9c0c5c13f7d4aad08f9836de9f)

Steve Loughran 7 years ago
parent
commit
0b5d0c3740

+ 6 - 0
hadoop-project/pom.xml

@@ -1100,6 +1100,12 @@
         <version>2.9.1</version>
         <version>2.9.1</version>
       </dependency>
       </dependency>
 
 
+      <dependency>
+        <groupId>com.microsoft.azure</groupId>
+        <artifactId>azure-storage</artifactId>
+        <version>7.0.0</version>
+      </dependency>
+
       <dependency>
       <dependency>
         <groupId>com.aliyun.oss</groupId>
         <groupId>com.aliyun.oss</groupId>
         <artifactId>aliyun-sdk-oss</artifactId>
         <artifactId>aliyun-sdk-oss</artifactId>

+ 3 - 1
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/NativeAzureFileSystemHelper.java

@@ -87,8 +87,10 @@ final class NativeAzureFileSystemHelper {
     if (errorCode != null
     if (errorCode != null
         && (errorCode.equals(StorageErrorCodeStrings.BLOB_NOT_FOUND)
         && (errorCode.equals(StorageErrorCodeStrings.BLOB_NOT_FOUND)
             || errorCode.equals(StorageErrorCodeStrings.RESOURCE_NOT_FOUND)
             || errorCode.equals(StorageErrorCodeStrings.RESOURCE_NOT_FOUND)
+            || errorCode.equals(StorageErrorCodeStrings.CONTAINER_NOT_FOUND)
             || errorCode.equals(StorageErrorCode.BLOB_NOT_FOUND.toString())
             || errorCode.equals(StorageErrorCode.BLOB_NOT_FOUND.toString())
-            || errorCode.equals(StorageErrorCode.RESOURCE_NOT_FOUND.toString()))) {
+            || errorCode.equals(StorageErrorCode.RESOURCE_NOT_FOUND.toString())
+            || errorCode.equals(StorageErrorCode.CONTAINER_NOT_FOUND.toString()))) {
 
 
       return true;
       return true;
     }
     }

+ 6 - 3
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestContainerChecks.java

@@ -75,7 +75,7 @@ public class ITestContainerChecks extends AbstractWasbTestWithTimeout {
       assertTrue("Should've thrown.", false);
       assertTrue("Should've thrown.", false);
     } catch (FileNotFoundException ex) {
     } catch (FileNotFoundException ex) {
       assertTrue("Unexpected exception: " + ex,
       assertTrue("Unexpected exception: " + ex,
-          ex.getMessage().contains("does not exist."));
+          ex.getMessage().contains("is not found"));
     }
     }
     assertFalse(container.exists());
     assertFalse(container.exists());
 
 
@@ -115,7 +115,7 @@ public class ITestContainerChecks extends AbstractWasbTestWithTimeout {
       assertTrue("Should've thrown.", false);
       assertTrue("Should've thrown.", false);
     } catch (FileNotFoundException ex) {
     } catch (FileNotFoundException ex) {
       assertTrue("Unexpected exception: " + ex,
       assertTrue("Unexpected exception: " + ex,
-          ex.getMessage().contains("does not exist."));
+          ex.getMessage().contains("is not found"));
     }
     }
     assertFalse(container.exists());
     assertFalse(container.exists());
 
 
@@ -143,7 +143,7 @@ public class ITestContainerChecks extends AbstractWasbTestWithTimeout {
       assertTrue("Should've thrown.", false);
       assertTrue("Should've thrown.", false);
     } catch (FileNotFoundException ex) {
     } catch (FileNotFoundException ex) {
       assertTrue("Unexpected exception: " + ex,
       assertTrue("Unexpected exception: " + ex,
-          ex.getMessage().contains("does not exist."));
+          ex.getMessage().contains("is not found"));
     }
     }
     assertFalse(container.exists());
     assertFalse(container.exists());
 
 
@@ -165,6 +165,9 @@ public class ITestContainerChecks extends AbstractWasbTestWithTimeout {
     assertFalse(fs.rename(foo, bar));
     assertFalse(fs.rename(foo, bar));
     assertFalse(container.exists());
     assertFalse(container.exists());
 
 
+    // Create a container outside of the WASB FileSystem
+    container.create();
+
     // But a write should.
     // But a write should.
     assertTrue(fs.createNewFile(foo));
     assertTrue(fs.createNewFile(foo));
     assertTrue(container.exists());
     assertTrue(container.exists());