Skip to content

Commit

Permalink
Only take recent producer metrics (opensource4you#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
chia7712 authored Jul 29, 2022
1 parent a45388a commit be13aab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/org/astraea/app/cost/NodeLatencyCost.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.astraea.app.cost;

import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -44,6 +45,10 @@ public BrokerCost brokerCost(ClusterInfo clusterInfo, ClusterBean clusterBean) {
Map.Entry::getKey,
e ->
e.getValue().stream()
.sorted(
Comparator.comparing(HasProducerNodeMetrics::createdTimestamp)
.reversed())
.limit(1)
.mapToDouble(HasProducerNodeMetrics::requestLatencyAvg)
.sum()));
return () -> result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.astraea.app.cost;

import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -44,6 +45,10 @@ public BrokerCost brokerCost(ClusterInfo clusterInfo, ClusterBean clusterBean) {
Map.Entry::getKey,
e ->
e.getValue().stream()
.sorted(
Comparator.comparing(HasProducerNodeMetrics::createdTimestamp)
.reversed())
.limit(1)
.mapToDouble(m -> m.incomingByteRate() + m.outgoingByteRate())
.sum()));
return () -> result;
Expand Down

0 comments on commit be13aab

Please sign in to comment.