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

dynomite tokens #822

Open
vummitimohan opened this issue Aug 17, 2023 · 1 comment
Open

dynomite tokens #822

vummitimohan opened this issue Aug 17, 2023 · 1 comment

Comments

@vummitimohan
Copy link

I would like to create a dynomite cluster with 2 racks and each rack having 7 to 8 nodes, can any one suggest me the token for each node, I tried to find the token for each node using below formula but its giving me the decimal numbers

nodeToken = (4294967295 / numberOfNodesInRack) * nodeIndex

can any one help me here

@ljluestc
Copy link


def calculate_tokens(racks=2, nodes_per_rack=8):
    max_token = 4294967295  # 32-bit token space
    tokens = []
    
    # Calculate tokens for each rack
    for rack_index in range(racks):
        # Each rack gets a fraction of the total token range
        rack_start_token = (max_token // racks) * rack_index
        rack_end_token = (max_token // racks) * (rack_index + 1) - 1
        
        # Calculate the range of tokens for each node in this rack
        for node_index in range(nodes_per_rack):
            # Tokens are evenly distributed within the rack's range
            node_token = rack_start_token + (rack_end_token - rack_start_token) * node_index // (nodes_per_rack - 1)
            tokens.append(node_token)
    
    return tokens

# Example: Create tokens for 2 racks and 8 nodes per rack
tokens = calculate_tokens(racks=2, nodes_per_rack=8)

# Print the tokens
for idx, token in enumerate(tokens):
    print(f"Node {idx+1}: Token {token}")

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

2 participants