Ejemplo n.º 1
0
wxGISEnumReturnType wxGISTaskManager::Wait(int nId, wxString & sMsg)
{
    //block until timeout, error or succeed. wait for nId message
    wxDateTime dtNow(wxDateTime::Now());
    wxTimeSpan sp = wxDateTime::Now() - dtNow;
    while(sp.GetSeconds() < NET_WAIT_TIMEOUT)
    {
        TSKMNGR_RESULT Res = PopResult(nId);
        if(Res.nId == nId)
        {
            sMsg = Res.sMsg;
            if(Res.nSate == enumGISNetCmdStErr)
            {
                return enumGISReturnFailed;
            }
            else
            {
                return enumGISReturnOk;
            }
        }

        wxTheApp->Yield(true);
        sp = wxDateTime::Now() - dtNow;
    };
    return enumGISReturnTimeout;
}
Ejemplo n.º 2
0
void CViewTransfers::GetDocStatus(size_t item, wxString& strBuffer) const {
    CMainDocument* pDoc = wxGetApp().GetDocument();
    FILE_TRANSFER* transfer = 0;
    if (pDoc) {
        transfer = pDoc->file_transfer(item);
    }

    CC_STATUS status;
    int retval = pDoc->GetCoreClientStatus(status);

    if ((transfer) && (!retval)) {
        wxDateTime dtNextRequest((time_t)transfer->next_request_time);
        wxDateTime dtNow(wxDateTime::Now());
        if (dtNextRequest > dtNow) {
            wxTimeSpan tsNextRequest(dtNextRequest - dtNow);
            strBuffer = _("Retry in ") + tsNextRequest.Format();
        } else if (ERR_GIVEUP_DOWNLOAD == transfer->status) {
            strBuffer = _("Download failed");
        } else if (ERR_GIVEUP_UPLOAD == transfer->status) {
            strBuffer = _("Upload failed");
        } else {
            if (status.network_suspend_reason) {
                strBuffer = _("Suspended");
            } else {
                if (transfer->xfer_active) {
                    strBuffer = transfer->generated_locally? _("Uploading") : _("Downloading");
                } else {
                    strBuffer = transfer->generated_locally? _("Upload pending") : _("Download pending");
                }
            }
        }
    }
}
Ejemplo n.º 3
0
//-------------------------------------------------------------------//
// OnDatetimeToday()																	//
//-------------------------------------------------------------------//
// 
//-------------------------------------------------------------------//
void DateTimeSelector::OnDatetimeToday() 
{
	COleDateTime dtNow( time(0) );
	m_SelectedDate = dtNow;
	m_CalendarDate = dtNow;

	// Redisplay.
	UpdateData( FALSE );
}
void CXTPCalendarEventRecurrenceDlg::InitMonthCBs(CComboBox& wndCB)
{
	for (int nMonth = 0; nMonth < 12; nMonth++)
	{
		_AddLocaleString(wndCB, LOCALE_SMONTHNAME1 + nMonth, nMonth + 1);
	}

	COleDateTime dtNow(COleDateTime::GetCurrentTime());
	wndCB.SetCurSel(dtNow.GetMonth() - 1);
}
Ejemplo n.º 5
0
void CADODB::PeekVar(_Parameter *param, va_list varlist)  /*throw(_com_error &)*/
{
	switch (param->GetType())
	{
	case adChar:
	case adVarChar:
		param->Value = va_arg(varlist, LPCTSTR);
		break;
	case adBSTR:
	case adVarWChar:
		param->Value = va_arg(varlist, BSTR);
		break;

	case adInteger:
		param->Value = (long)va_arg(varlist, INT);
		break;
	case adSmallInt:
		param->Value = va_arg(varlist, short);
		break;
	case adTinyInt:
		param->Value = va_arg(varlist, BYTE);
		break;

	case adBoolean:
		param->Value = va_arg(varlist, bool);
		break;

	case adSingle:
		param->Value = va_arg(varlist, float);
		break;
	case adDouble:
		param->Value = va_arg(varlist, double);
		break;

	case adDate:
		{
			COleDateTime dtNow(va_arg(varlist, __time64_t));
			param->Value = (DATE)dtNow;
		}
		break;

	case adCurrency:
		param->Value = va_arg(varlist, CURRENCY);
		break;

	default:
		ASSERT(FALSE);
		break;
	}

	return;
}
Ejemplo n.º 6
0
void CViewTransfers::GetDocStatus(wxInt32 item, wxString& strBuffer) const {
    FILE_TRANSFER* transfer = NULL;
    CMainDocument* pDoc = wxGetApp().GetDocument();
    int retval;
    strBuffer = wxString("", wxConvUTF8);
    
    transfer = pDoc->file_transfer(item);
    if (!transfer) return;
    CC_STATUS      status;

    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));

    retval = pDoc->GetCoreClientStatus(status);
    if (retval) return;

    wxDateTime dtNextRequest((time_t)transfer->next_request_time);
    wxDateTime dtNow(wxDateTime::Now());

    strBuffer = transfer->is_upload?_("Upload"):_("Download");
    strBuffer += wxString(": ", wxConvUTF8);
    if (dtNextRequest > dtNow) {
        wxTimeSpan tsNextRequest(dtNextRequest - dtNow);
        strBuffer += _("retry in ") + tsNextRequest.Format();
    } else if (transfer->status == ERR_GIVEUP_DOWNLOAD || transfer->status == ERR_GIVEUP_UPLOAD) {
        strBuffer = _("failed");
    } else {
        if (status.network_suspend_reason) {
            strBuffer += _("suspended");
            strBuffer += wxString(" - ", wxConvUTF8);
            strBuffer += suspend_reason_wxstring(status.network_suspend_reason);
        } else {
            if (transfer->xfer_active) {
                strBuffer += _("active");
            } else {
                strBuffer += _("pending");
            }
        }
    }
    if (transfer->project_backoff) {
        wxString x;
        FormatTime(transfer->project_backoff, x);
        strBuffer += _(" (project backoff: ") + x + _(")");
    }
}
Ejemplo n.º 7
0
void CViewProjects::GetDocStatus(wxInt32 item, wxString& strBuffer) const {
    PROJECT* project = NULL;
    CMainDocument* pDoc = wxGetApp().GetDocument();
    
    if (pDoc) {
        project = pDoc->project(item);
    }

    if (project) {
        if (project->suspended_via_gui) {
            append_to_status(strBuffer, _("Suspended by user"));
        }
        if (project->dont_request_more_work) {
            append_to_status(strBuffer, _("Won't get new tasks"));
        }
        if (project->ended) {
            append_to_status(strBuffer, _("Project ended - OK to remove"));
        }
        if (project->detach_when_done) {
            append_to_status(strBuffer, _("Will remove when tasks done"));
        }
        if (project->sched_rpc_pending) {
            append_to_status(strBuffer, _("Scheduler request pending"));
            append_to_status(strBuffer,
                rpc_reason_string_translated(project->sched_rpc_pending)
            );
        }
        if (project->scheduler_rpc_in_progress) {
            append_to_status(strBuffer, _("Scheduler request in progress"));
        }
        if (project->trickle_up_pending) {
            append_to_status(strBuffer, _("Trickle up message pending"));
        }
        wxDateTime dtNextRPC((time_t)project->min_rpc_time);
        wxDateTime dtNow(wxDateTime::Now());
        if (dtNextRPC > dtNow) {
            wxTimeSpan tsNextRPC(dtNextRPC - dtNow);
            append_to_status(strBuffer, _("Communication deferred ") + tsNextRPC.Format());
        }
    }
}
wxInt32 CViewTransfersGrid::FormatStatus(wxInt32 item, wxString& strBuffer) const {
    CMainDocument* doc = wxGetApp().GetDocument();
    FILE_TRANSFER* transfer = wxGetApp().GetDocument()->file_transfer(item);
    CC_STATUS      status;

    wxASSERT(doc);
    wxASSERT(wxDynamicCast(doc, CMainDocument));

    doc->GetCoreClientStatus(status);

    wxDateTime dtNextRequest((time_t)transfer->next_request_time);
    wxDateTime dtNow(wxDateTime::Now());

    if (transfer) {
        if      (dtNextRequest > dtNow) {
            wxTimeSpan tsNextRequest(dtNextRequest - dtNow);
            strBuffer = _("Retry in ") + tsNextRequest.Format();
        } else if (ERR_GIVEUP_DOWNLOAD == transfer->status) {
            strBuffer = _("Download failed");
        } else if (ERR_GIVEUP_UPLOAD == transfer->status) {
            strBuffer = _("Upload failed");
        } else {
            if (status.network_suspend_reason) {
                strBuffer = _("Suspended");
            } else {
                if (transfer->xfer_active) {
                    strBuffer = transfer->generated_locally? _("Uploading") : _("Downloading");
                } else {
                    strBuffer = transfer->generated_locally? _("Upload pending") : _("Download pending");
                }
            }
        }
    }

	strBuffer = wxT(" ") + strBuffer;

    return 0;
}
	void CloudScheduleTaskLoop::refreshKpiInfo()
	{
		bmco_debug(theLogger, "refreshKpiInfo()");
		
		MetaKPIInfoOp *tmpKPIPtr = NULL;
		std::vector<MetaKPIInfo> vecKPIInfo;
		tmpKPIPtr = dynamic_cast<MetaKPIInfoOp*>(ctlOper->getObjectPtr(MetaKPIInfoOp::getObjName()));

		if (!tmpKPIPtr->getAllKPIInfo(vecKPIInfo))
		{
			bmco_error(theLogger, "Failed to execute getAllKPIInfo on MetaShmKPIInfoTable");
		}

		std::string cloudKPIStr;
		std::string KPIInfoPath = ZNODE_ZOOKEEPER_STATUS_KPI + "/bol/" + g_sessionData.getBolName();
		
		try
		{
			if (!CloudDatabaseHandler::instance()->nodeExist(KPIInfoPath))
			{
				if (!CloudDatabaseHandler::instance()->createNode(KPIInfoPath, ZOO_EPHEMERAL))
				{
					bmco_error_f3(theLogger, "%s|%s|Faild to createNode: %s", 
						std::string("0"), std::string(__FUNCTION__), KPIInfoPath);
					return;
				}
			}

			Json::Value root(Json::objectValue);
			Json::Value field(Json::objectValue);
			Json::Value record(Json::arrayValue);

			Bmco::Timestamp now;
			LocalDateTime dtNow(now);
			std::string stNow = DateTimeFormatter::format(dtNow, DateTimeFormat::SORTABLE_FORMAT);

			MetaBolInfo::Ptr ptr = new MetaBolInfo(BOL_NORMAL, "", "");
			MetaBolInfoOp *p = dynamic_cast<MetaBolInfoOp *>(
				   ctlOper->getObjectPtr(MetaBolInfoOp::getObjName()));
			if (!p->Query(ptr))
			{
				bmco_error(theLogger, "Failed to query MetaBolInfo definition.");
				return;
			}

			// 第一行存放本BOL的状态指标
			BolStatus status = ptr->status;
			std::string bolName = g_sessionData.getBolName();
			std::string subsys = g_sessionData.getsetSubSys();
			std::string domainName = g_sessionData.getDomainName();
			
			field["kpi_id"] = "指标编号";
			field["seq_no"] = "bol名称";
			field["bol_name"] = "bol名称";
			field["kpi_value"] = "指标值";
			field["kpi_value2"] = "指标值2";
			field["status_time"] = "变更时间";

			Json::Value array(Json::objectValue);
			array["kpi_id"] = std::string("1001");
			array["seq_no"] = bolName;
			array["bol_name"] = bolName;
			array["kpi_value"] = Bmco::format("%?d", Bmco::UInt32(status));
			array["kpi_value2"] = "";
			array["status_time"] = stNow;
			record[0] = array;

			for (int i = 0; i < vecKPIInfo.size(); i++)
			{
				if (1003 != vecKPIInfo[i].KPI_ID)
				{
					continue;
				}
				
				LocalDateTime dt(vecKPIInfo[i].Create_date);
				std::string stCreateTime = DateTimeFormatter::format(dt, DateTimeFormat::SORTABLE_FORMAT);
		 		dt = vecKPIInfo[i].Modi_date;
	    		std::string stModityTime = DateTimeFormatter::format(dt, DateTimeFormat::SORTABLE_FORMAT);

				Json::Value array(Json::objectValue);
				array["kpi_id"] = Bmco::format("%?d", vecKPIInfo[i].KPI_ID);
				array["seq_no"] = std::string(vecKPIInfo[i].Seq_No.c_str());
				array["bol_name"] = std::string(vecKPIInfo[i].Bol_Cloud_Name.c_str());
				array["kpi_value"] = std::string(vecKPIInfo[i].KPI_Value.c_str());
				array["kpi_value2"] = std::string("");
				array["status_time"] = stModityTime;
				record[i+1] = array;
			}

			root["name"] = "c_info_kpi";
			root["desc"] = "指标信息";
			root["field"] = field;
			root["record"] = record;

			Json::FastWriter jfw;
			std::string oss = jfw.write(root);
			if (!CloudDatabaseHandler::instance()->setNodeData(KPIInfoPath, oss))
			{
				bmco_error(theLogger, "Faild to write KPIInfo");
			}
		}
		catch (boost::bad_lexical_cast &e)  
		{
			bmco_error_f3(theLogger,"%s|%s|%s",std::string("0"),std::string(__FUNCTION__),std::string(e.what()));
			return;
		}
		catch(Bmco::Exception &e)
		{
			bmco_error_f3(theLogger,"%s|%s|%s",std::string("0"),std::string(__FUNCTION__),e.displayText());
			return;
		}
		catch(std::exception& e)
		{
			bmco_error_f3(theLogger,"%s|%s|%s",std::string("0"),std::string(__FUNCTION__),std::string(e.what()));
			return;
		}
		catch(...)
		{
			bmco_error_f2(theLogger,"%s|%s|unknown exception occured when recordHostBaseInfo!",
									std::string("0"),std::string(__FUNCTION__));
			return;
		}
	}
	void CloudScheduleTaskLoop::refreshBpcbInfo()
	{
		std::vector<MetaBpcbInfo> vBpcbInfo;
		MetaBpcbInfoOp *p = dynamic_cast<MetaBpcbInfoOp *>(
		      ctlOper->getObjectPtr(MetaBpcbInfoOp::getObjName()));
		if (!p->getAllBpcbInfo(vBpcbInfo))
		{
			bmco_error_f2(theLogger, "%s|%s|Fail to getAllBpcbInfo", 
				std::string("0"),std::string(__FUNCTION__));
			return;
		}
		
		std::string cloudStatusStr;
		std::string bpcbInfoPath = ZNODE_ZOOKEEPER_STATUS_BPCB + "/" + g_sessionData.getBolName();

		try
		{
			if (!CloudDatabaseHandler::instance()->nodeExist(bpcbInfoPath))
			{
				if (!CloudDatabaseHandler::instance()->createNode(bpcbInfoPath, ZOO_EPHEMERAL))
				{
					bmco_error_f3(theLogger, "%s|%s|Faild to createNode %s", 
						std::string("0"), std::string(__FUNCTION__), bpcbInfoPath);
					return;
				}
			}

			Json::Value root(Json::objectValue);
			Json::Value field(Json::objectValue);
			Json::Value record(Json::arrayValue);

			std::string bolName = g_sessionData.getBolName();

			Bmco::Timestamp now;
			LocalDateTime dtNow(now);
			std::string stNow = DateTimeFormatter::format(dtNow, DateTimeFormat::SORTABLE_FORMAT);
			
			field["bpcb_id"] = "bpcbid";
			field["sys_pid"] = "系统进程ID";
			field["program_id"] = "程序ID";
			field["create_date"] = "调度启动时间";
			field["heart_beat"] = "心跳时间";
			field["status"] = "进程状态";
			field["fd_limitation"] = "打开文件限制数";
			field["fd_inusing"] = "已打开文件数";
			field["cpu"] = "cpu使用率";
			field["ram"] = "RAM使用数";
			field["flow_id"] = "所属流程ID";
			field["instance_id"] = "实例ID";
			field["task_source"] = "任务来源";
			field["source_id"] = "来源ID";
			field["snapshot"] = "snapshot标志位";
			field["action_flag"] = "action";
			field["bol_name"] = "bolname";
			field["status_time"] = "状态变更时间";

			for (int i = 0; i < vBpcbInfo.size(); i++)
			{
				LocalDateTime dt(vBpcbInfo[i].m_tHeartBeat);
				std::string stHeartBeat = DateTimeFormatter::format(dt, DateTimeFormat::SORTABLE_FORMAT);
		 		dt = vBpcbInfo[i].m_tCreateTime;
	    		std::string stCreateTime = DateTimeFormatter::format(dt, DateTimeFormat::SORTABLE_FORMAT);

				Json::Value array(Json::objectValue);
				array["bpcb_id"] = Bmco::format("%?d", vBpcbInfo[i].m_iBpcbID);
				array["sys_pid"] = Bmco::format("%?d", vBpcbInfo[i].m_iSysPID);
				array["program_id"] = Bmco::format("%?d", vBpcbInfo[i].m_iProgramID);
				array["create_date"] = stCreateTime;
				array["heart_beat"] = stHeartBeat;
				array["status"] = Bmco::format("%?d", vBpcbInfo[i].m_iStatus);
				array["fd_limitation"] = Bmco::format("%?d", vBpcbInfo[i].m_iFDLimitation);
				array["fd_inusing"] = Bmco::format("%?d", vBpcbInfo[i].m_iFDInUsing);
				array["cpu"] = Bmco::format("%?d", vBpcbInfo[i].m_iCPU);
				array["ram"] = Bmco::format("%?d", vBpcbInfo[i].m_iRAM);
				array["flow_id"] = Bmco::format("%?d", vBpcbInfo[i].m_iFlowID);
				array["instance_id"] = Bmco::format("%?d", vBpcbInfo[i].m_iInstanceID);
				array["task_source"] = Bmco::format("%?d", vBpcbInfo[i].m_iTaskSource);
				array["source_id"] = Bmco::format("%?d", vBpcbInfo[i].m_iSourceID);
				array["snapshot"] = Bmco::format("%?d", vBpcbInfo[i].m_iSnapShot);
				array["action_flag"] = Bmco::format("%?d", vBpcbInfo[i].m_iAction);
				array["bol_name"] = bolName;
				array["status_time"] = stNow;
				record[i] = array;
			}

			root["name"] =  "c_info_bpcb";
			root["desc"] =  "bpcb信息";
			root["field"] = field;
			root["record"] = record;

			Json::FastWriter jfw;
			std::string oss = jfw.write(root);
			if (!CloudDatabaseHandler::instance()->setNodeData(bpcbInfoPath, oss))
			{
				bmco_error(theLogger, "Faild to write  MetaBpcbInfo");
			}
		}
		catch (boost::bad_lexical_cast &e)  
		{
			bmco_error_f3(theLogger,"%s|%s|%s",std::string("0"),std::string(__FUNCTION__),std::string(e.what()));
			return;
		}
		catch(Bmco::Exception &e)
		{
			bmco_error_f3(theLogger,"%s|%s|%s",std::string("0"),std::string(__FUNCTION__),e.displayText());
			return;
		}
		catch(std::exception& e)
		{
			bmco_error_f3(theLogger,"%s|%s|%s",std::string("0"),std::string(__FUNCTION__),std::string(e.what()));
			return;
		}
		catch(...)
		{
			bmco_error_f2(theLogger,"%s|%s|unknown exception occured when recordHostBaseInfo!",
									std::string("0"),std::string(__FUNCTION__));
			return;
		}
	}
	void CloudScheduleTaskLoop::refreshChunkInfo()
	{
		std::vector<MetaChunkInfo> vChunkInfo;
		MetaChunkInfoOp *p = dynamic_cast<MetaChunkInfoOp *>(
		      ctlOper->getObjectPtr(MetaChunkInfoOp::getObjName()));
		if (!p->Query(vChunkInfo))
		{
			bmco_error_f2(theLogger, "%s|%s|Fail to getAllChunkInfo", 
				std::string("0"),std::string(__FUNCTION__));
			return;
		}
		
		std::string cloudStatusStr;
		std::string chunkInfoPath = ZNODE_ZOOKEEPER_STATUS_CHUNK + "/" + g_sessionData.getBolName();

		try
		{
			if (!CloudDatabaseHandler::instance()->nodeExist(chunkInfoPath))
			{
				if (!CloudDatabaseHandler::instance()->createNode(chunkInfoPath, ZOO_EPHEMERAL))
				{
					bmco_error_f3(theLogger, "%s|%s|Faild to createNode %s", 
						std::string("0"), std::string(__FUNCTION__), chunkInfoPath);
					return;
				}
			}

			Json::Value root(Json::objectValue);
			Json::Value field(Json::objectValue);
			Json::Value record(Json::arrayValue);

			Bmco::Timestamp now;
			LocalDateTime dtNow(now);
			std::string stNow = DateTimeFormatter::format(dtNow, DateTimeFormat::SORTABLE_FORMAT);

			field["chunk_id"] = "内存块号";
			field["used_size"] = "使用大小";
			field["status_time"] = "修改时间";
			field["bol_id"] = "BOLID";

			for (int i = 0; i < vChunkInfo.size(); i++)
			{
				Json::Value array(Json::objectValue);
				array["chunk_id"] = Bmco::format("%?d", vChunkInfo[i].id);
				array["used_size"] = Bmco::format("%?d", vChunkInfo[i].usedBytes);
				array["status_time"] = stNow;
				array["bol_id"] = 0;
				record[i] = array;
			}

			root["name"] = "c_info_chunk";
			root["desc"] = "chunk信息";
			root["field"] = field;
			root["record"] = record;

			Json::FastWriter jfw;
			std::string oss = jfw.write(root);
			if (!CloudDatabaseHandler::instance()->setNodeData(chunkInfoPath, oss))
			{
				bmco_error(theLogger, "Faild to write  MetaChunkInfo");
			}
		}
		catch (boost::bad_lexical_cast &e)  
		{
			bmco_error_f3(theLogger,"%s|%s|%s",std::string("0"),std::string(__FUNCTION__),std::string(e.what()));
			return;
		}
		catch(Bmco::Exception &e)
		{
			bmco_error_f3(theLogger,"%s|%s|%s",std::string("0"),std::string(__FUNCTION__),e.displayText());
			return;
		}
		catch(std::exception& e)
		{
			bmco_error_f3(theLogger,"%s|%s|%s",std::string("0"),std::string(__FUNCTION__),std::string(e.what()));
			return;
		}
		catch(...)
		{
			bmco_error_f2(theLogger,"%s|%s|unknown exception occured when recordHostBaseInfo!",
									std::string("0"),std::string(__FUNCTION__));
			return;
		}
	}
