have client keep track of number of silent DS checkins

This commit is contained in:
Stephen Birarda 2013-09-06 09:41:27 -07:00
parent 67299b0eea
commit 9244ec1c25
5 changed files with 24 additions and 2 deletions

View file

@ -81,6 +81,8 @@ int main(int argc, char* const argv[]) {
AvatarMixer::run();
}
qDebug() << "Assignment finished or never started - waiting for new assignment";
// reset our NodeList by switching back to unassigned and clearing the list
nodeList->setOwnerType(NODE_TYPE_UNASSIGNED);
nodeList->clear();

View file

@ -110,6 +110,10 @@ void AudioMixer::run() {
}
while (true) {
if (NodeList::getInstance()->getNumNoReplyDomainCheckIns() == MAX_SILENT_DOMAIN_SERVER_CHECK_INS) {
break;
}
if (Logstash::shouldSendStats()) {
gettimeofday(&beginSendTime, NULL);
}

View file

@ -102,6 +102,10 @@ void AvatarMixer::run() {
while (true) {
if (NodeList::getInstance()->getNumNoReplyDomainCheckIns() == MAX_SILENT_DOMAIN_SERVER_CHECK_INS) {
break;
}
// send a check in packet to the domain server if DOMAIN_SERVER_CHECK_IN_USECS has elapsed
if (usecTimestampNow() - usecTimestamp(&lastDomainServerCheckIn) >= DOMAIN_SERVER_CHECK_IN_USECS) {
gettimeofday(&lastDomainServerCheckIn, NULL);

View file

@ -64,7 +64,8 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
_ownerType(newOwnerType),
_nodeTypesOfInterest(NULL),
_ownerID(UNKNOWN_NODE_ID),
_lastNodeID(UNKNOWN_NODE_ID + 1)
_lastNodeID(UNKNOWN_NODE_ID + 1),
_numNoReplyDomainCheckIns(0)
{
memcpy(_domainHostname, DEFAULT_DOMAIN_HOSTNAME, sizeof(DEFAULT_DOMAIN_HOSTNAME));
memcpy(_domainIP, DEFAULT_DOMAIN_IP, sizeof(DEFAULT_DOMAIN_IP));
@ -329,9 +330,15 @@ void NodeList::sendDomainServerCheckIn() {
}
_nodeSocket.send(_domainIP, DEFAULT_DOMAINSERVER_PORT, checkInPacket, checkInPacketSize);
// increment the count of un-replied check-ins
_numNoReplyDomainCheckIns++;
}
int NodeList::processDomainServerList(unsigned char* packetData, size_t dataBytes) {
// this is a packet from the domain server, reset the count of un-replied check-ins
_numNoReplyDomainCheckIns = 0;
int readNodes = 0;
char nodeType;
@ -367,7 +374,7 @@ int NodeList::processDomainServerList(unsigned char* packetData, size_t dataByte
return readNodes;
}
const char ASSIGNMENT_SERVER_HOSTNAME[] = "assignment.highfidelity.io";
const char ASSIGNMENT_SERVER_HOSTNAME[] = "localhost";
const sockaddr_in assignmentServerSocket = socketForHostnameAndHostOrderPort(ASSIGNMENT_SERVER_HOSTNAME,
ASSIGNMENT_SERVER_PORT);

View file

@ -42,6 +42,8 @@ extern const int DEFAULT_DOMAINSERVER_PORT;
const int UNKNOWN_NODE_ID = 0;
const int MAX_SILENT_DOMAIN_SERVER_CHECK_INS = 5;
class Assignment;
class NodeListIterator;
@ -88,6 +90,8 @@ public:
int size() { return _numNodes; }
int getNumAliveNodes() const;
int getNumNoReplyDomainCheckIns() const { return _numNoReplyDomainCheckIns; }
void clear();
void setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest);
@ -146,6 +150,7 @@ private:
uint16_t _lastNodeID;
pthread_t removeSilentNodesThread;
pthread_t checkInWithDomainServerThread;
int _numNoReplyDomainCheckIns;
void handlePingReply(sockaddr *nodeAddress);
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);