From 159ade2452a9badc553ecb5df02950e4221adb10 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Thu, 9 May 2019 17:07:25 +0100 Subject: [PATCH] Use bitrate instead of videostreams for load balancing. --- src/main/java/org/jitsi/jicofo/Bridge.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jitsi/jicofo/Bridge.java b/src/main/java/org/jitsi/jicofo/Bridge.java index 4a038a0a16..29771a3255 100644 --- a/src/main/java/org/jitsi/jicofo/Bridge.java +++ b/src/main/java/org/jitsi/jicofo/Bridge.java @@ -101,6 +101,11 @@ class Bridge */ private int videoStreamCountDiff = 0; + /** + * The last reported bitrate in Kbps. + */ + private int lastReportedBitrateKbps = 0; + /** * Holds bridge version (if known - not all bridge version are capable of * reporting it). @@ -154,6 +159,13 @@ void setStats(ColibriStatsExtension stats) setVideoStreamCount(videoStreamCount); } + Integer bitrateUpKbps = stats.getValueAsInt(STAT_NAME_BITRATE_UP); + Integer bitrateDownKbps = stats.getValueAsInt(STAT_NAME_BITRATE_DOWN); + if (bitrateUpKbps != null && bitrateDownKbps != null) + { + lastReportedBitrateKbps = bitrateDownKbps + bitrateUpKbps; + } + setIsOperational(!Boolean.valueOf(stats.getValueAsString( JigasiDetector.STAT_NAME_SHUTDOWN_IN_PROGRESS))); } @@ -249,7 +261,8 @@ private void verifyFailureThreshold() } /** - * The least value is returned the least the bridge is loaded. + * The least value is returned the least the bridge is loaded. Currently + * we use the bitrate to estimate load. *

* {@inheritDoc} */ @@ -268,8 +281,7 @@ else if (!meOperational && otherOperational) return 1; } - return this.getEstimatedVideoStreamCount() - - o.getEstimatedVideoStreamCount(); + return this.lastReportedBitrateKbps - o.lastReportedBitrateKbps; } private int getEstimatedVideoStreamCount()