Skip to content

Add Constant for Zookeeper user Path; Improve naming standardization. #3122

Merged
dlmarion merged 6 commits into
apache:mainfrom
ddanielr:bugfix/zk-user-path-constant
Dec 19, 2022
Merged

Add Constant for Zookeeper user Path; Improve naming standardization. #3122
dlmarion merged 6 commits into
apache:mainfrom
ddanielr:bugfix/zk-user-path-constant

Conversation

@ddanielr

Copy link
Copy Markdown
Contributor

Fixes #3120 by adding constant for "/users" ZK path.

Also updated case style of ZKUserPath variable for consistency.

Creates a constant to replace the hard-coded "/users" string in ZK user operations.
Standardizes pathing across all ZK classes that utilize a userPath.
Updates instances of the ZKUserPath variable case to match majority for ease of searching.

@dlmarion dlmarion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@EdColeman

Copy link
Copy Markdown
Contributor

I am surprised that the instance variable name convention that variables should start with a lower case letter is not complaining about ZKUserPath - with is seems to consistent with other variable names in places, but I thought that this would be against conventions.

In this case, I lean towards favoring convention and consistency could be examined separably (another pr making the other variables consistent and following convention - if that does not violate any API concerns)

@ddanielr

Copy link
Copy Markdown
Contributor Author

@EdColeman yeah I wasn't sure what our desired state was as the formatter and style guide wasn't throwing errors and other private variables in the same classes also didn't match.

I'm happy to switch everything to the zkUserPath option instead.

Update all instances of the ZKUserPath with zkUserPath to conform to naming conventions.
Implements a ServerContext Method for determining zkUserPath instead of creating a local concatenated zkUserPath variable each time.
serverDirs = info.getServerDirs();

propStore = memoize(() -> ZooPropStore.initialize(getInstanceID(), getZooReaderWriter()));
zkUserPath = memoize(() -> Constants.ZROOT + "/" + getInstanceID() + Constants.ZUSERS);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to use memoize here. That's for lazy loading instances with a supplier to load when needed but the zkUserPath is just a final String value so it should be fine to just use directly, ie zkUserPath = Constants.ZROOT + "/" + getInstanceID() + Constants.ZUSERS;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops just missed the early comments that suggested we SHOULD be using that so I guess ignore my comment :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommended memoize because getInstanceID() may not be ready right away. We have had some bootstrapping issues with this, especially around the Initialize code. I could have been overly cautious in my recommendation, though. It might not actually be needed here. If it's not, I'm fine with dropping that bit and just making it a final String.

@cshannon
cshannon dismissed their stale review December 16, 2022 19:54

misread comment

Update the MockServerContext to expect a call to the zkUserPath() method.

@ctubbsii ctubbsii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Assuming the build passes.
By the way, since you're a new contributor to this project, I just want to share my recommended howto guide on writing good commit messages: https://cbea.ms/git-commit/
Regardless of what you write, an existing committer should be checking and polishing up the commit message for accuracy, phrasing, etc. when we squash and merge, but it helps if they are written well up front. The biggest problem is long first lines, or omission of the blank second line. So, those are things to watch out for.

@dlmarion
dlmarion merged commit 284aee3 into apache:main Dec 19, 2022
@ddanielr
ddanielr deleted the bugfix/zk-user-path-constant branch December 19, 2022 20:06
@ctubbsii ctubbsii added this to the 3.0.0 milestone Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZK Users path missing in Constants

5 participants