Example #1
0
void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeType) {
    // change the logging target name while the assignment is running
    LogHandler::getInstance().setTargetName(targetName);

    auto nodeList = DependencyManager::get<NodeList>();
    nodeList->setOwnerType(nodeType);

    // send a domain-server check in immediately and start the timer to fire them every DOMAIN_SERVER_CHECK_IN_MSECS
    checkInWithDomainServerOrExit();
    _domainServerTimer.start();

    // start sending stats packet once we connect to the domain
    connect(&nodeList->getDomainHandler(), SIGNAL(connectedToDomain(const QString&)), &_statsTimer, SLOT(start()));

    // stop sending stats if we disconnect
    connect(&nodeList->getDomainHandler(), &DomainHandler::disconnectedFromDomain, &_statsTimer, &QTimer::stop);
}
Example #2
0
void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeType, bool shouldSendStats) {
    // change the logging target name while the assignment is running
    LogHandler::getInstance().setTargetName(targetName);

    auto nodeList = DependencyManager::get<NodeList>();
    nodeList->setOwnerType(nodeType);

    _domainServerTimer = new QTimer();
    connect(_domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
    _domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);

    if (shouldSendStats) {
        // start sending stats packet once we connect to the domain
        connect(&nodeList->getDomainHandler(), &DomainHandler::connectedToDomain, this, &ThreadedAssignment::startSendingStats);
        
        // stop sending stats if we disconnect
        connect(&nodeList->getDomainHandler(), &DomainHandler::disconnectedFromDomain, this, &ThreadedAssignment::stopSendingStats);
    }
}
Example #3
0
void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeType, bool shouldSendStats) {
    // change the logging target name while the assignment is running
    LogHandler::getInstance().setTargetName(targetName);

    auto nodeList = DependencyManager::get<NodeList>();
    nodeList->setOwnerType(nodeType);

    // this is a temp fix for Qt 5.3 - rebinding the node socket gives us readyRead for the socket on this thread
    nodeList->rebindNodeSocket();

    _domainServerTimer = new QTimer();
    connect(_domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
    _domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);

    if (shouldSendStats) {
        // send a stats packet every 1 second
        _statsTimer = new QTimer();
        connect(_statsTimer, &QTimer::timeout, this, &ThreadedAssignment::sendStatsPacket);
        _statsTimer->start(1000);
    }
}
Example #4
0
void AssignmentClient::assignmentCompleted() {

    // we expect that to be here the previous assignment has completely cleaned up
    assert(_currentAssignment.isNull());

    // reset our current assignment pointer to NULL now that it has been deleted
    _currentAssignment = NULL;

    // reset the logging target to the the CHILD_TARGET_NAME
    LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);

    qDebug() << "Assignment finished or never started - waiting for new assignment.";

    auto nodeList = DependencyManager::get<NodeList>();

    // have us handle incoming NodeList datagrams again, and make sure our ThreadedAssignment isn't handling them
    connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, this, &AssignmentClient::readPendingDatagrams);

    // reset our NodeList by switching back to unassigned and clearing the list
    nodeList->setOwnerType(NodeType::Unassigned);
    nodeList->reset();
    nodeList->resetNodeInterestSet();
}
void AssignmentClient::assignmentCompleted() {
    // we expect that to be here the previous assignment has completely cleaned up
    assert(_currentAssignment.isNull());

    // reset our current assignment pointer to null now that it has been deleted
    _currentAssignment = nullptr;

    // reset the logging target to the the CHILD_TARGET_NAME
    LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);

    qCDebug(assigmnentclient) << "Assignment finished or never started - waiting for new assignment.";

    auto nodeList = DependencyManager::get<NodeList>();

    // tell the packet receiver to stop dropping packets
    nodeList->getPacketReceiver().setShouldDropPackets(false);

    // reset our NodeList by switching back to unassigned and clearing the list
    nodeList->setOwnerType(NodeType::Unassigned);
    nodeList->reset();
    nodeList->resetNodeInterestSet();
    
    _isAssigned = false;
}