Skip to content

Commit 26c61a2

Browse files
committed
refine the upload path in gen2 deploy
1 parent 8dc3543 commit 26c61a2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Utils/hdinsight-node-common/src/com/microsoft/azure/hdinsight/spark/common/ADLSGen2Deploy.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import java.io.File;
4040
import java.net.URI;
4141
import java.net.URISyntaxException;
42+
import java.util.regex.Matcher;
43+
import java.util.regex.Pattern;
4244

4345
public class ADLSGen2Deploy implements Deployable, ILogger {
4446
@NotNull
@@ -97,8 +99,12 @@ public Observable<String> deploy(@NotNull File src) {
9799

98100
@Nullable
99101
private String getArtifactUploadedPath(String rootPath) throws URISyntaxException {
100-
//convert https://fullAccountName/fileSystem/sparksubmission/guid/artifact.jar to /SparkSubmission/xxxx
101-
int index = rootPath.indexOf("SparkSubmission");
102-
return String.format("/%s", rootPath.substring(index));
102+
//convert https://fullAccountName/fileSystem/subfolder/guid/artifact.jar to /subfolder/xxxx
103+
Matcher m = Pattern.compile(SparkBatchJob.AdlsGen2RestfulPathPattern).matcher(rootPath);
104+
if (m.find()) {
105+
return m.group("subpath");
106+
}
107+
108+
throw new URISyntaxException(rootPath, "Cannot get valid artifact path");
103109
}
104110
}

Utils/hdinsight-node-common/src/com/microsoft/azure/hdinsight/spark/common/SparkBatchJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
public class SparkBatchJob implements ISparkBatchJob, ILogger {
6666
public static final String WebHDFSPathPattern = "^(https?://)([^/]+)(/.*)?(/webhdfs/v1)(/.*)?$";
67-
public static final String AdlsGen2RestfulPathPattern = "^(https://)(?<accountName>[^/.\\s]+)(\\.)(dfs\\.core\\.windows\\.net)(/)(?<fileSystem>[^/.\\s]+)(/[^/.\\s]+)*/?$";
67+
public static final String AdlsGen2RestfulPathPattern = "^(https://)(?<accountName>[^/.\\s]+)(\\.)(dfs\\.core\\.windows\\.net)(/)(?<fileSystem>[^/.\\s]+)(?<subpath>/[^\\s]+)*/?$";
6868

6969
@Nullable
7070
private String currentLogUrl;

0 commit comments

Comments
 (0)