Skip to content

Commit

Permalink
fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
qoo332001 committed May 22, 2023
1 parent 848f4e9 commit e3dd72e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ public static Map<Integer, Long> brokerMigrationSecond(
Map.Entry::getKey,
brokerSize ->
brokerSize.getValue() / brokerOutRate.get(brokerSize.getKey()).orElse(0)));
brokerInRate.forEach(
(b, rate) -> System.out.println("broker: " + b + " inRate: " + rate.orElse(0)));
brokerOutRate.forEach(
(b, rate) -> System.out.println("broker: " + b + " OutRate: " + rate.orElse(0)));
return Stream.concat(before.nodes().stream(), after.nodes().stream())
.map(NodeInfo::id)
.distinct()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ public MetricSensor metricSensor() {
var inRate = maxRateSensor.measure(REPLICATION_IN_RATE);
var outRate = maxRateSensor.measure(REPLICATION_OUT_RATE);
return List.of(
(MaxReplicationInRateBean)
new MaxReplicationInRateBean(
() ->
new BeanObject(
newInMetrics.beanObject().domainName(),
newInMetrics.beanObject().properties(),
Map.of(STATISTICS_RATE_KEY, Math.max(oldInRate.orElse(0), inRate)),
current.toMillis()),
(MaxReplicationOutRateBean)
current.toMillis())),
new MaxReplicationOutRateBean(
() ->
new BeanObject(
newOutMetrics.beanObject().domainName(),
newOutMetrics.beanObject().properties(),
Map.of(STATISTICS_RATE_KEY, Math.max(oldOutRate.orElse(0), outRate)),
current.toMillis()));
current.toMillis())));
};
}

Expand All @@ -103,7 +103,17 @@ public MoveCost moveCost(ClusterInfo before, ClusterInfo after, ClusterBean clus
return () -> planMigrateSecond > this.maxMigrateTime.getSeconds();
}

public interface MaxReplicationInRateBean extends HasMaxRate {}
public record MaxReplicationInRateBean(HasMaxRate hasMaxRate) implements HasMaxRate {
@Override
public BeanObject beanObject() {
return hasMaxRate.beanObject();
}
}

public interface MaxReplicationOutRateBean extends HasMaxRate {}
public record MaxReplicationOutRateBean(HasMaxRate hasMaxRate) implements HasMaxRate {
@Override
public BeanObject beanObject() {
return hasMaxRate.beanObject();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ private static ClusterBean clusterBean() {
Map.of(
0,
List.of(
(PartitionMigrateTimeCost.MaxReplicationInRateBean) () -> inBean0,
(PartitionMigrateTimeCost.MaxReplicationOutRateBean) () -> outBean0),
new PartitionMigrateTimeCost.MaxReplicationInRateBean(() -> inBean0),
new PartitionMigrateTimeCost.MaxReplicationOutRateBean(() -> outBean0)),
1,
List.of(
(PartitionMigrateTimeCost.MaxReplicationInRateBean) () -> inBean1,
(PartitionMigrateTimeCost.MaxReplicationOutRateBean) () -> outBean1),
new PartitionMigrateTimeCost.MaxReplicationInRateBean(() -> inBean1),
new PartitionMigrateTimeCost.MaxReplicationOutRateBean(() -> outBean1)),
2,
List.of(
(PartitionMigrateTimeCost.MaxReplicationInRateBean) () -> inBean2,
(PartitionMigrateTimeCost.MaxReplicationOutRateBean) () -> outBean2)));
new PartitionMigrateTimeCost.MaxReplicationInRateBean(() -> inBean2),
new PartitionMigrateTimeCost.MaxReplicationOutRateBean(() -> outBean2))));
}
}

0 comments on commit e3dd72e

Please sign in to comment.