Beispiel #1
0
void BoltRankProtocol::run()
{
	int counter = 0;

	std::size_t connections = 0;
	std::string protocol = "";

	while(!killRunThread)
	{
		tupleQueueLock.lock();
		if ( !tupleQueue.empty() )
		{
			Tuple tuple = tupleQueue.front();
			tupleQueue.pop_front();
			tupleQueueLock.unlock();

			if (tuple.getNumElements() == 0)
			{
				continue;
			}

			if ( atoi(tuple.getElement(1).c_str()) > connections)
			{
				connections = atoi(tuple.getElement(1).c_str());
				protocol = tuple.getElement(0);

				std::cout << "Most visited: " << tuple.getSingleStringComa() << std::endl;
			}
		}
		else
		{
			tupleQueueLock.unlock();
		}
	}
}
Beispiel #2
0
void BoltFilterFemale::run()
{
	int counter = 0;
	std::cout << "running female stasl" << std::endl;
	while(!killRunThread)
	{
		tupleQueueLock.lock();
		if ( !tupleQueue.empty() )
		{
			Tuple tuple = tupleQueue.front();
			tupleQueue.pop_front();
			tupleQueueLock.unlock();

			if (tuple.getElement(1) == "female" ) 
			{
				++counter;
				if (counter % 100 == 0)
				{
					std::cout << "Females: " << counter << std::endl;
				}
			}
		}
		else
		{
			tupleQueueLock.unlock();
		}
	}
}
Beispiel #3
0
void BoltSumBytes::run()
{
	int counter = 0;
	std::unordered_map<std::string,unsigned int> protocolMap;

	while(!killRunThread)
	{
		tupleQueueLock.lock();
		if ( !tupleQueue.empty() )
		{
			Tuple tuple = tupleQueue.front();
			tupleQueue.pop_front();
			tupleQueueLock.unlock();

			if(tuple.getNumElements() != 3)
			{
				continue;
			}

			std::string protocol = tuple.getElement(0);
			unsigned int sent = atoi(tuple.getElement(1).c_str());
			unsigned int recv = atoi(tuple.getElement(2).c_str());

			unsigned int sum = protocolMap[protocol];
			sum = sum + sent + recv;

			protocolMap[protocol] = sum;
			std::stringstream ss;
			ss << protocol << std::endl;
			ss << protocolMap[protocol] << std::endl;
			Tuple newTuple(ss.str());

			std::cout << newTuple.getSingleStringComa() << std::endl;
			emit(newTuple);

		}
		else
		{
			tupleQueueLock.unlock();
		}
	}
}