Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ccmlib/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def populate(self, nodes, debug=False, tokens=None, use_vnodes=False, ipprefix=N
if dcs is None or len(dcs) <= 1:
tokens = self.balanced_tokens(node_count)
else:
tokens = self.balanced_tokens_across_dcs(dcs)
tokens = self.balanced_tokens_across_dcs(node_locations)

assert node_count == len(node_locations)
for i in range(1, node_count + 1):
Expand Down Expand Up @@ -379,18 +379,18 @@ def balanced_tokens(self, node_count):
return [int(t - 2 ** 63) for t in ptokens]
return [int(i * (2 ** 127 // node_count)) for i in range(0, node_count)]

def balanced_tokens_across_dcs(self, dcs):
def balanced_tokens_across_dcs(self, node_locations):
tokens = []
current_dc = dcs[0]
current_dc = node_locations[0][0]
count = 0
dc_count = 0
for dc in dcs:
if dc == current_dc:
for dc in node_locations:
if dc[0] == current_dc:
count += 1
else:
new_tokens = [tk + (dc_count * 100) for tk in self.balanced_tokens(count)]
tokens.extend(new_tokens)
current_dc = dc
current_dc = dc[0]
count = 1
dc_count += 1
new_tokens = [tk + (dc_count * 100) for tk in self.balanced_tokens(count)]
Expand Down
2 changes: 1 addition & 1 deletion ccmlib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ def _update_config(self):
}
if self.pid:
values['pid'] = self.pid
if self.initial_token:
if self.initial_token is not None:
values['initial_token'] = self.initial_token
if self.__install_dir is not None:
values['install_dir'] = self.__install_dir
Expand Down