Esempio n. 1
0
void ProcessCommander::endIdleConnections()
{
	ConnectionVector idleConnections = _idleConnections;
	_idleConnections.clear();
	for(ConnectionVector::const_iterator i=idleConnections.begin();i!=idleConnections.end();++i)
	{
		(*i)->StopClient();
	}
}
Esempio n. 2
0
void ProcessCommander::Run(bool finishConnections)
{
	_errors.clear();
	_finishConnections = finishConnections;
	
	if(!_observation.GetItems().empty() && !_tasks.empty())
	{
		const std::string thisHostName = GetHostName();
		
		// make a list of the involved nodes
		_nodeCommands.Initialize(_observation);
		
		// recycle idle connections
		ConnectionVector list = _idleConnections;
		_idleConnections.clear();
		for(ConnectionVector::iterator i=list.begin();i!=list.end();++i)
		{
			onConnectionAwaitingCommand(*i);
		}
		
		if(_processes.empty())
		{
			//construct a process for each unique node name
			std::vector<std::string> list;
			_nodeCommands.NodeList(list);
			for(std::vector<std::string>::const_iterator i=list.begin();i!=list.end();++i)
			{
				RemoteProcess *process = new RemoteProcess(*i, thisHostName);
				process->SignalFinished() = boost::bind(&ProcessCommander::onProcessFinished, this, _1, _2, _3);
				process->Start();
				_processes.push_back(process);
			}
		}
		
		// We will now start accepting connections. The Run() method will not return until the server
		// stops listening and there are no more io operations pending. With asynchroneous
		// handles, the server and its connections will call onEvent...(). These handles
		// will push new tasks until all tasks in the ProcessCommander are finished.
		_server.Run();
	}
}
// return connections for user belonging to current priority
ConnectionVector
ProportionalFair::getConnectionsForPrio(int currentPrio, const UserID user)
{
    ConnectionVector currentPrioConns;
    ConnectionVector allRegisteredConns = colleagues.registry->getConnectionsForUser(user);
    for (ConnectionVector::const_iterator iter = allRegisteredConns.begin();
         iter != allRegisteredConns.end();
         ++iter)
    {
        wns::scheduler::ConnectionID currentConnection = *iter;
        // check if the connection has the current priority
        if (colleagues.registry->getPriorityForConnection(currentConnection) == currentPrio)
        {
            if (colleagues.queue->queueHasPDUs(currentConnection))
            {
                currentPrioConns.push_back(currentConnection);
            }
            // else: this conection is empty, go to the next connection of this user
        }
        // else: this connection belongs to another, i.e. lower priority, go to the next connection of this user
    }
    return currentPrioConns;
}