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 may break with special name #188

Open
qixiaobo opened this issue Mar 21, 2022 · 2 comments
Open

leaf may break with special name #188

qixiaobo opened this issue Mar 21, 2022 · 2 comments

Comments

@qixiaobo
Copy link
Contributor

qixiaobo commented Mar 21, 2022

[ERROR] [main] c.s.i.l.s.SnowflakeZookeeperHolder:? []Start node ERROR {}
java.lang.NumberFormatException: For input string: "server"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.parseInt(Integer.java:615)
	at com.sankuai.inf.leaf.snowflake.SnowflakeZookeeperHolder.init(SnowflakeZookeeperHolder.java:89)
	at com.sankuai.inf.leaf.snowflake.SnowflakeIDGenImpl.<init>(SnowflakeIDGenImpl.java:50)

I Found that

//表示新启动的节点,创建持久节点 ,不用check时间
                    String newNode = createNode(curator);
                    zk_AddressNode = newNode;
                    String[] nodeKey = newNode.split("-");
                    workerID = Integer.parseInt(nodeKey[1]);

While We set this application name to xxx-xxx like below
idgen-server
then newNode will return snowflake.idgen-server.forever.xxxx:xxxx-sequence
So server will be parsed. Then this will cause leaf not start as expected

@qixiaobo
Copy link
Contributor Author

We should achieve workId as the last index of nodeKey other than 1

@qixiaobo
Copy link
Contributor Author

A simple workaround is just to make this name to idgen_server

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

No branches or pull requests

1 participant