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

FlakeIdGenerator advanced configuration #14150

Closed
lukasherman opened this issue Nov 20, 2018 · 7 comments · Fixed by #16278
Closed

FlakeIdGenerator advanced configuration #14150

lukasherman opened this issue Nov 20, 2018 · 7 comments · Fixed by #16278

Comments

@lukasherman
Copy link
Contributor

Hello Hazelcast team,
is it possible to externalize FlakeIdGeneratorProxy constants, namely EPOCH_START, BITS_TIMESTAMP, BITS_SEQUENCE, BITS_NODE_ID, ALLOWED_FUTURE_MILLIS into FlakeIdGeneratorConfig?
This would allow as to generate wider range of IDs for different use cases, such as those which rotate once per day, week, month, in exchange for shorter generated bit length.

With regards
Lukas Herman

@lukasherman
Copy link
Contributor Author

The tricky part is to correctly handle possible id overflow. The current implementation simply grows without any bounds.

@mmedenjak
Copy link
Contributor

Hi @lukasherman ! Yes, it's possible but currently it's not high-priority. We'll consider it.

@mmedenjak mmedenjak modified the milestones: 3.12, 3.13 Feb 25, 2019
@mmedenjak mmedenjak removed this from the 3.13 milestone Apr 17, 2019
@lukasherman
Copy link
Contributor Author

@mmedenjak are you interested in PR for that?

@mmedenjak
Copy link
Contributor

@lukasherman yes, sure. Keep in mind that the master branch is now targeting Hazelcast 4.0 while the maintenance-3.x branch are patch releases for 3.12. Although it might be possible to introduce some smaller enhancements in patch releases, generally we refrain from it as we have various compatibility restraints (e.g. no serialization changes).
What I'm saying is - it will be easier for you to create it against master but that means it will come out in Hazelcast 4.0.

@lukasherman
Copy link
Contributor Author

OK, no problem. I have implemented the changes as a separate service into 3.1x. The code might need some review though. What is the schedule for 4.0? I need some planning first.

@mmedenjak
Copy link
Contributor

Roughly, this fall.

@lukasherman
Copy link
Contributor Author

We are analyzing FlakeIdGenerator nodeId overflow behavior and would like to get your opinion whether the following code:

int newNodeId = getNodeEngine().getClusterService().getMemberListJoinVersion();

could be replaced by getMemberIndex():

 private int getMemberIndex(){
        int index = 0;
        Iterator<Member> memberIterator = getNodeEngine().getClusterService().getMembers().iterator();
        while (memberIterator.hasNext()){
            index++;
            if(memberIterator.next().localMember()){
                break;
            }
        }
        return index;
    }

It is not clear whether member index invariant applies to this use case.

Thanks and regards
Lukas

mmedenjak pushed a commit that referenced this issue Jan 7, 2020
FlakeIdGenerator advanced configuration. Externalizes the following properties:
- epochStart
- bitsTimestamp
- bitsSequence
- bitsNodeId
- allowedFutureMillis

Fixes #14150

Authored by: @lukasherman
@mmedenjak mmedenjak added this to the 4.0 milestone Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants