Skip to content
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

add an API to get total count of recursive sub nodes of one node #720

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

TyqITstudent
Copy link

In production environment, there will be always a situation that there are a lot of recursive sub nodes of one node. We need to count total number of it.

Now, we can only use API getChildren which returns the List of first level of sub nodes. We need to iterate every sub node to get recursive sub nodes. It will cost a lot of time.

In zookeeper server side, it uses Hasp<String, DataNode> to store node. The key of the map represents the path of the node. We can iterate the map get total number of all levels of sub nodes of one node.

Copy link
Contributor

@nkalmar nkalmar left a comment

Choose a reason for hiding this comment

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

Missing some import, that's why the build is failing.

final String serverPath = prependChroot(clientPath);
RequestHeader h = new RequestHeader();
h.setType(ZooDefs.OpCode.getAllChildrenNumber);
GetAllChildrenNumberRequest request = new GetAllChildrenNumberRequest();
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to import the class GetAllChildrenNumberRequest which jute generates.

@@ -616,6 +616,14 @@ private void processEvent(Object event) {
} else {
cb.processResult(rc, clientPath, p.ctx, null);
}
} else if (p.response instanceof GetAllChildrenNumberResponse) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Also need to import GetAllChildrenNumberResponse

Copy link
Author

Choose a reason for hiding this comment

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

Also need to import GetAllChildrenNumberResponse

I have added the import, and how to re-trigger the Jenkins build to check the code?

Copy link
Author

Choose a reason for hiding this comment

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

Also need to import GetAllChildrenNumberResponse

OK, thanks for your remind.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Interesting work.
I left some questions

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

My comments were lost.

I suggest to:

  • name the API 'countChildren'
  • add a flag to ask for a recursive traversal or simply have the count without listing
  • add also the async version of the method

@eolivelli
Copy link
Contributor

At every push CI will retest your work.
Alternatively you can close and reopen the PR

@TyqITstudent
Copy link
Author

name the API 'countChildren'
add a flag to ask for a recursive traversal or simply have the count without listing
add also the async version of the method

  1. your name is better, I can change method name.
  2. you means that the method returns the number of first level children (if flag is false)?
  3. I will add the async method.

@TyqITstudent
Copy link
Author

At every push CI will retest your work.
Alternatively you can close and reopen the PR

When Jenkins check these parts, I change nothing but output are errors. Could you please help me to solve this? (In compile area)
Jenkins compile result.

@eolivelli
Copy link
Contributor

eolivelli commented Nov 24, 2018

@TyqITstudent
For the 'recursive' flag I mean:

  • true: recurse thw tree
  • false: count only first level

About the build...does the build pass locally on your machine? (Use ant clean to clean up before building)
It seems you are not renaming classes/fields in every point of code

@TyqITstudent
Copy link
Author

It seems you are not renaming classes/fields in every point of code

Ok, thanks for your remind.

@@ -50,6 +50,8 @@

public final int getChildren = 8;

public final int getAllChildrenNumber = 20;
Copy link
Contributor

Choose a reason for hiding this comment

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

20 is already taken for deleteContainer, please change it to something else (22 seems to be the first free number until 100)

Copy link
Author

Choose a reason for hiding this comment

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

OK, I will change the number.

@maoling
Copy link
Member

maoling commented Jan 8, 2019

@TyqITstudent
are you still working on this issue?can we move on?or let me pick it up(smirk)?

@TyqITstudent
Copy link
Author

are you still working on this issue?can we move on?or let me pick it up(smirk)?

I have no time to pay attention to this issue recently. You can do whatever you want.

@TyqITstudent
Copy link
Author

@TyqITstudent
are you still working on this issue?can we move on?or let me pick it up(smirk)?

Thanks for that.

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.

5 participants