max_records)
const 106 boolallow_exception)
const 114 "Group "+ group +
" is unknown");
118 returnfound->second->m_Jobs;
130 for(en = group_ids.
first(); en.
valid(); ++en) {
133jobs |= found->second->m_Jobs;
147 "Group "+ group +
" is unknown");
150bv &= found->second->m_Jobs;
162 for(en = group_ids.
first(); en.
valid(); ++en) {
165jobs_in_groups |= found->second->m_Jobs;
167bv &= jobs_in_groups;
189 returnfound->second->m_GroupId;
203 "Group with id "+ to_string(group_id) +
" is unknown");
205 return*found->second->m_GroupToken;
213 for(list<string>::const_iterator k(tokens.begin());
214k != tokens.end(); ++k) {
224 unsigned intfirst_job_id,
227 if(first_job_id == 0 ||
count== 0 || group_id == 0)
234found->second->m_Jobs.set_range(first_job_id, first_job_id +
count- 1);
235 returnfound->second->m_GroupId;
241 "Group with id "+ to_string(group_id) +
" is unknown");
248 if(job_id == 0 || group.empty())
256found->second->m_Jobs.set_bit(job_id);
257 returnfound->second->m_GroupId;
262 m_IDToAttr[group_id]->m_Jobs.set_bit(job_id);
270 if(group_id == 0 || job_id == 0)
277found->second->m_Jobs.set_bit(job_id);
284 "Group with id "+ to_string(group_id) +
" is unknown");
296 throwruntime_error(
"Error while restoring jobs from the dump. " 297 "The group with id "+ to_string(group_id) +
298 " is not found in the loaded dictionary." 299 " (Lost group dictionary dump?)");
300found->second->m_Jobs.set_bit(job_id);
307 if(group_id == 0 || job_id == 0)
314found->second->m_Jobs.set_bit(job_id,
false);
316 if(found->second->CanBeDeleted())
326 const string& scope,
336 while(en.
valid()) {
340 if(batch.
count() >= batch_size) {
346 if(batch.
count() > 0)
359 unsigned intmax_group_id = 0;
363 if(candidate->first > max_group_id)
366max_group_id = candidate->first;
368 if(candidate->second->CanBeDeleted()) {
382 unsigned intdel_count = 0;
386 for( ; en.
valid(); ++en) {
387 unsigned intgroup_id = *en;
395 if(found->second->CanBeDeleted())
399 if(del_count >= max_to_del)
409 unsigned intstill_candidate = 0;
413 for( ; en.
valid(); ++en) {
414 unsigned intgroup_id = *en;
422 if(found->second->CanBeDeleted())
427 returnstill_candidate;
453unique_ptr<string> new_token(
new string(group));
456new_attr->m_GroupToken = new_token.get();
457new_attr->m_GroupId = group_id;
477 const string& scope,
486 if(batch.
get_bit(k->first)) {
489 if(printed >= batch.
count())
502 const string& scope,
513 else if(!scope.empty()) {
521 "OK: ID: "+ to_string(group_attr.
m_GroupId) +
"\n";
528 for( ; en.
valid(); ++en) {
529 unsigned intjob_id = *en;
536 buffer+=
"OK: JOBS: NONE\n";
539 buffer+=
"OK: NUMBER OF JOBS: "+ to_string(jobs.
count()) +
"\n";
551 deleteto_del->second->m_GroupToken;
552 deleteto_del->second;
564 unsigned intgroup_id = to_del->second->m_GroupId;
565 const string* group_token = to_del->second->m_GroupToken;
570 deleteto_del->second;
575 ERR_POST(
"Internal inconsistency detected. The group "+
576to_string(group_id) +
" exists in the id->attr container " 577 "and does not exist in the token->attr container.");
590 const string& qname)
const 597 if(k->second->m_Jobs.any())
598groups_to_dump.
set_bit(k->first);
601 if(!groups_to_dump.
any())
605FILE * grp_dict_file = fopen(grp_dict_file_name.c_str(),
"wb");
607 if(grp_dict_file ==
NULL)
608 throwruntime_error(
"Cannot open file "+ grp_dict_file_name +
612setbuf(grp_dict_file,
NULL);
614 if(groups_to_dump.
any()) {
618header.
Write(grp_dict_file);
619}
catch(
constexception & ex) {
620fclose(grp_dict_file);
621 throwruntime_error(
"Writing error while dumping groups header: "+
627 for( ; en.
valid(); ++en) {
630 const string& token = *(grp_it->second->m_GroupToken);
635memcpy(grp_dump.
token, token.data(), token.size());
638grp_dump.
Write(grp_dict_file);
639}
catch(
constexception & ex) {
640fclose(grp_dict_file);
641 throwruntime_error(
"Writing error while dumping groups: "+
646fclose(grp_dict_file);
651 const string& qname)
const 654 if(access(grp_dict_file_name.c_str(), F_OK) != -1)
655 remove(grp_dict_file_name.c_str());
660 const string& qname)
const 662 const stringfname(
"group_dict_dump.");
663 stringupper_queue_name = qname;
665 returndump_dir_name + fname + upper_queue_name;
677 const string& qname)
679 if(!
CDir(dump_dir_name).Exists())
683 if(!
CFile(grp_dict_file_name).Exists())
686FILE * grp_dict_file = fopen(grp_dict_file_name.c_str(),
"rb");
687 if(grp_dict_file ==
NULL)
688 throwruntime_error(
"Cannot open file "+ grp_dict_file_name +
689 " to load dumped groups");
692header.
Read(grp_dict_file);
695 while(grp_dump.
Read(grp_dict_file, header.
fixed_size) == 0) {
708}
catch(
constexception & ex) {
709fclose(grp_dict_file);
711 throwruntime_error(
"Reading error while loading dumped groups: "+
715fclose(grp_dict_file);
unsigned int m_LastGroupID
void RemoveJob(unsigned int group_id, unsigned int job_id)
TNSBitVector m_RegisteredGroups
string x_PrintOne(const SNSGroupJobs &group_attr, const CQueue *queue, const TNSBitVector &scope_jobs, const string &scope, bool verbose) const
CFastMutex m_LastGroupIDLock
void x_DeleteSingleInMemory(TGroupIDToAttrMap::iterator to_del)
void RemoveDump(const string &dump_dir_name, const string &queue_name) const
unsigned int CollectGarbage(unsigned int max_to_del)
unsigned int x_GetNextGroupID(void)
TNSBitVector GetRegisteredGroups(void) const
string x_PrintSelected(const TNSBitVector &batch, const CQueue *queue, const TNSBitVector &scope_jobs, const string &scope, bool verbose) const
unsigned int CheckRemoveCandidates(void)
TNSBitVector GetJobs(const string &group, bool allow_exception=true) const
unsigned int ResolveGroup(const string &group)
bool CanAccept(const string &group, size_t max_records) const
void x_InitLastGroupID(unsigned int value)
unsigned int x_CreateGroup(const string &group)
void AddJobToGroup(unsigned int group_id, unsigned int job_id)
string x_GetDumpFileName(const string &dump_dir_name, const string &qname) const
unsigned int AddJob(const string &group, unsigned int job_id)
unsigned int AddJobs(unsigned int group_id, unsigned int first_job_id, unsigned int count)
void FinalizeGroupDictionaryLoading(void)
TGroupIDToAttrMap m_IDToAttr
string Print(const CQueue *queue, const TNSBitVector &scope_jobs, const string &scope, size_t batch_size, bool verbose) const
TNSBitVector m_RemoveCandidates
void ResolveGroups(const list< string > &tokens, TNSBitVector &group_ids_vector)
TGroupTokenToAttrMap m_TokenToAttr
void RestrictByGroup(const string &group, TNSBitVector &bv) const
void Dump(const string &dump_dir_name, const string &queue_name) const
void LoadFromDump(const string &dump_dir_name, const string &queue_name)
NetSchedule internal exception.
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.
bool get_bit(size_type n) const noexcept
returns true if bit n is set and false is bit n is 0.
bool any() const noexcept
Returns true if any bits in this bitset are set, and otherwise returns false.
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)
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
Include a standard set of the NCBI C++ Toolkit most basic headers.
static void DLIST_NAME() remove(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
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.
const GenericPointer< typename T::ValueType > T2 value
const string kNoScopeOnly
const TNSBitVector kEmptyBitVector
int Read(FILE *f, size_t fixed_size_from_header)
char token[kNetScheduleMaxDBDataSize]
bool CanBeDeleted(void) const
const string * m_GroupToken
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