A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/nc__storage_8cpp_source.html below:

NCBI C++ ToolKit: src/app/netcache/nc_storage.cpp Source File

49 # include <sys/types.h> 50 # include <sys/stat.h> 52 # include <sys/mman.h> 55 #define __NC_CACHEDATA_ALL_MONITOR 0 57 #define __NC_CACHEDATA_INTR_SET 1 59 #if __NC_CACHEDATA_ALL_MONITOR 119 #if __NC_CACHEDATA_INTR_SET 145

intr::base_hook<TTimeTableHook>,

146

intr::constant_time_size<false>,

149

intr::base_hook<TKeyMapHook>,

150

intr::constant_time_size<true>,

165  return

x->

key

< y->

key

;

168 typedef

std::set<SNCCacheData*, SCacheDeadCompare>

TTimeTableMap

;

169 typedef

std::set<SNCCacheData*, SCacheKeyCompare>

TKeyMap

;

187 #if __NC_CACHEDATA_ALL_MONITOR 188 struct

SAllCacheTable

196 #if __NC_CACHEDATA_MONITOR 199 void

SNCCacheData::x_Register(

void

)

201

s_AllCacheLock.

Lock

();

202

s_AllCacheSet.

insert

(

this

);

203

s_AllCacheLock.

Unlock

();

205 void

SNCCacheData::x_Revoke(

void

)

207

s_AllCacheLock.

Lock

();

208

s_AllCacheSet.

erase

(

this

);

209

s_AllCacheLock.

Unlock

();

268 #if __NC_CACHEDATA_ALL_MONITOR 269 static

TAllCacheBuckets s_AllCache;

297 #define DB_CORRUPTED(msg) \ 299  SRV_LOG(Fatal, "Database is corrupted. "

<< msg \

300

<< " Bug, faulty disk or somebody writes to database?"); \

316 #if __NC_CACHEDATA_INTR_SET 317

TKeyMap::iterator

lb

= cache->

key_map

.lower_bound(search_mask);

319  if

