std::string getSurlsList() { std::string builtList; if(m_surls.empty()) { return builtList; } std::set<SurlPtr>::const_iterator const vectorEnd = m_surls.end(); bool first = true; for (std::set<SurlPtr>::const_iterator i = m_surls.begin(); i != vectorEnd; ++i) { Surl* current = i->get(); if(first) { first = false; } else { builtList += ' '; } builtList += current->getSurl(); } return builtList; }
bool operator< (Surl other) const { return m_surlString.size() < other.getSurl().size(); }
void storm::BolStatusRequest::loadFromDB(struct srm_dbfd* db){ srmlogit(STORM_LOG_DEBUG, "storm::BolStatusRequest::loadFromDB", "R_token: %s\n", m_requestToken.c_str()); std::string query(""); if(m_surls.size() > 0) { query += "SELECT r.client_dn, r.status, r.errstring, r.remainingTotalTime, " " c.sourceSURL , s.fileSize , s.estimatedWaitTime , " " s.remainingPinTime , s.statusCode , s.explanation" " FROM request_queue r JOIN (request_BoL c, status_BoL s) ON " "(c.request_queueID=r.ID AND s.request_BoLID=c.ID) " "WHERE r.r_token=" + sqlFormat(m_requestToken) + " and c.sourceSURL in ("; bool first = true; std::set<SurlPtr>::const_iterator const vectorEnd = m_surls.end(); for (std::set<SurlPtr>::const_iterator i = m_surls.begin(); i != vectorEnd; ++i) { Surl* current = i->get(); if(first) { first = false; } else { query += " , "; } query += sqlFormat(current->getSurl()); } query += ")"; } else { query += "SELECT r.client_dn, r.status, r.errstring, r.remainingTotalTime, " " c.sourceSURL , s.fileSize , s.estimatedWaitTime , " " s.remainingPinTime , s.statusCode , s.explanation" " FROM request_queue r JOIN (request_BoL c, status_BoL s) ON " "(c.request_queueID=r.ID AND s.request_BoLID=c.ID) " "WHERE r.r_token=" + sqlFormat(m_requestToken); } file_status_results_t results; storm_db::vector_exec_query(db, query, results); if (results.size() == 0) { if(m_surls.size() > 0) { srmlogit(STORM_LOG_INFO, "storm::BolStatusRequest::loadFromDB()", "No tokens found for token %s and the requested SURLs\n", m_requestToken.c_str()); throw storm::token_not_found("No request found for token " + m_requestToken + " and the requested SURLs\n"); } else { srmlogit(STORM_LOG_INFO, "storm::BolStatusRequest::loadFromDB()", "No tokens found for token %s\n", m_requestToken.c_str()); throw storm::token_not_found("No request found for token " + m_requestToken + "\n"); } } fillCommonFields(results); std::vector<file_status_result_t>::const_iterator const vectorEnd = results.end(); for (std::vector<file_status_result_t>::const_iterator i = results.begin(); i != vectorEnd; ++i) { file_status_result_t currentResutl = *i; storm::Surl surl(currentResutl["sourceSURL"].c_str()); BolTurl* turl; if(currentResutl["fileSize"].empty()) { turl = new BolTurl(surl); } else { turl = new BolTurl(surl, strtoull(currentResutl["fileSize"].c_str(),(char**)NULL,10)); } if(currentResutl["statusCode"].empty()) { srmlogit(STORM_LOG_ERROR, "storm::BolStatusRequest::loadFromDB()", "Error,status code for SURL %s is empty. Continuing without filling SURLs informations.\n", currentResutl["targetSURL"].c_str()); delete turl; continue; } turl->setStatus(static_cast<ns1__TStatusCode>(atoi(currentResutl["statusCode"].c_str()))); turl->setExplanation(currentResutl["explanation"]); if(!currentResutl["estimatedWaitTime"].empty()) { turl->setEstimatedWaitTime(atoi(currentResutl["estimatedWaitTime"].c_str())); } if(!currentResutl["remainingPinTime"].empty()) { turl->setRemainingPinLifetime(atoi(currentResutl["remainingPinTime"].c_str())); } m_turls.insert(TurlPtr(turl)); } }