: m_Verbose(
verbose), m_Db(
NULL), m_Timeout(timeout, 0)
64cout <<
"Connecting to the NetStorage meta info database..." 68cout <<
"Connected"<< endl;
70cerr <<
"Error connecting to the NetStorage meta info database"<< endl;
79cout <<
"Closing the NetStorage meta info database connection..." 83cout <<
"Closed"<< endl;
91cout <<
"Getting the application lock..."<< endl;
96 query.SetParameter(
"@Resource",
"GarbageCollectorLock");
97 query.SetParameter(
"@LockMode",
"Exclusive");
98 query.SetParameter(
"@LockOwner",
"Session");
99 query.SetParameter(
"@LockTimeout", 0);
102 intstatus =
query.GetStatus();
107 "sp_getapplock return code: "+
109}
catch(
constexception & exc) {
110cerr <<
"Error getting the application lock: "<< exc.what() << endl;
113cerr <<
"Unknown error getting the application lock " 114 "for the database"<< endl;
119cout <<
"Got"<< endl;
126cout <<
"Releasing the application lock..."<< endl;
131 query.SetParameter(
"@Resource",
"GarbageCollectorLock");
132 query.SetParameter(
"@LockOwner",
"Session");
135 if(
query.GetStatus() != 0)
137 "Error releasing the application lock");
140cerr << ex.
what() << endl;
144cerr <<
"Exception while releasing the application lock " 145 "for the database: "<< ex.
what() << endl;
147}
catch(
conststd::exception & ex) {
149cerr <<
"Exception while releasing the application lock " 150 "for the database: "<< ex.
what() << endl;
153 string msg=
"Unknown error of releasing the application lock " 161cout <<
"Released"<< endl;
168cout <<
"Reading the NetStorage meta info " 169 "database connection parameters..."<< endl;
174 "database",
"password",
178cout <<
"Read"<< endl;
194cout <<
"Creating CDatabase (uri: "<< uri <<
")..."<< endl;
197cout <<
"Created"<< endl;
204vector<string> candidates;
205 string stmt=
"SELECT object_loc FROM Objects " 206 "WHERE tm_expiration IS NOT NULL AND " 207 "tm_expiration < GETDATE()";
210cout <<
"Retrieving the expired objects from the NetStorage meta info " 211 "database..."<< endl;
218candidates.push_back(
row[
"object_loc"].AsString());
221cerr <<
"Error retrieving the expired objects from the NetStorage meta " 222 "info database"<< endl;
227cout <<
"Retrieved "<< candidates.size()
228<<
" expired object(s)"<< endl;
236 string stmt=
"SELECT version FROM Versions " 237 "WHERE name = 'db_structure'";
241cout <<
"Retrieving the version of the NetStorage meta info " 242 "database structure..."<< endl;
250 string msg=
"Too many NetStorage meta info " 251 "database structure versions";
256db_ver =
row[
"version"].AsInt4();
261cerr <<
"Error retrieving the version of the NetStorage meta info " 262 "database structure..."<< endl;
267 string msg=
"Cannot find the version of the NetStorage meta info " 268 "database structure";
274cout <<
"Retrieved: "<< db_ver << endl;
281 const string& hit_id)
287cout <<
"Removing attributes of object "<< locator << endl;
289 string stmt=
"DELETE FROM AttrValues WHERE object_id IN (" 290 "SELECT object_id FROM Objects WHERE object_loc='"+
297 ctx->SetRequestID();
299 ctx->SetHitID(hit_id);
301.Print(
"action",
"meta_attributes_remove")
302.Print(
"locator", locator);
307 ctx->SetRequestStatus(200);
314 ctx->SetRequestStatus(500);
319cerr <<
"Exception while removing attributes of object " 322}
catch(
conststd::exception & ex ) {
325 ctx->SetRequestStatus(500);
330cerr <<
"std::exception while removing attributes of object " 336 ctx->SetRequestStatus(500);
341cerr <<
"Unknown exception while removing attributes of object " 348cout <<
"Removing the object record for "<< locator << endl;
350 stmt=
"DELETE FROM Objects WHERE object_loc='"+ locator +
"'";
355 ctx->SetRequestID();
357 ctx->SetHitID(hit_id);
359.Print(
"action",
"meta_object_remove")
360.Print(
"locator", locator);
365 ctx->SetRequestStatus(200);
372 ctx->SetRequestStatus(500);
377cerr <<
"Exception while removing the object record for " 380}
catch(
conststd::exception & ex ) {
383 ctx->SetRequestStatus(500);
388cerr <<
"std::exception while removing the object record for " 394 ctx->SetRequestStatus(500);
399cerr <<
"Unknown exception while removing the object record for "Database connection object.
void Close(void)
Close database object.
void Connect(void)
Explicitly (re)connect to the database server.
CQuery NewQuery(void)
Get new CQuery object for this database.
SDbAccessInfo m_DbAccessInfo
CNetStorageGCDatabase(const CNcbiRegistry ®, bool verbose, unsigned int timeout)
void x_CreateDatabase(const CNcbiRegistry ®)
void RemoveObject(const string &locator, bool dryrun, const string &hit_id)
void x_ReadDbAccessInfo(const CNcbiRegistry ®)
void ReleaseAppLock(void)
vector< string > GetGCCandidates(void)
~CNetStorageGCDatabase(void)
int GetDBStructureVersion(void)
Object used to execute queries and stored procedures on the database server and retrieve result sets.
Convenience class to initialize database connection parameters from URL-like strings and/or applicati...
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
void PrintRequestStop(void)
Print request stop message (for request-driven applications)
CDiagContext & GetDiagContext(void)
Get diag context instance.
static void SetRequestContext(CRequestContext *ctx)
Shortcut to CDiagContextThreadData::GetThreadData().SetRequestContext()
void PrintRequestStart(const string &message)
Print request start message (for request-driven applications)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
string GetEncryptedString(const string §ion, const string &name, TFlags flags=0, const string &password=kEmptyStr) const
Get a value that was (potentially) stored encrypted.
virtual string GetString(const string §ion, const string &name, const string &default_value, TFlags flags=0) const
Get the parameter string value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Defines NCBI C++ diagnostic APIs, classes, and macros.
const string k_UnknownException
Defines CRequestContext class for NCBI C++ diagnostic API.
Defines NCBI C++ secure resources API.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
#define row(bind, expected)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4