Loading src/Client.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ Client::~Client() if(m_thread_sp) { m_thread_sp->interrupt(); //m_thread_sp->interrupt(); m_thread_sp->join(); } Loading Loading @@ -82,7 +82,7 @@ void Client::stop() if(m_thread_sp) { m_thread_sp->interrupt(); //m_thread_sp->interrupt(); m_thread_sp->join(); } Loading Loading @@ -411,6 +411,8 @@ void Client::handleReadData(FileWrapper::SP fileWrapper_sp, std::size_t recvByte { WARN_STREAM << "Client::handleReadData() bad I/O" << endl; fileWrapper_sp->cleanUp(); onTransferFailed(); } } Loading src/Client.h +1 −1 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ protected: const boost::system::error_code&); //------------------------------------------------------------------------------ // [Protected] Transfer result methods // [Protected] Protocol and transfer result handler methods //------------------------------------------------------------------------------ void onTransferCompleted(FileWrapper::SP); Loading src/ProtocolManager.cpp +55 −11 Original line number Diff line number Diff line Loading @@ -80,24 +80,36 @@ bool ProtocolManager::hasNextFile() m_recoveryMode = false; return true; } else if(m_failedFileRowset_sp && if(m_failedFileRowset_sp && m_failedFileRowsetIt != m_failedFileRowset_sp->end()) { DEBUG_STREAM << "ProtocolManager::hasNextFile() from failed list" << endl; boost::posix_time::ptime now(boost::posix_time::second_clock::local_time()); if(m_recoveryModeTime.is_not_a_date_time()) m_recoveryModeTime = now; //FIXME: inhibition of retry for n seconds boost::posix_time::time_duration diff = now - m_recoveryModeTime; if(diff.total_seconds() > 30) { DEBUG_STREAM << "ProtocolManager::hasNextFile() from failed list" << endl; m_recoveryModeTime = now; m_recoveryMode = true; return true; } else { DEBUG_STREAM << "ProtocolManager::hasNextFile() " << "wait from failed list" << endl; } } DEBUG_STREAM << "ProtocolManager::hasNextFile() lists empty" << endl; m_recoveryMode = false; return false; } } //============================================================================== // ProtocolManager::createRequest() Loading Loading @@ -280,6 +292,7 @@ void ProtocolManager::setFileTransfered(FileWrapper::SP fileWrapper_sp) throw std::invalid_argument("Empty file name found on failed list"); string fileName = m_failedFileRowsetIt->get<1>().get(); //FIXME: not incremented in case of exception!!! ++m_failedFileRowsetIt; DBManager::TransactionSP auxTransaction_sp = m_dBManager_sp->getAuxTransaction(); Loading Loading @@ -315,9 +328,40 @@ void ProtocolManager::setFileFailed() throw(std::logic_error, std::runtime_error throw std::invalid_argument("Empty file name found on new list"); string fileName = m_newFileRowsetIt->get<1>().get(); if(!m_newFileRowsetIt->get<2>()) throw std::invalid_argument("Empty update time found on new list"); std::tm currentTm = m_newFileRowsetIt->get<2>().get(); INFO_STREAM << "ProtocolManager::setFileFailed() file " << fileName << " version " << fileVersion << " transfered" << endl; boost::posix_time::ptime currentPtime = boost::posix_time::ptime_from_tm(currentTm); boost::posix_time::ptime nextPtime(boost::posix_time::pos_infin); //FIXME: not incremented in case of exception!!! ++m_newFileRowsetIt; if(m_newFileRowsetIt != m_newFileRowset_sp->end()) { if(!m_newFileRowsetIt->get<2>()) throw std::invalid_argument("Empty next update time found on new list"); std::tm nextTm = m_newFileRowsetIt->get<2>().get(); nextPtime =boost::posix_time::ptime_from_tm(nextTm); } DBManager::TransactionSP auxTransaction_sp = m_dBManager_sp->getAuxTransaction(); DBManager::TransactionSP mainTransaction_sp = m_dBManager_sp->getMainTransaction(); if(nextPtime > currentPtime) m_dBManager_sp->persistLastTimestamp(currentPtime); m_dBManager_sp->addFailedFile(fileVersion, fileName); auxTransaction_sp->commit(); mainTransaction_sp->commit(); } else { Loading src/ProtocolManager.h +4 −1 Original line number Diff line number Diff line Loading @@ -97,9 +97,12 @@ protected: //Address and port of remote endpoint std::string m_remoteEndpoint; //Processing file from recovery list //Processing file from failed list bool m_recoveryMode; //Processing file from failed list last timestamp boost::posix_time::ptime m_recoveryModeTime; //New file list shared pointer DBManager::NewFileRowsetSP m_newFileRowset_sp; Loading Loading
src/Client.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ Client::~Client() if(m_thread_sp) { m_thread_sp->interrupt(); //m_thread_sp->interrupt(); m_thread_sp->join(); } Loading Loading @@ -82,7 +82,7 @@ void Client::stop() if(m_thread_sp) { m_thread_sp->interrupt(); //m_thread_sp->interrupt(); m_thread_sp->join(); } Loading Loading @@ -411,6 +411,8 @@ void Client::handleReadData(FileWrapper::SP fileWrapper_sp, std::size_t recvByte { WARN_STREAM << "Client::handleReadData() bad I/O" << endl; fileWrapper_sp->cleanUp(); onTransferFailed(); } } Loading
src/Client.h +1 −1 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ protected: const boost::system::error_code&); //------------------------------------------------------------------------------ // [Protected] Transfer result methods // [Protected] Protocol and transfer result handler methods //------------------------------------------------------------------------------ void onTransferCompleted(FileWrapper::SP); Loading
src/ProtocolManager.cpp +55 −11 Original line number Diff line number Diff line Loading @@ -80,24 +80,36 @@ bool ProtocolManager::hasNextFile() m_recoveryMode = false; return true; } else if(m_failedFileRowset_sp && if(m_failedFileRowset_sp && m_failedFileRowsetIt != m_failedFileRowset_sp->end()) { DEBUG_STREAM << "ProtocolManager::hasNextFile() from failed list" << endl; boost::posix_time::ptime now(boost::posix_time::second_clock::local_time()); if(m_recoveryModeTime.is_not_a_date_time()) m_recoveryModeTime = now; //FIXME: inhibition of retry for n seconds boost::posix_time::time_duration diff = now - m_recoveryModeTime; if(diff.total_seconds() > 30) { DEBUG_STREAM << "ProtocolManager::hasNextFile() from failed list" << endl; m_recoveryModeTime = now; m_recoveryMode = true; return true; } else { DEBUG_STREAM << "ProtocolManager::hasNextFile() " << "wait from failed list" << endl; } } DEBUG_STREAM << "ProtocolManager::hasNextFile() lists empty" << endl; m_recoveryMode = false; return false; } } //============================================================================== // ProtocolManager::createRequest() Loading Loading @@ -280,6 +292,7 @@ void ProtocolManager::setFileTransfered(FileWrapper::SP fileWrapper_sp) throw std::invalid_argument("Empty file name found on failed list"); string fileName = m_failedFileRowsetIt->get<1>().get(); //FIXME: not incremented in case of exception!!! ++m_failedFileRowsetIt; DBManager::TransactionSP auxTransaction_sp = m_dBManager_sp->getAuxTransaction(); Loading Loading @@ -315,9 +328,40 @@ void ProtocolManager::setFileFailed() throw(std::logic_error, std::runtime_error throw std::invalid_argument("Empty file name found on new list"); string fileName = m_newFileRowsetIt->get<1>().get(); if(!m_newFileRowsetIt->get<2>()) throw std::invalid_argument("Empty update time found on new list"); std::tm currentTm = m_newFileRowsetIt->get<2>().get(); INFO_STREAM << "ProtocolManager::setFileFailed() file " << fileName << " version " << fileVersion << " transfered" << endl; boost::posix_time::ptime currentPtime = boost::posix_time::ptime_from_tm(currentTm); boost::posix_time::ptime nextPtime(boost::posix_time::pos_infin); //FIXME: not incremented in case of exception!!! ++m_newFileRowsetIt; if(m_newFileRowsetIt != m_newFileRowset_sp->end()) { if(!m_newFileRowsetIt->get<2>()) throw std::invalid_argument("Empty next update time found on new list"); std::tm nextTm = m_newFileRowsetIt->get<2>().get(); nextPtime =boost::posix_time::ptime_from_tm(nextTm); } DBManager::TransactionSP auxTransaction_sp = m_dBManager_sp->getAuxTransaction(); DBManager::TransactionSP mainTransaction_sp = m_dBManager_sp->getMainTransaction(); if(nextPtime > currentPtime) m_dBManager_sp->persistLastTimestamp(currentPtime); m_dBManager_sp->addFailedFile(fileVersion, fileName); auxTransaction_sp->commit(); mainTransaction_sp->commit(); } else { Loading
src/ProtocolManager.h +4 −1 Original line number Diff line number Diff line Loading @@ -97,9 +97,12 @@ protected: //Address and port of remote endpoint std::string m_remoteEndpoint; //Processing file from recovery list //Processing file from failed list bool m_recoveryMode; //Processing file from failed list last timestamp boost::posix_time::ptime m_recoveryModeTime; //New file list shared pointer DBManager::NewFileRowsetSP m_newFileRowset_sp; Loading