Skip to content

Commit d8a1162

Browse files
committed
Cleaned up the ui
1 parent 565702b commit d8a1162

File tree

1 file changed

+6
-7
lines changed
  • cratedb_toolkit/admin/xmover/analysis

1 file changed

+6
-7
lines changed

cratedb_toolkit/admin/xmover/analysis/shard.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -878,25 +878,24 @@ def refresh_data(self):
878878
updated_shards: list[ShardInfo] = self.analyzer.shards
879879
self.calculate_heat_deltas(self.reference_shards, updated_shards)
880880
self.latest_shards = sorted(updated_shards, key=lambda s: self.seq_deltas[self._get_shard_compound_id(s)], reverse=True)
881-
self.latest_shards = self.latest_shards[:20]
882881

883-
def monitor_shards(self):
882+
def monitor_shards(self, interval_in_seconds: int = 10, n_shards: int = 25):
884883
self.reference_shards = {self._get_shard_compound_id(shard): shard for shard in self.analyzer.shards}
885884
self.refresh_data()
886885

887-
console.print(Panel.fit("[bold blue]The 25 most Hot Shards[/bold blue]"))
886+
console.print(Panel.fit(f"[bold blue]The {n_shards} Hottest Shards[/bold blue]"))
888887
shards_table = self.display_shards_table_header()
889888

890-
with Live(self.generate_table(self.latest_shards, self.seq_deltas), refresh_per_second=4, console=console) as live:
889+
with Live(self.generate_table(self.latest_shards[:n_shards], self.seq_deltas), refresh_per_second=4, console=console) as live:
891890
while True:
892-
sleep(10)
891+
sleep(interval_in_seconds)
893892
self.refresh_data()
894893
# self.display_shards_table_rows(shards_table, self.latest_shards, self.deltas)
895-
live.update(self.generate_table(self.latest_shards, self.seq_deltas))
894+
live.update(self.generate_table(self.latest_shards[:n_shards], self.seq_deltas))
896895

897896
def generate_table(self, sorted_shards: list[ShardInfo], deltas: dict[str, int]):
898897
t = self.display_shards_table_header()
899-
self.display_shards_table_rows(t, self.latest_shards, self.seq_deltas)
898+
self.display_shards_table_rows(t, sorted_shards, deltas)
900899
return t
901900

902901
# Cluster summary table

0 commit comments

Comments
 (0)