Load balancer now detects what streams are available on what servers, does not direct traffic if not configured
This commit is contained in:
parent
4b360c8164
commit
e05268f670
2 changed files with 15 additions and 0 deletions
|
@ -1697,6 +1697,10 @@ void Controller::handlePrometheus(HTTP::Parser & H, Socket::Connection & conn, i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jsonForEach(Storage["streams"], sIt){
|
||||||
|
resp["conf_streams"].append(sIt.key());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
H.Chunkify(resp.toString(), conn);
|
H.Chunkify(resp.toString(), conn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ class hostDetails{
|
||||||
private:
|
private:
|
||||||
tthread::mutex *hostMutex;
|
tthread::mutex *hostMutex;
|
||||||
std::map<std::string, struct streamDetails> streams;
|
std::map<std::string, struct streamDetails> streams;
|
||||||
|
std::set<std::string> conf_streams;
|
||||||
unsigned int cpu;
|
unsigned int cpu;
|
||||||
unsigned long long ramMax;
|
unsigned long long ramMax;
|
||||||
unsigned long long ramCurr;
|
unsigned long long ramCurr;
|
||||||
|
@ -138,6 +139,10 @@ public:
|
||||||
availBandwidth);
|
availBandwidth);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (conf_streams.size() && !conf_streams.count(s) && !conf_streams.count(s.substr(0, s.find_first_of("+ ")))){
|
||||||
|
MEDIUM_MSG("Stream %s not available from %s", s.c_str(), host.c_str());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
// Calculate score
|
// Calculate score
|
||||||
unsigned int cpu_score = (weight_cpu - (cpu * weight_cpu) / 1000);
|
unsigned int cpu_score = (weight_cpu - (cpu * weight_cpu) / 1000);
|
||||||
unsigned int ram_score = (weight_ram - ((ramCurr * weight_ram) / ramMax));
|
unsigned int ram_score = (weight_ram - ((ramCurr * weight_ram) / ramMax));
|
||||||
|
@ -263,6 +268,12 @@ public:
|
||||||
}else{
|
}else{
|
||||||
streams.clear();
|
streams.clear();
|
||||||
}
|
}
|
||||||
|
conf_streams.clear();
|
||||||
|
if (d.isMember("conf_streams") && d["conf_streams"].size()){
|
||||||
|
jsonForEach(d["conf_streams"], it){
|
||||||
|
conf_streams.insert(it->asStringRef());
|
||||||
|
}
|
||||||
|
}
|
||||||
addBandwidth *= 0.75;
|
addBandwidth *= 0.75;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue