Пример #1
0
int main(int argc, char* argv[]) {
	/*
	 * Signals
	 */
	boost::asio::io_service signalService;
	boost::asio::signal_set signals(signalService, SIGINT, SIGTERM, SIGQUIT);
	signals.async_wait(handle_stop);
	boost::thread signalThread(
			boost::bind(&boost::asio::io_service::run, &signalService));

	/*
	 * Static Class initializations
	 */
	TriggerOptions::Load(argc, argv);
	MyOptions::Load(argc, argv);
	try {
		ZMQHandler::Initialize(Options::GetInt(OPTION_ZMQ_IO_THREADS));
	} catch (const zmq::error_t& ex) {
		LOG_ERROR("Failed to initialize ZMQ because: " << ex.what());
		exit(1);
	}
	HLTStruct HLTConfParams;
	HLTriggerManager::fillStructFromXMLFile(HLTConfParams);
	L1TriggerProcessor::initialize(HLTConfParams.l1);
	L2TriggerProcessor::initialize(HLTConfParams.l2);

	FarmStatistics::init();
	FarmStatistics farmstats;
	farmstats.startThread("StatisticsWriter");
	/*
	 * initialize NIC handler and start gratuitous ARP request sending thread
	 */
	NetworkHandler NetworkHandler(Options::GetString(OPTION_ETH_DEVICE_NAME));
	NetworkHandler.startThread("ArpSender");

	SourceIDManager::Initialize(Options::GetInt(OPTION_TS_SOURCEID),
			Options::GetIntPairList(OPTION_DATA_SOURCE_IDS),
			Options::GetIntPairList(OPTION_L1_DATA_SOURCE_IDS));

	BurstIdHandler::initialize(Options::GetInt(OPTION_FIRST_BURST_ID),
			&onBurstFinished);

	HandleFrameTask::initialize();

	EventSerializer::initialize();
	try {
		StorageHandler::initialize();
	}
	catch(const zmq::error_t& ex) {
		LOG_ERROR("Failed to initialize StorageHandler because: " << ex.what());
		exit(1);
	}
	StorageHandler sh;
	sh.startThread("StorageHandler");

		//StrawReceiver::initialize();

	L1Builder::initialize();
	L2Builder::initialize();

	Event::initialize(MyOptions::GetBool(OPTION_PRINT_MISSING_SOURCES));

//  Initialize Detector counts. L1=32 because 0=gtk, 1-30 Lkr, 31 MUV
//  20 should be changed with a proper dynamic definition of the number of L0 sources
	DetectorStatistics::init(20,32);
	DetectorStatistics::clearL0DetectorStatistics();
	DetectorStatistics::clearL1DetectorStatistics();

	// Get the list of farm nodes and find my position
	vector<std::string> nodes = Options::GetStringList(OPTION_FARM_HOST_NAMES);
	std::string myIP = EthernetUtils::ipToString(
			EthernetUtils::GetIPOfInterface(
					Options::GetString(OPTION_ETH_DEVICE_NAME)));
	uint logicalNodeID = 0xffffffff;
	for (size_t i = 0; i < nodes.size(); ++i) {
		if (myIP == nodes[i]) {
			logicalNodeID = i;
			break;
		}
	}
	if (logicalNodeID == 0xffffffff) {
		LOG_ERROR(
				"You must provide a list of farm nodes IP addresses containing the IP address of this node!");
		exit(1);
	}

	EventPool::initialize(
			Options::GetInt(OPTION_MAX_NUMBER_OF_EVENTS_PER_BURST),
			nodes.size(), logicalNodeID,
			Options::GetInt(OPTION_NUMBER_OF_FRAGS_PER_L0MEP));

	l1::L1DistributionHandler::Initialize(
			Options::GetInt(OPTION_MAX_TRIGGERS_PER_L1MRP),
			Options::GetInt(OPTION_MIN_USEC_BETWEEN_L1_REQUESTS),
			Options::GetStringList(OPTION_CREAM_MULTICAST_GROUP),
			Options::GetInt(OPTION_CREAM_RECEIVER_PORT),
			Options::GetInt(OPTION_CREAM_MULTICAST_PORT));

	/*
	 * Burst Handler
	 */
	LOG_INFO("Start burst handler thread.");
	BurstIdHandler bHandler;
	bHandler.startThread("BurstHandler");
	/*
	 * Monitor
	 */
	LOG_INFO("Starting Monitoring Services");
	monitoring::MonitorConnector monitor;
	monitoring::MonitorConnector::setState(INITIALIZING);
	monitor.startThread("MonitorConnector");

	/*
	 * L1 Distribution handler
	 */
	l1::L1DistributionHandler l1Handler;
	l1Handler.startThread("L1DistributionHandler");

	/*
	 * Packet Handler
	 */
	unsigned int numberOfPacketHandler = NetworkHandler::GetNumberOfQueues();
	LOG_INFO("Starting " << numberOfPacketHandler << " PacketHandler threads");

	for (unsigned int i = 0; i < numberOfPacketHandler; i++) {
		PacketHandler* handler = new PacketHandler(i);
		packetHandlers.push_back(handler);

		uint coresPerSocket = std::thread::hardware_concurrency()
				/ 2/*hyperthreading*/;
		uint cpuMask = i % 2 == 0 ? i / 2 : coresPerSocket + i / 2;
		handler->startThread(i, "PacketHandler", cpuMask, 25,
				MyOptions::GetInt(OPTION_PH_SCHEDULER));

	}

	//for (unsigned int i = 0; i < 4; i++) {
	for (unsigned int i = 0;
			i < std::thread::hardware_concurrency() - numberOfPacketHandler;
			i++) {
		TaskProcessor* tp = new TaskProcessor();
		taskProcessors.push_back(tp);
		tp->startThread(i, "TaskProcessor");

	}

	CommandConnector c;
	c.startThread(0, "Commandconnector", -1, 1);
	monitoring::MonitorConnector::setState(RUNNING);

	/*
	 * Join PacketHandler and other threads
	 */
	AExecutable::JoinAll();
	return 0;
}
Пример #2
0
int main(int argc, char* argv[]) {
	/*
	 * Signals
	 */
	boost::asio::io_service signalService;
	boost::asio::signal_set signals(signalService, SIGINT, SIGTERM, SIGQUIT);
	signals.async_wait(handle_stop);
	boost::thread signalThread(
			boost::bind(&boost::asio::io_service::run, &signalService));


	L1TriggerProcessor::registerDownscalingAlgorithms();

	L1TriggerProcessor::registerReductionAlgorithms();
	/*
	 * Static Class initializations
	 */
	TriggerOptions::Load(argc, argv);
	MyOptions::Load(argc, argv);

	ZMQHandler::Initialize(Options::GetInt(OPTION_ZMQ_IO_THREADS));

	L1TriggerProcessor::initialize(
			TriggerOptions::GetDouble(OPTION_L1_BYPASS_PROBABILITY));
	L2TriggerProcessor::initialize(
			TriggerOptions::GetDouble(OPTION_L2_BYPASS_PROBABILITY));

	/*
	 * initialize NIC handler and start gratuitous ARP request sending thread
	 */
	NetworkHandler NetworkHandler(Options::GetString(OPTION_ETH_DEVICE_NAME));
	NetworkHandler.startThread("ArpSender");

	SourceIDManager::Initialize(Options::GetInt(OPTION_TS_SOURCEID),
			Options::GetIntPairList(OPTION_DATA_SOURCE_IDS),
			Options::GetIntPairList(OPTION_CREAM_CRATES),
			Options::GetIntPairList(OPTION_INACTIVE_CREAM_CRATES),
			Options::GetInt(OPTION_MUV_CREAM_CRATE_ID));

	BurstIdHandler::initialize(Options::GetInt(OPTION_FIRST_BURST_ID));

	HandleFrameTask::initialize();

	EventSerializer::initialize();
	StorageHandler::initialize();
	StrawReceiver::initialize();

	L1Builder::initialize();
	L2Builder::initialize();

	Event::initialize(MyOptions::GetBool(OPTION_PRINT_MISSING_SOURCES),
			Options::GetBool(OPTION_WRITE_BROKEN_CREAM_INFO));

	EventPool::initialize(Options::GetInt(
	OPTION_MAX_NUMBER_OF_EVENTS_PER_BURST));

	cream::L1DistributionHandler::Initialize(
			Options::GetInt(OPTION_MAX_TRIGGERS_PER_L1MRP),
			Options::GetInt(OPTION_NUMBER_OF_EBS),
			Options::GetInt(OPTION_MIN_USEC_BETWEEN_L1_REQUESTS),
			Options::GetStringList(OPTION_CREAM_MULTICAST_GROUP),
			Options::GetInt(OPTION_CREAM_RECEIVER_PORT),
			Options::GetInt(OPTION_CREAM_MULTICAST_PORT));

	/*
	 * Monitor
	 */
	LOG_INFO<<"Starting Monitoring Services";
	monitoring::MonitorConnector monitor;
	monitoring::MonitorConnector::setState(INITIALIZING);
	monitor.startThread("MonitorConnector");

	/*
	 * L1 Distribution handler
	 */
	cream::L1DistributionHandler l1Handler;
	l1Handler.startThread("L1DistributionHandler");

	/*
	 * Packet Handler
	 */
	unsigned int numberOfPacketHandler = NetworkHandler::GetNumberOfQueues();
	LOG_INFO<< "Starting " << numberOfPacketHandler
	<< " PacketHandler threads" << ENDL;

	for (unsigned int i = 0; i < numberOfPacketHandler; i++) {
		PacketHandler* handler = new (tbb::task::allocate_root()) PacketHandler(
				i);
		packetHandlers.push_back(handler);

		uint coresPerSocket = std::thread::hardware_concurrency()
				/ 2/*hyperthreading*/;
		uint cpuMask = i % 2 == 0 ? i / 2 : coresPerSocket + i / 2;
		handler->startThread(i, "PacketHandler", cpuMask, 15,
				MyOptions::GetInt(OPTION_PH_SCHEDULER));
	}

	CommandConnector c;
	c.startThread(0, "Commandconnector", -1, 0);
	monitoring::MonitorConnector::setState(RUNNING);

	/*
	 * Join PacketHandler and other threads
	 */
	AExecutable::JoinAll();
	return 0;
}