(*ver_data) + ver_data->
chunks.capacity() *
sizeof(
char*);
221 size_tadd_releasable,
222 size_tsub_releasing)
281mem = (
char*)
malloc(mem_size);
305 while(!cons_list.empty()) {
307cons_list.pop_front();
316 Uint4diff = old_size - new_size;
318mem = (
char*)realloc(mem, new_size);
344 while(freed < to_free && !s_VersMap->
empty()) {
345TVerDataMap::iterator it =
s_VersMap->begin();
366vector<SNCBlobVerData*>& to_list)
368 if(from_list.size() == 0)
371 size_tprev_size = to_list.size();
372to_list.resize(prev_size + from_list.size(),
NULL);
373memcpy(&to_list[prev_size], &from_list[0],
381vector<SNCBlobVerData*> *next_add =
newvector<SNCBlobVerData*>;
382vector<SNCBlobVerData*> *next_del =
newvector<SNCBlobVerData*>;
383vector<SNCBlobVerData*> *prev_add =
nullptr, *prev_del =
nullptr;
435 for(
Uint4 i= 0;
i< was_del_size; ++
i) {
437 if(ver_data->is_linked()) {
445 if(was_del_size != 0 && new_size != 0) {
466 #if __NC_TASKS_MONITOR 467m_TaskName =
"CWriteBackControl";
498 for(
Uint4 i= 0;
i< cnt_datas; ++
i) {
506 size_tcur_size_change = 0;
510 if(cur_size_change < soft_limit)
511soft_limit -= cur_size_change;
535 state.avg_tdiff_blobcopy = 0;
536 state.max_tdiff_blobcopy = 0;
543 state.avg_tdiff_blobnotify = 0;
544 state.max_tdiff_blobnotify = 0;
649: m_TimeBucket(time_bucket),
650m_NeedReleaseMem(
false),
651m_NeedAbort(
false),
652m_CacheData(cache_data),
666 #if __NC_TASKS_MONITOR 667m_TaskName =
"CNCBlobVerManager";
694 boolfor_new_version)
701 else if(for_new_version || !cache_data->
coord.
empty()) {
739 if(cache_data->
ver_mgr!=
nullptr) {
815 if(cur_time + 60 >= cur_ver->
dead_time) {
820 if(write_time != 0) {
906 data->coord.clear();
907 data->data_coord.clear();
908 data->create_time = 0;
910 data->dead_time = 0;
982 #if __NC_TASKS_MONITOR 983m_TaskName =
"CCurVerReader";
1008ver_data->
size= cache_data->
size;
1013 if(ver_data->
size!= 0) {
1023 SRV_LOG(
Error,
"Problem reading meta-information about blob " 1035 size_tmem_size = (
char*)
maps[0]->coords - (
char*)
maps[0]
1036+ map_size *
sizeof(
maps[0]->
coords[0]);
1071updated_on_server(0),
1084is_cur_version(
false),
1085meta_has_changed(
false),
1086move_or_rewrite(
false),
1087is_releasable(
false),
1088request_data_write(
false),
1089need_write_all(
false),
1090need_stop_write(
false),
1091need_mem_release(
false),
1092delete_scheduled(
false),
1093map_move_counter(0),
1094last_access_time(0),
1100saved_access_time(0),
1109 #if __NC_TASKS_MONITOR 1110m_TaskName =
"SNCBlobVerData";
1118 SRV_FATAL(
"chunk_maps not released");
1462 if(add_meta_size != 0) {
1476: m_ChunkMaps(
NULL),
1477m_MetaInfoReady(
false),
1478m_WriteMemRequested(
false),
1481 #if __NC_TASKS_MONITOR 1482m_TaskName =
"CNCBlobAccessor";
1500 const string& password,
1522cache_data, new_version);
1603<<
" is corrupted. Blob will be deleted");
1768 for(
int t=0; !res &&
t<2; ++
t) {
1769 key.append(1,
'\1');
1772res = cr_time <=
i->second;
1786 Uint8longago = now > lifespan ? (now-lifespan) : 0;
1791 if(
f->second < longago) {
1797 if(
f->second < longago) {
1809}
else if(
i->second < when) {
1813 key.append(1,
'\1');
1815 key.append(1,
'\1').append(nc_key.
RawKey()).append(1,
'\1');
1821}
else if(
i->second < when) {
1847 boolres=
false,
error=
false;;
1848 const char*begin =
data.data();
1849 const char*end = begin +
data.size();
1852 while(end != begin) {
1859 const char*blank = strchr(begin,
' ');
1864 const char*eol = strchr(blank,separator);
1869 stringcache(blank+1, eol-blank-1);
1976 if(!
m_Key.empty()) {
2029 intcur_secs =
int(cur_srv_time.
Sec());
virtual ~CBulkCleaner(void)
State x_RequestBlobAccess(void)
State x_StartSession(void)
State x_FinishSession(void)
CNCBlobAccessor * m_BlobAccess
virtual ~CCurVerReader(void)
CNCBlobVerManager * m_VerMgr
virtual void ExecuteSlice(TSrvThreadNum thr_num)
This is the main method to do all work this task should do.
CCurVerReader(CNCBlobVerManager *mgr)
static void x_DeleteData(SNCCacheData *cache_data)
Mutex created to have minimum possible size (its size is 4 bytes) and to sleep using kernel capabilit...
void Unlock(void)
Unlock the mutex.
void Lock(void)
Lock the mutex.
static void Register(EAlertType alert_type, const string &message)
@ eDebugCacheFailedMgrAttach
@ eDebugWriteBlobInfoFailed
@ eDebugCacheFailedMgrDetach
@ eDebugDeleteSNCBlobVerData
static string GetPurgeData(char separator='\n')
ENCAccessType m_AccessType
Type of access requested for the blob.
virtual ~CNCBlobAccessor(void)
void RequestMetaInfo(CSrvTask *owner)
void SetNewVerExpire(int dead_time)
static bool Purge(const CNCBlobKeyLight &nc_key, Uint8 when)
void MoveReadPos(Uint4 move_size)
bool IsMetaInfoReady(void)
static bool HasPutSucceeded(const string &blob_key)
static void SetFailedWriteCount(int failed_write)
size_t GetWriteMemSize(void)
static int GetFailedWriteCount(void)
unsigned int GetCurBlobTTL(void) const
static void PutFailed(const string &blob_key)
CNCBlobVerManager * m_VerManager
void SetNewBlobExpire(int expire, int dead_time=0)
bool IsPurged(const CNCBlobKeyLight &nc_key) const
bool ReplaceBlobInfo(const SNCBlobVerData &new_info)
CSrvRef< SNCBlobVerData > m_CurData
void x_CreateNewData(void)
static bool UpdatePurgeData(const string &data, char separator='\n')
void SetBlobTTL(unsigned int ttl)
Set blob's timeout after last access before it will be deleted.
unsigned int GetNewVersionTTL(void) const
string m_Password
Password that was used for access to the blob.
CSrvRef< SNCBlobVerData > m_NewData
SNCChunkMaps * m_ChunkMaps
void Prepare(const string &key, const string &password, Uint2 time_bucket, ENCAccessType access_type)
Prepare lock for the blob identified by key, subkey and version.
Uint8 GetCurBlobCreateTime(void) const
unsigned int GetNewBlobTTL(void) const
void x_DelCorruptedVersion(void)
void SetCreateServer(Uint8 create_server, Uint4 create_id)
Uint4 GetReadMemSize(void)
static Uint8 GetPurgeCount()
Uint4 m_ChunkPos
Current position of reading/writing inside blob's chunk.
string GetCurPassword(void) const
static void PutSucceeded(const string &blob_key)
void SetBlobVersion(int ver)
CNCBlobAccessor(void)
Create holder of blob lock bound to the given NetCache storage.
void SetBlobCreateTime(Uint8 create_time)
bool IsBlobExists(void) const
Check if blob exists.
virtual void ExecuteSlice(TSrvThreadNum thr_num)
This is the main method to do all work this task should do.
bool IsCurBlobExpired(void) const
Check if blob is already expired but not yet deleted by GC.
void Release(void)
Release blob lock.
void Initialize(SNCCacheData *cache_data)
Initialize and acquire the lock.
int GetNewBlobExpire(void) const
const string & PackedKey(void) const
const CTempString & RawKey(void) const
string KeyForLogs(void) const
const CTempString & Cache(void) const
bool IsICacheKey(void) const
static bool WriteBlobInfo(const string &blob_key, SNCBlobVerData *ver_data, SNCChunkMaps *maps, Uint8 cnt_chunks, SNCCacheData *cache_data)
Write meta information about blob into the database.
static void ChangeCacheDeadTime(SNCCacheData *cache_data)
static bool ReadBlobInfo(SNCBlobVerData *ver_data)
Get meta information about blob with given coordinates.
static CNCBlobAccessor * GetBlobAccess(ENCAccessType access, const string &key, const string &password, Uint2 time_bucket)
Acquire access to the blob identified by key, subkey and version.
static string FindBlob(Uint2 bucket, const string &mask, Uint8 cr_time_hi)
static void ReleaseCacheData(SNCCacheData *cache_data)
static void ReferenceCacheData(SNCCacheData *cache_data)
static Uint4 GetNewBlobId(void)
static void DeleteBlobInfo(const SNCBlobVerData *ver_data, SNCChunkMaps *maps)
Delete blob from database.
static char * WriteChunkData(SNCBlobVerData *ver_data, SNCChunkMaps *maps, SNCCacheData *cache_data, Uint8 chunk_num, char *buffer, Uint4 buf_size)
static bool IsAbandoned(void)
static string PrintablePassword(const string &pass)
static bool ReadChunkData(SNCBlobVerData *ver_data, SNCChunkMaps *maps, Uint8 chunk_num, char *&buffer, Uint4 &buf_size)
virtual ~CNCBlobVerManager(void)
void x_DeleteCurVersion(void)
const string & GetKey(void)
SNCCacheData * GetCacheData(void)
void ObtainReference(void)
void RequestCurVersion(CSrvTransConsumer *consumer)
void DeleteVersion(const SNCBlobVerData *ver_data)
CSrvRef< SNCBlobVerData > CreateNewVersion(void)
static CNCBlobVerManager * Get(Uint2 time_bucket, const string &key, SNCCacheData *cache_data, bool for_new_version)
CCurVerReader * m_CurVerReader
void DeadTimeChanged(SNCBlobVerData *ver_data)
SNCCacheData * m_CacheData
void RequestMemRelease(void)
virtual void ExecuteSlice(TSrvThreadNum thr_num)
This is the main method to do all work this task should do.
void DeleteDeadVersion(int cut_time)
CSrvRef< SNCBlobVerData > GetCurVersion(void)
void FinalizeWriting(SNCBlobVerData *ver_data)
virtual void DeleteThis(void)
Virtual method "deleting" this object.
CSrvRef< SNCBlobVerData > m_CurVersion
static void GetSlotByICacheKey(const CNCBlobKeyLight &key, Uint2 &slot, Uint2 &time_bucket)
static Uint2 GetCntTimeBuckets(void)
static Uint8 GetSelfID(void)
static bool IsInitiallySynced(void)
static void DiskDataWrite(size_t data_size)
static void DiskBlobWrite(Uint8 blob_size)
static void DiskDataRead(size_t data_size)
Class used in all diagnostic logging.
CSrvDiagMsg & StartRequest(void)
Starts "request-start" message.
CSrvDiagMsg & PrintParam(CTempString name, CTempString value)
Adds parameter to "request-start" or "extra" message.
void StopRequest(void)
Prints "request-stop" message.
void Flush(void)
Finishes current message and prepare to start new one.
void CallRCU(void)
Method to be called to schedule call of ExecuteRCU() at appropriate time.
void SetState(State state)
Sets current state of the machine.
Main working entity in TaskServer.
CRequestContext * GetDiagCtx(void)
Get current diagnostic context for the task.
void RunAfter(Uint4 delay_sec)
This call is basically equivalent to SetRunnable() but with guarantee that task will be scheduled for...
void SetPriority(Uint4 prty)
Set and retrieve task's priority.
void SetRunnable(bool boost=false)
Set this task "runnable", i.e.
virtual void Terminate(void)
Stops task's execution and deletes it.
void ReleaseDiagCtx(void)
Releases current diagnostic context of the task.
void CreateNewDiagCtx(void)
Create new diagnostic context for this task to work in.
Class incorporating convenient methods to work with struct timespec.
static int CurSecs(void)
Current time in seconds since epoch (time_t).
time_t & Sec(void)
Read/set number of seconds since epoch stored in the object.
static CSrvTime Current(void)
Exact current time with precision up to nanoseconds.
Uint8 AsUSec(void) const
Converts object's value to microseconds since epoch.
Consumer of notification about transition completeness in CSrvTransitionTask.
bool IsTransFinished(void)
Check if transition completeness was consumed.
bool m_TransFinished
Flag showing that transition was already consumed.
bool IsTransStateFinal(void)
Checks if "Final" state was already reached.
void FinishTransition(void)
Finish the transition process and change task's state from "Transition" to "Final" with notification ...
static TSrvThreadNum GetMaxRunningThreads(void)
Returns maximum number of worker threads allowed ([task_server]/max_threads parameter in ini-file).
static TSrvThreadNum GetCurThreadNum(void)
Returns number of current worker thread. Number is 0-based.
static bool IsInShutdown(void)
Checks if TaskServer received request to shutdown.
CWBMemDeleter(char *mem, Uint4 mem_size)
virtual void ExecuteRCU(void)
Method implementing RCU job that was scheduled earlier by CallRCU().
virtual ~CWBMemDeleter(void)
static void Initialize(void)
virtual void ExecuteSlice(TSrvThreadNum thr_num)
This is the main method to do all work this task should do.
static void RecordNotifyUpdateBlob(Uint8 update_received)
static void StartSyncBlob(Uint8 create_time)
static void ReadState(SNCStateStat &state)
static void ResetStatCounters(void)
virtual ~CWriteBackControl(void)
static void AnotherServerMain(void)
CNCBlobVerManager * ver_mgr
CNCBlobVerManager * Get_ver_mgr(void) const
container_type::const_iterator const_iterator
container_type::iterator iterator
const_iterator begin() const
const_iterator end() const
const_iterator find(const key_type &key) const
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
const_iterator end() const
static const int chunk_size
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define ERASE_ITERATE(Type, Var, Cont)
Non-constant version with ability to erase current element, if container permits.
TValue Add(int delta) THROWS_NONE
Atomically add value (=delta), and return new counter value.
TValue Get(void) const THROWS_NONE
Get atomic counter value.
void SetRequestID(TCount rid)
Set request ID.
void Critical(CExceptionArgs_Base &args)
void Error(CExceptionArgs_Base &args)
bool NotNull(void) const THROWS_NONE
Check if pointer is not null â same effect as NotEmpty().
void AddReference(void) const
Add reference to object.
void Reset(void)
Reset reference object.
void RemoveReference(void) const
Remove reference to object.
bool Referenced(void) const THROWS_NONE
Check if object is referenced.
void Swap(TThisType &ref)
Swaps the pointer with another reference.
bool ReferencedOnlyOnce(void) const THROWS_NONE
Check if object is referenced only once.
uint8_t Uint1
1-byte (8-bit) unsigned integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
uint16_t Uint2
2-byte (16-bit) unsigned integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
static Uint8 StringToUInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to Uint8.
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.
@ fConvErr_NoThrow
Do not throw an exception on error.
@ fAllowTrailingSymbols
Ignore trailing non-numerics characters.
unsigned int
A callback function used to compare two keys in a database.
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
static const size_t kNCMaxBlobChunkSize
Maximum size of blob chunk stored in database.
static const Uint2 kNCMaxChunksInMap
static const Uint1 kNCMaxBlobMapsDepth
intr::rbtree< SNCBlobVerData, intr::base_hook< TVerDataMapHook >, intr::constant_time_size< false >, intr::compare< SCompareVerAccessTime > > TVerDataMap
static Uint4 s_CntConsumers
static bool s_FailMonitor
static void s_SubReleasingMem(size_t mem_size)
static TSrvConsList s_ConsList
vector< SNCBlobVerData * > s_WBToAddList
static char * s_AllocWriteBackMem(Uint4 mem_size, CSrvTransConsumer *consumer)
Uint4 s_TaskPriorityWbMemRelease
static CAtomicCounter s_FailedCounter
static void s_AddReleasingMem(size_t add_releasing, size_t sub_releasable)
static void s_ReleaseMemory(size_t soft_limit)
void SetWBHardSizeLimit(Uint8 limit)
static size_t s_CalcChunkMapsSize(Uint2 map_size)
static Uint8 s_BlobSyncMaxTDiff
static void s_AddCurrentMem(size_t mem_size)
void SetWBSoftSizeLimit(Uint8 limit)
vector< SNCBlobVerData * > s_WBToDelList
static CBulkCleaner * s_BulkCleaner
static set< string > s_FailedKeys
static void s_ScheduleVerDelete(SNCBlobVerData *ver_data)
static Uint8 s_BlobNotify
static int s_WBWriteTimeout2
void SetWBWriteTimeout(int timeout1, int timeout2)
static Uint8 s_BlobNotifyTDiff
static const size_t kDefChunkMapsSize
static Uint8 s_LatestPurge
static char * s_ReallocWriteBackMem(char *mem, Uint4 old_size, Uint4 new_size)
static const size_t kVerManagerSize
static int s_WBWriteTimeout
static TVerDataMap * s_VersMap
static void s_SubCurrentMem(size_t mem_size)
static ssize_t s_WBCurSize
static SWriteBackData * s_GetWBData(void)
static Uint8 s_AnotherServerMain
static SWriteBackData * s_WBData
static Uint8 s_BlobSyncTDiff
static void s_TransferVerList(vector< SNCBlobVerData * > &from_list, vector< SNCBlobVerData * > &to_list)
static size_t s_CalcVerDataSize(SNCBlobVerData *ver_data)
static CWriteBackControl * s_WBControl
map< string, Uint8 > TForgets
static TForgets s_Forgets
static void s_ProcessWBAddDel(Uint4 was_del_size)
static size_t s_WBSoftSizeLimit
Uint8 GetWBSoftSizeLimit(void)
static void s_AddReleasableMem(SNCBlobVerData *ver_data, size_t add_releasable, size_t sub_releasing)
static void s_SubReleasableMem(size_t mem_size)
int GetWBWriteTimeout(void)
static void s_FreeWriteBackMem(char *mem, Uint4 mem_size, Uint4 sub_releasing)
Uint8 GetWBHardSizeLimit(void)
static Uint8 s_BlobNotifyMaxTDiff
void SetWBInitialSyncComplete(void)
static ssize_t s_WBReleasingSize
static size_t s_WBHardSizeLimit
static CMiniMutex s_ConsListLock
static void s_CollectWBData(SWriteBackData *wb_data)
static int s_FailedReserve
static ssize_t s_WBReleasableSize
int GetWBFailedWriteDelay(void)
void SetWBFailedWriteDelay(int delay)
static CMiniMutex s_FailedListLock
static bool s_IsCurVerOlder(const SNCBlobVerData *cur_ver, const SNCBlobVerData *new_ver)
static void s_NotifyConsumers(void)
static Uint2 s_WBFailedWriteDelay
static TForgets s_ForgetKeys
ENCAccessType
Type of access to NetCache blob.
@ eNCReadData
Read blob data.
@ eNCCopyCreate
(Re-)write blob from another NetCache (as opposed to writing from client)
@ eNCCreate
Create blob or re-write its contents.
#define NCBI_CONST_UINT8(v)
static void write_size(CNcbiOstream &stream, size_t size)
Defines CRequestContext class for NCBI C++ diagnostic API.
#define SRV_LOG(sev, msg)
Macro to be used for printing log messages.
CSrvRef< C > SrvRef(C *object)
T AtomicAdd(T volatile &var, T add_value)
#define ACCESS_ONCE(x)
Purpose of this macro is to force compiler to access variable exactly at the place it's written (no m...
bool AtomicCAS(T volatile &var, T old_value, T new_value)
intr::list< CSrvTransConsumer, intr::base_hook< TSrvConsListHook >, intr::constant_time_size< false > > TSrvConsList
constexpr Uint8 kUSecsPerSecond
Full information about NetCache blob (excluding key)
virtual ~SNCBlobVerData(void)
size_t RequestMemRelease(void)
virtual void DeleteThis(void)
Virtual method "deleting" this object.
void x_DeleteVersion(void)
bool x_WriteCurChunk(char *write_mem, Uint4 write_size)
bool x_WriteBlobInfo(void)
void x_FreeChunkMaps(void)
void AddChunkMem(char *mem, Uint4 mem_size)
CNCBlobVerManager * ver_manager
void SetNonReleasable(void)
void RequestDataWrite(void)
SNCBlobVerData(CNCBlobVerManager *mgr)
SNCChunkMaps * chunk_maps
bool x_ExecuteWriteAll(void)
virtual void ExecuteSlice(TSrvThreadNum thr_num)
This is the main method to do all work this task should do.
SNCChunkMaps(Uint2 map_size)
SNCChunkMapInfo * maps[kNCMaxBlobMapsDepth+1]
vector< SNCBlobVerData * > * to_del_list
vector< SNCBlobVerData * > * to_add_list
Uint2 TSrvThreadNum
Type for thread number in TaskServer.
voidp calloc(uInt items, uInt size)
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