68 m_ConcurrentProcessorCount(0)
75 switch (it.second->m_State) {
83 PSG_ERROR(
"Reply is going to be deleted when a processor has "
84 "not unlocked an event");
93 PSG_ERROR(
"Reply is going to be deleted when a processor is "
94 "locked on a condition variable");
95 it.second->m_WaitObject.notify_all();
104 unique_ptr<SPSGS_RequestBase> req,
106 m_HttpRequest(http_request),
107 m_Request(move(req)),
108 m_RequestContext(request_context),
111 m_ConcurrentProcessorCount(0)
133 "Multiple lock of the same event is not supported");
148 auto it =
m_Wait.find(event_name);
154 switch (it->second->m_State) {
162 it->second->m_WaitCount = 0;
164 it->second->m_WaitObject.notify_all();
179 auto it =
m_Wait.find(event_name);
185 switch (it->second->m_State) {
195 ++it->second->m_WaitCount;
197 auto status = it->second->m_WaitObject.wait_for(scope_lock,
198 chrono::seconds(timeout_sec));
199 if (status == cv_status::timeout) {
202 if (--it->second->m_WaitCount == 0)
205 string message =
"Timeout (" + to_string(timeout_sec) +
206 " seconds) waiting on event '" + event_name +
"'";
242 "User request is not initialized");
252 "User request is not initialized");
262 "User request is not initialized");
271 return GetRequest<SPSGS_ResolveRequest>().m_Hops;
275 return GetRequest<SPSGS_BlobRequestBase>().m_Hops;
277 return GetRequest<SPSGS_TSEChunkRequest>().m_Hops;
279 return GetRequest<SPSGS_AccessionVersionHistoryRequest>().m_Hops;
289 "User request is not initialized");
297 return "unknown (request is not initialized)";
326 msg +=
"processor: " + item.first +
327 ", concurrency limit: " + to_string(item.second);
338 auto now = psg_clock_t::now();
339 uint64_t mks = chrono::duration_cast<chrono::microseconds>
347 json.
SetByKey(
"enabled processors", enabled_procs);
353 json.
SetByKey(
"disabled processors", disabled_procs);
396 json.
SetByKey(
"exclude blobs", exclude_blobs);
430 for (
const auto & name :
m_Names) {
431 names.AppendString(name);
438 for (
const auto & seq_id :
m_SeqIds) {
497 if (item.second == name) {
498 ret =
max(ret, item.first);
528 if (item.first >= priority) {
529 auto it = find(ret.begin(), ret.end(), item.second);
530 if (it != ret.end()) {
542 if (item.second == annot_name)
549 vector<pair<TProcessorPriority, string>>
575 if (it->second <
int(rs)) {
576 it->second =
int(rs);
599 if (it->first == priority && it->second ==
m_Names[0]) {
620 if (it->second <
int(rs)) {
621 it->second =
int(rs);
static CJsonNode NewArrayNode()
Create a new JSON array node.
void SetString(const string &key, const string &value)
Set a JSON object element to the specified string value.
void AppendString(const string &value)
For an array node, add a string node at the end of the array.
void SetBoolean(const string &key, bool value)
Set a JSON object element to the specified boolean value.
void SetInteger(const string &key, Int8 value)
Set a JSON object element to the specified integer value.
void SetByKey(const string &key, CJsonNode::TInstance value)
For a JSON object node, insert a new element or update an existing element.
static CJsonNode NewObjectNode()
Create a new JSON object node.
void WaitFor(const string &event_name, size_t timeout_sec=10)
void Lock(const string &event_name)
map< string, SWaitData * > m_Wait
void SetRequestContext(void)
virtual CJsonNode Serialize(void) const
CRef< CRequestContext > GetRequestContext(void)
EPSGS_Type GetRequestType(void) const
string GetLimitedProcessorsMessage(void)
CRef< CRequestContext > m_RequestContext
unique_ptr< SPSGS_RequestBase > m_Request
size_t m_ConcurrentProcessorCount
void Unlock(const string &event_name)
bool NeedProcessorEvents(void)
vector< pair< string, size_t > > m_LimitedProcessors
uint64_t m_BacklogTimeMks
@ ePSGS_AnnotationRequest
@ ePSGS_BlobBySatSatKeyRequest
@ ePSGS_IPGResolveRequest
@ ePSGS_AccessionVersionHistoryRequest
@ ePSGS_BlobBySeqIdRequest
psg_time_point_t GetStartTimestamp(void) const
virtual string GetName(void) const
const_iterator end() const
const_iterator find(const key_type &key) const
iterator_bool insert(const value_type &val)
The NCBI C++ standard methods for dealing with std::string.
static const struct name_t names[]
static void SetRequestContext(CRequestContext *ctx)
Shortcut to CDiagContextThreadData::GetThreadData().SetRequestContext()
static CRequestContext & GetRequestContext(void)
Shortcut to CDiagContextThreadData::GetThreadData().GetRequestContext()
CRef< CRequestContext > Clone(void) const
Copy current request context to a new one.
void SetReadOnly(bool read_only)
Switch request context to read-only mode.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
bool NotNull(void) const THROWS_NONE
Check if pointer is not null – same effect as NotEmpty().
unsigned int
A callback function used to compare two keys in a database.
size_t GetNextRequestId(void)
static atomic< bool > s_RequestIdLock(false)
static size_t s_NextRequestId
#define PSG_ERROR(message)
#define PSG_WARNING(message)
const int kUnknownPriority
psg_clock_t::time_point psg_time_point_t
long PSGToString(long signed_value, char *buf)
unsigned __int64 uint64_t
@ ePSGS_LockedSomebodyWaits
@ ePSGS_LockedNobodyWaits
virtual string GetName(void) const
virtual CJsonNode Serialize(void) const
EPSGS_CacheAndDbUse m_UseCache
TProcessorPriority RegisterProcessedName(TProcessorPriority priority, const string &name)
bool WasSent(const string &annot_name) const
map< string, int > m_ErrorAnnotations
vector< string > GetNotProcessedName(TProcessorPriority priority)
vector< pair< TProcessorPriority, string > > m_Processed
vector< pair< TProcessorPriority, string > > GetProcessedNames(void) const
vector< string > m_SeqIds
TProcessorPriority RegisterBioseqInfo(TProcessorPriority priority)
virtual string GetName(void) const
void ReportBlobError(TProcessorPriority priority, EPSGS_ResultStatus rs)
unsigned long m_ResendTimeoutMks
void ReportResultStatus(const string &annot_name, EPSGS_ResultStatus rs)
TProcessorPriority m_ProcessedBioseqInfo
virtual CJsonNode Serialize(void) const
virtual CJsonNode Serialize(void) const
virtual string GetName(void) const
CBlobRecord::TTimestamp m_LastModified
virtual CJsonNode Serialize(void) const
virtual string GetName(void) const
vector< string > m_ExcludeBlobs
unsigned long m_ResendTimeoutMks
EPSGS_AccSubstitutioOption m_AccSubstOption
EPSGS_CacheAndDbUse m_UseCache
static string TSEOptionToString(EPSGS_TSEOption option)
void AppendCommonParameters(CJsonNode &json) const
unsigned long m_SendBlobIfSmall
EPSGS_TSEOption m_TSEOption
optional< string > m_Protein
EPSGS_CacheAndDbUse m_UseCache
optional< string > m_Nucleotide
virtual CJsonNode Serialize(void) const
virtual string GetName(void) const
static string TraceToString(EPSGS_Trace trace)
static string CacheAndDbUseToString(EPSGS_CacheAndDbUse option)
vector< string > m_DisabledProcessors
vector< string > m_EnabledProcessors
static string AccSubstitutioOptionToString(EPSGS_AccSubstitutioOption option)
psg_time_point_t m_StartTimestamp
void AppendCommonParameters(CJsonNode &json) const
static string OutputFormatToString(EPSGS_OutputFormat format)
EPSGS_CacheAndDbUse m_UseCache
virtual CJsonNode Serialize(void) const
virtual string GetName(void) const
TPSGS_BioseqIncludeData m_IncludeDataFlags
EPSGS_OutputFormat m_OutputFormat
EPSGS_AccSubstitutioOption m_AccSubstOption
virtual CJsonNode Serialize(void) const
EPSGS_CacheAndDbUse m_UseCache
virtual string GetName(void) const