Skip to content

Commit e3dd72e

Browse files
committed
fix issue
1 parent 848f4e9 commit e3dd72e

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

common/src/main/java/org/astraea/common/cost/MigrationCost.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ public static Map<Integer, Long> brokerMigrationSecond(
126126
Map.Entry::getKey,
127127
brokerSize ->
128128
brokerSize.getValue() / brokerOutRate.get(brokerSize.getKey()).orElse(0)));
129+
brokerInRate.forEach(
130+
(b, rate) -> System.out.println("broker: " + b + " inRate: " + rate.orElse(0)));
131+
brokerOutRate.forEach(
132+
(b, rate) -> System.out.println("broker: " + b + " OutRate: " + rate.orElse(0)));
129133
return Stream.concat(before.nodes().stream(), after.nodes().stream())
130134
.map(NodeInfo::id)
131135
.distinct()

common/src/main/java/org/astraea/common/cost/PartitionMigrateTimeCost.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,20 @@ public MetricSensor metricSensor() {
7676
var inRate = maxRateSensor.measure(REPLICATION_IN_RATE);
7777
var outRate = maxRateSensor.measure(REPLICATION_OUT_RATE);
7878
return List.of(
79-
(MaxReplicationInRateBean)
79+
new MaxReplicationInRateBean(
8080
() ->
8181
new BeanObject(
8282
newInMetrics.beanObject().domainName(),
8383
newInMetrics.beanObject().properties(),
8484
Map.of(STATISTICS_RATE_KEY, Math.max(oldInRate.orElse(0), inRate)),
85-
current.toMillis()),
86-
(MaxReplicationOutRateBean)
85+
current.toMillis())),
86+
new MaxReplicationOutRateBean(
8787
() ->
8888
new BeanObject(
8989
newOutMetrics.beanObject().domainName(),
9090
newOutMetrics.beanObject().properties(),
9191
Map.of(STATISTICS_RATE_KEY, Math.max(oldOutRate.orElse(0), outRate)),
92-
current.toMillis()));
92+
current.toMillis())));
9393
};
9494
}
9595

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

106-
public interface MaxReplicationInRateBean extends HasMaxRate {}
106+
public record MaxReplicationInRateBean(HasMaxRate hasMaxRate) implements HasMaxRate {
107+
@Override
108+
public BeanObject beanObject() {
109+
return hasMaxRate.beanObject();
110+
}
111+
}
107112

108-
public interface MaxReplicationOutRateBean extends HasMaxRate {}
113+
public record MaxReplicationOutRateBean(HasMaxRate hasMaxRate) implements HasMaxRate {
114+
@Override
115+
public BeanObject beanObject() {
116+
return hasMaxRate.beanObject();
117+
}
118+
}
109119
}

common/src/test/java/org/astraea/common/cost/PartitionMigrateTimeCostTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,15 @@ private static ClusterBean clusterBean() {
168168
Map.of(
169169
0,
170170
List.of(
171-
(PartitionMigrateTimeCost.MaxReplicationInRateBean) () -> inBean0,
172-
(PartitionMigrateTimeCost.MaxReplicationOutRateBean) () -> outBean0),
171+
new PartitionMigrateTimeCost.MaxReplicationInRateBean(() -> inBean0),
172+
new PartitionMigrateTimeCost.MaxReplicationOutRateBean(() -> outBean0)),
173173
1,
174174
List.of(
175-
(PartitionMigrateTimeCost.MaxReplicationInRateBean) () -> inBean1,
176-
(PartitionMigrateTimeCost.MaxReplicationOutRateBean) () -> outBean1),
175+
new PartitionMigrateTimeCost.MaxReplicationInRateBean(() -> inBean1),
176+
new PartitionMigrateTimeCost.MaxReplicationOutRateBean(() -> outBean1)),
177177
2,
178178
List.of(
179-
(PartitionMigrateTimeCost.MaxReplicationInRateBean) () -> inBean2,
180-
(PartitionMigrateTimeCost.MaxReplicationOutRateBean) () -> outBean2)));
179+
new PartitionMigrateTimeCost.MaxReplicationInRateBean(() -> inBean2),
180+
new PartitionMigrateTimeCost.MaxReplicationOutRateBean(() -> outBean2))));
181181
}
182182
}

0 commit comments

Comments
 (0)