57 string cache_svc = reg.
GetString(
"RmtFileStatusCache",
"service",
"IC_SV_TrackHubs_PROD");
58 string cache_name = reg.
GetString(
"RmtFileStatusCache",
"cache",
"rmttrackstatus");
84 return cache->Read(sNCKey,
version, sSubKey,
data, data_size);
97 cache->Store(sNCKey, 0,
"counter", &count_zero,
sizeof(count_zero));
99 cache->Store(sNCKey, 0,
"time_stamp", &time_stamp,
sizeof(time_stamp));
102 cache->Store(sNCKey, 0,
"time_interval", &time_interval,
sizeof(time_interval));
113 LOG_POST(
Warning<<
"CRmtFileStatus::Check(): " <<
" return forced Access");
118 bool isCurrentAccessibilityKnown{
x_Read(cache, sNCKey, 0,
"access_action", &CurrentAccessibility,
sizeof(CurrentAccessibility))};
121 !isCurrentAccessibilityKnown) {
122 LOG_POST(
Warning<<
"CRmtFileStatus::Check(): " <<
"return Access, CurrentAccessibility: " << CurrentAccessibility <<
", isCurrentAccessibilityKnown: " << isCurrentAccessibilityKnown);
127 bool isCurrentCounterKnown{
x_Read(cache, sNCKey, 0,
"counter", &CurrentCounter,
sizeof(CurrentCounter))};
128 if(!isCurrentCounterKnown) {
134 LOG_POST(
Warning<<
"CRmtFileStatus::Check(): " <<
"return Access, CurrentCounter: " << CurrentCounter);
137 cache->Store(sNCKey, 0,
"counter", &CurrentCounter,
sizeof(CurrentCounter));
140 bool isCurrentTimeStampKnown{
x_Read(cache, sNCKey, 0,
"time_stamp", &TimeStamp,
sizeof(TimeStamp))};
142 bool isCurrentTimeIntervalKnown{
x_Read(cache, sNCKey, 0,
"time_interval", &TimeInterval,
sizeof(TimeInterval))};
145 if(!isCurrentTimeStampKnown || !isCurrentTimeIntervalKnown) {
147 LOG_POST(
Warning<<
"CRmtFileStatus::Check(): " <<
"return Access, no time record");
150 if(time(
NULL) - TimeStamp > TimeInterval) {
151 LOG_POST(
Warning<<
"CRmtFileStatus::Check(): " <<
"return Access, time stamp: " << TimeStamp <<
", time interval: " << TimeInterval <<
", actual time diff: " << (time(
NULL) - TimeStamp));
152 TimeStamp = time(
NULL);
153 cache->Store(sNCKey, 0,
"time_stamp", &TimeStamp,
sizeof(TimeStamp));
156 cache->Store(sNCKey, 0,
"time_interval", &TimeInterval,
sizeof(TimeInterval));
161 LOG_POST(
Warning<<
"CRmtFileStatus::Check(): " <<
"return Skip, CurrentCounter: " << CurrentCounter <<
", time stamp: " << TimeStamp <<
", time interval: " << TimeInterval <<
", actual time diff: " << (time(
NULL) - TimeStamp));
176 bool isCurrentAccessibilityKnown{
x_Read(cache, sNCKey, 0,
"access_action", &CurrentAccessibility,
sizeof(CurrentAccessibility))};
177 cache->Store(sNCKey, 0,
"access_action", &KnownAccessibility,
sizeof(KnownAccessibility));
179 !isCurrentAccessibilityKnown ||
183 LOG_POST(
Warning<<
"CRmtFileStatus::Set(" << sKey <<
") was " << CurrentAccessibility <<
", set to: " << KnownAccessibility);
Checksum and hash calculation classes.
CChecksum – Checksum calculator.
static CNcbiApplication * Instance(void)
Singleton method.
Client to NetCache server (implements ICache interface)
static string x_KeyToNCKey(const string &sKey)
time_t TTimeStamp
in seconds
static TTimeStamp m_MaxCheckInterval
@ ESuggestedAction_Access
try to access the remote file
@ ESuggestedAction_Skip
do not access the file
static unique_ptr< CNetICacheClient > m_pCacheClient
static bool x_Read(CNetICacheClient *cache, const string &sNCKey, int version, const string &sSubKey, void *data, size_t data_size)
static bool m_isStatusNotAvailable
static TCounter m_MaxCount
static CNetICacheClient * x_Init()
static void Set(const string &sKey, ESuggestedAction KnownAccessibility)
static void x_ResetSkipLimits(const string &sNCKey)
static ESuggestedAction Check(const string &sKey)
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
void AddLine(const char *line, size_t len)
string GetResultHex(void) const
Return string with checksum/hash in hexadecimal form.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Warning(CExceptionArgs_Base &args)
virtual int GetInt(const string §ion, const string &name, int default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get integer value of specified parameter name.
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.
const string version
version string
Miscellaneous common-use basic types and functionality.