mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:10:49 +02:00
update domain-server to leverage intel tbb hash
This commit is contained in:
parent
da8fc5d5c5
commit
270823be43
2 changed files with 42 additions and 65 deletions
|
@ -821,11 +821,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
|||
|
||||
if (nodeData->isAuthenticated()) {
|
||||
// if this authenticated node has any interest types, send back those nodes as well
|
||||
NodeHashSnapshot snapshotHash = nodeList->getNodeHash().snapshot_table();
|
||||
|
||||
for (auto it = snapshotHash.begin(); it != snapshotHash.end(); it++) {
|
||||
SharedNodePointer otherNode = it->second;
|
||||
|
||||
nodeList->eachNode([&](const SharedNodePointer& otherNode){
|
||||
// reset our nodeByteArray and nodeDataStream
|
||||
QByteArray nodeByteArray;
|
||||
QDataStream nodeDataStream(&nodeByteArray, QIODevice::Append);
|
||||
|
@ -866,7 +862,9 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
|||
// append the nodeByteArray to the current state of broadcastDataStream
|
||||
broadcastPacket.append(nodeByteArray);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
// always write the last broadcastPacket
|
||||
|
@ -963,10 +961,7 @@ void DomainServer::readAvailableDatagrams() {
|
|||
|
||||
void DomainServer::setupPendingAssignmentCredits() {
|
||||
// enumerate the NodeList to find the assigned nodes
|
||||
NodeHashSnapshot snapshotHash = NodeList::getInstance()->getNodeHash().snapshot_table();
|
||||
|
||||
for (auto it = snapshotHash.begin(); it != snapshotHash.end(); it++) {
|
||||
SharedNodePointer node = it->second;
|
||||
NodeList::getInstance()->eachNode([&](const SharedNodePointer& node){
|
||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||
|
||||
if (!nodeData->getAssignmentUUID().isNull() && !nodeData->getWalletUUID().isNull()) {
|
||||
|
@ -1000,7 +995,9 @@ void DomainServer::setupPendingAssignmentCredits() {
|
|||
_pendingAssignmentCredits.insert(nodeData->getWalletUUID(), freshTransaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void DomainServer::sendPendingTransactionsToServer() {
|
||||
|
@ -1126,16 +1123,13 @@ void DomainServer::sendHeartbeatToDataServer(const QString& networkAddress) {
|
|||
// add the number of currently connected agent users
|
||||
int numConnectedAuthedUsers = 0;
|
||||
|
||||
NodeHashSnapshot snapshotHash = NodeList::getInstance()->getNodeHash().snapshot_table();
|
||||
|
||||
for (auto it = snapshotHash.begin(); it != snapshotHash.end(); it++) {
|
||||
|
||||
SharedNodePointer node = it->second;
|
||||
|
||||
NodeList::getInstance()->eachNode([&numConnectedAuthedUsers](const SharedNodePointer& node){
|
||||
if (node->getLinkedData() && !static_cast<DomainServerNodeData*>(node->getLinkedData())->getUsername().isEmpty()) {
|
||||
++numConnectedAuthedUsers;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
const QString DOMAIN_HEARTBEAT_KEY = "heartbeat";
|
||||
const QString HEARTBEAT_NUM_USERS_KEY = "num_users";
|
||||
|
@ -1438,12 +1432,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
QJsonObject assignedNodesJSON;
|
||||
|
||||
// enumerate the NodeList to find the assigned nodes
|
||||
NodeHashSnapshot snapshotHash = NodeList::getInstance()->getNodeHash().snapshot_table();
|
||||
|
||||
for (auto it = snapshotHash.begin(); it != snapshotHash.end(); it++) {
|
||||
|
||||
SharedNodePointer node = it->second;
|
||||
|
||||
NodeList::getInstance()->eachNode([this, &assignedNodesJSON](const SharedNodePointer& node){
|
||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||
|
||||
if (!nodeData->getAssignmentUUID().isNull()) {
|
||||
|
@ -1451,7 +1440,9 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
QString uuidString = uuidStringWithoutCurlyBraces(nodeData->getAssignmentUUID());
|
||||
assignedNodesJSON[uuidString] = jsonObjectForNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
assignmentJSON["fulfilled"] = assignedNodesJSON;
|
||||
|
||||
|
@ -1505,14 +1496,12 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
QJsonArray nodesJSONArray;
|
||||
|
||||
// enumerate the NodeList to find the assigned nodes
|
||||
LimitedNodeList* nodeList = LimitedNodeList::getInstance();
|
||||
|
||||
NodeHashSnapshot snapshotHash = nodeList->getNodeHash().snapshot_table();
|
||||
|
||||
for (auto it = snapshotHash.begin(); it != snapshotHash.end(); it++) {
|
||||
LimitedNodeList::getInstance()->eachNode([this, &nodesJSONArray](const SharedNodePointer& node){
|
||||
// add the node using the UUID as the key
|
||||
nodesJSONArray.append(jsonObjectForNode(it->second));
|
||||
}
|
||||
nodesJSONArray.append(jsonObjectForNode(node));
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
rootJSON["nodes"] = nodesJSONArray;
|
||||
|
||||
|
@ -2040,18 +2029,9 @@ void DomainServer::addStaticAssignmentsToQueue() {
|
|||
QHash<QUuid, SharedAssignmentPointer>::iterator staticAssignment = staticHashCopy.begin();
|
||||
while (staticAssignment != staticHashCopy.end()) {
|
||||
// add any of the un-matched static assignments to the queue
|
||||
bool foundMatchingAssignment = false;
|
||||
|
||||
// enumerate the nodes and check if there is one with an attached assignment with matching UUID
|
||||
NodeHashSnapshot snapshotHash = NodeList::getInstance()->getNodeHash().snapshot_table();
|
||||
|
||||
for (auto it = snapshotHash.begin(); it != snapshotHash.end(); it++) {
|
||||
if (it->first == staticAssignment->data()->getUUID()) {
|
||||
foundMatchingAssignment = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMatchingAssignment) {
|
||||
if (NodeList::getInstance()->nodeWithUUID(staticAssignment->data()->getUUID())) {
|
||||
// this assignment has not been fulfilled - reset the UUID and add it to the assignment queue
|
||||
refreshStaticAssignmentAndAddToQueue(*staticAssignment);
|
||||
}
|
||||
|
|
|
@ -345,11 +345,8 @@ int LimitedNodeList::findNodeAndUpdateWithDataFromPacket(const QByteArray& packe
|
|||
}
|
||||
|
||||
SharedNodePointer LimitedNodeList::nodeWithUUID(const QUuid& nodeUUID) {
|
||||
try {
|
||||
return _nodeHash.at(nodeUUID);
|
||||
} catch (std::out_of_range) {
|
||||
return SharedNodePointer();
|
||||
}
|
||||
NodeHash::const_iterator it = _nodeHash.find(nodeUUID);
|
||||
return it == _nodeHash.cend() ? SharedNodePointer() : it->second;
|
||||
}
|
||||
|
||||
SharedNodePointer LimitedNodeList::sendingNodeForPacket(const QByteArray& packet) {
|
||||
|
|
Loading…
Reference in a new issue