(

strncmp

(search_mask.

key

.data(),

lb

->key.data(), search_mask.

key

.size())== 0) {

320  if

(

Uint8

(

lb

->expire) <= cur_time) {

323  if

(

lb

->create_time <= cr_time_hi) {

332

TKeyMap::iterator

lb

= cache->

key_map

.lower_bound(&search_mask);

334  if

(

strncmp

(search_mask.

key

.data(), (*lb)->key.data(), search_mask.

key

.size())== 0) {

335  if

((*lb)->expire <= cur_time) {

338  if

((*lb)->create_time <= cr_time_hi) {

355  if

(

mask

.empty()) {

359  const char

* mb =

mask

.data();

360  const char

* me =

mask

.data() +

mask

.size() - 1;

361  bool

show_exp =

false

;

362  while

(*mb ==

'\"'

|| *mb ==

'\''

|| *mb ==

'*'

) {

366  while

(me > mb && *me ==

'\1'

&& *(me-1) ==

'\1'

) {

369  if

(me == mb && *me ==

'\1'

) {

372

search_mask.

key

.assign(mb, me+1-mb);

385  bool

extra = cr_time_lo != 0 || cr_time_hi != 0 ||

386

expire_lo != 0 || expire_hi != 0 ||

387

vexpire_lo != 0 || vexpire_hi != 0 ||

388

size_lo != 0 || size_hi != 0 || create_server != 0;

393 #if __NC_CACHEDATA_INTR_SET 394

TKeyMap::iterator

lb

= cache->

key_map

.lower_bound(search_mask);

397  if

(

strncmp

(search_mask.

key

.data(),

lb

->key.data(), search_mask.

key

.size())== 0) {

398  if

(!show_exp &&

Uint8

(

lb

->expire) <= cur_time) {

402

(

lb

->create_time >= cr_time_lo && (cr_time_hi == 0 ||

lb

->create_time < cr_time_hi)) &&

403

(

lb

->expire >= expire_lo && ( expire_hi == 0 ||

lb

->expire < expire_hi)) &&

404

(

lb

->ver_expire >= vexpire_lo && (vexpire_hi == 0 ||

lb

->ver_expire < vexpire_hi)) &&

405

(

lb

->size >= size_lo && ( size_hi == 0 ||

lb

->size < size_hi)) &&

406

(create_server == 0 ||

lb

->create_server == create_server))) {

409  buffer

->append(bkey.data(), bkey.size());

411  if

(cr_time_lo != 0 || cr_time_hi != 0) {

414  if

(expire_lo != 0 || expire_hi != 0) {

415  buffer

->WriteText(sep).WriteText(

"exp="

).WriteNumber(

lb

->expire);

417  if

(vexpire_lo != 0 || vexpire_hi != 0) {

418  buffer

->WriteText(sep).WriteText(

"ver_dead="

).WriteNumber(

lb

->ver_expire);

420  if

(create_server != 0) {

421  buffer

->WriteText(sep).WriteText(

"cr_srv="

).WriteNumber(

lb

->create_server);

423  if

(size_lo != 0 || size_hi != 0) {

424  buffer

->WriteText(sep).WriteText(

"size="

).WriteNumber(

lb

->size);

427  buffer

->append(

"\n"

,1);

434

TKeyMap::iterator

lb

= cache->

key_map

.lower_bound(&search_mask);

436  if

(

strncmp

(search_mask.

key

.data(), (*lb)->key.data(), search_mask.

key

.size())== 0) {

437  if

(!show_exp && (*lb)->expire <= cur_time) {

441

((*lb)->create_time >= cr_time_lo && (cr_time_hi == 0 || (*lb)->create_time <= cr_time_hi)) &&

442

((*lb)->expire >= expire_lo && ( expire_hi == 0 || (*lb)->expire <= expire_hi)) &&

443

((*lb)->ver_expire >= vexpire_lo && (vexpire_hi == 0 || (*lb)->ver_expire <= vexpire_hi)) &&

444

((*lb)->size >= size_lo && ( size_hi == 0 || (*lb)->size <= size_hi)) &&

445

(create_server == 0 || (*lb)->create_server == create_server))) {

448  buffer

->append(bkey.data(), bkey.size());

450  if

(cr_time_lo != 0 || cr_time_hi != 0) {

453  if

(expire_lo != 0 || expire_hi != 0) {

454  buffer

->WriteText(

",exp="

).WriteNumber((*lb)->expire);

456  if

(vexpire_lo != 0 || vexpire_hi != 0) {

457  buffer

->WriteText(

",ver_dead="

).WriteNumber((*lb)->ver_expire);

459  if

(create_server != 0) {

460  buffer

->WriteText(

",cr_srv="

).WriteNumber((*lb)->create_server);

462  if

(size_lo != 0 || size_hi != 0) {

463  buffer

->WriteText(

",size="

).WriteNumber((*lb)->size);

466  buffer

->append(

"\n"

,1);

482  char

* mem_ptr =

NULL

;

485

mem_ptr = (

char

*)mmap(

NULL

, file_size, PROT_READ | PROT_WRITE,

487  if

(mem_ptr == MAP_FAILED) {

500

munmap(mem_ptr, file_size);

510  int

res = mlock(mem_ptr, mem_size);

568  if

(warn_pct <= 0 || warn_pct >= 100) {

569  SRV_LOG

(

Error

,

"Parameter db_limit_percentage_alert has wrong value " 570

<< warn_pct <<

". Assuming it's 65."

);

576  SRV_LOG

(

Error

,

"Parameter db_limit_percentage_alert_delta has wrong value " 577

<< warn_pct <<

". Assuming it's 5."

);

688

guard_file.

GetMode

(&user_mode, &grp_mode, &oth_mode);

690

guard_file.

SetMode

(user_mode, grp_mode, oth_mode);

700  "InstanceGuard file "

+

s_GuardName

+

" was present on startup"

);

701  INFO

(

"NetCache wasn't finished cleanly in previous run. " 702  "Will try to work with storage as is."

);

709

writer.

Write

(pid.c_str(), pid.size());

712  SRV_LOG

(

Critical

,

"Can't lock the database (other instance is running?): "

<< ex);

741  for

(

int i

= 0;

i

< 2; ++

i

) {

751  if

(

info

->fd == -1) {

764  if

(file_size == -1) {

766

<<

"). File "

<<

info

->file_name

767

<<

" will be deleted."

);

772  if

(!

info

->file_map)

791

--

info

->index_head;

798  SRV_LOG

(

Error

,

"Index file is broken, reinitializing storage. "

<< ex);

802  SRV_LOG

(

Critical

,

"Cannot open or create index file for the storage."

);

829  SRV_LOG

(

Error

,

"Error in soft reinitialization, trying harder. "

<< ex);

848  if

((

char

*)ind_rec < min_ptr || ind_rec >= file_info->

index_head

) {

849  DB_CORRUPTED

(

"Bad record number requested, rec_num="

<< rec_num

851

<<

". It produces pointer "

<< (

void

*)ind_rec

852

<<

" which is not in the range between "

<< (

void

*)min_ptr

853

<<

" and "

<< (

void

*)file_info->

index_head

<<

"."

);

856  if

((next_num != 0 && next_num < rec_num) || ind_rec->

prev_num

> rec_num)

860

<<

" contains bad next_num "

<< next_num

861

<<

" and/or prev_num "

<< ind_rec->

prev_num

<<

"."

);

873

<<

" has been deleted."

);

983  if

(file_info.

IsNull

()) {

997

cnt_chunks = (cnt_chunks + map_size - 1) / map_size;

1007  DB_CORRUPTED

(

"Size parameters are resulted in bad map_depth" 1008

<<

", size="

<<

size 1010

<<

", map_size="

<< map_size);

1033  return Uint4

((

char

*)&meta_rec.

key_data

[key_size] - (

char

*)&meta_rec);

1040  return Uint4

((

char

*)&map_rec.

down_coords

[cnt_downs] - (

char

*)&map_rec);

1047  return Uint4

((

char

*)&data_rec.

chunk_data

[data_size] - (

char

*)&data_rec);

1054  char

* rec_end = rec_ptr + ind_rec->

rec_size

;

1056  if

(rec_ptr < min_ptr || rec_ptr >= (

char

*)ind_rec

1057

|| rec_end < rec_ptr || rec_end > (

char

*)ind_rec

1058

|| (file_info->

index_head

- ind_rec == 1 && (

char

*)rec_ptr != min_ptr))

1062

<<

" has wrong offset "

<< ind_rec->

offset 1063

<<

" and/or size "

<< ind_rec->

rec_size 1064

<<

". It results in address "

<< (

void

*)rec_ptr

1065

<<

" that doesn't fit between "

<< (

void

*)min_ptr

1066

<<

" and "

<< (

void

*)ind_rec <<

"."

);

1077

<<

" has wrong type "

<<

int

(ind_rec->

rec_type

)

1078

<<

" when should be "

<<

int

(

eFileRecMeta

) <<

"."

);

1084  if

(ind_rec->

rec_size

< min_size) {

1087

<<

" has wrong rec_size "

<< ind_rec->

rec_size 1088

<<

" for meta record." 1089

<<

" It's less than minimum "

<< min_size <<

"."

);

1100

<<

" has wrong type "

<<

int

(ind_rec->

rec_type

)

1105  if

(ind_rec->

rec_size

< min_size) {

1108

<<

" has wrong rec_size "

<< ind_rec->

rec_size 1109

<<

" for map record." 1110

<<

" It's less than minimum "

<< min_size <<

"."

);

1121

<<

" has wrong type "

<<

int

(ind_rec->

rec_type

)

1126  if

(ind_rec->

rec_size

< min_size) {

1129

<<

" has wrong rec_size "

<< ind_rec->

rec_size 1130

<<

" for data record." 1131

<<

" It's less than minimum "

<< min_size <<

"."

);

1149  size_t

true_type_idx = type_idx;

1152

file_info->

file_id

= file_id;

1159 #ifdef NCBI_OS_LINUX 1161

O_RDWR | O_CREAT | O_TRUNC |

O_NOATIME

,

1163  if

(file_info->

fd

== -1) {

1164  SRV_LOG

(

Critical

,

"Cannot create new storage file, errno="

<< errno);

1169  if

(trunc_res != 0) {

1198  switch

(true_type_idx) {

1209  SRV_FATAL

(

"Unsupported file type: "

<< true_type_idx);

1215

(*s_DBFiles)[file_id] = file_info;

1260

is_releasing(

false

),

1272 #ifdef NCBI_OS_LINUX 1275

<<

", errno="

<< errno);

1279  if

(errno != ENOENT) {

1281

<<

", errno="

<< errno);

1314 #if __NC_CACHEDATA_ALL_MONITOR 1315

s_AllCache[

i

] =

new

SAllCacheTable();

1321  int

max_create_time = 0;

1357  string

is(

"\": "

),iss(

"\": \""

), eol(

",\n\""

),

str

(

"_str"

), eos(

"\""

);

1402  string

is(

"\": "

),iss(

"\": \""

), eol(

",\n\""

),

str

(

"_str"

), eos(

"\""

);

1417  Uint8

cache_count = 0, timetable_count = 0;

1425 #if __NC_CACHEDATA_INTR_SET 1427

expire =

max

( expire, it->dead_time);

1428

++blob_per_file[it->coord.file_id];

1430  size

+= (*it)->size;

1431

expire =

max

( expire, (*it)->dead_time);

1432

++blob_per_file[(*it)->coord.file_id];

1439  table

->lock.Lock();

1440

timetable_count +=

table

->time_map.size();

1441  table

->lock.Unlock();

1444  string

is(

"\": "

),iss(

"\": \""

), eol(

",\n\""

),

str

(

"_str"

), eos(

"\""

);

1452 #if __NC_CACHEDATA_ALL_MONITOR 1453  size_t

ncaches_count = 0;

1454  ITERATE

(TAllCacheBuckets, tt, s_AllCache) {

1455

SAllCacheTable*

table

= tt->second;

1456  table

->lock.Lock();

1457

ncaches_count +=

table

->all_cache_set.size();

1458  table

->lock.Unlock();

1462 #if __NC_CACHEDATA_MONITOR 1463

s_AllCacheLock.

Lock

();

1464  size_t

all_caches_count = s_AllCacheSet.

size

();

1465

s_AllCacheLock.

Unlock

();

1473  for

( ;

b

!= blob_per_file.

end

(); ++

b

) {

1476  if

(file_info.

IsNull

()) {

1477  if

(

b

->first != 0) {

1491  string

eol(

"\n{\""

), more(

","

);

1496  bool

is_first =

true

;

1503 #if __NC_CACHEDATA_INTR_SET 1516

sendBuff.

append

(

","

, 1);

1519

sendBuff.

append

(eol.data(), eol.size());

1522

sendBuff.

append

(

key

.SubKey().data(),

key

.SubKey().size()).

append

(

"\": ["

,4);

1538

sendBuff.

append

(

"]}"

, 2);

1542

sendBuff.

append

(

"\n]"

,2);

1548  bool

use_mask =

false

, is_id =

false

, is_audit =

false

;

1549  if

(!

mask

.empty()) {

1550

is_audit =

mask

==

"audit"

;

1561  string

is(

"\": "

),iss(

"\": \""

), eol(

",\n\""

),

str

(

"_str"

), eos(

"\""

);

1566  bool

is_first =

true

;

1569  if

(is_id && it->second->file_id !=

id

) {

1590  Uint4

expired_count = 0, null_cache_count = 0, wrong_cache_count = 0;

1600 #if __NC_CACHEDATA_INTR_SET 1601

all_cache_data.

insert

(&(*it));

1603

all_cache_data.

insert

(*it);

1612  Uint4

prev_rec_num = 0;

1616  if

(rec_num <= prev_rec_num) {

1622  if

((

char

*)next_ind < min_ptr || next_ind >= ind_rec) {

1627  char

* next_rec_start = file_info->

file_map

+ next_ind->

offset

;

1628  if

(next_rec_start < min_ptr || next_rec_start > (

char

*)next_ind

1629

|| (rec_num == 1 && next_rec_start != min_ptr)) {

1634  char

* next_rec_end;

1635

next_rec_end = next_rec_start + next_ind->

rec_size

;

1636  if

(next_rec_end < next_rec_start || next_rec_end > (

char

*)next_ind) {

1641  if

(next_ind->

prev_num

!= prev_rec_num) {

1642

next_ind->

prev_num

= prev_rec_num;

1684  if

(next_ind->

rec_size

< min_rec_size) {

1706

}

else if

(all_cache_data.

find

(next_ind->

cache_data

) == all_cache_data.

end

()) {

1707

++wrong_cache_count;

1710

min_ptr = next_rec_end;

1712

prev_rec_num = rec_num;

1752  static const char

digits[] = {

'0'

,

'1'

,

'2'

,

'3'

,

'4'

,

'5'

,

'6'

,

'7'

,

1753  '8'

,

'9'

,

'a'

,

'b'

,

'c'

,

'd'

,

'e'

,

'f'

};

1755  string result

(32,

'\0'

);

1756  for

(

int i

= 0, j = 0;

i

< 16; ++

i

) {

1758  result

[j++] = digits[c >> 4];

1759  result

[j++] = digits[c & 0xF];

1780 #if __NC_CACHEDATA_INTR_SET 1782

TKeyMap::insert_commit_data commit_data;

1783

pair<TKeyMap::iterator, bool> ins_res

1785  if

(ins_res.second) {

1788  data

->time_bucket = time_bucket;

1789

cache->

key_map

.insert_unique_commit(*

data

, commit_data);

1792 #if __NC_CACHEDATA_ALL_MONITOR 1793

SAllCacheTable*

table

= s_AllCache[time_bucket];

1794  table

->lock.Lock();

1796  table

->lock.Unlock();

1800  data

= &*ins_res.first;

1805  if

(it == cache->

key_map

.end()) {

1815

TKeyMap::iterator it = cache->

key_map

.find( &search_mask);

1816  if

(it != cache->

key_map

.end()) {

1819  if

(

data

->time_bucket != time_bucket) {

1823

}

else if

(need_create) {

1826  data

->time_bucket = time_bucket;

1830 #if __NC_CACHEDATA_ALL_MONITOR 1831

SAllCacheTable*

table

= s_AllCache[time_bucket];

1832  table

->lock.Lock();

1834  table

->lock.Unlock();

1848  data

->ref_cnt.Add(1);

1854  if

(

data

->ref_cnt.Get() == 0) {

1860  if

(

data

->ref_cnt.Add(-1) != 0) {

1873  if

(!

data

->coord.empty() &&

data

->dead_time == 0) {

1878  if

(

data

->ref_cnt.Get() != 0 || !

data

->coord.empty()

1889 #if __NC_CACHEDATA_INTR_SET 1896 #if __NC_CACHEDATA_ALL_MONITOR 1897

SAllCacheTable*

table

= s_AllCache[time_bucket];

1898  table

->lock.Lock();

1900  table

->lock.Unlock();

1930  const string

&

key

,

1931  const string

& password,

1935

accessor->

Prepare

(

key

, password, time_bucket, access);

1958  Uint4

true_rec_size = rec_size;

1959  if

(true_rec_size & 7)

1960

true_rec_size += 8 - (true_rec_size & 7);

1963  bool

need_signal_switch =

false

;

1992

need_signal_switch =

true

;

2016  if

(prev_ind_rec->

next_num

!= 0) {

2027  if

(need_signal_switch)

2043  if

(file_info.

IsNull

()) {

2059

<<

" has wrong cache_data pointer "

<< ind_rec->

cache_data 2064

ver_data->

ttl

= meta_rec->

ttl

;

2067

ver_data->

size

= meta_rec->

size

;

2091  for

(

Uint2 i

= 0;

i

< cnt_downs; ++

i

) {

2094  if

(file_info.

IsNull

()) {

2136  size_t

coords_size = cnt_downs *

sizeof

(map_rec->

down_coords

[0]);

2139

cout <<

"s_SaveOneMapImpl: " 2141

<<

" cnt_downs="

<< cnt_downs

2142

<<

" map_idx="

<< map_rec->

map_idx 2144

<<

" down_coords="

;

2145  for

(

Uint2

c=0; c<cnt_downs; ++c) {

2155

memset(save_map->

coords

, 0, map_size *

sizeof

(save_map->

coords

[0]));

2179  Uint1

cur_level = 0;

2184

&& (maps[cur_level]->map_idx == ver_data->

map_size 2185

|| (maps[cur_level]->

map_idx

> 1 && save_all_deps)))

2187

cnt_downs = maps[cur_level]->

map_idx

;

2190

ver_data->

map_size

, cur_level + 1, cache_data))

2202

&& (maps[cur_level]->map_idx == ver_data->

map_size 2203

|| (prev_idx > 0 && save_all_deps)))

2205

cnt_downs = maps[cur_level]->

map_idx

;

2207

prev_idx = maps[cur_level]->

map_idx

;

2209

ver_data->

map_size

, cur_level + 1, cache_data))

2228  if

(old_coord.

empty

()) {

2246  if

(down_coord.

empty

()) {

2250  else if

(ver_data->

size

!= 0) {

2280

meta_rec->

size

= ver_data->

size

;

2285

meta_rec->

ttl

= ver_data->

ttl

;

2292  char

* key_data = meta_rec->

key_data

;

2293  if

(ver_data->

password

.empty()) {

2298

memcpy(key_data, ver_data->

password

.data(), 16);

2301

memcpy(key_data, blob_key.data(), blob_key.size());

2303

ver_data->

coord

= meta_coord;

2306  if

(!down_coord.

empty

()) {

2308  if

(down_file.

IsNull

()) {

2324  if

(!old_coord.

empty

()) {

2344  if

(coord.

empty

()) {

2348  if

(file_info.

IsNull

()) {

2358

<<

" has wrong up_coord "

<< ind_rec->

chain_coord 2359

<<

" when should be "

<< up_coord <<

"."

);

2367  if

(cnt_downs != 0) {

2369  for

(

Uint2 i

= 0;

i

< cnt_downs; ++

i

) {

2387  if

(ver_data->

size

!= 0) {

2390

ver_data->

coord

,

true

);

2398

empty_coord.

clear

();

2401  while

(idx < ver_data->map_size

2418  if

(map_file.

IsNull

()) {

2446

<<

" has wrong index "

<< map_rec->

map_idx 2447

<<

" and/or depth "

<< map_rec->

map_depth 2448

<<

" when it should be "

<< map_info->

map_idx 2449

<<

" and "

<< map_depth <<

"."

);

2464  Uint1

cur_index = 0;

2465  Uint8

level_num = chunk_num;

2467

map_idx[cur_index] =

Uint2

(level_num % ver_data->

map_size

);

2471  while

(level_num != 0);

2478  if

(this_map->

map_idx

== this_index

2486

this_map->

map_idx

= this_index;

2507  while

(

depth

> 0) {

2508

this_index = map_idx[

depth

];

2512

this_map->

map_idx

= this_index;

2526  if

(chunk_num != 0) {

2537

chunk_coord = maps->

maps

[0]->

coords

[map_idx[0]];

2541  if

(data_file.

IsNull

()) {

2569

<<

" in chunk record "

<< chunk_coord.

rec_num 2570

<<

" has wrong chunk number "

<< data_rec->

chunk_num 2571

<<

" and/or chunk index "

<< data_rec->

chunk_idx 2572

<<

". Deleting blob."

);

2591  Uint1

cur_index = 0;

2592  Uint8

level_num = chunk_num;

2594

map_idx[cur_index] =

Uint2

(level_num % ver_data->

map_size

);

2602

<<

" with map_size="

<< ver_data->

map_size

<<

"."

);

2634

maps->

maps

[0]->

coords

[map_idx[0]] = data_coord;

2645  table

->lock.Lock();

2647 #if __NC_CACHEDATA_INTR_SET 2648  table

->time_map.erase(

table

->time_map.iterator_to(*cache_data));

2650  table

->time_map.erase(cache_data);

2659 #if __NC_CACHEDATA_INTR_SET 2660  table

->time_map.insert_equal(*cache_data);

2662  table

->time_map.insert(cache_data);

2666  table

->lock.Unlock();

2732  Int8

allowed_db_size = total_space;

2735

allowed_db_size = 16;

2739

allowed_db_size = 16;

2745  return

allowed_db_size;

2825 #if __NC_CACHEDATA_INTR_SET 2826

res =

max

( res, it->dead_time);

2828

res =

max

( res, (*it)->dead_time);

2839

blobs_lst.

clear

();

2841  Uint2

bucket_num = (slot - 1) * slot_buckets + 1;

2842  for

(

Uint2 i

= 0;

i

< slot_buckets; ++

i

, ++bucket_num) {

2855 #if __NC_CACHEDATA_INTR_SET 2865  for

(

Uint8 i

= 0;

i

< cnt_blobs; ++

i

) {

2866  Uint2

key_slot = 0, key_bucket = 0;

2868

key_slot != slot

) {

2869  SRV_FATAL

(

"Slot verification failed, blob key: "

<< info_ptr->

key

<<

2870  ", expected slot: "

<< slot <<

", calculated slot: "

<< key_slot);

2872  if

(key_bucket != bucket_num) {

2874  ", slot: "

<< slot <<

2875  ", expected bucket: "

<< bucket_num <<

", calculated bucket: "

<< key_bucket);

2888

blob_sum->

size

= info_ptr->

size

;

2895

blobs_lst[info_ptr->

key

] = blob_sum;

2897

info_ptr->~SNCTempBlobInfo();

2916  table

->lock.Lock();

2917  if

(!

table

->time_map.empty()) {

2918 #if __NC_CACHEDATA_INTR_SET 2920  table

->time_map.begin()->dead_time);

2923

(*

table

->time_map.begin())->dead_time);

2926  table

->lock.Unlock();

2929  state

.min_dead_time = 0;

2938  if

(map_depth != 0) {

2940  if

(cnt_downs != 0) {

2942  for

(

Uint2 i

= 0;

i

< cnt_downs; ++

i

) {

2962

<<

" which is referenced by blob "

<< cache_data->

key 2963

<<

". Deleting blob."

);

2967  SNCDBFileInfo

* file_info = it_file->second.GetNCPointerOrNull();

2970  if

(it_recs == recs_set.

end

()) {

2972

<<

" references record with coord "

<< map_coord

2973

<<

", but its index wasn't in live chain. Deleting blob."

);

2981

<<

" when should be "

<< up_coord

2982

<<

". Correcting it."

);

2989

rec_size += 8 - (rec_size & 7);

2992  if

(map_depth == 0) {

2995

<<

" with size "

<< cache_data->

size 2996

<<

" references record with coord "

<< map_coord

2997

<<

" that has type "

<<

int

(map_ind->

rec_type

)

2999

<<

". Deleting blob."

);

3003  if

(chunk_num > cnt_chunks) {

3005

<<

" with size "

<< cache_data->

size 3006

<<

" has too many data chunks, should be "

<< cnt_chunks

3007

<<

". Deleting blob."

);

3012  if

(chunk_num < cnt_chunks)

3015

need_size = (cache_data->

size

- 1) % cache_data->

chunk_size

+ 1;

3016  if

(data_size != need_size) {

3018

<<

" with size "

<< cache_data->

size 3019

<<

" references data record with coord "

<< map_coord

3020

<<

" that has data size "

<< data_size

3021

<<

" when it should be "

<< need_size

3022

<<

". Deleting blob."

);

3029

<<

" with size "

<< cache_data->

size 3030

<<

" references record with coord "

<< map_coord

3031

<<

" at map_depth="

<< map_depth

3032

<<

". Record has type "

<<

int

(map_ind->

rec_type

)

3034

<<

". Deleting blob."

);

3041

<<

" with size "

<< cache_data->

size 3042

<<

" references map with coord "

<< map_coord

3043

<<

" that has wrong index "

<< map_rec->

map_idx 3044

<<

" and/or map depth "

<< map_rec->

map_depth 3045

<<

", they should be "

<< up_index

3046

<<

" and "

<< map_depth

3047

<<

". Deleting blob."

);

3051  for

(

Uint2 i

= 0;

i

< cnt_downs; ++

i

) {

3053

map_coord,

i

, cache_data, cnt_chunks,

3054

chunk_num, sizes_map))

3056  for

(

Uint2

j = 0; j <

i

; ++j) {

3062  if

(chunk_num < cnt_chunks && cnt_downs != cache_data->map_size) {

3064

<<

" with size "

<< cache_data->

size 3065

<<

" references map record with coord "

<< map_coord

3066

<<

" that has "

<< cnt_downs

3067

<<

" children when it should be "

<< cache_data->

map_size 3068

<<

" because accumulated chunk_num="

<< chunk_num

3069

<<

" is less than total "

<< cnt_chunks

3070

<<

". Deleting blob."

);

3075

recs_set.

erase

(it_recs);

3090

<<

" at offset "

<< ind_rec->

offset

<<

" was corrupted." 3092

<<

", expire="

<< meta_rec->

expire 3096

<<

", map_size="

<< meta_rec->

map_size 3097

<<

". Deleting it."

);

3103  char

* key_data = meta_rec->

key_data

;

3104  char

* key_end = (

char

*)meta_rec + ind_rec->

rec_size

;

3107  string key

(key_data, key_end - key_data);

3115

<<

" at offset "

<< ind_rec->

offset

<<

" was corrupted." 3117

<<

", cnt_special="

<<

cnt 3118

<<

". Deleting it."

);

3121  Uint2

slot = 0, time_bucket = 0;

3129

cache_data->

coord

= coord;

3131

cache_data->

size

= meta_rec->

size

;

3142  if

(meta_rec->

size

== 0) {

3146

<<

" was corrupted. size=0 but chain_coord=" 3157

<<

" at offset "

<< ind_rec->

offset

<<

" was corrupted." 3158

<<

", size="

<< meta_rec->

size 3160

<<

", map_size="

<< meta_rec->

map_size 3162

<<

"). Deleting it."

);

3166  Uint8

chunk_num = 0;

3168

TSizesMap sizes_map;

3170

cnt_chunks, chunk_num, sizes_map))

3175  ITERATE

(TSizesMap, it, sizes_map) {

3177  info

->used_size += it->second;

3178  if

(

info

->garb_size < it->second) {

3181  info

->garb_size -= it->second;

3188

rec_size += 8 - (rec_size & 7);

3204

bucket_cache = it_bucket->second;

3207 #if __NC_CACHEDATA_INTR_SET 3208

TKeyMap::insert_commit_data commit_data;

3209

pair<TKeyMap::iterator, bool> ins_res =

3211  if

(ins_res.second) {

3212

bucket_cache->

key_map

.insert_unique_commit(*cache_data, commit_data);

3216

TKeyMap::iterator ins_res = bucket_cache->

key_map

.find(cache_data);

3217  if

(ins_res == bucket_cache->

key_map

.end()) {

3218

bucket_cache->

key_map

.insert(cache_data);

3223 #if __NC_CACHEDATA_INTR_SET 3225

bucket_cache->

key_map

.erase(ins_res.first);

3226

bucket_cache->

key_map

.insert_equal(*cache_data);

3229

bucket_cache->

key_map

.erase(old_data);

3230

bucket_cache->

key_map

.insert(cache_data);

3232 #if __NC_CACHEDATA_ALL_MONITOR 3233

s_AllCache[time_bucket]->all_cache_set.erase(old_data);

3236 #if __NC_CACHEDATA_INTR_SET 3237

time_table->

time_map

.erase(time_table->

time_map

.iterator_to(*old_data));

3239

time_table->

time_map

.erase(old_data);

3261 #if __NC_CACHEDATA_INTR_SET 3262

time_table->

time_map

.insert_equal(*cache_data);

3264

time_table->

time_map

.insert(cache_data);

3266 #if __NC_CACHEDATA_ALL_MONITOR 3267

s_AllCache[time_bucket]->all_cache_set.insert(cache_data);

3326

file_to_del = file_info;

3363  Uint4

prev_rec_num = 0;

3367  if

(rec_num <= prev_rec_num) {

3369

<<

" contains wrong next_num="

<< rec_num

3370

<<

" (it's not greater than current "

<< prev_rec_num

3371

<<

"). Won't cache anything else from this file."

);

3372  goto

wrap_index_and_return;

3376  if

((

char

*)next_ind < min_ptr || next_ind >= ind_rec) {

3378

<<

" contains wrong next_num="

<< rec_num

3379

<<

" in index record "

<< (file_info->

index_head

- ind_rec)

3380

<<

". It produces pointer "

<< (

void

*)next_ind

3381

<<

" which is not in the range between "

<< (

void

*)min_ptr

3382

<<

" and "

<< (

void

*)ind_rec

3383

<<

". Won't cache anything else from this file."

);

3384  goto

wrap_index_and_return;

3386  char

* next_rec_start = file_info->

file_map

+ next_ind->

offset

;

3387  if

(next_rec_start < min_ptr || next_rec_start > (

char

*)next_ind

3388

|| (rec_num == 1 && next_rec_start != min_ptr))

3391

<<

" contains wrong offset="

<< ind_rec->

offset 3392

<<

" in index record "

<< rec_num

3393

<<

", resulting ptr "

<< (

void

*)next_rec_start

3394

<<

" which is not in the range "

<< (

void

*)min_ptr

3395

<<

" and "

<< (

void

*)next_ind

3396

<<

". This record will be ignored."

);

3397  goto

ignore_rec_and_continue;

3399  char

* next_rec_end;

3400

next_rec_end = next_rec_start + next_ind->

rec_size

;

3401  if

(next_rec_end < next_rec_start || next_rec_end > (

char

*)next_ind) {

3403

<<

" contains wrong rec_size="

<< next_ind->

rec_size 3404

<<

" for offset "

<< next_ind->

offset 3405

<<

" in index record "

<< rec_num

3406

<<

" (resulting end ptr "

<< (

void

*)next_rec_end

3407

<<

" is greater than index record "

<< (

void

*)next_ind

3408

<<

"). This record will be ignored."

);

3409  goto

ignore_rec_and_continue;

3411  if

(next_ind->

prev_num

!= prev_rec_num)

3412

next_ind->

prev_num

= prev_rec_num;

3418  goto

ignore_rec_and_continue;

3422

<<

" contains wrong rec_size="

<< next_ind->

rec_size 3423

<<

" for offset "

<< next_ind->

offset 3424

<<

" in index record "

<< rec_num

3425

<<

", rec_type="

<<

int

(next_ind->

rec_type

)

3427

<<

". This record will be ignored."

);

3428  goto

ignore_rec_and_continue;

3436

<<

" contains wrong rec_size="

<< next_ind->

rec_size 3437

<<

" for offset "

<< next_ind->

offset 3438

<<

" in index record "

<< rec_num

3439

<<

", rec_type="

<<

int

(next_ind->

rec_type

)

3441

<<

". This record will be ignored."

);

3442  goto

ignore_rec_and_continue;

3455  if

(next_ind->

rec_size

< min_rec_size) {

3457

<<

" contains wrong rec_size="

<< next_ind->

rec_size 3458

<<

" for offset "

<< next_ind->

offset 3459

<<

" in index record "

<< rec_num

3460

<<

", rec_type="

<<

int

(next_ind->

rec_type

)

3461

<<

", min_size="

<< min_rec_size

3462

<<

". This record will be ignored."

);

3463  goto

ignore_rec_and_continue;

3469

<<

" with type "

<<

int

(file_info->

file_type

)

3470

<<

" contains wrong rec_type="

<< next_ind->

rec_type 3471

<<

" in index record "

<< rec_num

3472

<<

"). This record will be ignored."

);

3473  goto

ignore_rec_and_continue;

3476

recs_set.

insert

(rec_num);

3477

min_ptr = next_rec_end;

3479

prev_rec_num = rec_num;

3482

ignore_rec_and_continue:

3485  goto

finalize_and_return;

3487

wrap_index_and_return:

3490

finalize_and_return:

3597  Uint4

file_id = it_id->first;

3606  for

(; it_rec != recs_set.

end

(); ++it_rec) {

3617 #if __NC_TASKS_MONITOR 3618

m_TaskName =

"CBlobCacher"

;

3638  ", allowed db size is "

+

g_ToSizeStr

(allowed_db_size) +

3639  " ("

+

g_ToSmartStr

(cur_db_size * 100 / allowed_db_size) +

"%)"

);

3654

<<

msg

<<

". Will no longer accept any writes from clients."

);

3668

<<

msg

<<

". Will no longer accept any writes."

);

3678

<<

msg

<<

". Will no longer accept any writes from clients."

);

3690  ", allowed db size is "

+

g_ToSizeStr

(allowed_db_size) +

3691  " ("

+

g_ToSmartStr

(cur_db_size * 100 / allowed_db_size) +

"%)"

);

3699

CExpiredCleaner::State

3720  if

(

key

.IsICacheKey()) {

3741  if

(!coord.

empty

()) {

3786  if

(!coord.

empty

()) {

3815

CExpiredCleaner::State

3842

CExpiredCleaner::State

3855  table

->lock.Lock();

3856

TTimeTableMap::iterator it = time_map.begin();

3862 #if __NC_CACHEDATA_INTR_SET 3871  if

(dead_time != 0) {

3874 #if __NC_CACHEDATA_INTR_SET 3875

time_map.erase(time_map.iterator_to(*cache_data));

3877

time_map.insert_equal(*cache_data);

3879

it = time_map.iterator_to(*last_data);

3883

it = time_map.begin();

3885

time_map.erase(cache_data);

3887

time_map.insert(cache_data);

3889

it = time_map.find(last_data);

3892

it = time_map.begin();

3901

last_data = cache_data;

3904  table

->lock.Unlock();

3917

CExpiredCleaner::State

3932

: m_DoExtraGC(

false

)

3934 #if __NC_TASKS_MONITOR 3935

m_TaskName =

"CExpiredCleaner"

;

3944

CSpaceShrinker::State

3979  if

(!chain_coord.

empty

()) {

3981  if

(chain_file.

IsNull

()) {

3982  goto

wipe_new_record;

3988  goto

wipe_new_record;

4001

<<

" links down to record with coord "

<< new_ind->

chain_coord 4002

<<

" but it has up coord "

<< chain_ind->

chain_coord

);

4007

up_index = map_rec->

map_idx

;

4010  for

(

Uint2 i

= 0;

i

< cnt_downs; ++

i

) {

4013  if

(down_file.

IsNull

()) {

4014  goto

wipe_new_record;

4018  goto

wipe_new_record;

4021

<<

" links down to record with coord "

<< down_coord

4022

<<

" at index "

<<

i 4023

<<

" but it has up coord "

<< down_ind->

chain_coord

);

4026  goto

check_up_index;

4035  if

(up_map->

down_coords

[up_index] != old_coord) {

4037

<<

" links up to map with coord "

<< new_ind->

chain_coord 4038

<<

" but at the index "

<< up_index

4039

<<

" it has coord "

<< up_map->

down_coords

[up_index]);

4044

<<

" links up to meta with coord "

<< new_ind->

chain_coord 4045

<<

" but it has down coord "

<< chain_ind->

chain_coord

);

4059  goto

unlock_and_wipe;

4065  goto

unlock_and_wipe;

4077  DB_CORRUPTED

(

"Coord "

<< old_coord <<

" of the current version for blob " 4078

<<

m_CacheData

->

key

<<

" changed while move was in progress."

);

4101  goto

unlock_and_wipe;

4103  goto

wipe_new_record;

4161

CSpaceShrinker::State

4173  Uint8

total_rel_used = 0;

4174  Uint8

total_rel_garb = 0;

4178  SNCDBFileInfo

* this_file = it_file->second.GetNCPointerOrNull();

4180  bool

is_current =

false

;

4196  else if

(need_move) {

4202  double

this_pct = double(this_file->

garb_size

)

4207  if

(this_pct > max_pct) {

4216

total_rel_used += this_file->

used_size

;

4217

total_rel_garb += this_file->

garb_size

;

4224  if

(max_pct < 0.9) {

4241

CSpaceShrinker::State

4262

CSpaceShrinker::State

4288

CSpaceShrinker::State

4307  SRV_FATAL

(

"Blob coords index broken"

);

4329 #if __NC_CACHEDATA_ALL_MONITOR 4330  bool

found =

false

;

4331

SAllCacheTable*

table

=

nullptr

;

4333

vector<SAllCacheTable*> v_all;

4334

v_all.reserve(s_AllCache.size());

4335  ITERATE

(TAllCacheBuckets, tt, s_AllCache) {

4336

v_all.push_back(tt->second);

4338

shuffle(v_all.begin(), v_all.end(), default_random_engine());

4339  ITERATE

(vector<SAllCacheTable*>, tt, v_all) {

4341  table

->lock.Lock();

4343  table

->lock.Unlock();

4351  table

->lock.Lock();

4353  table

->lock.Unlock();

4404  if

(max_map_depth == 0 || coord.

empty

())

4408  if

(file_info.

IsNull

()) {

4419

CSpaceShrinker::State

4437  char

* cur_chunk_ptr =

NULL

;

4440  if

(cur_chunk_ptr) {

4441  if

(cur_chunk_ptr != (

char

*)data_rec->

chunk_data

)

4486

CSpaceShrinker::State

4514

CSpaceShrinker::State

4522  SRV_LOG

(

Warning

,

"Didn't find anything to process in the file"

);

4545

CSpaceShrinker::State

4560 #if __NC_TASKS_MONITOR 4561

m_TaskName =

"CSpaceShrinker"

;

4571

: m_FileInfo(file_info),

4588 #if __NC_TASKS_MONITOR 4589

m_TaskName =

"CRecNoSaver"

;

4605  INFO

(

"Updated Purge data: "

<< forget);

4619

next_save = cur_time;

4621  if

(cur_time < next_save) {

4631  s_IndexDB

->SetMaxSyncLogRecNo(log_rec_no);

4645 #if __NC_TASKS_MONITOR 4646

m_TaskName =

"CDiskFlusher"

;

4686 #ifdef NCBI_OS_LINUX 4689

<<

", errno="

<< errno);

4701 #if __NC_TASKS_MONITOR 4702

m_TaskName =

"CNewFileCreator"

;

4714  bool

need_new =

false

;

ncbi::TMaskedQueryRegions mask

TRecNumsSet * m_CurRecsSet

bool x_CacheMetaRec(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec, SNCDataCoord coord)

State x_PreCacheRecNums(void)

State x_StartCreateFiles(void)

State x_FinishCaching(void)

State x_StartCacheBlobs(void)

TRecNumsSet::iterator m_CurRecIt

virtual ~CBlobCacher(void)

State x_CacheNextRecord(void)

void x_DeleteIndexes(SNCDataCoord map_coord, Uint1 map_depth)

State x_CancelCaching(void)

TNCDBFilesMap::const_iterator m_CurFile

State x_CleanOrphanRecs(void)

bool x_CacheMapRecs(SNCDataCoord map_coord, Uint1 map_depth, SNCDataCoord up_coord, Uint2 up_index, SNCCacheData *cache_data, Uint8 cnt_chunks, Uint8 &chunk_num, map< Uint4, Uint4 > &sizes_map)

State x_CacheNextFile(void)

State x_DelFileAndRetryCreate(void)

State x_StartCaching(void)

State x_CreateInitialFile(void)

virtual ~CDiskFlusher(void)

State x_FlushNextFile(void)

State x_CheckFlushTime(void)

static void x_DeleteData(SNCCacheData *cache_data)

vector< SNCCacheData * > m_CacheDatas

virtual ~CExpiredCleaner(void)

State x_CleanNextBucket(void)

State x_DeleteNextData(void)

State x_FinishSession(void)

State x_StartSession(void)

Class for support low level input/output for files.

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.

virtual ~CMovedRecDeleter(void)

CMovedRecDeleter(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec)

virtual void ExecuteRCU(void)

Method implementing RCU job that was scheduled earlier by CallRCU().

CSrvRef< SNCDBFileInfo > m_FileInfo

static void Register(EAlertType alert_type, const string &message)

@ eDebugReadBlobInfoFailed0

@ eStorageReinit

Data storage was reinitialized.

@ eDiskSpaceCritical

Free disk space is below critical threshold.

@ eDatabaseTooLarge

Database is too large (warning)

@ eDiskSpaceLow

Free disk space is below threshold.

@ eStartAfterCrash

InstanceGuard file was present on startup.

@ eDatabaseOverLimit

Database size exceeded its limit (error, stop write)

@ eDiskSpaceNormal

Free disk space is back to normal.

@ eDebugReleaseCacheData1

@ eDebugReleaseCacheData2

@ eDebugReadBlobInfoFailed1

@ eDebugReadBlobInfoFailed2

@ eDebugDeleteVersionData

static string GetPurgeData(char separator='\n')

ENCAccessType GetAccessType(void) const

Get type of access this holder was created for.

Uint2 GetTimeBucket(void) const

const string & GetBlobKey(void) const

Get key of the blob.

static void SetFailedWriteCount(int failed_write)

static int GetFailedWriteCount(void)

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.

static Uint8 GetPurgeCount()

void Initialize(SNCCacheData *cache_data)

Initialize and acquire the lock.

static void GetFullBlobsList(Uint2 slot, TNCBlobSumList &blobs_lst, const CNCPeerControl *peer)

static Int8 GetAllowedDBSize(Int8 free_space)

static bool NeedStopWrite(void)

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 SaveMaxSyncLogRecNo(void)

static void ChangeCacheDeadTime(SNCCacheData *cache_data)

static void WriteBlobList(TNCBufferType &buffer, const CTempString &mask)

static void GetBList(const string &mask, unique_ptr< TNCBufferType > &buffer, SNCBlobFilter *filters, const string &sep)

static Int8 GetDBSize(void)

Get total size of database for the storage.

static bool ReConfig(const CNcbiRegistry &new_reg, string &err_message)

static Uint8 GetMaxSyncLogRecNo(void)

static void MeasureDB(SNCStateStat &state)

static string GetPurgeData(void)

static bool ReadBlobInfo(SNCBlobVerData *ver_data)

Get meta information about blob with given coordinates.

static void SavePurgeData(void)

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 void Finalize(void)

static void WriteDbInfo(TNCBufferType &sendBuff, const CTempString &mask)

static size_t GetNDBFiles(void)

Get number of files in the database.

static void WriteEnvInfo(CSrvSocketTask &task)

static string FindBlob(Uint2 bucket, const string &mask, Uint8 cr_time_hi)

static void ReleaseCacheData(SNCCacheData *cache_data)

static bool IsDBSizeAlert(void)

static int GetLatestBlobExpire(void)

static bool IsDraining(void)

static bool Initialize(bool do_reinit)

static Uint8 GetMaxBlobSizeStore(void)

static bool IsCleanStart(void)

static void CheckDiskSpace(void)

static void ReferenceCacheData(SNCCacheData *cache_data)

static Uint4 GetNewBlobId(void)

static void AbandonDB(void)

static void WriteSetup(CSrvSocketTask &task)

static Int8 GetDiskFree(void)

static void DeleteBlobInfo(const SNCBlobVerData *ver_data, SNCChunkMaps *maps)

Delete blob from database.

static bool AcceptWritesFromPeers(void)

static void SetDraining(bool draining)

static void WriteBlobStat(CSrvSocketTask &task)

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)

SNCCacheData * GetCacheData(void)

void ObtainReference(void)

void RequestCurVersion(CSrvTransConsumer *consumer)

void DeleteDeadVersion(int cut_time)

CSrvRef< SNCBlobVerData > GetCurVersion(void)

Connection to index database in NetCache storage.

static bool IsThisServerKey(const string &packed_key)

static bool GetSlotByKey(const string &key, Uint2 &slot, Uint2 &time_bucket)

static Uint2 GetCntSlotBuckets(void)

static Uint8 GetMaxBlobSizeSync(void)

static Uint2 GetCntTimeBuckets(void)

bool AcceptsBlobKey(const CNCBlobKeyLight &key) const

static bool IsInitiallySynced(void)

static void CachingCompleted(void)

static void DBFileCleaned(bool success, Uint4 seen_recs, Uint4 moved_recs, Uint4 moved_size)

static Uint8 GetLastRecNo(void)

virtual void ExecuteSlice(TSrvThreadNum thr_num)

This is the main method to do all work this task should do.

virtual ~CNewFileCreator(void)

virtual void ExecuteSlice(TSrvThreadNum thr_num)

This is the main method to do all work this task should do.

virtual ~CRecNoSaver(void)

Exception thrown from all SQLite-related objects and functions.

CSimpleBufferT & append(const void *buf, size_t len)

void reserve_mem(size_type new_size)

Reserve memory. No data preservation guarantees.

State x_CheckCurVersion(void)

State x_FinishMoveRecord(void)

SNCCacheData * m_CacheData

CSrvRef< SNCDBFileInfo > m_MaxFile

TFilesList::iterator m_CurDelFile

State x_MoveNextRecord(void)

State x_DeleteNextFile(void)

CNCBlobVerManager * m_VerMgr

CSrvRef< SNCBlobVerData > m_CurVer

State x_PrepareToShrink(void)

State x_FinishSession(void)

virtual ~CSpaceShrinker(void)

State x_FinishMoves(void)

SNCDataCoord x_FindMetaCoord(SNCDataCoord coord, Uint1 max_map_depth)

Class used in all diagnostic logging.

CSrvDiagMsg & PrintExtra(void)

Starts "extra" message.

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.

Task controlling a socket.

CSrvSocketTask & WriteText(CTempString message)

Write text into socket.

CSrvSocketTask & WriteNumber(NumType num)

Write number into socket as string, i.e.

void SetState(State state)

Sets current state of the machine.

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 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.

Uint1 Print(char *buf, EFormatType fmt) const

Formats time value in the object and writes it in buf.

@ eFmtJson

For JSON output.

bool IsTransFinished(void)

Check if transition completeness was consumed.

static const CNcbiRegistry & GetConfRegistry(void)

Obtains reference to registry read from application's ini-file.

static void RequestShutdown(ESrvShutdownType shutdown_type)

Asks server to start shutdown procedures.

static bool IsInShutdown(void)

Checks if TaskServer received request to shutdown.

CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...

virtual void ExecuteRCU(void)

Method implementing RCU job that was scheduled earlier by CallRCU().

CAtomicCounter_WithAutoInit ref_cnt

CNCBlobVerManager * Get_ver_mgr(void) const

TNCBufferType & WriteNumber(NumType num)

TNCBufferType & WriteText(const char *buf)

TNCBufferType & WriteBool(bool b)

container_type::const_iterator const_iterator

container_type::iterator iterator

const_iterator begin() const

const_iterator end() const

const_iterator lower_bound(const key_type &key) const

iterator_bool insert(const value_type &val)

const_iterator upper_bound(const key_type &key) const

container_type::value_type value_type

const_iterator find(const key_type &key) const

iterator_bool insert(const value_type &val)

const_iterator begin() const

parent_type::iterator iterator

const_iterator find(const key_type &key) const

const_iterator end() const

static const int chunk_size

static unsigned char depth[2 *(256+1+29)+1]

static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)

static const char * str(char *buf, int n)

#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.

void Set(TValue new_value) THROWS_NONE

Set atomic counter value.

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 SetRequestStatus(int status)

#define ERR_POST(message)

Error posting with file, line number information but without error codes.

void Critical(CExceptionArgs_Base &args)

void Error(CExceptionArgs_Base &args)

void Warning(CExceptionArgs_Base &args)

void Info(CExceptionArgs_Base &args)

static string CreateAbsolutePath(const string &path, ERelativeToWhat rtw=eRelativeToCwd)

Get an absolute path from some, possibly relative, path.

size_t Write(const void *buf, size_t count) const

Write file.

bool GetMode(TMode *user_mode, TMode *group_mode=0, TMode *other_mode=0, TSpecialModeBits *special=0) const

Get permission mode(s) of a directory entry.

void SetFileSize(Uint8 length, EPositionMoveMethod pos=eCurrent) const

Set new size for the file.

unsigned int TMode

Bitwise OR of "EMode".

virtual bool SetMode(TMode user_mode, TMode group_mode=fDefault, TMode other_mode=fDefault, TSpecialModeBits special=0, TSetModeFlags flags=eEntryOnly) const

Set permission mode(s) of a directory entry.

Int8 GetLength(void) const

Get size of file.

virtual bool Remove(TRemoveFlags flags=eRecursive) const

Remove a directory entry.

static string MakePath(const string &dir=kEmptyStr, const string &base=kEmptyStr, const string &ext=kEmptyStr)

Assemble a path from basic components.

static Uint8 GetFreeDiskSpace(const string &path)

Get free disk space information.

void SetFileHandle(TFileHandle handle)

Close previous handle if needed and use given handle for all I/O.

virtual bool Exists(void) const

Check if directory "dirname" exists.

bool Create(TCreateFlags flags=fCreate_Default) const

Create the directory using "dirname" passed in the constructor.

virtual bool Exists(void) const

Check existence of file.

@ fDefault

Default flags.

@ eExclusive

"write" lock.

@ eBegin

Absolute position from beginning of the file.

TSeqPos GetLength(const CSeq_id &id, CScope *scope)

Get sequence length if scope not null, else return max possible TSeqPos.

bool NotNull(void) const THROWS_NONE

Check if pointer is not null – same effect as NotEmpty().

void Reset(void)

Reset reference object.

bool IsNull(void) const THROWS_NONE

Check if pointer is null – same effect as Empty().

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

int64_t Int8

8-byte (64-bit) signed integer

uint64_t Uint8

8-byte (64-bit) unsigned integer

static TPid GetPid(void)

Get process identifier (pid) for the current process.

virtual const string & Get(const string &section, const string &name, TFlags flags=0) const

Get the parameter value.

virtual int GetInt(const string &section, 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 &section, 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 SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)

Find the pattern in the specified range of a string using a case insensitive search.

static Uint8 StringToUInt8_DataSize(const CTempString str, TStringToNumFlags flags=0)

Convert string that can contain "software" qualifiers to Uint8.

static string UInt8ToString_DataSize(Uint8 value, TNumToStringFlags flags=0, unsigned int max_digits=3)

Convert UInt8 to string using "software" qualifiers.

static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)

Replace occurrences of a substring within a string.

static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)

Convert UInt to string.

static unsigned int StringToUInt(const CTempString str, TStringToNumFlags flags=0, int base=10)

Convert string to unsigned int.

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.

static string UInt8ToString(Uint8 value, TNumToStringFlags flags=0, int base=10)

Convert UInt8 to string.

unsigned int

A callback function used to compare two keys in a database.

<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table

if(yy_accept[yy_current_state])

void Logging_DiskSpaceAlert(void)

const struct ncbi::grid::netcache::search::fields::SIZE size

const struct ncbi::grid::netcache::search::fields::KEY key

int strncmp(const char *str1, const char *str2, size_t count)

map< Uint4, CSrvRef< SNCDBFileInfo > > TNCDBFilesMap

Information about all database parts in NetCache storage.

static const Uint4 kNCMaxDBFileId

static const Uint1 kNCMaxBlobMapsDepth

const Uint8 kNCLargestBlobSize

static Int8 s_DiskCritical

static const Uint8 kMetaSignature

static void s_UnmapFile(char *mem_ptr, size_t file_size)

static bool s_UpdateUpCoords(SFileChunkMapRec *map_rec, SFileIndexRec *map_ind, SNCDataCoord coord)

static const char * kNCStorage_RegSection

static string s_Path

Directory for all database files of the storage.

static const Uint8 kDataSignature

static Int8 s_DiskFreeLimit

static SFileChunkDataRec * s_CalcChunkAddress(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec)

static void s_CleanDatabase(void)

Reinitialize database cleaning all data from it.

static Uint1 s_CalcMapDepthImpl(Uint8 size, Uint4 chunk_size, Uint2 map_size)

static Uint8 s_MaxBlobSizeStore

static const char * kNCStorage_DBFileExt

static int s_FlushTimePeriod

#define DB_CORRUPTED(msg)

static Uint1 s_CalcMapDepth(Uint8 size, Uint4 chunk_size, Uint2 map_size)

static void s_UnlockInstanceGuard(void)

Unlock and delete specially named file used to ensure only one instance working with database.

static bool s_NeedSaveLogRecNo

Uint4 s_TaskPriorityWbMemRelease

static const char * kNCStorage_MaxBlobSizeStore

static bool s_ReadMapInfo(SNCDataCoord map_coord, SNCChunkMapInfo *map_info, Uint1 map_depth)

static const char * kNCStorage_MapsFileSuffix

static void s_MoveRecToGarbageNoLock(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec)

static char * s_CalcRecordAddress(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec)

static SWritingInfo s_AllWritings[s_CntAllFiles]

static const char * kNCStorage_WbMemRelease

static Int8 s_ExtraGCOffSize

static int s_LastRecNoSaveTime

static const char * kNCStorage_ExtraGCOffParam

static const char * kNCStorage_ExtraGCOnParam

static void s_MoveRecToGarbage(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec)

static const char * kNCStorage_MinDBSizeParam

static CSrvRef< SNCDBFileInfo > s_GetDBFileNoLock(Uint4 file_id)

static bool s_OpenIndexDB(void)

Open and read index database file.

static const char * kNCStorage_StopWriteOffParam

static Uint4 s_CalcChunkRecSize(size_t data_size)

static string s_GuardName

Name of guard file excluding several instances to run on the same database.

static const char * kNCStorage_DataFileSuffix

static const char * kNCStorage_FlushTimeParam

static SNCCacheData * s_GetKeyCacheData(Uint2 time_bucket, const string &key, bool need_create)

#define __NC_CACHEDATA_ALL_MONITOR

static EStopCause s_IsStopWrite

static Int8 s_StopWriteOnSize

static const char * kNCStorage_IndexFileSuffix

static bool s_CreateNewFile(size_t type_idx, bool need_lock)

Do set of procedures creating and initializing new database part and switching storage to using new d...

static const char * kNCStorage_StopWriteOnParam

static const size_t kMemPageAlignMask

Mask that can move pointer address or memory size to the memory page boundary.

static const char * kNCStorage_FailedMoveParam

static const char * kNCStorage_MetaFileSuffix

intr::rbtree< SNCCacheData, intr::base_hook< TKeyMapHook >, intr::constant_time_size< true >, intr::compare< SCacheKeyCompare > > TKeyMap

static size_t const s_CntAllFiles

static const char * kNCStorage_MinRecNoSaveParam

static const char * kNCStorage_FailedWriteSize

static char * s_MapFile(TFileHandle fd, size_t file_size)

static bool s_ReadStorageParams(void)

Read all storage parameters from registry.

static const char * kNCStorage_StartedFileName

static unique_ptr< CFileLock > s_GuardLock

Lock for guard file representing this instance running.

static TNCDBFilesMap * s_DBFiles

List of all database parts in the storage.

static Uint4 s_CalcMetaRecSize(Uint2 key_size)

static CExpiredCleaner * s_ExpiredCleaner

static CMiniMutex s_NextWriteLock

manages access to s_AllWritings

static Int8 s_StopWriteOffSize

static volatile Int8 s_CurDBSize

Current size of storage database. Kept here for printing statistics.

static unique_ptr< CNCDBIndexFile > s_IndexDB

Index database file.

static int s_FailedMoveDelay

static TBucketCacheMap s_BucketsCache

Internal cache of blobs identification information sorted to be able to search by key,...

static bool s_GetNextWriteCoord(EDBFileIndex file_index, Uint4 rec_size, SNCDataCoord &coord, CSrvRef< SNCDBFileInfo > &file_info, SFileIndexRec *&ind_rec)

static SFileIndexRec * s_GetIndexRecTry(SNCDBFileInfo *file_info, Uint4 rec_num)

static Uint4 s_CalcChunkDataSize(Uint4 rec_size)

static const char * kNCStorage_GCBatchParam

static void s_DeleteIndexRecNoLock(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec)

static Uint2 s_CalcCntMapDowns(Uint4 rec_size)

static void s_DeleteDBFile(const CSrvRef< SNCDBFileInfo > &file_info, bool need_lock)

static Uint4 s_NewFileSize

static const size_t kMemPageSize

Size of memory page that is a granularity of all allocations from OS.

static bool s_IsIndexDeleted(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec)

intr::rbtree< SNCCacheData, intr::base_hook< TTimeTableHook >, intr::constant_time_size< false >, intr::compare< SCacheDeadCompare > > TTimeTableMap

static void s_SwitchToNextFile(SWritingInfo &w_info)

static bool s_EnsureDirExist(const string &dir_name)

static void s_InitializeAccessor(CNCBlobAccessor *acessor)

static int s_MinRecNoSavePeriod

static void s_DeleteIndexRec(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec)

static string s_GetFileName(Uint4 file_id, ENCDBFileType file_type)

Make name of file with meta-information in given database part.

static int s_MaxGarbagePct

static bool s_ReadVariableParams(const CNcbiRegistry &reg)

Read from registry only those parameters that can be changed on the fly, without re-starting the appl...

static Int8 s_CurBlobsCnt

static Uint4 s_LastFileId

static int s_WarnLimitOnPct

static const char * kNCStorage_DiskCriticalParam

static ENCDBFileType const s_AllFileTypes[]

static SFileIndexRec * s_GetIndexRec(SNCDBFileInfo *file_info, Uint4 rec_num)

map< Uint2, SBucketCache * > TBucketCacheMap

static CAtomicCounter s_BlobCounter

static bool s_SaveChunkMap(SNCBlobVerData *ver_data, SNCCacheData *cache_data, SNCChunkMapInfo **maps, Uint2 cnt_downs, bool save_all_deps)

static CRecNoSaver * s_RecNoSaver

static const char * kNCStorage_MinFreeDiskParam

static int s_GCBatchSize

Number of blobs treated by GC and by caching mechanism in one batch.

static CSrvRef< SNCDBFileInfo > s_GetDBFile(Uint4 file_id)

static CMiniMutex s_IndexLock

manages access to s_IndexDB

static void s_LockFileMem(const void *mem_ptr, size_t mem_size)

map< Uint2, STimeTable * > TTimeBuckets

#define __NC_CACHEDATA_INTR_SET

static Int8 s_ExtraGCOnSize

static SFileChunkMapRec * s_CalcMapAddress(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec)

static SFileMetaRec * s_CalcMetaAddress(SNCDBFileInfo *file_info, SFileIndexRec *ind_rec)

static bool s_LockInstanceGuard(void)

Make sure that current storage database is used only with one instance of NetCache.

static const char * kNCStorage_GuardNameParam

static int s_LastFlushTime

static const char * kNCStorage_FileSizeParam

static string s_GetIndexFileName(void)

Make name of the index file in the storage.

static const Uint8 kMapsSignature

static void s_MoveDataToGarbage(SNCDataCoord coord, Uint1 map_depth, SNCDataCoord up_coord, bool need_lock)

static SFileIndexRec * s_GetIndOrDeleted(SNCDBFileInfo *file_info, Uint4 rec_num)

static bool s_SaveOneMapImpl(SNCChunkMapInfo *save_map, SNCChunkMapInfo *up_map, Uint2 cnt_downs, Uint2 map_size, Uint1 map_depth, SNCCacheData *cache_data)

static CSrvRef< SNCDBFileInfo > s_GetDBFileTry(Uint4 file_id)

static SBucketCache * s_GetBucketCache(Uint2 bucket)

static CNewFileCreator * s_NewFileCreator

static CDiskFlusher * s_DiskFlusher

static volatile Int8 s_GarbageSize

static const Uint1 kSignatureSize

static const char * kNCStorage_FilePrefixParam

static CMiniMutex s_DBFilesLock

Read-write lock to work with s_DBFiles.

static CSpaceShrinker * s_SpaceShrinker

static const char * kNCStorage_GarbagePctParam

static bool s_ReinitializeStorage(void)

Check if database need re-initialization depending on different parameters and state of the guard fil...

static int s_WarnLimitOffPct

static bool s_NeedSavePurgeData

static TTimeBuckets s_TimeTables

static const char * kNCStorage_MoveLifeParam

static const char * kNCStorage_PathParam

static Uint4 s_CalcMapRecSize(Uint2 cnt_downs)

static string s_Prefix

Name of the storage.

intr::set_base_hook< intr::tag< SKeyMap_tag >, intr::optimize_size< true > > TKeyMapHook

void SetWBHardSizeLimit(Uint8 limit)

void SetWBSoftSizeLimit(Uint8 limit)

void SetWBWriteTimeout(int timeout1, int timeout2)

Uint8 GetWBSoftSizeLimit(void)

int GetWBWriteTimeout(void)

Uint8 GetWBHardSizeLimit(void)

int GetWBFailedWriteDelay(void)

void SetWBFailedWriteDelay(int delay)

@ eStatus_ServerError

Internal server error.

@ eStatus_OK

Command is ok and execution is good.

@ eStatus_ShuttingDown

operation canceled because server needs to shutdown.

ENCAccessType

Type of access to NetCache blob.

@ eNCCopyCreate

(Re-)write blob from another NetCache (as opposed to writing from client)

@ eNCCreate

Create blob or re-write its contents.

Defines process management classes.

#define NCBI_CONST_UINT8(v)

Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...

Process information in the NCBI Registry, including working with configuration files.

double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)

Defines CRequestContext class for NCBI C++ diagnostic API.

static SLJIT_INLINE sljit_ins lb(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)

static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)

#define INFO(msg)

Macro to be used for printing informational messages.

#define SRV_LOG(sev, msg)

Macro to be used for printing log messages.

CSrvRef< C > SrvRef(C *object)

std::enable_if< std::is_unsigned< T >::value, string >::type g_ToSizeStr(T size)

string g_ToSmartStr(T num)

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...

T AtomicSub(T volatile &var, T sub_value)

bool AtomicCAS(T volatile &var, T old_value, T new_value)

constexpr Uint8 kUSecsPerSecond

bool operator()(const SNCCacheData &x, const SNCCacheData &y) const

bool operator()(const SNCCacheData &x, const SNCCacheData &y) const

SNCDataCoord down_coords[1]

SNCCacheData * cache_data

Full information about NetCache blob (excluding key)

CNCBlobVerManager * ver_manager

SNCChunkMapInfo * maps[kNCMaxBlobMapsDepth+1]

Information about database part in NetCache storage.

CAtomicCounter cnt_unfinished

virtual ~SNCDBFileInfo(void)

SFileIndexRec * index_head

CSrvRef< SNCDBFileInfo > next_file

CSrvRef< SNCDBFileInfo > cur_file

Uint2 TSrvThreadNum

Type for thread number in TaskServer.


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