From 23d95f0035852c89a8b876e5b1e08f7482294cb9 Mon Sep 17 00:00:00 2001 From: qoo332001 Date: Thu, 18 Aug 2022 14:28:16 +0800 Subject: [PATCH] update --- .../java/org/astraea/app/cost/MoveCost.java | 43 +------------------ 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/org/astraea/app/cost/MoveCost.java b/app/src/main/java/org/astraea/app/cost/MoveCost.java index b672773a65..cf8523ba01 100644 --- a/app/src/main/java/org/astraea/app/cost/MoveCost.java +++ b/app/src/main/java/org/astraea/app/cost/MoveCost.java @@ -238,54 +238,15 @@ public ClusterCost clusterCost( ClusterInfo originClusterInfo, ClusterInfo newClusterInfo, ClusterBean clusterBean) { if (overflow(originClusterInfo, newClusterInfo, clusterBean)) return () -> OVERFLOW_SCORE; var migratedReplicas = getMigrateReplicas(originClusterInfo, newClusterInfo, true); - var replicaSize = getReplicaSize(clusterBean); var replicaDataRate = replicaDataRate(clusterBean, duration); - var brokerMigrateInSize = - migratedReplicas.stream() - .map( - replicaMigrateInfo -> - Map.entry( - replicaMigrateInfo.brokerSink, - (double) replicaSize.get(replicaMigrateInfo.sourceTPR()))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, Double::sum)); var trafficSeries = migratedReplicas.stream() .map(x -> replicaDataRate.get(x.sourceTPR())) .sorted() .filter(x -> x != 0.0) .collect(Collectors.toList()); - var meanTrafficSeries = trafficSeries.stream().mapToDouble(x -> x).sum() / trafficSeries.size(); - var SDTrafficSeries = - Math.sqrt( - trafficSeries.stream() - .mapToDouble(score -> Math.pow((score - meanTrafficSeries), 2)) - .sum() - / trafficSeries.size()); - - var totalMigrateTraffic = trafficSeries.stream().mapToDouble(x -> x).sum(); - var totalReplicaTrafficInSink = - replicaDataRate.entrySet().stream() - .filter(x -> brokerMigrateInSize.containsKey(x.getKey().brokerId())) - .mapToDouble(Map.Entry::getValue) - .sum(); - var meanMigrateSize = trafficSeries.stream().mapToDouble(x -> x).sum() / trafficSeries.size(); - var sdMigrateSize = - Math.sqrt( - trafficSeries.stream() - .mapToDouble(score -> Math.pow((score - meanMigrateSize), 2)) - .sum() - / trafficSeries.size()); - var totalMigrateSize = - brokerMigrateInSize.values().stream().mapToDouble(x -> x / 1024.0 / 1024.0).sum(); - var total = - totalBrokerCapacity.values().stream() - .mapToDouble(x -> x.values().stream().mapToDouble(y -> y).sum()) - .sum() - / 1024.0 - / 1024.0; - var totalMigrateSizeScore = totalMigrateSize / total > 1 ? 1 : totalMigrateSize / total; - if (replicaDataRate.containsValue(-1.0)) return () -> 999.0; - return () -> SDTrafficSeries; + if (replicaDataRate.containsValue(-1.0)) return () -> OVERFLOW_SCORE; + return () -> Dispersion.correlationCoefficient().calculate(trafficSeries); } public Map getReplicaSize(ClusterBean clusterBean) {