コード例 #1
0
int AcsLogServiceImpl::LogRecordBatch::svc()
{
   sendRecords(buffer_);
   while(!shutdown_){
      ACE_Time_Value timeout = ACE_OS::gettimeofday() + ACE_Time_Value(1, 0);
      mutex_.acquire();
      waitCond_.wait(&timeout);
      mutex_.release();
      if(!shutdown_)
         sendRecords();
   }
   return 0;
}
コード例 #2
0
void AcsLogServiceImpl::LogRecordBatch::
add(const ::Logging::XmlLogRecordSeq *reclist)
{
   batchMutex_.acquire();
   if (reclist->length() == 0){
      batchMutex_.release();
      return;
   }
   else if (reclist->length() > BATCH_LEN - 1){
      waitCond_.signal();
      batchMutex_.release();
      sendRecords(const_cast<Logging::XmlLogRecordSeq *>(reclist));
      return;
   }
   if(buffer_->length() < (size_ + reclist->length()))
      buffer_->length(size_ + reclist->length() + 10);

   for(CORBA::ULong i = 0; i < reclist->length(); i++, size_++)
      (*buffer_)[size_] = (*reclist)[i];
   if(size_ > BATCH_LEN){
      waitCond_.signal();
		while (size_ > 100 * BATCH_LEN)
		{
			usleep(1);
			/*if the size of the batch is huge, wait for flush*/
		}
   }
   batchMutex_.release();
}
コード例 #3
0
/**
 * gets called regularly to send data over the network
 */
void IpfixNetflowExporter::onTimeout(void* dataPtr)
{
	timeoutRegistered = false;

	if (recordsAlreadySent) {
		timeval tv;
		gettimeofday(&tv, 0);
		if (nextTimeout.tv_sec>tv.tv_sec || (nextTimeout.tv_sec==tv.tv_sec && nextTimeout.tv_nsec>tv.tv_usec*1000)) {
			// next timeout is in the future, reregister it
			timer->addTimeout(this, nextTimeout, NULL);
			// as the next timeout is not over yet, we don't need to send the records
			return;
		}
	}
	sendRecords(true);
}
コード例 #4
0
void AcsLogServiceImpl::LogRecordBatch::
sendRecords()
{
   batchMutex_.acquire();
   if (size_ > 0){
      /*save the current buffer status*/
      tmpBuffer = buffer_;
      tmpSize = size_;
      /*interchange the buffers*/
      nBuff = (nBuff + 1) % 3;
      buffer_ = &buffer[nBuff];
      size_ = 0;
      batchMutex_.release();
      /*send the buffer through NC*/
      tmpBuffer->length(tmpSize);
      sendRecords(tmpBuffer);
      /*prepare the size of the buffer*/
      tmpBuffer->length(BATCH_LEN * 2);
      return;
   }
   batchMutex_.release();
}
コード例 #5
0
/**
 * Put new Data Record in outbound exporter queue
 * @param rec Data Data Record
 */
void IpfixNetflowExporter::onDataRecord(IpfixDataRecord* record)
{
	registerTimeout();
	recordCache.push(record);
	sendRecords();
}
コード例 #6
0
/**
 * during reconfiguration ensure, that all cached flows are exported
 */
void IpfixNetflowExporter::onReconfiguration1()
{
	sendRecords(true);
}
コード例 #7
0
/**
 * sends all cached records
 */
void IpfixNetflowExporter::performShutdown()
{
	sendRecords(true);
	close(sockfd);
}
コード例 #8
0
ファイル: wifi_con.c プロジェクト: BaixiangLiu/ykt4sungard
/***********************************************************************
		module		:	[WIFI]
		function		:	[wifi上传菜单]
  		return		:	[无]
		comment	:	[全局普通函数]
		machine		:	[EH-0818]
		language	:	[CHN]
 		keyword		:	[WIFI]
		date			:	[11/07/25]
 		author		:	[chen-zhengkai]
************************************************************************/
void wifi_upload_menu()
{
	int select = -1;
	//int conStatus = 0;		//连接状态,0:连接正常
	char db_menu_str[] =	"1. 启动连接"
							"2. 上传数据"
							"3. 网络设置"
							"4. 断开连接"
							"5. 重启模块";

	BROWINFO	info;
	info.iStr = db_menu_str;		//浏览内容指针
	info.lPtr = 0;					//显示内容iStr的起始显示行
	info.cPtr = 0;					//当前选择行

	while (1) {
		//以下BROWINFO结构成员变量必须参与循环,有可能会被EXT_Brow_Select函数改变
//		 conStatus = CWiFi_GetRepStatus(g_pHandle[0]);
//		 if (!conStatus) {
//		 	strncpy(db_menu_str, "1. 断开连接(已连接)", 21);
//		}
//		else {
//			strncpy(db_menu_str, "1. 启动连接(未连接)", 21);
//		}
		info.startLine = 2;				//在LCD上的显示起始行
		info.dispLines = 5;				//在LCD上的显示行数
		info.mInt = 5;					//显示内容的总行数
		info.lineMax = 11;				//每行最大字符数
		info.sFont = 0;					//7x9大字体显示
		info.numEnable = 0;				//是否允许数字键代替方向控制
		info.qEvent = EXIT_KEY_F1|EXIT_AUTO_QUIT|EXIT_KEY_POWER|EXIT_KEY_CANCEL;    //可导致函数退出的事件标志
		info.autoexit = 1200;			//自动退出的时间
		//菜单
		Disp_Clear();
		DispStr_CE(0, 0, "wifi传输菜单", DISP_CENTER);
		select = EXT_Brow_Select(&info);

		switch (select) {
			case 0:		//启动连接,断开连接
				connectWifi();	//启动连接
				break;
			case 1:		//上传数据
				sendRecords();
				break;
			case 2:		//网络设置
				wifinet_set();
				break;
			case 3:		//断开连接
				disConnect();
				break;
			case 4:		//重启模块
				resetWifi();
				break;
			default:	//降低CPU占用率,降低能耗
				if (info.qEvent == EXIT_KEY_F1  || EXIT_AUTO_QUIT 
                                || EXIT_KEY_POWER || EXIT_KEY_CANCEL) { //返回上级菜单 
					return;
				}
				Sys_Power_Sleep(3);
				break;
		}
	}
}
コード例 #9
0
AcsLogServiceImpl::LogRecordBatch::~LogRecordBatch()
{
   sendRecords();
   waitCond_.signal();
   buffer_->length(0);
}