X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=include%2Ffreenet%2Fiindexrequester.h;h=678e43e118cb89f422d5c0b35fdcecaa28190c03;hb=278ee758050cb7772cd95946688c5b40104f4d8b;hp=aecc00a3fe24f3ad8801312745d151c645ed2b58;hpb=8a0a83a78390f22f99d4487cda2569909dfbc28e;p=fms.git diff --git a/include/freenet/iindexrequester.h b/include/freenet/iindexrequester.h index aecc00a..678e43e 100644 --- a/include/freenet/iindexrequester.h +++ b/include/freenet/iindexrequester.h @@ -3,7 +3,6 @@ #include "../idatabase.h" #include "../ilogger.h" -#include "../datetime.h" #include "../option.h" #include "../stringfunctions.h" #include "ifreenetregistrable.h" @@ -11,6 +10,10 @@ #include "ifcpmessagehandler.h" #include "iperiodicprocessor.h" +#include +#include +#include + #ifdef XMEM #include #endif @@ -40,15 +43,15 @@ protected: virtual const bool HandleGetFailed(FCPMessage &message)=0; virtual void RemoveFromRequestList(const IDTYPE id); - DateTime m_tempdate; - DateTime m_lastreceived; - DateTime m_lastpopulated; + Poco::DateTime m_tempdate; + Poco::DateTime m_lastreceived; + Poco::DateTime m_lastpopulated; std::string m_messagebase; std::map m_ids; // map of all ids we know and whether we have requested file from them yet std::vector m_requesting; // list of ids we are currently requesting from // these MUST be populated by child class - long m_maxrequests; + int m_maxrequests; std::string m_fcpuniquename; }; @@ -71,21 +74,21 @@ void IIndexRequester::FCPConnected() // make sure variables have been initialized by the derived class if(m_maxrequests==-1) { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IIndexRequester::FCPConnected maxrequests not initialized correctly!"); + m_log->fatal("IIndexRequester::FCPConnected maxrequests not initialized correctly!"); } if(m_fcpuniquename=="") { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IIndexRequester::FCPConnected fcpuniquename not initialized correctly!"); + m_log->fatal("IIndexRequester::FCPConnected fcpuniquename not initialized correctly!"); } if(m_fcpuniquename.find("|")!=std::string::npos) { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IIndexRequester::FCPConnected fcpuniquename contains | character! This is not a valid character!"); + m_log->fatal("IIndexRequester::FCPConnected fcpuniquename contains | character! This is not a valid character!"); } - m_lastreceived.SetToGMTime(); + m_lastreceived=Poco::Timestamp(); m_requesting.clear(); PopulateIDList(); - m_lastpopulated.SetToGMTime(); + m_lastpopulated=Poco::Timestamp(); } template @@ -101,7 +104,7 @@ const bool IIndexRequester::HandleMessage(FCPMessage &message) if(message["Identifier"].find(m_fcpuniquename)==0) { - m_lastreceived.SetToGMTime(); + m_lastreceived=Poco::Timestamp(); if(message.GetName()=="DataFound") { @@ -140,17 +143,16 @@ void IIndexRequester::InitializeIIndexRequester() m_fcpuniquename=""; Option::Instance()->Get("MessageBase",m_messagebase); - m_tempdate.SetToGMTime(); - m_lastreceived.SetToGMTime(); - m_lastpopulated.SetToGMTime(); - m_lastpopulated.Add(0,-10); + m_tempdate=Poco::Timestamp(); + m_lastreceived=Poco::Timestamp(); + m_lastpopulated=Poco::Timestamp(); + m_lastpopulated-=Poco::Timespan(0,0,10,0,0); } template void IIndexRequester::Process() { - DateTime now; - now.SetToGMTime(); + Poco::DateTime now; // max is the smaller of the config value or the total number of ids we will request from typename std::map::size_type max=m_maxrequests>m_ids.size() ? m_ids.size() : m_maxrequests; @@ -172,24 +174,24 @@ void IIndexRequester::Process() else { // we requested from all ids in the list, repopulate the list (only every 10 minutes) - if(m_lastpopulated<(now-1.0/144.0)) + if(m_lastpopulated<(now-Poco::Timespan(0,0,10,0,0))) { PopulateIDList(); - m_lastpopulated.SetToGMTime(); + m_lastpopulated=Poco::Timestamp(); } } } // special case - if there were 0 ids on the list when we started then we will never get a chance to repopulate the list // this will recheck for ids every minute - if(m_ids.size()==0 && m_tempdate<(now-(1.0/1440.0))) + if(m_ids.size()==0 && m_tempdate<(now-Poco::Timespan(0,0,1,0,0))) { PopulateIDList(); m_tempdate=now; } // if we haven't received any messages to this object in 10 minutes, clear the requests and repopulate id list - if(m_ids.size()>0 && m_lastreceived<(now-(1.0/144.0))) + if(m_ids.size()>0 && m_lastreceived<(now-Poco::Timespan(0,0,10,0,0))) { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IIndexRequester::Process() Object has not received any messages in 10 minutes. Restarting requests."); + m_log->error("IIndexRequester::Process "+m_fcpuniquename+" Object has not received any messages in 10 minutes. Restarting requests."); FCPConnected(); }