From 824163d4e4e3c1e17c28f6d319db64d643047076 Mon Sep 17 00:00:00 2001 From: chez-shanpu Date: Fri, 23 Jul 2021 22:24:06 +0900 Subject: [PATCH] Fix calc cost --- pkg/appagent/appagent.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/appagent/appagent.go b/pkg/appagent/appagent.go index 20c8259..cf0ce37 100644 --- a/pkg/appagent/appagent.go +++ b/pkg/appagent/appagent.go @@ -16,7 +16,7 @@ const startVertexName = "start" const ratioMetricsTypeOption = "ratio" const bytesMetricsTypeOption = "bytes" const infCost = 999999 -const byteToBit = 8.0 +const byteToBit = 8 func GetSRNodesInfo(tls bool, certFilePath, mntAddr string) (*api.NodesInfo, error) { var opts []grpc.DialOption @@ -63,7 +63,7 @@ func MakeGraph(nodesInfo *api.NodesInfo, metricsType string, require float64) (* cost = infCost } } else if metricsType == bytesMetricsTypeOption { - if require <= (float64(node.LinkCap)-node.LinkUsageBytes)*byteToBit { + if int64(require) <= (node.LinkCap - int64(node.LinkUsageBytes*byteToBit)) { cost = 1 } else { cost = infCost