33 #include <unordered_set>
34 #include <unordered_map>
109 case eStart:
return "Start";
111 case eReply:
return "Reply";
112 case eDone:
return "Done";
113 case eSend:
return "Send";
115 case eClose:
return "Close";
116 case eRetry:
return "Retry";
117 case eFail:
return "Fail";
146 unique_lock<mutex> lock(
m_Mutex);
149 cout << ss.rdbuf() << endl;
151 cout <<
m_Separator <<
'\n' << ss.rdbuf() << flush;
162 cout <<
"\n]" << endl;
166 template <
class... TArgs>
168 m_JsonObj(SetObject())
173 catch (exception& e) {
178 Set(
"message", e.what());
194 Set(error_obj[
"message"], message);
198 m_JsonObj(SetObject())
200 Set(
"jsonrpc",
"2.0");
207 id_value.SetString(
id);
211 template <
class TItem>
214 Fill(status, std::move(item));
217 template <
class TItem,
class... TArgs>
220 if (
auto request_id =
s_GetReply(item)->GetRequest()->
template GetUserContext<string>()) {
221 Set(
"request_id", *request_id);
224 Fill(status, std::move(item), std::forward<TArgs>(args)...);
242 return "UnknownItem";
248 rv.
Set(
"reply",
"NewItem");
256 auto reply_item_type = reply_item->GetType();
263 Set(
"processor_id", reply_item->GetProcessorId());
267 return Fill(reply_item, reply_item_status);
270 switch (reply_item_type) {
272 return Fill(static_pointer_cast<CPSG_BlobData>(reply_item));
275 return Fill(static_pointer_cast<CPSG_BlobInfo>(reply_item));
278 return Fill(static_pointer_cast<CPSG_SkippedBlob>(reply_item));
281 return Fill(static_pointer_cast<CPSG_BioseqInfo>(reply_item));
284 return Fill(static_pointer_cast<CPSG_NamedAnnotInfo>(reply_item));
287 return Fill(static_pointer_cast<CPSG_NamedAnnotStatus>(reply_item));
290 return Fill(static_pointer_cast<CPSG_PublicComment>(reply_item));
293 return Fill(static_pointer_cast<CPSG_Processor>(reply_item));
296 return Fill(static_pointer_cast<CPSG_IpgInfo>(reply_item));
303 throw logic_error(
"Received unknown item: " + to_string(reply_item_type));
308 return (request->GetType() ==
CPSG_Request::eBlob) && dynamic_pointer_cast<const CRawRequest>(request);
318 if (
auto request = blob_data->GetReply()->GetRequest();
s_IsRawRequest(request)) {
321 Set(
"reply", blob_id->GetId());
323 for (
const auto& p : json_doc.GetObject()) {
332 Set(
"id", blob_data);
334 os << blob_data->GetStream().rdbuf();
335 auto data = os.str();
337 if (
const auto data_size = data.size(); data_size <=
sm_DataLimit) {
340 Set(
"length",
static_cast<Uint8>(data_size));
342 hash.Calculate(data.data(), data_size);
343 Set(
"hash",
hash.GetResultHex());
351 Set(
"id", blob_info);
352 Set(
"compression", blob_info->GetCompression());
353 Set(
"format", blob_info->GetFormat());
354 Set(
"storage_size", blob_info->GetStorageSize());
355 Set(
"size", blob_info->GetSize());
356 Set(
"is_dead", blob_info->IsDead());
357 Set(
"is_suppressed", blob_info->IsSuppressed());
358 Set(
"is_withdrawn", blob_info->IsWithdrawn());
359 Set(
"hup_release_date", blob_info->GetHupReleaseDate().AsString());
360 Set(
"owner", blob_info->GetOwner());
361 Set(
"original_load_date", blob_info->GetOriginalLoadDate().AsString());
363 Set(
"division", blob_info->GetDivision());
364 Set(
"username", blob_info->GetUsername());
365 Set(
"id2_info", blob_info->GetId2Info());
366 Set(
"n_chunks", blob_info->GetNChunks());
384 Set(
"id", skipped_blob);
387 const auto& sent_seconds_ago = skipped_blob->GetSentSecondsAgo();
389 if (!sent_seconds_ago.IsNull()) {
390 Set(
"sent_seconds_ago", sent_seconds_ago.GetValue());
393 const auto& time_until_resend = skipped_blob->GetTimeUntilResend();
395 if (!time_until_resend.IsNull()) {
396 Set(
"time_until_resend", time_until_resend.GetValue());
402 const auto included_info = bioseq_info->IncludedInfo();
419 Set(
"name", named_annot_info->GetName());
420 Set(
"blob_id", named_annot_info->GetBlobId());
421 Set(
"id2_annot_info", named_annot_info->GetId2AnnotInfo());
428 for (
const auto& status : named_annot_status->GetId2AnnotStatusList()) {
430 auto obj = ar.back().ResetObject();
431 Set(obj[
"name"], status.first);
438 Set(
"id", public_comment);
439 Set(
"text", public_comment->GetText());
444 switch (progress_status) {
461 const auto progress_status = processor->GetProgressStatus();
466 Set(
"processor_id", processor->GetProcessorId());
474 Set(
"protein", ipg_info->GetProtein());
475 Set(
"ipg", ipg_info->GetIpg());
476 Set(
"nucleotide", ipg_info->GetNucleotide());
477 Set(
"tax_id", ipg_info->GetTaxId());
478 Set(
"gb_state", ipg_info->GetGbState());
481 template <
class TItem>
486 for (
auto message = std::move(first_message); !message.empty(); message = item->GetNextMessage()) {
488 errors.ResetArray().push_back(message);
490 errors.SetArray().push_back(message);
511 for (
const auto& bio_id : bio_ids) {
513 Set(ar.back(), bio_id);
524 if (!last_modified.IsNull()) {
525 Set(obj[
"last_modified"], last_modified.GetValue());
541 if (!servers.empty()) {
542 sort(servers.begin(), servers.end(), [](
const auto& l,
const auto&
r) { return l.second < r.second; });
543 return servers.back().first.AsString();
552 for (
const auto& item :
m_Items) {
567 void Process(shared_ptr<CPSG_BlobInfo> blob_info);
568 void Process(shared_ptr<CPSG_BlobData> blob_data);
569 void Process(shared_ptr<CPSG_NamedAnnotInfo> named_annot_info);
570 void Process(shared_ptr<CPSG_BlobInfo> blob_info, shared_ptr<CPSG_BlobData> blob_data);
572 template <
class TItem>
576 unordered_map<string, pair<shared_ptr<CPSG_BlobInfo>, shared_ptr<CPSG_BlobData>>>
m_Data;
580 template <
class TItem>
595 auto message = item->GetNextMessage();
597 if (message.empty())
break;
599 ss << delim << message;
606 auto message = item->GetNextMessage();
608 if (message.empty())
break;
610 ss <<
"\n\t" << message;
626 Process(static_pointer_cast<CPSG_BlobInfo>(item));
629 Process(static_pointer_cast<CPSG_BlobData>(item));
632 Process(static_pointer_cast<CPSG_NamedAnnotInfo>(item));
655 return chunk_id->GetId2Chunk() == 999999999 ? CID2S_Split_Info::GetTypeInfo() : CID2S_Chunk::GetTypeInfo();
658 return CSeq_entry::GetTypeInfo();
663 auto& p =
m_Data[blob_info->GetId()->Repr()];
666 Process(std::move(blob_info), std::move(p.second));
668 p.first = std::move(blob_info);
674 auto& p =
m_Data[blob_data->GetId()->Repr()];
677 Process(std::move(p.first), std::move(blob_data));
679 p.second = std::move(blob_data);
685 auto& is = blob_data->GetStream();
693 unique_ptr<CObjectIStream>
in;
695 if (blob_info->GetCompression().find(
"zip") == string::npos) {
714 cerr <<
"Failed to process blob '" << blob_data->GetId()->Repr() <<
"': " << ex.
ReportThis() << endl;
728 for (
const auto&
info : named_annot_info->GetId2AnnotInfoList() ) {
733 template <
class... TArgs>
747 template <
class... TArgs>
761 template <
class... TArgs>
764 const auto type = item->GetType();
767 m_Items.try_emplace(
type, item);
769 TBase::ItemComplete(json_out, status, item);
771 if (
auto [it,
result] = m_Items.try_emplace(
type,
nullptr); !
result && it->second) {
777 template <
class... TArgs>
780 for (
const auto& p : m_Items) {
781 if (
auto& item = p.second) {
787 TBase::ReplyComplete(json_out, status, reply);
791 template <
class... TArgs>
797 template <
class... TArgs>
807 s_ReplyComplete<>(json_out, status, reply);
811 template <
class... TArgs>
826 "/objtools/pubseq_gateway/client/",
827 R
"(\S+: (\S+:[0-9]+)/\S+?\S+&client_id=\S+)",
828 R"(\S+: Closed with status \S+)",
829 R"(\S+: \S+&item_type=reply&\S+&exec_time=([0-9]+)\\n)"
842 using namespace placeholders;
853 auto item_complete = bind(&s_ItemComplete<SOneRequestParams>, ref(json_out), _1, _2);
863 return data_only_copy;
872 void ItemComplete(
SJsonOut& json_out,
EPSG_Status status,
const shared_ptr<CPSG_ReplyItem>& item);
873 void ReplyComplete(
SJsonOut& json_out,
EPSG_Status status,
const shared_ptr<CPSG_Reply>& reply);
876 template <
class TParams>
887 while (m_InputQueue.Pop(
id)) {
890 auto user_context = make_shared<SNonVerbose<SBatchResolveParams>>(std::move(
id));
891 auto request = make_shared<CPSG_Request_Resolve>(std::move(bio_id), m_Params.bio_id_resolution, std::move(user_context));
893 request->IncludeInfo(m_Params.include_info);
894 request->SetAccSubstitution(m_Params.acc_substitution);
910 context->ItemComplete(json_out, status, item);
915 reported.emplace(status);
916 s_ItemComplete<verbose>(json_out, status, item);
924 context->ReplyComplete(json_out, status, reply);
929 if (
auto first_message = reply->GetNextMessage(); !first_message.empty() || (reported.find(status) == reported.end())) {
931 json_out << result_doc;
935 template <
class TParams>
940 return &s_ItemComplete<verbose>;
946 template <
class TParams>
951 return &s_ReplyComplete<verbose>;
957 template <
class TParams>
960 return &s_NewItem<TParams>;
966 string line, protein,
n;
968 while (m_InputQueue.Pop(line)) {
972 auto user_context = make_shared<SNonVerbose<SBatchResolveParams>>(std::move(line));
973 auto request = make_shared<CPSG_Request_IpgResolve>(std::move(protein), 0, std::move(nucleotide), std::move(user_context));
995 while (m_InputQueue.Pop(line)) {
1002 }
else if (!json_schema.
Validate(json_doc)) {
1005 if (m_Params.echo) json_out << json_doc;
1010 auto params_obj = json_obj[
"params"].
GetObject();
1011 auto user_context = make_shared<string>(
id);
1014 if (
auto request =
SRequestBuilder::Build(method, params_obj, std::move(user_context), std::move(request_context))) {
1031 const auto request = reply->GetRequest();
1032 const auto& request_id = *request->GetUserContext<
string>();
1049 const auto request = reply->GetRequest();
1059 const auto request = reply->GetRequest();
1069 const auto request = item->GetReply()->GetRequest();
1070 const auto& request_id = *request->GetUserContext<
string>();
1085 if (m_Params.testing) {
1087 if (m_Params.server) {
1094 if (m_Params.server) {
1105 const auto request = item->GetReply()->GetRequest();
1106 const auto& request_id = *request->GetUserContext<
string>();
1119 return &s_NewItem<SInteractiveParams, no_verbose>;
1123 template <
class TParams>
1125 json_out(params.pipe, params.server),
1131 template <
class TParams>
1135 using namespace placeholders;
1140 for (
int n = params.worker_threads;
n > 0; --
n) {
1141 m_PsgQueues.emplace_back(params.service, item_complete, reply_complete, new_item);
1143 queue.SetRequestFlags(params.request_flags);
1144 queue.SetUserArgs(params.user_args);
1150 shared_ptr<CPSG_Reply>
s_GetReply(shared_ptr<CPSG_ReplyItem>& item)
1152 return item->GetReply();
1162 switch (psg_status) {
1181 if (req_obj.has(
"id")) {
1182 auto id_node = req_obj[
"id"];
1184 if (id_node.IsValue()) {
1185 auto id_value = id_node.
GetValue();
1187 if (id_value.IsString()) {
1197 template <
class TCreateContext>
1202 vector<shared_ptr<CPSG_Request>> requests;
1203 unordered_set<string> ids;
1210 cerr <<
"Error in request '" << line <<
"': " << json_doc.
GetReadError() << endl;
1217 cerr <<
"Error in request '" << line <<
"': no id or id is empty" << endl;
1219 }
else if (!json_schema.
Validate(json_doc)) {
1220 cerr <<
"Error in request '" <<
id <<
"': " << json_schema.
GetValidationError() << endl;
1222 }
else if (!ids.insert(
id).second) {
1223 cerr <<
"Error in request '" <<
id <<
"': duplicate ID" << endl;
1228 auto params_obj = json_obj[
"params"].
GetObject();
1229 auto user_context = create_context(
id, params_obj);
1231 if (!user_context)
return {};
1234 requests.emplace_back(std::move(request));
1235 if (report_progress_after && (requests.size() % report_progress_after == 0)) cerr <<
'.';
1245 if (params.
delay < 0.0) {
1246 cerr <<
"DELAY must be non-negative" << endl;
1250 const size_t kReportProgressAfter = 2000;
1252 using TReplyStorage = deque<shared_ptr<CPSG_Reply>>;
1255 auto requests = ReadCommands([](
string id,
CJson_ConstNode&){
return make_shared<SMetrics>(std::move(
id)); },
SParams::verbose ? kReportProgressAfter : 0);
1257 if (requests.empty())
return -1;
1260 atomic_int to_submit(
static_cast<int>(requests.size()));
1261 auto wait = [&]() {
while (start > 0) this_thread::sleep_for(chrono::microseconds(1)); };
1263 auto l = [&](
CPSG_Queue& queue, TReplyStorage& replies) {
1268 auto i = to_submit--;
1273 auto& request = requests[requests.size() -
i];
1274 auto metrics = request->GetUserContext<
SMetrics>();
1288 const auto type = reply_item->GetType();
1293 metrics->AddItem({
type, status});
1307 replies.emplace_back(reply);
1311 this_thread::sleep_for(chrono::duration<double>(params.
delay));
1316 vector<CPSG_Queue> queues;
1320 queues.emplace_back(params.
service);
1322 queues.back().SetUserArgs(params.
user_args);
1325 vector<thread> threads;
1330 threads.emplace_back(l, ref(queues[params.
local_queue ?
i : 0]), ref(replies[
i]));
1337 cerr <<
"\nSubmitting requests: ";
1338 size_t previous = requests.size() / kReportProgressAfter;
1340 while (to_submit > 0) {
1341 size_t current = to_submit / kReportProgressAfter;
1343 for (
auto i = current;
i < previous; ++
i) {
1348 this_thread::sleep_for(chrono::milliseconds(100));
1351 cerr <<
"\nWaiting for threads: " << params.
user_threads <<
'\n';
1354 for (
auto&
t : threads) {
1366 for (
auto& thread_replies : replies) {
1367 for (
auto& reply : thread_replies) {
1380 if (!getline(is, line)) {
1382 }
else if (!line.empty()) {
1396 auto context = params_obj.
find(
"context");
1399 if (context != params_obj.
end()) {
1400 auto context_obj = context->value.GetObject();
1402 auto sid = context_obj.find(
"sid");
1404 if (sid != context_obj.end()) {
1405 ctx.SetSessionID(sid->value.GetValue().GetString());
1408 auto phid = context_obj.find(
"phid");
1410 if (phid != context_obj.end()) {
1411 ctx.SetHitID(phid->value.GetValue().GetString());
1414 auto auth_token = context_obj.find(
"auth_token");
1416 if (auth_token != context_obj.end()) {
1417 ctx.SetProperty(
"auth_token", auth_token->value.GetValue().GetString());
1420 auto client_ip = context_obj.find(
"client_ip");
1422 if (client_ip != context_obj.end()) {
1423 ctx.SetClientIP(client_ip->value.GetValue().GetString());
1427 if (!
ctx.IsSetSessionID())
ctx.SetSessionID();
1428 if (!
ctx.IsSetHitID())
ctx.SetHitID();
1431 extra.
Print(
"request", request);
1432 extra.
Print(
"params", params_obj);
1443 }
else if (json.
IsInt8()) {
1456 for (
size_t i = 0;
i < json.
size(); ++
i) {
1463 for (
const auto& pair : json) {
1502 schema_doc = RequestSchema();
1504 }
else if (!schema_doc.
Read(*schema_is)) {
1505 cerr <<
"Error on reading JSON schema: " << schema_doc.
GetReadError() << endl;
1509 cerr <<
"Error on validating JSON schema: " << meta_schema.GetValidationError() << endl;
1523 cout <<
"Error on reading JSON document (" << line_no <<
"): " << input_doc.
GetReadError() << endl;
1524 if (rv == 0) rv = -2;
1525 }
else if (
schema.Validate(input_doc)) {
1526 cout <<
"JSON document (" << line_no <<
") is valid" << endl;
1528 cout <<
"Error on validating JSON document (" << line_no <<
"): " <<
schema.GetValidationError() << endl;
1529 if (rv == 0) rv = -3;
1533 cout << line_no <<
" JSON document(s) have been checked" << endl;
1542 if (
auto value = objects::CSeq_id::WhichInverseSeqId(
type))
return value;
1549 auto id =
array[0].GetValue().GetString();
1562 if (
input.has(
"bio_ids")) {
1563 auto bio_ids =
input[
"bio_ids"].GetArray();
1565 for (
const auto& bio_id : bio_ids) {
1566 rv.push_back(GetBioId(bio_id.GetArray()));
1569 rv.push_back(GetBioId(
input[
"bio_id"].GetArray()));
1578 auto id =
array[0].GetValue().GetString();
1579 return array.size() > 1 ?
CPSG_BlobId(std::move(
id),
array[1].GetValue().GetInt8()) : std::move(
id);
1585 return {
static_cast<int>(
array[0].GetValue().GetInt4()),
array[1].GetValue().GetString() };
1590 auto na_array =
input[
"named_annots"].GetArray();
1593 for (
const auto& na : na_array) {
1594 names.push_back(na.GetValue().GetString());
1603 const auto& info_flags = GetInfoFlags();
1605 auto i = info_flags.begin();
1606 bool all_info_except = specified(
i->name);
1609 for (++
i;
i != info_flags.end(); ++
i) {
1610 if (specified(
i->name)) {
1611 if (all_info_except) {
1612 include_info &= ~
i->value;
1614 include_info |=
i->value;
1625 if (!
input.has(
"exclude_blobs"))
return;
1627 auto blob_ids =
input[
"exclude_blobs"].GetArray();
1629 for (
const auto& blob_id : blob_ids) {
1630 exclude(blob_id.GetValue().GetString());
1636 if (!
input.has(
"request_flags"))
return;
1638 for (
const auto& request_flag :
input[
"request_flags"].GetArray()) {
1639 const auto value = request_flag.GetValue().GetString();
1641 if (
value ==
"exclude-hup") {
1644 }
else if (
value ==
"include-hup") {
1723 "$ref": "#/definitions/bio_id"
1756 "$id": "#include_data",
1766 "$id": "#include_info",
1789 "$id": "#named_annots",
1796 "$id": "#exclude_blobs",
1802 "acc_substitution": {
1803 "$id": "#acc_substitution",
1810 "snp_scale_limit": {
1811 "$id": "#snp_scale_limit",
1839 "$id": "#request_flags",
1857 "$ref": "#/definitions/jsonrpc"
1868 "$ref": "#/definitions/bio_id"
1871 "$ref": "#/definitions/include_data"
1874 "$ref": "#/definitions/exclude_blobs"
1876 "acc_substitution": {
1877 "$ref": "#/definitions/acc_substitution"
1879 "bio_id_resolution": {
1886 "$ref": "#/definitions/context"
1889 "$ref": "#/definitions/request_flags"
1915 "$ref": "#/definitions/jsonrpc"
1926 "$ref": "#/definitions/blob_id"
1929 "$ref": "#/definitions/include_data"
1932 "$ref": "#/definitions/context"
1935 "$ref": "#/definitions/request_flags"
1961 "$ref": "#/definitions/jsonrpc"
1972 "$ref": "#/definitions/bio_id"
1975 "$ref": "#/definitions/include_info"
1977 "acc_substitution": {
1978 "$ref": "#/definitions/acc_substitution"
1980 "bio_id_resolution": {
1984 "$ref": "#/definitions/context"
1987 "$ref": "#/definitions/request_flags"
2009 "$id": "#named_annot",
2013 "$ref": "#/definitions/jsonrpc"
2024 "$ref": "#/definitions/bio_id"
2027 "$ref": "#/definitions/bio_ids"
2030 "$ref": "#/definitions/named_annots"
2032 "acc_substitution": {
2033 "$ref": "#/definitions/acc_substitution"
2035 "bio_id_resolution": {
2038 "snp_scale_limit": {
2039 "$ref": "#/definitions/snp_scale_limit"
2042 "$ref": "#/definitions/context"
2045 "$ref": "#/definitions/request_flags"
2083 "$ref": "#/definitions/jsonrpc"
2094 "$ref": "#/definitions/chunk_id"
2097 "$ref": "#/definitions/context"
2100 "$ref": "#/definitions/request_flags"
2122 "$id": "#ipg_resolve",
2126 "$ref": "#/definitions/jsonrpc"
2146 "$ref": "#/definitions/context"
2149 "$ref": "#/definitions/request_flags"
2189 "$ref": "#/definitions/jsonrpc"
2203 "$ref": "#/definitions/context"
2206 "$ref": "#/definitions/request_flags"
2230 "$ref": "#/definitions/biodata"
2233 "$ref": "#/definitions/blob"
2236 "$ref": "#/definitions/resolve"
2239 "$ref": "#/definitions/named_annot"
2242 "$ref": "#/definitions/chunk"
2245 "$ref": "#/definitions/ipg_resolve"
2248 "$ref": "#/definitions/raw"
User-defined methods of the data storage class.
User-defined methods of the data storage class.
Checksum and hash calculation classes.
CHash – Hash calculator.
static void SetDataLimit(size_t value)
static bool sm_SetReplyType
static auto sm_PreviewSize
void Set(const char *name, shared_ptr< TReplyItem > &reply_item)
static CJsonResponse NewItem(const shared_ptr< CPSG_ReplyItem > &reply_item)
static void SetReplyType(bool value)
void Fill(EPSG_Status status, TItem item, string first_message)
static void SetPreviewSize(size_t value)
void FillWithRequestID(EPSG_Status status, TItem item, EDoNotAddRequestID)
void push_back(void)
Add null element to the end of the array.
size_t size(void) const
Return the number of elements in the array.
bool IsObject(void) const
CJson_ConstObject GetObject(void) const
Get JSON object contents of the node.
CJson_ConstArray GetArray(void) const
Get JSON array contents of the node.
CJson_ConstValue GetValue(void) const
Get JSON value contents of the node.
EJsonType GetType(void) const
Get value type.
const_iterator find(const CJson_Node::TKeyType &name) const
Return an iterator that points to the location of the element.
const_iterator end(void) const
Return an iterator that points to the location after the last element.
Uint4 GetUint4(void) const
Uint8 GetUint8(void) const
bool GetBool(void) const
Get primitive value data.
TStringType GetString(void) const
double GetDouble(void) const
bool IsDouble(void) const
bool IsNumber(void) const
bool Read(std::istream &in)
Read JSON data from a stream.
std::string GetReadError(void) const
Get most recent read error.
bool ParseString(const TStringType &v)
Read JSON data from a UTF8 string.
bool ReadSucceeded(void) const
Test if the most recent read was successful.
bool Write(std::ostream &out, TJson_Write_Flags flags=fJson_Write_IndentWithSpace, unsigned int indent_char_count=4) const
Write JSON data into a stream.
CJson_Object ResetObject(void)
Erase node data and convert it into JSON object.
CJson_Array ResetArray(void)
Erase node data and convert it into JSON array.
CJson_Node & AssignCopy(const CJson_ConstNode &n)
Copy Node contents data into this node.
CJson_Node & SetNull(void)
Erase node data and convert it into JSON NULL value.
CJson_Value SetValue(void)
Get JSON value contents of the node.
void insert(const CJson_Node::TKeyType &name)
Insert null element into the object.
CJson_Object insert_object(const CJson_Node::TKeyType &name)
Insert object type element into the object.
bool Validate(const CJson_Document &v)
Validate JSON document against schema.
std::string GetValidationError() const
Return validation error.
Bio-id (such as accession)
const string & GetId() const
Get ID.
TType GetType() const
Get type.
const string & GetId() const
Get ID.
const TLastModified & GetLastModified() const
Get last modified.
CNullable< Int8 > TLastModified
const string & GetId2Info() const
Get ID2 info.
int GetId2Chunk() const
Get ID2 chunk number.
A class derived from the queue class that additionally allows to run event loop.
bool Run(CDeadline deadline)
Process everything in the queue until it's empty or times out.
A queue to retrieve data (accession resolution info; bio-sequence; annotation blobs) from the storage...
bool SendRequest(shared_ptr< CPSG_Request > request, CDeadline deadline)
Push request into the queue.
shared_ptr< CPSG_Reply > SendRequestAndGetReply(shared_ptr< CPSG_Request > request, CDeadline deadline)
Push request into the queue and get corresponding reply.
void Stop()
Stop accepting new requests.
@ eEndOfReply
No more items expected in the (overall!) reply.
@ eSmartTSE
If ID2 split is available, return split info blob only.
@ eSlimTSE
If ID2 split is available, return split info blob only.
@ eWholeTSE
If ID2 split is available, return all split blobs.
@ eOrigTSE
Return all Cassandra data chunks of the blob itself.
CNullable< string > TNucleotide
vector< string > TAnnotNames
Names of the named annotations.
@ fName
Requests name to use for canonical bio-id.
CParallelProcessing(const TParams ¶ms)
list< SThread > m_Threads
list< CPSG_EventLoop > m_PsgQueues
static vector< shared_ptr< CPSG_Request > > ReadCommands(TCreateContext create_context, size_t report_progress_after=0)
static int JsonCheck(istream *schema_is)
static int OneRequest(const SOneRequestParams ¶ms, shared_ptr< CPSG_Request > request)
static CParallelProcessing< SBatchResolveParams > CreateParallelProcessing(const SBatchResolveParams ¶ms)
static CJson_Document RequestSchema()
static bool ReadLine(string &line, istream &is=cin)
static int Performance(const SPerformanceParams ¶ms)
Take guard of the current CRequestContext, handle app-state, start/stop logging and request status in...
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
CZipStreamDecompressor – zlib based decompression stream processor.
void Print(const CCompactSAMApplication::AlignInfo &ai)
static const struct name_t names[]
std::ofstream out("events_result.xml")
main entry point for tests
#define TAX_ID_TO(T, tax_id)
@ eTakeOwnership
An object can take ownership of another.
#define NCBI_ALWAYS_TROUBLE(mess)
#define _DEBUG_CODE(code)
CDiagContext_Extra & Print(const string &name, const string &value)
The method does not print the argument, but adds it to the string.
CDiagContext & GetDiagContext(void)
Get diag context instance.
static void SetRequestContext(CRequestContext *ctx)
Shortcut to CDiagContextThreadData::GetThreadData().SetRequestContext()
void SetRequestID(TCount rid)
Set request ID.
static CRequestContext & GetRequestContext(void)
Shortcut to CDiagContextThreadData::GetThreadData().GetRequestContext()
void SetStatus(int status)
Set request context status.
@ e499_BrokenConnection
Non-standard status code - used to indicate broken connection while serving normal request.
@ e500_InternalServerError
string ReportThis(TDiagPostFlags flags=eDPF_Exception) const
Report this exception only.
#define ENUM_METHOD_NAME(EnumName)
ESerialDataFormat
Data file format.
@ eSerial_AsnText
ASN.1 text.
@ eSerial_AsnBinary
ASN.1 binary.
static CObjectOStream * Open(ESerialDataFormat format, CNcbiOstream &outStream, bool deleteOutStream)
Create serial object writer and attach it to an output stream.
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
void Copy(const CObjectTypeInfo &type)
Copy data.
int64_t Int8
8-byte (64-bit) signed 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.
static string Base64Encode(const CTempString str, size_t line_len=0)
Base64-encode string.
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
static string Base64Decode(const CTempString str)
Base64-decode string.
@ eNoWait
No-wait, expires immediately.
@ eInfinite
Infinite deadline.
unsigned int
A callback function used to compare two keys in a database.
constexpr auto sort(_Init &&init)
constexpr bool empty(list< Ts... >) noexcept
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static const char * prefix[]
string ReadLine(CNcbiIstream &in)
static SQLCHAR output[256]
void s_ItemComplete< SInteractiveParams >(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_ReplyItem > &item)
void s_ItemComplete(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_ReplyItem > &item)
CRequestStatus::ECode s_PsgStatusToRequestStatus(EPSG_Status psg_status)
@ eJsonRpc_InvalidRequest
@ eJsonRpc_ExceptionOnRead
const char * s_StrStatus(EPSG_Status status)
false_type no_server_mode
string s_ProgressStatusToString(CPSG_Processor::EProgressStatus progress_status)
string s_GetId(const CJson_Document &req_doc)
auto s_IsRawResponse(const CPSG_BlobId *blob_id)
void s_ReplyComplete< SOneRequestParams >(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_Reply > &reply)
shared_ptr< CPSG_Reply > s_GetReply(shared_ptr< CPSG_ReplyItem > &item)
void s_NewItem(SJsonOut &, const shared_ptr< CPSG_ReplyItem > &)
void s_ReplyComplete< SInteractiveParams, testing, server_mode >(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_Reply > &reply)
const initializer_list< SInfoFlag > kInfoFlags
void s_ReplyComplete(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_Reply > &reply)
void s_NewItem< SInteractiveParams, verbose >(SJsonOut &json_out, const shared_ptr< CPSG_ReplyItem > &item)
const initializer_list< SDataFlag > kDataFlags
void s_ReplyComplete< SInteractiveParams, testing, no_server_mode >(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_Reply > &reply)
ESerialDataFormat s_GetInputFormat(const string &format)
void s_ReplyComplete< no_verbose >(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_Reply > &reply)
void s_ReplyComplete< SInteractiveParams, no_testing, no_server_mode >(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_Reply > &reply)
TTypeInfo s_GetInputType(const shared_ptr< CPSG_BlobData > &blob_data)
auto s_IsRawRequest(shared_ptr< const CPSG_Request > &request)
void s_ItemComplete< no_verbose >(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_ReplyItem > &item)
const char * s_GetItemName(CPSG_ReplyItem::EType type, bool trouble=true)
string s_ReasonToString(CPSG_SkippedBlob::EReason reason)
void s_ReplyComplete< SInteractiveParams, no_testing, server_mode >(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_Reply > &reply)
void s_NewItem< SOneRequestParams >(SJsonOut &json_out, const shared_ptr< CPSG_ReplyItem > &reply_item)
EPSG_Status
Retrieval result.
@ eSuccess
Successfully retrieved.
@ eInProgress
Retrieval is not finalized yet, more info may come.
@ eForbidden
User is not authorized for the retrieval.
@ eCanceled
Request canceled.
@ eError
An error was encountered while trying to send request or to read and to process the reply.
vector< CPSG_BioId > CPSG_BioIds
static const char * schema
SImpl(const TParams ¶ms)
void(*)(SJsonOut &, EPSG_Status, const shared_ptr< CPSG_ReplyItem > &) TItemComplete
void(*)(SJsonOut &, EPSG_Status, const shared_ptr< CPSG_Reply > &) TReplyComplete
void Init(const TParams ¶ms)
TReplyComplete GetReplyComplete()
TItemComplete GetItemComplete()
void Submitter(CPSG_Queue &output)
void(*)(SJsonOut &, const shared_ptr< CPSG_ReplyItem > &) TNewItem
bool ReportErrors(EPSG_Status status, TItem item, const char *prefix)
unordered_map< string, pair< shared_ptr< CPSG_BlobInfo >, shared_ptr< CPSG_BlobData > > > m_Data
SDataOnlyCopy(const SOneRequestParams::SDataOnly ¶ms)
const SOneRequestParams::SDataOnly & m_Params
void ItemComplete(EPSG_Status status, const shared_ptr< CPSG_ReplyItem > &item)
void ReplyComplete(EPSG_Status status, const shared_ptr< CPSG_Reply > &reply)
void Process(shared_ptr< CPSG_BlobInfo > blob_info)
SInteractiveNewRequestStart(const string &request, CJson_ConstObject params_obj)
const size_t preview_size
static string GetService(string service, bool one_server)
const TJson_Write_Flags m_Flags
SJsonOut & operator<<(const CJson_Document &doc)
static const char * Name(EType t)
void OutputItems(ostream &os) const
SNewRequestContext(const SNewRequestContext &)=delete
CRef< CRequestContext > Get() const
void operator=(const SNewRequestContext &)=delete
CRef< CRequestContext > m_RequestContext
SNonVerboseBase(string id)
set< EPSG_Status > reported
static void ReplyComplete(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_Reply > &reply)
static void ItemComplete(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_ReplyItem > &item)
void ReplyComplete(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_Reply > &reply)
map< CPSG_ReplyItem::EType, shared_ptr< CPSG_ReplyItem > > m_Items
void ItemComplete(SJsonOut &json_out, EPSG_Status status, const shared_ptr< CPSG_ReplyItem > &item)
const ESerialDataFormat output_format
const CLogLatencies::EWhich which
static void SetDefault(const T &value)
const SPSG_UserArgs user_args
const CPSG_Request::TFlags request_flags
static CPSG_Request_Resolve::TIncludeInfo GetIncludeInfo(TSpecified specified)
static CPSG_BioId::TType GetBioIdType(const string &type)
function< void(string)> TExclude
static shared_ptr< TRequest > Build(const TInput &input, TArgs &&... args)
static const initializer_list< SInfoFlag > & GetInfoFlags()
static const initializer_list< SDataFlag > & GetDataFlags()
function< bool(const string &)> TSpecified