NCBI C++ ToolKit
wgs_processor.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef WGS_PROCESSOR__HPP
2 #define WGS_PROCESSOR__HPP
3 
4 /* $Id: wgs_processor.hpp 99364 2023-03-16 15:59:23Z vasilche $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Aleksey Grichenko, Eugene Vasilchenko
30  *
31  * File Description: processor for data from WGS
32  *
33  */
34 
35 #include "ipsgs_processor.hpp"
36 #include "psgs_request.hpp"
37 #include "psgs_reply.hpp"
38 #include "timing.hpp"
40 
41 
43 
44 class CThreadPool;
45 
47 class CID2_Blob_Id;
48 class CID2_Reply_Data;
49 class CWGSResolver;
50 class CSeq_id;
51 class CAsnBinData;
53 
56 
57 
58 class CWGSClient;
60 struct SWGSData;
61 
62 const string kWGSProcessorEvent = "WGS";
63 
65 {
66 public:
67  CPSGS_WGSProcessor(void);
68  ~CPSGS_WGSProcessor(void) override;
69 
70  virtual bool CanProcess(shared_ptr<CPSGS_Request> request,
71  shared_ptr<CPSGS_Reply> reply) const override;
72  IPSGS_Processor* CreateProcessor(shared_ptr<CPSGS_Request> request,
73  shared_ptr<CPSGS_Reply> reply,
74  TProcessorPriority priority) const override;
75 
76  void Process(void) override;
77  void Cancel(void) override;
78  EPSGS_Status GetStatus(void) override;
79  string GetName(void) const override;
80  string GetGroupName(void) const override;
81 
82  void ResolveSeqId(void);
83  void OnResolvedSeqId(void);
84 
85  void GetBlobBySeqId(void);
86  void OnGotBlobBySeqId(void);
87 
88  void GetBlobByBlobId(void);
89  void OnGotBlobByBlobId(void);
90 
91  void GetChunk(void);
92  void OnGotChunk(void);
93 
94 private:
95  CPSGS_WGSProcessor(const shared_ptr<CWGSClient>& client,
96  shared_ptr<ncbi::CThreadPool> thread_pool,
97  shared_ptr<CPSGS_Request> request,
98  shared_ptr<CPSGS_Reply> reply,
99  TProcessorPriority priority);
100 
101  void x_LoadConfig(void);
102  bool x_IsEnabled(CPSGS_Request& request) const;
103  void x_InitClient(void) const;
104 
105  void x_ProcessResolveRequest(void);
106  void x_ProcessBlobBySeqIdRequest(void);
108  void x_ProcessTSEChunkRequest(void);
109 
112  typedef int TID2ChunkId;
113  typedef vector<string> TBlobIds;
114 
117  EPSGOperationStatus status,
118  size_t blob_size);
121  const objects::CID2_Reply_Data& data);
124  void x_SendResult(const string& data_to_send, EOutputFormat output_format);
125  void x_SendBioseqInfo(void);
126  void x_SendBlobProps(const string& psg_blob_id, CBlobRecord& blob_props);
127  void x_SendBlobForbidden(const string& psg_blob_id);
128  void x_SendBlobData(const string& psg_blob_id, const objects::CID2_Reply_Data& data);
129  void x_SendChunkBlobProps(const string& id2_info,
130  TID2ChunkId chunk_id,
131  CBlobRecord& blob_props);
132  void x_SendChunkBlobData(const string& id2_info,
133  TID2ChunkId chunk_id,
134  const objects::CID2_Reply_Data& data);
135  void x_SendSplitInfo(void);
136  void x_SendMainEntry(void);
137  void x_SendExcluded(void);
138  void x_SendForbidden(void);
139  void x_SendBlob(void);
140  void x_SendChunk(void);
141  void x_WriteData(objects::CID2_Reply_Data& data,
142  const objects::CAsnBinData& obj,
143  bool compress) const;
144 
145  static void x_SendError(shared_ptr<CPSGS_Reply> reply,
146  const string& msg);
147  static void x_SendError(shared_ptr<CPSGS_Reply> reply,
148  const string& msg, const exception& exc);
149  void x_SendError(const string& msg);
150  void x_SendError(const string& msg, const exception& exc);
151 
152  template<class C> static int x_GetBlobState(const C& obj) {
153  return obj.IsSetBlob_state() ? obj.GetBlob_state() : 0;
154  }
155 
156  void x_UnlockRequest(void);
157  void x_WaitForOtherProcessors(void);
158  void x_Finish(EPSGS_Status status);
159  bool x_IsCanceled();
161 
163  shared_ptr<SWGSProcessor_Config> m_Config;
164  mutable shared_ptr<CWGSClient> m_Client;
168  CRef<objects::CSeq_id> m_SeqId; // requested seq-id
169  string m_PSGBlobId; // requested blob-id
170  string m_Id2Info; // requested id2-info
171  int64_t m_ChunkId; // requested chunk-id
173  shared_ptr<SWGSData> m_WGSData;
177  shared_ptr<ncbi::CThreadPool> m_ThreadPool;
178 };
179 
180 
184 
185 #endif // CDD_PROCESSOR__HPP
CFastMutex –.
Definition: ncbimtx.hpp:667
CID2_Blob_Id –.
Definition: ID2_Blob_Id.hpp:66
void x_SendResult(const string &data_to_send, EOutputFormat output_format)
void x_SendChunkBlobData(const string &id2_info, TID2ChunkId chunk_id, const objects::CID2_Reply_Data &data)
void x_ProcessBlobBySatSatKeyRequest(void)
void OnGotBlobBySeqId(void)
void GetBlobBySeqId(void)
void x_ProcessResolveRequest(void)
vector< string > TBlobIds
void x_InitClient(void) const
static void x_SendError(shared_ptr< CPSGS_Reply > reply, const string &msg)
void x_SendBlobProps(const string &psg_blob_id, CBlobRecord &blob_props)
EPSGS_Status GetStatus(void) override
Tells the processor status (if it has finished or in progress)
EOutputFormat x_GetOutputFormat(void)
string GetName(void) const override
Tells the processor name (used in logging and tracing)
void Process(void) override
Main processing function.
void x_ProcessTSEChunkRequest(void)
void x_Finish(EPSGS_Status status)
string GetGroupName(void) const override
Tells the processor group name.
void x_SendBlobData(const string &psg_blob_id, const objects::CID2_Reply_Data &data)
CRef< objects::CSeq_id > m_SeqId
void x_WriteData(objects::CID2_Reply_Data &data, const objects::CAsnBinData &obj, bool compress) const
void OnGotBlobByBlobId(void)
void x_UnlockRequest(void)
virtual bool CanProcess(shared_ptr< CPSGS_Request > request, shared_ptr< CPSGS_Reply > reply) const override
Tells if processor can process the given request.
SPSGS_ResolveRequest::EPSGS_OutputFormat EOutputFormat
static int x_GetBlobState(const C &obj)
SPSGS_ResolveRequest::TPSGS_BioseqIncludeData TBioseqInfoFlags
shared_ptr< CWGSClient > m_Client
void x_RegisterTimingNotFound(EPSGOperation operation)
shared_ptr< ncbi::CThreadPool > m_ThreadPool
void OnResolvedSeqId(void)
shared_ptr< SWGSData > m_WGSData
void GetBlobByBlobId(void)
void x_ProcessBlobBySeqIdRequest(void)
void x_SendSplitInfo(void)
void x_SendForbidden(void)
psg_time_point_t m_Start
~CPSGS_WGSProcessor(void) override
IPSGS_Processor * CreateProcessor(shared_ptr< CPSGS_Request > request, shared_ptr< CPSGS_Reply > reply, TProcessorPriority priority) const override
Create processor to fulfil PSG request using the data source.
void x_SendBlobForbidden(const string &psg_blob_id)
void Cancel(void) override
The infrastructure request to cancel processing.
void x_SendExcluded(void)
void x_RegisterTiming(psg_time_point_t start, EPSGOperation operation, EPSGOperationStatus status, size_t blob_size)
void x_WaitForOtherProcessors(void)
void x_SendChunkBlobProps(const string &id2_info, TID2ChunkId chunk_id, CBlobRecord &blob_props)
void x_SendMainEntry(void)
void x_SendBioseqInfo(void)
shared_ptr< SWGSProcessor_Config > m_Config
EOutputFormat m_OutputFormat
void x_RegisterTimingFound(psg_time_point_t start, EPSGOperation operation, const objects::CID2_Reply_Data &data)
bool x_IsEnabled(CPSGS_Request &request) const
EPSGS_Status m_Status
Main class implementing functionality of pool of threads.
Interface class (and self-factory) for request processor objects that can retrieve data from a given ...
EPSGS_Status
The GetStatus() method returns a processor current status.
#define C(s)
Definition: common.h:231
operation
Bit operations.
Definition: bmconst.h:191
int TProcessorPriority
psg_clock_t::time_point psg_time_point_t
static CNamedPipeClient * client
signed __int64 int64_t
Definition: stdint.h:135
EPSGOperationStatus
Definition: timing.hpp:60
EPSGOperation
Definition: timing.hpp:65
const string kWGSProcessorEvent
BEGIN_NAMESPACE(objects)
END_NCBI_NAMESPACE
END_NAMESPACE(objects)
BEGIN_NCBI_NAMESPACE
#define compress
Definition: zconf.h:37
Modified on Sun Feb 25 03:07:43 2024 by modify_doxy.py rev. 669887