-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Nio set default configurations #27340
Conversation
This reverts commit f47c221.
API changes have been detected in API changes + public static void setDefaultConfigurations(Map<String, Object> config) |
|
||
// Specs require a public zero argument constructor. | ||
/** | ||
* Creates an AzureFileSystemProvider. | ||
*/ | ||
public AzureFileSystemProvider() { | ||
this.openFileSystems = new ConcurrentHashMap<>(); | ||
Configuration config = Configuration.getGlobalConfiguration(); |
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.
Are there scenarios where user can call AzureFileSystemProvider
ctor directly? If yes we could consider adding AzureFileSystemProvider(Configuration)
overload in case somebody would like to customize configuration source.
Btw. what do we do with config
? it doesn't seem to be consumed anyhow.
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.
This was left over from when the original request was to set defaults from the environment, but the customer ask has changed to setting them on a static method. I thought I had reverted all the commits about environment reading but it looks like I missed one.
But in general no, there customer does not generally use the constructor directly. The jvm's ClassLoader will find it an initialize it
* | ||
* @param config The configurations map. Please see the docs on {@link AzureFileSystemProvider for more information} | ||
*/ | ||
public static void setDefaultConfigurations(Map<String, Object> config) { |
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.
is there any alternative design where this doesn't have to be a global ?
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 think the request was that it be global. What are your concerns around that? Perhaps I can find another way to address those and meet the customer ask.
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.
There's plenty of literature why global variables are dangerous. In this particular case the concern would be that users can modify this in flight while application is in the middle of processing workload which can potentially open a can of interesting race conditions for them.
On the other hand I understand the need for this convenience given that it's not the user interacting with types in this package but NIO magic doing it for them.
It seems the scenario here is to be able programmatically configure this at the startup of the application. I suggest we implement it in such a way that this configuration can be set only once during lifetime of user's program, so that they won't be tempted to modifying those settings in-flight.
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.
Makes sense. I can add an if statement to see if the values have already been set and throw if they have. I think that can satisfy the temptation to change things mid run, but if you are still more concerned about race conditions, I could try doing something with atomic values to prevent the chance of even very tight concurrent updates on startup. The latter strikes me as overkill personally
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.
"Double checked lock" might be good candidate for that.
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'll look into that and put something up for your consideration.
* @param config The configurations map. Please see the docs on {@link AzureFileSystemProvider for more information} | ||
*/ | ||
public static void setDefaultConfigurations(Map<String, Object> config) { | ||
defaultConfigurations = Collections.unmodifiableMap(config); |
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.
this doesn't block somebody with reference to config
from making further modifications. Should map be copied?
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.
Updated.
@@ -3,6 +3,9 @@ | |||
## 12.0.0-beta.17 (Unreleased) | |||
|
|||
### Features Added | |||
- Added `AzurePath.fromBlobUrl` to help convert from a blob url to an AzurePath | |||
- Added a configuration option `AZURE_STORAGE_SKIP_INITIAL_CONTAINER_CHECK` to skip the initial container check in cases where the authentication method used will not have necessary permissions. |
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.
there doesn't seem to be a reference to this option in the PR.
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.
Mishandled a merge with main here and this is a duplicate entry. Removing
...azure-storage-blob-nio/src/main/java/com/azure/storage/blob/nio/AzureFileSystemProvider.java
Outdated
Show resolved
Hide resolved
949234e
to
3fe5a8f
Compare
…rage/blob/nio/AzureFileSystemProvider.java Co-authored-by: Kamil Sobol <[email protected]>
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.
lgtm
if (defaultConfigurations == null) { | ||
defaultConfigurations = Collections.unmodifiableMap(new HashMap<>(config)); | ||
} else { | ||
throw new IllegalStateException("Default Configurations can be set only once"); |
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.
please call this out in javadoc.
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.
There should be a throws declaration on the javadoc
…azure-sdk-for-java into nioConfigureFromEnvironment
/azp run java - storage - ci |
Azure Pipelines successfully started running 1 pipeline(s). |
This pull request is protected by Check Enforcer. What is Check Enforcer?Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass. Why am I getting this message?You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged. What should I do now?If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows: What if I am onboarding a new service?Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment: |
* @param endpoint The default endpoint to set. May be null | ||
* @throws IllegalStateException If the configurations have already been set | ||
*/ | ||
public static void setDefaultConfigurations(Map<String, Object> config, String endpoint) { |
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.
Looks like we extracted endpoint for convenience. Which seems to indicate that Map<String, Object>
is not easy to use, i.e. it doesn't describe very well types and properties allowed.
Since this API isn't related to any NIO SPI then maybe we should consider taking here strongly typed options instead of map and convert it into Map<String,Object> behind the scenes?
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.
Without making any claims about whether the map is easy to use or not as that can be a separate discussion, we extracted the endpoint for a different reason than for convenience. Typically, customers will create a new file system via FileSystemProvider#newFileSystem(uri, map)
. The idea was to imitate this signature but allow access to the behavior in a different location (though looking at it, I should potentially swap the order). The ask for a default endpoint came later in the discussion, and I didn't want to add it into the map because we don't respect that map option in the newFileSystem()
method as that's not how it's intended to be used. It seemed like it would be confusing if the map options were identical except for the endpoint option which was respected in one method but ignored in another.
Hi @rickle-msft. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days. |
Hi @rickle-msft. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing "/reopen" if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the "no-recent-activity" label; otherwise, this is likely to be closed again with the next cleanup pass. |
Resolves #23653