m_WNClientsOpCount(0),
54m_ReaderClientsOpCount(0),
55m_WaitGetClientsOpCount(0),
56m_WaitReadClientsCount(0)
140 size_tmax_records)
const 151 size_tmax_records)
const 157 size_tnew_aff_count = 0;
158 for(vector<string>::const_iterator k = aff_tokens.begin();
159k != aff_tokens.end(); ++k)
169 if(aff_token.empty())
173 map<
const string*,
180 returnaffinity->second;
194 return*(found->second.m_AffToken);
202 unsigned intclient_id,
211 map<
const string*,
216 unsigned intaff_id = found->second;
222jobs_affinity->second.AddJob(job_id);
225 x_AddClient(jobs_affinity->second, client_id, cmd_group);
239 string* new_token =
new string(token);
246new_job_affinity.
AddJob(job_id);
249 x_AddClient(new_job_affinity, client_id, cmd_group);
269vector<unsigned int> & aff_ids)
271 if(!tokens.empty()) {
272aff_ids.reserve(tokens.size());
273 for(list<string>::const_iterator k(tokens.begin());
274k != tokens.end(); ++k) {
277resolved_affs.
set_bit(aff_id,
true);
278aff_ids.push_back(aff_id);
290 map<
const string*,
294 returnfound->second;
306 string* new_token =
new string(token);
332 returnfound->second.m_Jobs;
346 for( ; en.
valid(); ++en) {
349jobs |= found->second.m_Jobs;
368 if(job_id == 0 || aff_id == 0)
379found->second.RemoveJob(job_id);
380 if(found->second.CanBeDeleted())
402 unsigned intclient_id,
416 if(client_id == 0 || aff_id == 0)
435 if(client_id == 0 || !aff_ids.
any())
440 for( ; en.
valid(); ++en) {
451 unsigned intclient_id,
456 if(client_id == 0 || !aff_ids.
any())
459 size_tdel_count = 0;
463 for( ; en.
valid(); ++en) {
475 if(found->second.CanBeDeleted()) {
488 unsigned intclient_id,
492 if(client_id == 0 || !aff_ids.
any())
498 for( ; en.
valid(); ++en) {
513 const string& scope,
523 while(en.
valid()) {
527 if(batch.
count() >= batch_size) {
535 if(batch.
count() > 0)
548 const string& scope,
558 if(batch[k->first]) {
560queue, clients_registry,
563 if(printed >= batch.
count())
577 const string& scope,
588 else if(!scope.empty()) {
595 buffer+=
"OK:AFFINITY: '"+
597 "OK: ID: "+ to_string(aff_id) +
"\n";
604 for( ; en.
valid(); ++en) {
605 unsigned intjob_id = *en;
612 buffer+=
"OK: JOBS: NONE\n";
615 buffer+=
"OK: NUMBER OF JOBS: "+ to_string(jobs.
count()) +
"\n";
619 buffer+=
"OK: WN CLIENTS (PREFERRED):\n";
622 for( ; en.
valid(); ++en)
627 buffer+=
"OK: WN CLIENTS (PREFERRED): NONE\n";
630 buffer+=
"OK: NUMBER OF WN CLIENTS (PREFERRED): "+
635 buffer+=
"OK: READER CLIENTS (PREFERRED):\n";
638m_ReaderClients.first());
639 for( ; en.
valid(); ++en)
644 buffer+=
"OK: READER CLIENTS (PREFERRED): NONE\n";
647 buffer+=
"OK: NUMBER OF READER CLIENTS (PREFERRED): "+
652 buffer+=
"OK: CLIENTS (EXPLICIT WGET):\n";
655m_WaitGetClients.first());
656 for( ; en.
valid(); ++en)
661 buffer+=
"OK: CLIENTS (EXPLICIT WGET): NONE\n";
664 buffer+=
"OK: NUMBER OF CLIENTS (EXPLICIT WGET): "+
669 buffer+=
"OK: CLIENTS (EXPLICIT READ):\n";
672m_WaitReadClients.first());
673 for( ; en.
valid(); ++en)
678 buffer+=
"OK: CLIENTS (EXPLICIT READ): NONE\n";
681 buffer+=
"OK: NUMBER OF CLIENTS (EXPLICIT READ): "+
699 throwruntime_error(
"Error while restoring jobs from the dump. " 700 "The affinity with id "+ to_string(aff_id) +
701 " is not found in the loaded dictionary." 702 " (Lost affinity dictionary dump?)");
704found->second.AddJob(job_id);
718 unsigned intmax_aff_id = 0;
723 if(candidate->first > max_aff_id)
726max_aff_id = candidate->first;
728 if(candidate->second.CanBeDeleted()) {
742 unsigned intdel_count = 0;
746 for( ; en.
valid(); ++en) {
747 unsigned intaff_id = *en;
756 if(found->second.CanBeDeleted()) {
759 if(del_count >= max_to_del)
770 unsigned intstill_candidate = 0;
774 for( ; en.
valid(); ++en) {
775 unsigned intaff_id = *en;
784 if(found->second.CanBeDeleted())
789 returnstill_candidate;
800 deletejobs_affinity->second.m_AffToken;
814 map<
const string*,
817found_aff->second.m_AffToken);
821 deletefound_aff->second.m_AffToken;
842 unsigned intclient_id,
860 unsigned intclient_id,
878 unsigned intclient_id,
896 unsigned intclient_id,
914 const string& qname)
const 922 if(k->second.m_Jobs.any())
923affs_to_dump.
set_bit(k->first);
926 if(!affs_to_dump.
any())
930FILE * aff_dict_file = fopen(aff_dict_file_name.c_str(),
"wb");
932 if(aff_dict_file ==
NULL)
933 throwruntime_error(
"Cannot open file "+ aff_dict_file_name +
934 " to dump affinities");
937setbuf(aff_dict_file,
NULL);
943header.
Write(aff_dict_file);
944}
catch(
constexception & ex) {
945fclose(aff_dict_file);
946 throwruntime_error(
"Writing error while dumping affinities: "+
951 for( ; en.
valid(); ++en) {
955 const string& token = *(aff_it->second.m_AffToken);
960memcpy(aff_dump.
token, token.data(), token.size());
963aff_dump.
Write(aff_dict_file);
964}
catch(
constexception & ex) {
965fclose(aff_dict_file);
966 throwruntime_error(
"Writing error while dumping affinities: "+
971fclose(aff_dict_file);
976 const string& qname)
const 979 if(access(aff_dict_file_name.c_str(), F_OK) != -1)
980 remove(aff_dict_file_name.c_str());
985 const string& qname)
const 987 const stringfname(
"aff_dict_dump.");
988 stringupper_queue_name = qname;
990 returndump_dir_name + fname + upper_queue_name;
1002 const string& qname)
1004 if(!
CDir(dump_dir_name).Exists())
1008 if(!
CFile(aff_dict_file_name).Exists())
1011FILE * aff_dict_file = fopen(aff_dict_file_name.c_str(),
"rb");
1012 if(aff_dict_file ==
NULL)
1013 throwruntime_error(
"Cannot open file "+ aff_dict_file_name +
1014 " to load dumped affinities");
1017header.
Read(aff_dict_file);
1020 while(aff_dump.
Read(aff_dict_file, header.
fixed_size) == 0) {
1021 string* new_token =
new string(aff_dump.
token,
1032}
catch(
constexception & ex) {
1033fclose(aff_dict_file);
1035 throwruntime_error(
"Reading error while loading dumped affinities: "+
1036 string(ex.what()));
1039fclose(aff_dict_file);
void RemoveJobFromAffinity(unsigned int job_id, unsigned int aff_id)
void SetWaitClientForAffinities(unsigned int client_id, const TNSBitVector &aff_ids, ECommandGroup cmd_group)
void x_AddClient(SNSJobsAffinity &aff_data, unsigned int client_id, ECommandGroup command_group)
unsigned int ResolveAffinity(const string &token)
unsigned int m_LastAffinityID
TNSBitVector GetJobsWithAffinity(unsigned int aff_id) const
void AddClientToAffinities(unsigned int client_id, const TNSBitVector &aff_ids, ECommandGroup cmd_group)
void Dump(const string &dump_dir_name, const string &queue_name) const
size_t RemoveClientFromAffinities(unsigned int client_id, const TNSBitVector &aff_ids, ECommandGroup cmd_group)
void AddClientToAffinity(unsigned int client_id, unsigned int aff_id, ECommandGroup cmd_group)
void FinalizeAffinityDictionaryLoading(void)
TNSBitVector GetJobsWithAffinities(const TNSBitVector &affs) const
void RemoveDump(const string &dump_dir_name, const string &queue_name) const
string x_PrintSelected(const TNSBitVector &batch, const CQueue *queue, const CNSClientsRegistry &clients_registry, const TNSBitVector &scope_jobs, const string &scope, bool verbose) const
void x_RemoveClient(SNSJobsAffinity &aff_data, unsigned int client_id, ECommandGroup command_group)
bool CanAccept(const string &aff_token, size_t max_records) const
string Print(const CQueue *queue, const CNSClientsRegistry &clients_registry, const TNSBitVector &scope_jobs, const string &scope, size_t batch_size, bool verbose) const
string GetTokenByID(unsigned int aff_id) const
size_t x_RemoveClientFromAffinities(unsigned int client_id, const TNSBitVector &aff_ids, bool is_wait_client, ECommandGroup cmd_group)
void ResolveAffinities(const list< string > &tokens, TNSBitVector &resolved_affs, vector< unsigned int > &aff_ids)
void x_AddWaitClient(SNSJobsAffinity &aff_data, unsigned int client_id, ECommandGroup command_group)
TNSBitVector GetRegisteredAffinities(void) const
map< unsigned int, SNSJobsAffinity > m_JobsAffinity
unsigned int CollectGarbage(unsigned int max_to_del)
void x_RemoveWaitClient(SNSJobsAffinity &aff_data, unsigned int client_id, ECommandGroup command_group)
void LoadFromDump(const string &dump_dir_name, const string &queue_name)
unsigned int GetIDByToken(const string &aff_token) const
map< const string *, unsigned int, SNSTokenCompare > m_AffinityIDs
void x_InitLastAffinityID(unsigned int value)
string x_GetDumpFileName(const string &dump_dir_name, const string &qname) const
unsigned int CheckRemoveCandidates(void)
unsigned int ResolveAffinityToken(const string &token, unsigned int job_id, unsigned int client_id, ECommandGroup command_group)
TNSBitVector m_RegisteredAffinities
void AddJobToAffinity(unsigned int job_id, unsigned int aff_id)
unsigned int x_GetNextAffinityID(void)
TNSBitVector m_RemoveCandidates
size_t RemoveWaitClientFromAffinities(unsigned int client_id, const TNSBitVector &aff_ids, ECommandGroup cmd_group)
void x_DeleteAffinity(unsigned int aff_id, map< unsigned int, SNSJobsAffinity >::iterator found_aff)
CFastMutex m_LastAffinityIDLock
string x_PrintOne(unsigned int aff_id, const SNSJobsAffinity &jobs_affinity, const CQueue *queue, const CNSClientsRegistry &clients_registry, const TNSBitVector &scope_jobs, const string &scope, bool verbose) const
string GetNodeName(unsigned int id) const
string MakeJobKey(unsigned int job_id) const
TJobStatus GetJobStatus(unsigned job_id) const
Constant iterator designed to enumerate "ON" bits.
bool valid() const noexcept
Checks if iterator is still valid.
Bitvector Bit-vector container with runtime compression of bits.
@ opt_free_0
Free unused 0 blocks.
bool any() const noexcept
Returns true if any bits in this bitset are set, and otherwise returns false.
void optimize(bm::word_t *temp_block=0, optmode opt_mode=opt_compress, statistics *stat=0)
Optimize memory bitvector's memory allocation.
bool set_bit(size_type n, bool val=true)
Sets bit n.
enumerator first() const
Returns enumerator pointing on the first non-zero bit.
void clear(const size_type *ids, size_type ids_size, bm::sort_order so=bm::BM_UNKNOWN)
clear list of bits in this bitset
size_type count() const noexcept
population count (count of ON bits)
const_iterator begin() const
const_iterator end() const
const_iterator find(const key_type &key) const
Include a standard set of the NCBI C++ Toolkit most basic headers.
static void DLIST_NAME() remove(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
EJobStatus
Job status codes.
static string StatusToString(EJobStatus status)
Printable status type.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string PrintableString(const CTempString str, TPrintableMode mode=fNewLine_Quote|fNonAscii_Passthru)
Get a printable version of the specified string.
static string & ToUpper(string &str)
Convert string to upper case â string& version.
@ BM_GAP
GAP compression is ON.
unsigned int
A callback function used to compare two keys in a database.
NetSchedule job status tracker.
const GenericPointer< typename T::ValueType > T2 value
const size_t k_OpLimitToOptimize
const string kNoScopeOnly
const TNSBitVector kEmptyBitVector
int Read(FILE *f, size_t fixed_size_from_header)
char token[kNetScheduleMaxDBDataSize]
void RemoveReadWaitClient(unsigned int client_id)
void AddReaderClient(unsigned int client_id)
size_t m_WaitGetClientsOpCount
size_t m_WNClientsOpCount
void AddJob(unsigned int job_id)
size_t m_WaitReadClientsCount
void RemoveWNWaitClient(unsigned int client_id)
void x_ReaderClientsOp(void)
void RemoveWNClient(unsigned int client_id)
size_t m_ReaderClientsOpCount
void AddReadWaitClient(unsigned int client_id)
const string * m_AffToken
void AddWNWaitClient(unsigned int client_id)
TNSBitVector m_ReaderClients
void AddWNClient(unsigned int client_id)
bool CanBeDeleted(void) const
TNSBitVector m_WaitGetClients
TNSBitVector m_WaitReadClients
void RemoveReaderClient(unsigned int client_id)
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