Ejemplo n.º 12
0
UINT CHFServerService::Run()
{
	CoInitializeEx(NULL, COINIT_MULTITHREADED);
	bool bTerminate = false;
	DWORD lNoUpdates = 0;
	unsigned long lTotalReceived = 0;
	unsigned long lTotalProcessed = 0;
	bool bEnableChecking = false;

	while(!bTerminate)
	{
		HANDLE hEvents[] = 
		{
			m_pServer->m_hHasSubscriptions,
			CHFServerService::GetStopEventHandle()
		};
		DWORD dwWaitResult = WaitForMultipleObjects(2, hEvents, FALSE, 15000)  ;

		switch(dwWaitResult)
		{
		case WAIT_TIMEOUT:
			{
				//			if(m_pServer->IsTerminate())
				//				break;

				long lCompositeUpdates   = ::InterlockedExchange(&m_pServer->m_lCompositeUpdates,	0L);
				long lRegionalUpdates    = ::InterlockedExchange(&m_pServer->m_lRegionalUpdates,	0L);
				long lProcessed          = ::InterlockedExchange(&m_pServer->m_lProcessedQuotes,	0L);
				long lHeartbeat          = ::InterlockedExchange(&m_pServer->m_lHeartbeat,			0L); 
				long lPeriodic           = ::InterlockedExchange(&m_pServer->m_lPeriodic,			0L); 
				long lPriceUpdates =  lCompositeUpdates + lRegionalUpdates;

				lTotalReceived  +=  lPriceUpdates;
				lTotalProcessed +=  lProcessed;
				DWORD lQueuesize = lTotalReceived -lTotalProcessed;

				CString strInfo("{");
				try
				{
					CStrategyPoolStatistics stat; 
					m_pServer->m_Pool.GetPoolStatistics(stat);
					for(CStrategyPoolStatistics::iterator itr = stat.begin(); itr != stat.end(); ++itr)
					{
						CString strForm;;
						strForm.Format(" %-6d ",*itr);
						strInfo+=strForm;
					}

//					for(std::vector<DWORD>::iterator itr = m_pServer->m_vecThreadPoolStatistics.begin();itr != m_pServer->m_vecThreadPoolStatistics.end();++itr)
//					{
//						CString strForm;;
//						strForm.Format(" %-6d ",*itr);
//						*itr = 0;
//						strInfo+=strForm;
//					}
				}catch(...){}
				strInfo+="}";

				EgLib::CEgLibTraceManager::Trace(LogInfoExt, _T("") , _T("ETI Realtime\t T% -6d [C% -6d] Pr% -6d(% -6d) HB % -3d\t Per %-3d %s"), lRegionalUpdates+lCompositeUpdates, lCompositeUpdates,  lProcessed, lQueuesize, lHeartbeat, lPeriodic, strInfo.GetString());	

				if(bEnableChecking && _Module.IsAutorestartEnabled())
				{
					vt_date dtNow(vt_date::GetCurrentDate());
					if(dtNow.get_day_of_week() != 0 && dtNow.get_day_of_week()!=6)
					{
						if(_Module.GetAutorestartBeginTime() && _Module.GetAutorestartEndTime() &&  _Module.GetAutorestartBeginTime() < _Module.GetAutorestartEndTime())
						{
							long lBeginHour = (long)_Module.GetAutorestartBeginTime()/100;
							long lEndHour   = (long)_Module.GetAutorestartEndTime()/100;
							long lBeginMinute = _Module.GetAutorestartBeginTime() - lBeginHour*100;
							long lEndMinute   = _Module.GetAutorestartEndTime() - lEndHour*100;

							if((dtNow.get_hour()>lBeginHour || (dtNow.get_hour() == lBeginHour && dtNow.get_minute() >= lBeginMinute)) && 
								(dtNow.get_hour()<lEndHour   || (dtNow.get_hour() == lEndHour   && dtNow.get_minute() <= lEndMinute) ))
							{
								if(lProcessed == 0 && lPriceUpdates != 0)
								{
									EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("No HF activity was processed in 15 seconds interval."));	
									m_pServer->OnIdle(true);
									//m_pServer->m_Pool.QueueRequest(reinterpret_cast<CHFServerThreadPool::RequestType>(new CEngineNoActivityMessage(m_pServer, false)));

								}
								else
									if(0==(lPriceUpdates+lHeartbeat+lPeriodic))
									{
										// No updates found in 15 seconds interval
										EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("No HF activity found in 15 seconds interval."));
										m_pServer->OnIdle(true);
									}
									else
										if(lPriceUpdates == 0)
										{
											if(++lNoUpdates > (_Module.AutorestartInterval()-1))
											{
												EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("No price updates found in %d seconds interval."),_Module.AutorestartInterval()*15 );	
												m_pServer->OnIdle(false);
												lNoUpdates = 0;
											}
										}
										else
										{
											if(lQueuesize > _Module.GetMaxQueueSize())
											{
												EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("The Processing queue exides maximum allowed qieie limit %d"), _Module.GetMaxQueueSize());
												m_pServer->OnIdle(true);
											}
											lNoUpdates = 0;
										}
							}
							else
								if(lPriceUpdates == 0 )
									EgLib::CEgLibTraceManager::Trace(LogWarning, __FUNCTION__ , _T("No price updates found in %d seconds interval but not working hours."),_Module.AutorestartInterval()*20 );	

						}
						else
							if(lPriceUpdates == 0 )
								EgLib::CEgLibTraceManager::Trace(LogWarning, __FUNCTION__ , _T("No price updates found in %d seconds interval but no autorestart enabled."),_Module.AutorestartInterval()*20 );	
					}
					else
						if(lPriceUpdates == 0 )
							EgLib::CEgLibTraceManager::Trace(LogWarning, __FUNCTION__ , _T("No price updates found in %d seconds interval but weekend."),_Module.AutorestartInterval()*20 );	
				}
				else
					if(bEnableChecking)
					{
						if(lPriceUpdates == 0 )
							EgLib::CEgLibTraceManager::Trace(LogWarning, __FUNCTION__ , _T("No price updates found in %d seconds interval but autorestart is disabled."),_Module.AutorestartInterval()*20 );	
					}
			}break;
		case WAIT_OBJECT_0:
			{
				EgLib::CEgLibTraceManager::Trace(LogInfoExt, __FUNCTION__ , _T("First subscription is detected. Do Reset Checking timer."));	
				bEnableChecking = true;
			}break;
		default:
			bTerminate = true;
			break;
		}
	}
	CoUninitialize();
	try
	{
		EgLib::CEgLibTraceManager::Trace(LogWarning, __FUNCTION__ , _T("Checking Thread Exit "));	
	}catch(...){}
	return 0 ;
}
Ejemplo n.º 13
0
bool Start()
{
	//为了统计准确,找到分钟的整点启动
	while(true)
	{
		ACE_Date_Time dtNow(ACE_OS::gettimeofday());
		if(dtNow.second() == 59)
		{
			break;
		}
		else
		{
			OUR_DEBUG((LM_INFO, "[Start]Wait for second 59,runtime wait[%d].\n", 59 - dtNow.second()));
			ACE_Time_Value tvSleep(1, 0);
			ACE_OS::sleep(tvSleep);
		}
	}

	for(uint32 i = 0; i < App_MainConfig::instance()->GerServerInfoCount(); i++)
	{
		_ServerInfo* pServerInfo = App_MainConfig::instance()->GetServerInfo(i);
		if(NULL != pServerInfo)
		{
			MonitorFSM* pMonitorFSM = g_MonitorFSMManager.Create(pServerInfo, App_MainConfig::instance()->GetMailAlert());

			if(NULL == pMonitorFSM)
			{
				OUR_DEBUG((LM_INFO, "[Start]pMonitorFSM new fail.\n"));
				return false;
			}

#ifdef WIN32
			App_ClientProConnectManager::instance()->Connect(i, 
				pServerInfo->m_szServerIP,
				pServerInfo->m_nPort,
				pServerInfo->m_u1IPType,
				pMonitorFSM->GetClientMessage());
#else
			App_ClientReConnectManager::instance()->Connect(i, 
				pServerInfo->m_szServerIP,
				pServerInfo->m_nPort,
				pServerInfo->m_u1IPType,
				pMonitorFSM->GetClientMessage());
#endif

			ACE_Time_Value tvSleep(0, 10000);
			ACE_OS::sleep(tvSleep);
		}
	}

#ifdef WIN32
	//启动主反应器
	App_ProactorManager::instance()->StartProactor();
#else
	App_ReactorManager::instance()->StartReactor();
#endif

	//注册定时器
	ACE_Time_Value tvInterval(App_MainConfig::instance()->GetTimeInterval(), 0);

	App_TimerManager::instance()->schedule(&g_MonitorFSMManager, 
		NULL, 
		ACE_OS::gettimeofday(), tvInterval);

	//启动定时器
	App_TimerManager::instance()->activate();

	OUR_DEBUG((LM_INFO, "[Init]Start OK.\n"));
	return true;
}