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 new key generator "LeafSegmentKeyGenerator" and related functions. #2449

Closed
wants to merge 7 commits into from
Closed

Conversation

wgy8283335
Copy link
Contributor

Fixes #1775.

Changes proposed in this pull request:

  • Add new key generator "LeafSegmentKeyGenerator" and related functions.

@wgy8283335
Copy link
Contributor Author

@terrymanu .
The test failed, due to LeafSegmentKeyGenrator test depends on zookeeper. Do u have any suggestion for me?
13:26:17.983 [pool-1-thread-1-SendThread(127.0.0.1:2181)] DEBUG org.apache.zookeeper.ClientCnxnSocketNIO - Ignoring exception during shutdown output
java.nio.channels.ClosedChannelException: null
at sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:797)
at sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:407)
at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:207)
at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1185)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1110)

@terrymanu
Copy link
Member

You can try to use curator-test which can startup a zookeeper in memory, or use mock to do unit-test

@wgy8283335
Copy link
Contributor Author

@terrymanu .THX, I will try it later.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 8249

  • 97 of 138 (70.29%) changed or added relevant lines in 4 files are covered.
  • 234 unchanged lines in 20 files lost coverage.
  • Overall coverage increased (+0.2%) to 60.843%

Changes Missing Coverage Covered Lines Changed/Added Lines %
sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/keygen/LeafSegmentKeyGenerator.java 48 54 88.89%
sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/keygen/LeafExceptionHandler.java 0 10 0.0%
sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/keygen/LeafCuratorZookeeper.java 41 66 62.12%
Files with Coverage Reduction New Missed Lines %
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/segment/dml/order/item/ExpressionOrderByItemSegment.java 1 0.0%
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/segment/dml/order/item/ColumnOrderByItemSegment.java 2 0.0%
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/filler/common/dml/OrderByFiller.java 2 0.0%
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/filler/common/dml/GroupByFiller.java 2 0.0%
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/segment/dml/order/item/OrderByItemSegment.java 4 0.0%
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/statement/dml/SelectStatement.java 5 0.0%
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/segment/dml/order/item/IndexOrderByItemSegment.java 5 0.0%
sharding-proxy/sharding-proxy-frontend/sharding-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/shardingproxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutor.java 6 0.0%
sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/sql/segment/dml/column/ColumnSegment.java 7 0.0%
sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/rewriter/ShardingSQLRewriter.java 8 74.24%
Totals Coverage Status
Change from base Build 8228: 0.2%
Covered Lines: 8167
Relevant Lines: 13423

💛 - Coveralls

@terrymanu terrymanu requested a review from tristaZero May 28, 2019 03:16
@terrymanu
Copy link
Member

Nice work, thank you.
Let @tristaZero to review it.

@terrymanu terrymanu added this to the 4.0.0.M2 milestone May 28, 2019
@tristaZero
Copy link
Contributor

@wgy8283335 Thanks, i think it is great after a quick look.
I will give you feedback as soon sa possiable.

@wgy8283335
Copy link
Contributor Author

@tristaZero. Thank you.

@tristaZero
Copy link
Contributor

tristaZero commented May 29, 2019

@wgy8283335

After reading your pr carefully and digging into the Leaf-segement and Leaf-Snowflake, i give my opinions about this pr, and also want to have
a discuss in detail with you, please let me know your feedback. Thanks.

1.The package of sharding-core-common should be basic package which is used by other packages, so it is better to move all the classes related to LeafSegmentKeyGenerator to sharding-orchestration-core.

2.When LeafSegmentKeyGenerator is in sharding-orchestration-core, maybe we can consider to use CuratorZookeeperRegistryCenter instead of LeafCuratorZookeeper. The function of incrementCacheId in LeafCuratorZookeeper can considered to move to LeafSegmentKeyGenerator, and moving tryLock() to CuratorZookeeperRegistryCenter is ok?

3.The API of generateKey() now is to return null in LeafSegmentKeyGenerator, but it is not allowed to modify APIs. Therefore using generateKey(), not generateKey(tableName) is a better choice.

4.Actually, LeafSegmentKeyGenerator really needs tableName as a key in zk. So i suggest set tableName in properties of LeafSegmentKeyGenerator and getTableName() from properties to use it in zk.

5.The another important thing is multiple schemas. If user use same tableName in multiple schemas, the node value of same table name in zk will be overwrite. So please consider use schemaName and tableName as note key.

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.

Leaf key generator implementation for Apache ShardingSphere
4 participants