Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
eduwercamacaro committed Feb 19, 2025
1 parent 1aecebe commit 1a7d2ec
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void forwardMetricsUpdates(long timestamp) {
PartitionMetricInventoryModel metricInventory = clusterStore.get(
PartitionMetricInventoryModel.METRIC_INVENTORY_STORE_KEY, PartitionMetricInventoryModel.class);
if (metricInventory != null) {
Map<TenantIdModel, AggregateMetricsModel> commandsPerTenant = new HashMap<>();
Map<TenantIdModel, List<AggregateMetricsModel>> commandsPerTenant = new HashMap<>();
for (PartitionMetricIdModel partitionMetricId : metricInventory.getMetrics()) {
TenantScopedStore tenantStore = TenantScopedStore.newInstance(
nativeStore, partitionMetricId.getTenantId(), new BackgroundContext());
Expand All @@ -187,17 +187,20 @@ private void forwardMetricsUpdates(long timestamp) {
List<RepartitionWindowedMetricModel> windowedMetrics =
partitionMetric.buildRepartitionCommand(LocalDateTime.now());
tenantStore.put(new StoredGetable<>(partitionMetric));
AggregateMetricsModel current = commandsPerTenant.getOrDefault(
List<AggregateMetricsModel> metricsPerTenant =
commandsPerTenant.getOrDefault(partitionMetricId.getTenantId(), new ArrayList<>());
AggregateMetricsModel current = new AggregateMetricsModel(
partitionMetricId.getTenantId(),
new AggregateMetricsModel(
partitionMetricId.getTenantId(),
partitionMetricId.getMetricId(),
new ArrayList<>(),
ctx.taskId().partition()));
partitionMetricId.getMetricId(),
new ArrayList<>(),
ctx.taskId().partition());
current.addWindowedMetric(windowedMetrics);
commandsPerTenant.putIfAbsent(partitionMetricId.getTenantId(), current);
metricsPerTenant.add(current);
commandsPerTenant.putIfAbsent(partitionMetricId.getTenantId(), metricsPerTenant);
}
forwardRepartitionCommands(commandsPerTenant.values());
forwardRepartitionCommands(commandsPerTenant.values().stream()
.flatMap(Collection::stream)
.toList());
}
}

Expand Down

0 comments on commit 1a7d2ec

Please sign in to comment.