Skip to content

Commit

Permalink
Add Wasbs support to Wasb Underfs
Browse files Browse the repository at this point in the history
Azure Blob Storage over https is currently unsupported by the `wasb`
underfile system; however, the version of [azure-hadoop
](https://hadoop.apache.org/docs/r2.7.3/hadoop-azure/index.html) used in
the underfs supports the https scheme (wasbs).

This PR merely changes the accepted `SCHEME` from `wasb://` to accepted
`SCHEMES` including both `wasb://` and `wasbs://`

`wasbs` support was tested by running `runUfsTests` in a k8s
installation. All tests were passed successfully.

pr-link: #10899
change-id: cid-03901dfde7792c9faf60890a45bb0d3819509831
  • Loading branch information
imiller31 committed Feb 13, 2020
1 parent acaa4db commit 6bcfc0b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,20 @@ public class WasbUnderFileSystem extends HdfsUnderFileSystem {
private static final Logger LOG = LoggerFactory.getLogger(WasbUnderFileSystem.class);

/** Constant for the wasb URI scheme. */
public static final String SCHEME = "wasb://";
public static final String SCHEME_INSECURE = "wasb://";

/** Constant for the wasbs URI scheme. */
public static final String SCHEME_SECURE = "wasbs://";

/**
* Prepares the configuration for this Wasb as an HDFS configuration.
*
* @param conf the configuration for this UFS
* @param isSecure whether blob storage is using https
* @return the created configuration
*/
public static Configuration createConfiguration(UnderFileSystemConfiguration conf) {
public static Configuration createConfiguration(UnderFileSystemConfiguration conf,
Boolean isSecure) {
Configuration wasbConf = HdfsUnderFileSystem.createConfiguration(conf);
for (Map.Entry<String, String> entry : conf.toMap().entrySet()) {
String key = entry.getKey();
Expand All @@ -53,8 +58,13 @@ public static Configuration createConfiguration(UnderFileSystemConfiguration con
wasbConf.set(key, value);
}
}
wasbConf.set("fs.AbstractFileSystem.wasb.impl", "org.apache.hadoop.fs.azure.Wasb");
wasbConf.set("fs.wasb.impl", "org.apache.hadoop.fs.azure.NativeAzureFileSystem");
if (isSecure) {
wasbConf.set("fs.AbstractFileSystem.wasbs.impl", "org.apache.hadoop.fs.azure.Wasbs");
wasbConf.set("fs.wasbs.impl", "org.apache.hadoop.fs.azure.NativeAzureFileSystem");
} else {
wasbConf.set("fs.AbstractFileSystem.wasb.impl", "org.apache.hadoop.fs.azure.Wasb");
wasbConf.set("fs.wasb.impl", "org.apache.hadoop.fs.azure.NativeAzureFileSystem");
}
return wasbConf;
}

Expand All @@ -67,7 +77,7 @@ public static Configuration createConfiguration(UnderFileSystemConfiguration con
*/
public static WasbUnderFileSystem createInstance(AlluxioURI uri,
UnderFileSystemConfiguration conf) {
Configuration wasbConf = createConfiguration(conf);
Configuration wasbConf = createConfiguration(conf, uri.getScheme().startsWith(SCHEME_SECURE));
return new WasbUnderFileSystem(uri, conf, wasbConf);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public UnderFileSystem create(String path, UnderFileSystemConfiguration conf) {

@Override
public boolean supportsPath(String path) {
return path != null && path.startsWith(WasbUnderFileSystem.SCHEME);
return path != null
&& (path.startsWith(WasbUnderFileSystem.SCHEME_SECURE)
|| path.startsWith(WasbUnderFileSystem.SCHEME_INSECURE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public void factory() {
"A UnderFileSystemFactory should exist for wasb paths when using this module",
factory);

factory = UnderFileSystemFactoryRegistry.find("wasbs://localhost/test/path", conf);
Assert.assertNotNull(
"A UnderFileSystemFactory should exist for wasbs paths when using this module",
factory);

factory = UnderFileSystemFactoryRegistry.find("alluxio://localhost/test/path", conf);
Assert.assertNull("A UnderFileSystemFactory should not exist for unsupported paths when using"
+ " this module.", factory);
Expand Down

0 comments on commit 6bcfc0b

Please sign in to comment.