-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WX-1114 Initial inclusion of Azure NIO 'fork' #7168
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
50bb6eb
WX-1114 Inital inclusion of Azure NIO 'fork'
kraefrei 23e706f
Remove tests due to artifact compile issue.
kraefrei f9511a1
Remove slf4j dependency from nio
kraefrei 8f905f6
Move nio library to top level project for compilation
kraefrei 6bc4fb6
Merge branch 'develop' into WX-1114
kraefrei 052859a
Clean up
kraefrei f2fc27f
Fix kotlin module merge strategy
kraefrei 6fecc12
Add README and clean up sdk documentation
kraefrei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Azure Storage Blob NIO FileSystemProvider | ||
|
||
[This is a copy of the NIO Filesystem implementation version 12.0.0-beta.19](https://github.com/Azure/azure-sdk-for-java/tree/2490e1e19e8531fe0a6378f40e299e7ec64cf3aa/sdk/storage/azure-storage-blob-nio) | ||
|
||
For more information on the initial design and commit history see the Azure SDK repository linked above. Changes to this repo were necessary to support some of the specific needs Cromwell as an App on Azure has as a system in Terra. This is something that has some precedent as it has been done for other filesystems in the past. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"AssetsRepo": "Azure/azure-sdk-assets", | ||
"AssetsRepoPrefixPath": "java", | ||
"TagPrefix": "java/storage/azure-storage-blob-nio", | ||
"Tag": "java/storage/azure-storage-blob-nio_b2a0ce219e" | ||
} |
69 changes: 69 additions & 0 deletions
69
azure-blob-nio/src/main/java/com/azure/storage/blob/nio/AzureBasicFileAttributeView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.storage.blob.nio; | ||
|
||
import com.azure.core.util.logging.ClientLogger; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.nio.file.attribute.BasicFileAttributeView; | ||
import java.nio.file.attribute.FileTime; | ||
|
||
/** | ||
* Provides support for basic file attributes. | ||
* <p> | ||
* The operations supported by this view and the attributes it reads are a strict subset of | ||
* {@link AzureBlobFileAttributeView} and has the same network behavior. Therefore, while this type is offered for | ||
* compliance with the NIO spec, {@link AzureBlobFileAttributeView} is generally preferred. | ||
* <p> | ||
* {@link #setTimes(FileTime, FileTime, FileTime)} is not supported. | ||
*/ | ||
public final class AzureBasicFileAttributeView implements BasicFileAttributeView { | ||
private static final ClientLogger LOGGER = new ClientLogger(AzureBasicFileAttributeView.class); | ||
|
||
static final String NAME = "azureBasic"; | ||
|
||
private final Path path; | ||
|
||
AzureBasicFileAttributeView(Path path) { | ||
this.path = path; | ||
} | ||
|
||
/** | ||
* Returns the name of the attribute view: {@code "azureBasic"} | ||
* | ||
* @return the name of the attribute view: {@code "azureBasic"} | ||
*/ | ||
@Override | ||
public String name() { | ||
return NAME; | ||
} | ||
|
||
/** | ||
* Reads the basic file attributes as a bulk operation. | ||
* <p> | ||
* All file attributes are read as an atomic operation with respect to other file system operations. | ||
* | ||
* @return {@link AzureBasicFileAttributes} | ||
*/ | ||
@Override | ||
public AzureBasicFileAttributes readAttributes() throws IOException { | ||
AzurePath.ensureFileSystemOpen(path); | ||
return new AzureBasicFileAttributes(path); | ||
} | ||
|
||
/** | ||
* Unsupported. | ||
* | ||
* @param lastModifiedTime the new last modified time, or null to not change the value | ||
* @param lastAccessTime the last access time, or null to not change the value | ||
* @param createTime the file's create time, or null to not change the value | ||
* @throws UnsupportedOperationException Operation not supported. | ||
* @throws IOException never | ||
*/ | ||
@Override | ||
public void setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime) throws IOException { | ||
throw LoggingUtility.logError(LOGGER, new UnsupportedOperationException()); | ||
} | ||
} |
165 changes: 165 additions & 0 deletions
165
azure-blob-nio/src/main/java/com/azure/storage/blob/nio/AzureBasicFileAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.storage.blob.nio; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.nio.file.attribute.BasicFileAttributes; | ||
import java.nio.file.attribute.FileAttribute; | ||
import java.nio.file.attribute.FileTime; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* Provides support for basic file attributes. | ||
* <p> | ||
* The properties available on this type are a strict subset of {@link AzureBlobFileAttributes}, and the two types have | ||
* the same network behavior. Therefore, while this type is offered for compliance with the NIO spec, | ||
* {@link AzureBlobFileAttributes} is generally preferred. | ||
* <p> | ||
* Some attributes are not supported. Refer to the javadocs on each method for more information. | ||
* <p> | ||
* If the target file is a virtual directory, most attributes will be set to null. | ||
*/ | ||
public final class AzureBasicFileAttributes implements BasicFileAttributes { | ||
// For verifying parameters on FileSystemProvider.readAttributes | ||
static final Set<String> ATTRIBUTE_STRINGS; | ||
static { | ||
Set<String> set = new HashSet<>(); | ||
set.add("lastModifiedTime"); | ||
set.add("isRegularFile"); | ||
set.add("isDirectory"); | ||
set.add("isVirtualDirectory"); | ||
set.add("isSymbolicLink"); | ||
set.add("isOther"); | ||
set.add("size"); | ||
set.add("creationTime"); | ||
ATTRIBUTE_STRINGS = Collections.unmodifiableSet(set); | ||
} | ||
|
||
private final AzureBlobFileAttributes internalAttributes; | ||
|
||
/* | ||
In order to support Files.exist() and other methods like Files.walkFileTree() which depend on it, we have had to add | ||
support for virtual directories. This is not ideal as customers will have to now perform null checks when inspecting | ||
attributes (or at least check if it is a virtual directory before inspecting properties). It also incurs extra | ||
network requests as we have to call a checkDirectoryExists() after receiving the initial 404. This is two | ||
additional network requests, though they only happen in the case when a file doesn't exist or is virtual, so it | ||
shouldn't happen in the majority of api calls. | ||
*/ | ||
AzureBasicFileAttributes(Path path) throws IOException { | ||
this.internalAttributes = new AzureBlobFileAttributes(path); | ||
} | ||
|
||
/** | ||
* Returns the time of last modification or null if this is a virtual directory. | ||
* | ||
* @return the time of last modification or null if this is a virtual directory | ||
*/ | ||
@Override | ||
public FileTime lastModifiedTime() { | ||
return this.internalAttributes.lastModifiedTime(); | ||
} | ||
|
||
/** | ||
* Returns the time of last modification or null if this is a virtual directory | ||
* <p> | ||
* Last access time is not supported by the blob service. In this case, it is typical for implementations to return | ||
* the {@link #lastModifiedTime()}. | ||
* | ||
* @return the time of last modification or null if this is a virtual directory | ||
*/ | ||
@Override | ||
public FileTime lastAccessTime() { | ||
return this.internalAttributes.lastAccessTime(); | ||
} | ||
|
||
/** | ||
* Returns the creation time. The creation time is the time that the file was created. Returns null if this is a | ||
* virtual directory. | ||
* | ||
* @return The creation time or null if this is a virtual directory | ||
*/ | ||
@Override | ||
public FileTime creationTime() { | ||
return this.internalAttributes.creationTime(); | ||
} | ||
|
||
/** | ||
* Tells whether the file is a regular file with opaque content. | ||
* | ||
* @return whether the file is a regular file. | ||
*/ | ||
@Override | ||
public boolean isRegularFile() { | ||
return this.internalAttributes.isRegularFile(); | ||
} | ||
|
||
/** | ||
* Tells whether the file is a directory. | ||
* <p> | ||
* Will only return true if the directory is a concrete directory. See | ||
* {@link AzureFileSystemProvider#createDirectory(Path, FileAttribute[])} for more information on virtual and | ||
* concrete directories. | ||
* | ||
* @return whether the file is a directory | ||
*/ | ||
@Override | ||
public boolean isDirectory() { | ||
return this.internalAttributes.isDirectory(); | ||
} | ||
|
||
/** | ||
* Tells whether the file is a virtual directory. | ||
* <p> | ||
* See {@link AzureFileSystemProvider#createDirectory(Path, FileAttribute[])} for more information on virtual and | ||
* concrete directories. | ||
* | ||
* @return whether the file is a virtual directory | ||
*/ | ||
public boolean isVirtualDirectory() { | ||
return this.internalAttributes.isVirtualDirectory(); | ||
} | ||
|
||
/** | ||
* Tells whether the file is a symbolic link. | ||
* | ||
* @return false. Symbolic links are not supported. | ||
*/ | ||
@Override | ||
public boolean isSymbolicLink() { | ||
return this.internalAttributes.isSymbolicLink(); | ||
} | ||
|
||
/** | ||
* Tells whether the file is something other than a regular file, directory, or symbolic link. | ||
* | ||
* @return false. No other object types are supported. | ||
*/ | ||
@Override | ||
public boolean isOther() { | ||
return this.internalAttributes.isOther(); | ||
} | ||
|
||
/** | ||
* Returns the size of the file (in bytes). | ||
* | ||
* @return the size of the file | ||
*/ | ||
@Override | ||
public long size() { | ||
return this.internalAttributes.size(); | ||
} | ||
|
||
/** | ||
* Returns the url of the resource. | ||
* | ||
* @return The file key, which is the url. | ||
*/ | ||
@Override | ||
public Object fileKey() { | ||
return this.internalAttributes.fileKey(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it makes sense to include the original README, CHANGELOG, and design doc in here. Maybe remove and add a new README that explains what we're doing and links out to the repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, I wasn't sure we'd keep it, but I had been thinking the initial copy should be pretty much the same, but I think I agree cleaning up irrelevant documentation won't break the bank.