Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 09ef42d7 authored by Michael Ott's avatar Michael Ott
Browse files

Make sure that host entries in lastSeen are unique

parent 797e1cbe
......@@ -68,9 +68,9 @@ void CARestAPI::GET_hosts(endpointArgs) {
}
std::ostringstream data;
data << "address,clientID,lastSeen" << std::endl;
std::vector<hostInfo_t> hostsVec = _mqttServer->collectLastSeen();
std::map<std::string, hostInfo_t> hostsVec = _mqttServer->collectLastSeen();
for(auto &el : hostsVec) {
data << el.address << "," << el.clientId << "," << std::to_string(el.lastSeen) << std::endl;
data << el.second.address << "," << el.second.clientId << "," << std::to_string(el.second.lastSeen) << std::endl;
}
res.body() = data.str();
res.result(http::status::ok);
......
......@@ -184,11 +184,20 @@ void SimpleMQTTServer::init(string addr, string port)
initSockets();
}
std::vector<hostInfo_t> SimpleMQTTServer::collectLastSeen() {
std::vector<hostInfo_t> hosts;
std::map<std::string, hostInfo_t> SimpleMQTTServer::collectLastSeen() {
std::map<std::string, hostInfo_t> hosts;
for(auto &t : acceptThreads) {
std::vector<hostInfo_t> tempHosts = t.collectLastSeen();
hosts.insert(hosts.end(), tempHosts.begin(), tempHosts.end());
for(auto &h1 : tempHosts) {
auto h2 = hosts.find(h1.clientId);
if (h2 != hosts.end()) {
if (h2->second.lastSeen < h1.lastSeen) {
h2->second = h1;
}
} else {
hosts[h1.clientId] = h1;
}
}
}
return hosts;
}
......
......@@ -140,7 +140,7 @@ public:
void start();
void stop();
void setMessageCallback(SimpleMQTTMessageCallback callback);
std::vector<hostInfo_t> collectLastSeen();
std::map<std::string, hostInfo_t> collectLastSeen();
SimpleMQTTServer();
SimpleMQTTServer(std::string addr, std::string port, uint64_t maxThreads=128, uint64_t maxConnPerThread=16);
......
......@@ -423,7 +423,10 @@ void SimpleMQTTServerMessageThread::run()
#endif
switch(msg[connectionId]->getType()) {
case MQTT_CONNECT: {
lastSeen[connectionId].clientId = msg[connectionId]->getTopic();
if (msg[connectionId]->getTopic().size() > 0) {
// clientId has been pre-populated with the IP address
lastSeen[connectionId].clientId = msg[connectionId]->getTopic();
}
sendAck(connectionId);
break;
}
......@@ -515,6 +518,8 @@ void SimpleMQTTServerMessageThread::assignConnections()
fds[i].fd = fdQueue[fdQueueReadPos].first;
lastSeen[i].lastSeen = getTimestamp();
lastSeen[i].address = fdQueue[fdQueueReadPos].second;
lastSeen[i].clientId = lastSeen[i].address;
numConnections++;
fdQueueReadPos = (fdQueueReadPos + 1) % SimpleMQTTConnectionsQueueLength;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment