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

Leaf key generator implementation for Apache ShardingSphere #1775

Closed
tristaZero opened this issue Jan 18, 2019 · 11 comments · Fixed by #2493
Closed

Leaf key generator implementation for Apache ShardingSphere #1775

tristaZero opened this issue Jan 18, 2019 · 11 comments · Fixed by #2493

Comments

@tristaZero
Copy link
Contributor

tristaZero commented Jan 18, 2019

Modifying API of generating gobally unique ID, and providing alternatives of gobally unique ID generator for users now is ongoing.

To meet users' different needs and make the module of globally unique ID key generator more powerful, we plan to implement Leaf key generator for ShardingSphere.

Welcome @Zhaodong Xie, the author of Leaf, to contribute to Apache ShardingSphere. He will be in charge of Leaf key generator implementation for Apache ShardingSphere.

[1] https://tech.meituan.com/MT_Leaf.html

@Yaccc
Copy link

Yaccc commented Jan 21, 2019

assign to me? @terrymanu

@terrymanu
Copy link
Member

Cannot assign issue if your account is not in apache LDAP.
Please just submit pull request anyway. :)

Yaccc pushed a commit to Yaccc/sharding-jdbc that referenced this issue Feb 20, 2019
@terrymanu terrymanu removed this from the 4.0.0.M1 milestone Mar 20, 2019
@wgy8283335
Copy link
Contributor

wgy8283335 commented Apr 16, 2019

@tristaZero. @terrymanu. I'd like to take the issue. Could you make an explanation of the new feature? Is it means creating a new generator which implements ShardingKeyGenerator in 'org.apache.shardingsphere.core.keygen.impl' package?

@terrymanu
Copy link
Member

Yes, you can reference https://tech.meituan.com/MT_Leaf.html

@wgy8283335
Copy link
Contributor

@terrymanu. I've read the reference. There are two kinds of generators in the leaf. One is leaf-segment and another is leaf-snowflake. I'd like to start with leaf-segment. The leaf-segment algorithm needs a third component to recode the latest id segment. The third component could be a database or zookeeper. I prefer to choose zookeeper to recode the latest id segment. Because, if id segments stored in a database, a conflit may happen when the table name of id segment is the same as another table of service. Another reason for using zookeeper, is that the zookeeper is necessary for leaf-snowflake. So, do you have any suggestion for me?

@terrymanu
Copy link
Member

Start from leaf-segment and use zookeeper t store for id segment is good idea.

@wgy8283335
Copy link
Contributor

@terrymanu. Thank you. I've got it.

@Yaccc
Copy link

Yaccc commented Apr 26, 2019

Is a bad idea!

@wgy8283335
Copy link
Contributor

@Yaccc, why?

@wgy8283335
Copy link
Contributor

@terrymanu. These days I've been reading through the source code of the key generator and registry center related. I'd like to discuss with you at the plan of coding leaf generator.

  1. As you know the leaf generator needs zookeeper client to communicate with zookeeper server. So the way of initializing the zookeeper client is a little hard to decide. Although, initializing the client and the definition of the client has been implemented in 'package org.apache.shardingsphere.orchestration.reg'. But it is hard to use them directly,.Beacuse the key generator is in 'package org.apache.shardingsphere.core.strategy.keygen'. So I'm planning to write these part on my own to initialize the client and the related functions.
  2. The property of the leaf segment generator, especially zookeeper client related.I'd like to use new parameter,this means orchestration register related parameter won't be used.
    These two points are what I like to discuss with you, do you have any suggestion?

@terrymanu
Copy link
Member

terrymanu commented May 16, 2019

@wgy8283335 Thank you for pay attention on this issue.

  1. As you know the leaf generator needs zookeeper client to communicate with zookeeper server. So the way of initializing the zookeeper client is a little hard to decide. Although, initializing the client and the definition of the client has been implemented in 'package org.apache.shardingsphere.orchestration.reg'. But it is hard to use them directly,.Beacuse the key generator is in 'package org.apache.shardingsphere.core.strategy.keygen'. So I'm planning to write these part on my own to initialize the client and the related functions.

I prefer the agree your point, because reg module is for orchestration only, not for sharding-core, so just copy some core codes to leaf plugin is fine.

  1. The property of the leaf segment generator, especially zookeeper client related.I'd like to use new parameter,this means orchestration register related parameter won't be used.

Yes, it should use new parameters, and we can put them to properties to let leaf plugin to read them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment