Loading src/Client.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -20,9 +20,6 @@ Client::Client(Tango::DeviceImpl* deviceImpl_p, Configuration::SP configuration_ m_dBManager_sp = DBManager::create(deviceImpl_p, configuration_sp); m_protocolManager_sp = ProtocolManager::create(deviceImpl_p, configuration_sp, m_dBManager_sp); m_state = Tango::OFF; m_status="Disconnected"; } Loading Loading @@ -57,6 +54,9 @@ void Client::start() m_dBManager_sp->connect(); m_protocolManager_sp = ProtocolManager::create(m_deviceImpl_p, m_configuration_sp, m_dBManager_sp); m_ioService.reset(); m_work_sp.reset(new boost::asio::io_service::work(m_ioService)); Loading Loading @@ -84,6 +84,8 @@ void Client::stop() m_thread_sp.reset(); m_protocolManager_sp.reset(); m_dBManager_sp->disconnect(); } Loading Loading @@ -140,7 +142,7 @@ void Client::writeStatus(std::string status) //============================================================================== void Client::run() { DEBUG_STREAM << "Client::run()" << endl; DEBUG_STREAM << "Client::run() Starting" << endl; while(true) { Loading @@ -165,6 +167,8 @@ void Client::run() break; } } DEBUG_STREAM << "Client::run() Stopping" << endl; } //============================================================================== Loading src/DBManager.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -105,4 +105,25 @@ DBManager::InformationList DBManager::retrieveInformation(std::string schema, return informationList; } //============================================================================== // DBManager::retrieveLastTimestamp() //============================================================================== std::tm DBManager::retrieveLastTimestamp(std::string schema, std::string table) throw(soci::soci_error) { DEBUG_STREAM << "DBManager::retrieveLastTimestamp()" << endl; boost::mutex::scoped_lock lock(m_connectionPoolMutex); if(m_session_sp->get_backend() == NULL) m_session_sp->reconnect(); std::tm lastTimestamp; *m_session_sp << "select coalesce(max(update_time),'1970-01-01 00:00:00') " "from "<< schema << "." << table, soci::into(lastTimestamp); return lastTimestamp; } } //namespace src/DBManager.h +3 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,9 @@ public: virtual InformationList retrieveInformation(std::string, std::string) throw(soci::soci_error); virtual std::tm retrieveLastTimestamp(std::string, std::string) throw(soci::soci_error); protected: //------------------------------------------------------------------------------ // [Protected] Class variables Loading src/PlainClient.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,8 @@ void PlainClient::handleConnect(const boost::system::error_code& errorCode, writeStatus(infoStream.str()); m_protocolManager_sp->setRemoteEndpoint(m_remoteEndpoint); startWriteRequest(); } else Loading src/ProtocolManager.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -205,14 +205,17 @@ RequestSP ProtocolManager::createMetadata() throw(std::runtime_error) std::string schema = m_configuration_sp->getDatabaseSchema(); std::string table = m_configuration_sp->getDatabaseTable(); Request::Metadata* metadata = request_sp->mutable_metadata(); std::tm timestamp = m_dBManager_sp->retrieveLastTimestamp(schema, table); INFO_STREAM << "ProtocolManager::createMetadata() Send schema " << schema << " table " << table << " to " << m_remoteEndpoint << endl; << schema << " table " << table << " timestamp " << asctime(×tamp) << " to " << m_remoteEndpoint << endl; Request::Metadata* metadata = request_sp->mutable_metadata(); metadata->set_schema(m_configuration_sp->getDatabaseSchema()); metadata->set_table(m_configuration_sp->getDatabaseTable()); metadata->set_timestamp(0); metadata->set_timestamp(mktime(×tamp)); return request_sp; } Loading Loading
src/Client.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -20,9 +20,6 @@ Client::Client(Tango::DeviceImpl* deviceImpl_p, Configuration::SP configuration_ m_dBManager_sp = DBManager::create(deviceImpl_p, configuration_sp); m_protocolManager_sp = ProtocolManager::create(deviceImpl_p, configuration_sp, m_dBManager_sp); m_state = Tango::OFF; m_status="Disconnected"; } Loading Loading @@ -57,6 +54,9 @@ void Client::start() m_dBManager_sp->connect(); m_protocolManager_sp = ProtocolManager::create(m_deviceImpl_p, m_configuration_sp, m_dBManager_sp); m_ioService.reset(); m_work_sp.reset(new boost::asio::io_service::work(m_ioService)); Loading Loading @@ -84,6 +84,8 @@ void Client::stop() m_thread_sp.reset(); m_protocolManager_sp.reset(); m_dBManager_sp->disconnect(); } Loading Loading @@ -140,7 +142,7 @@ void Client::writeStatus(std::string status) //============================================================================== void Client::run() { DEBUG_STREAM << "Client::run()" << endl; DEBUG_STREAM << "Client::run() Starting" << endl; while(true) { Loading @@ -165,6 +167,8 @@ void Client::run() break; } } DEBUG_STREAM << "Client::run() Stopping" << endl; } //============================================================================== Loading
src/DBManager.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -105,4 +105,25 @@ DBManager::InformationList DBManager::retrieveInformation(std::string schema, return informationList; } //============================================================================== // DBManager::retrieveLastTimestamp() //============================================================================== std::tm DBManager::retrieveLastTimestamp(std::string schema, std::string table) throw(soci::soci_error) { DEBUG_STREAM << "DBManager::retrieveLastTimestamp()" << endl; boost::mutex::scoped_lock lock(m_connectionPoolMutex); if(m_session_sp->get_backend() == NULL) m_session_sp->reconnect(); std::tm lastTimestamp; *m_session_sp << "select coalesce(max(update_time),'1970-01-01 00:00:00') " "from "<< schema << "." << table, soci::into(lastTimestamp); return lastTimestamp; } } //namespace
src/DBManager.h +3 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,9 @@ public: virtual InformationList retrieveInformation(std::string, std::string) throw(soci::soci_error); virtual std::tm retrieveLastTimestamp(std::string, std::string) throw(soci::soci_error); protected: //------------------------------------------------------------------------------ // [Protected] Class variables Loading
src/PlainClient.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,8 @@ void PlainClient::handleConnect(const boost::system::error_code& errorCode, writeStatus(infoStream.str()); m_protocolManager_sp->setRemoteEndpoint(m_remoteEndpoint); startWriteRequest(); } else Loading
src/ProtocolManager.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -205,14 +205,17 @@ RequestSP ProtocolManager::createMetadata() throw(std::runtime_error) std::string schema = m_configuration_sp->getDatabaseSchema(); std::string table = m_configuration_sp->getDatabaseTable(); Request::Metadata* metadata = request_sp->mutable_metadata(); std::tm timestamp = m_dBManager_sp->retrieveLastTimestamp(schema, table); INFO_STREAM << "ProtocolManager::createMetadata() Send schema " << schema << " table " << table << " to " << m_remoteEndpoint << endl; << schema << " table " << table << " timestamp " << asctime(×tamp) << " to " << m_remoteEndpoint << endl; Request::Metadata* metadata = request_sp->mutable_metadata(); metadata->set_schema(m_configuration_sp->getDatabaseSchema()); metadata->set_table(m_configuration_sp->getDatabaseTable()); metadata->set_timestamp(0); metadata->set_timestamp(mktime(×tamp)); return request_sp; } Loading