From 34a6e127a8066151ec580c316a47445013dea450 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 11 Mar 2009 09:12:11 +0100
Subject: [PATCH] Change the N1 score to percent of N1 failures

Since for a very many N+1 failures in a cluster, we could actually
degrade the N1 CV by making a node N+1 compliant, we need to make sure
this value only decreases when fixing non-compliant nodes.

The easiest way is to compute the N+1 score as a percentage of failed
nodes, with the caveat that the domain of values might not be fully
compatible with the other scores. It is still [0, 1] but does not vary
like the others.
---
 src/Cluster.hs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Cluster.hs b/src/Cluster.hs
index bef7cb616..5de0d8866 100644
--- a/src/Cluster.hs
+++ b/src/Cluster.hs
@@ -580,11 +580,11 @@ compDetailedCV nl =
         dsk_l = map Node.p_dsk nodes
         mem_cv = varianceCoeff mem_l
         dsk_cv = varianceCoeff dsk_l
-        n1_l = map (\n -> if Node.failN1 n then 1 else 0) nodes
-        n1_cv = varianceCoeff n1_l
+        n1_l = length $ filter Node.failN1 nodes
+        n1_score = (fromIntegral n1_l) / (fromIntegral $ length nodes)
         res_l = map Node.p_rem nodes
         res_cv = varianceCoeff res_l
-    in (mem_cv, dsk_cv, n1_cv, res_cv)
+    in (mem_cv, dsk_cv, n1_score, res_cv)
 
 -- | Compute the 'total' variance.
 compCV :: NodeList -> Double
-- 
GitLab