65 #define BINARY_REQUESTS 1
66 #define LONG_REQUESTS 1
70 #define CRequestSerializer CObjectOStreamAsnBinary
73 #define CRequestSerializer CObjectOStreamAsn
76 # define MAX_ASN_IN (20*1024)
78 # define MAX_ASN_IN 255
81 #define DEFAULT_DB_SERVER "PUBSEQ_OS_PUBLIC_GI64"
82 #define DEFAULT_DB_USER "anyone"
83 #define DEFAULT_DB_PASSWORD "allowed"
84 #define DEFAULT_DB_DRIVER "ftds;ctlib"
85 #define DEFAULT_NUM_CONN 2
86 #define MAX_MT_CONN 256
87 #define DEFAULT_EXCL_WGS_MASTER false
88 #define DEFAULT_TIMEOUT 40
89 #define DEFAULT_OPEN_TIMEOUT 20
91 #define NCBI_USE_ERRCODE_X Objtools_Rd_Pubseq2
101 const string& dbapi_driver)
102 : m_Server(server) , m_User(user), m_Password(pswd),
103 m_DbapiDriver(dbapi_driver),
106 m_SetCubbyUser(
false)
108 if ( m_Server.empty() ) {
111 if ( m_User.empty() ) {
114 if ( m_Password.empty() ) {
117 if ( m_DbapiDriver.empty() ) {
126 const string& driver_name)
129 m_SetCubbyUser(
false)
190 #if defined(NCBI_THREADS)
250 "CPubseq2Reader: no active command");
252 return *iter->second.m_Result;
263 "CPubseq2Reader: no active connection");
265 iter->second.m_Result =
result;
277 bool excl_wgs_master)
280 m_ExclWGSMaster(excl_wgs_master)
285 if ( m_ExclWGSMaster ) {
287 (
conn.LangCmd(
"set exclude_wgs_master on"));
291 m_Reader->x_InitConnection(
conn, m_Conn);
295 virtual string GetName(
void)
const {
296 return "CPubseq2Validator";
302 bool m_ExclWGSMaster;
307 while (
result.Fetch() ) {
308 for (
unsigned pos = 0; pos <
result.NofItems(); ++pos ) {
309 if (
result.ItemName(pos) == name ) {
340 m_DB_RPCCmd->DumpResults();
362 static const char* kEMyNCBIURL =
363 "https://www.ncbi.nlm.nih.gov/entrez/eutils/emyncbi.cgi?cmd=whoami&WebCubbyUser=";
365 if (!web_cookie.empty()) {
367 int response_timeout = 40;
369 session.
Get(
CUrl(kEMyNCBIURL + web_cookie),
CTimeout(response_timeout), 0);
376 if (
result.GetUE().IsUU() &&
result.GetUE().GetUU().IsSetUserName())
377 cubby_user =
result.GetUE().GetUU().GetUserName();
385 if (cubby_user.empty())
402 args[
"packet"]=
"3584";
403 args[
"version"]=
"125";
404 vector<string> driver_list;
406 size_t driver_count = driver_list.size();
407 vector<string> errmsg(driver_count);
408 for (
size_t i = 0;
i < driver_count; ++
i ) {
417 errmsg[
i] = exc.
what();
421 for (
size_t i = 0;
i < driver_count; ++
i ) {
422 ERR_POST_X(2,
"Failed to create dbapi context with driver '"
423 <<driver_list[
i]<<
"': "<<errmsg[
i]);
426 "Cannot create dbapi context with driver '"+
456 NcbiCout <<
"CPubseq2Reader::Connected to " <<
conn->ServerName()
471 packet.
Set().push_back(
Ref(&req));
489 s <<
" ID2-Request-Packet";
498 "failed to send init request");
502 s <<
"Sent ID2-Request-Packet.";
511 s <<
"Receiving ID2-Reply...";
529 "bad init reply: 'discard' is set");
533 "bad init reply: 'error' is set");
537 "bad init reply: 'end-of-reply' is not set");
541 "bad init reply: 'reply' is not 'init'");
543 if (
result->HaveMoreData() ) {
574 ERR_POST_X(4,
"CPubseq2Reader: extra blob data");
597 "CPubseq2Reader: packet size overflow");
599 size = mem_str.pcount();
614 cmd->SetParam(
"@service", &service);
615 cmd->SetParam(
"@asnin", &short_asn);
616 cmd->SetParam(
"@text", &text_in);
617 cmd->SetParam(
"@out_text", &text_out);
618 cmd->SetParam(
"@asnin_long", &long_asn);
622 while(
cmd->HasMoreResults() ) {
623 if (
cmd->HasFailed() ) {
625 "CPubseq2Reader: failed RPC");
633 while ( dbr->
Fetch() )
637 if ( sx_FetchNextItem(*dbr,
"asnout") ) {
648 "CPubseq2Reader: no more results");
653 const string& web_cookie)
678 objects::CPubseq2Reader>
695 objects::CReader* drv = 0;
701 drv =
new objects::CPubseq2Reader(params, driver);
User-defined methods of the data storage class.
ERW_Result PendingCount(size_t *)
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
ERW_Result Read(void *buf, size_t count, size_t *bytes_read)
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
CDB_Result_Reader(CDB_Result *db_result)
virtual void x_ReceiveReply(TConn conn, CID2_Reply &reply)=0
void x_SetContextData(CID2_Request &request)
void x_DisableProcessors()
static int GetDebugLevel(void)
Data loader exceptions, used by GenBank loader.
CObjectIStreamAsnBinary –.
Class factory for Pubseq reader.
CSimpleClassFactoryImpl< objects::CReader, objects::CPubseq2Reader > TParent
objects::CReader * CreateInstance(const string &driver=kEmptyStr, CVersionInfo version=NCBI_INTERFACE_VERSION(objects::CReader), const TPluginManagerParamTree *params=0) const
Create instance of TDriver.
virtual void x_ReceiveReply(TConn conn, CID2_Reply &reply) override
virtual void x_AddConnectionSlot(TConn conn) override
virtual void x_RemoveConnectionSlot(TConn conn) override
void x_InitConnection(CDB_Connection &db_conn, TConn conn)
CPubseq2Reader(int max_connections=0, const string &server=kEmptyStr, const string &user=kEmptyStr, const string &pswd=kEmptyStr, const string &dbapi_driver=kEmptyStr)
virtual void SetIncludeHUP(bool include_hup=true, const string &web_cookie=NcbiEmptyString) override
void x_SetCurrentResult(TConn conn, AutoPtr< CObjectIStream > result)
TConnections m_Connections
atomic< I_DriverContext * > m_Context
virtual string x_ConnDescription(TConn conn) const override
virtual void x_DisconnectAtSlot(TConn conn, bool failed) override
virtual void x_EndOfPacket(TConn conn) override
CObjectIStream & x_GetCurrentResult(TConn conn)
virtual int GetMaximumConnectionsLimit(void) const override
CDB_Connection & x_GetConnection(TConn conn)
virtual void x_ConnectAtSlot(TConn conn) override
virtual void x_SendPacket(TConn conn, const CID2_Request_Packet &packet) override
virtual ~CPubseq2Reader() override
Note about the "buf_size" parameter for streams in this API.
void x_SetIncludeHUP(bool include_hup)
void x_ReportDisconnect(const char *reader, const char *server, TConn conn, bool failed) const
virtual void OpenConnection(TConn conn)
void InitParams(CConfig &conf, const string &driver_name, int default_max_conn)
Template class helps to implement one driver class factory.
static string GetUserName(void)
Get actual user name for the current process.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CTimeout – Timeout interval.
definition of a Culling tree
A very basic data-read interface.
container_type::iterator iterator
const_iterator end() const
const_iterator find(const key_type &key) const
#define DBLB_INSTALL_DEFAULT()
Easy-to-use macro to install the default DBAPI service mapper.
static CS_CONNECTION * conn
void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)
Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...
element_type * get(void) const
Get pointer.
element_type * release(void)
Release will release ownership of pointer to caller.
@ eTakeOwnership
An object can take ownership of another.
I_DriverContext * GetDriverContext(const string &driver_name, string *err_msg=0, const map< string, string > *attr=0)
virtual EDB_ResType ResultType() const
Get type of the result.
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)
Read a result item body (for BLOB columns, mostly).
virtual CDB_RPCCmd * RPC(const string &rpc_name)
Make remote procedure call command.
virtual void SetTimeout(size_t nof_secs)
Set connection timeout.
virtual bool Fetch()
Fetch next row.
void SetValue(const void *v, size_t v_size)
CDB_VarChar & SetValue(const string &s, EEncoding enc=eEncoding_Unknown)
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Warning(CExceptionArgs_Base &args)
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
#define NCBI_RETHROW(prev_exception, exception_class, err_code, message)
Generic macro to re-throw an exception.
#define MSerial_AsnText
I/O stream manipulators –.
CHttpResponse Get(const CUrl &url, const CTimeout &timeout=CTimeout(CTimeout::eDefault), THttpRetries retries=null)
Shortcut for GET requests.
CNcbiIstream & ContentStream(void) const
Get input stream.
int GetStatusCode(void) const
Get response status code.
int GetInt(const string &driver_name, const string ¶m_name, EErrAction on_error, int default_value, const list< string > *synonyms=NULL)
Utility function to get an integer element of parameter tree Throws an exception when mandatory param...
string GetString(const string &driver_name, const string ¶m_name, EErrAction on_error, const string &default_value, const list< string > *synonyms=NULL)
Utility function to get an element of parameter tree Throws an exception when mandatory parameter is ...
bool GetBool(const string &driver_name, const string ¶m_name, EErrAction on_error, bool default_value, const list< string > *synonyms=NULL)
Utility function to get an integer element of parameter tree Throws an exception when mandatory param...
@ eErr_NoThrow
Return default value on error.
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
static void NCBI_EntryPointImpl(TDriverInfoList &info_list, EEntryPointRequest method)
Entry point implementation.
#define NCBI_INTERFACE_VERSION(iface)
Macro to construct CVersionInfo class using interface name (relies on CInterfaceVersion class)
list< SDriverInfo > TDriverInfoList
List of driver information.
EEntryPointRequest
Actions performed by the entry point.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
ERW_Result
Result codes for I/O operations.
@ eRW_NotImplemented
Action / information is not available.
@ eRW_Eof
End of data, should be considered permanent.
@ eRW_Success
Everything is okay, I/O completed.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static CStringUTF8 SQLEncode(const CStringUTF8 &str, ESqlEncode flag)
SQL-encode string.
@ eSqlEnc_TagNonASCII
Produce N'...' when input's not pure ASCII.
#define DEFINE_STATIC_FAST_MUTEX(id)
Define static fast mutex and initialize it.
@ eNonCompatible
major, minor does not match
E_Choice Which(void) const
Which variant is currently selected.
bool IsSetDiscard(void) const
Check if a value has been assigned to Discard data member.
const TReply & GetReply(void) const
Get the Reply member data.
Tdata & Set(void)
Assign a value to data member.
bool IsSetError(void) const
Check if a value has been assigned to Error data member.
void SetRequest(TRequest &value)
Assign a value to Request data member.
bool IsSetEnd_of_reply(void) const
true if this reply is the last one for the request false if more replies will follow Check if a value...
const string version
version string
const struct ncbi::grid::netcache::search::fields::SIZE size
Helper classes and templates to implement plugins.
#define DEFAULT_DB_PASSWORD
#define DEFAULT_DB_DRIVER
void GenBankReaders_Register_Pubseq2(void)
void NCBI_EntryPoint_xreader_pubseqos2(CPluginManager< objects::CReader >::TDriverInfoList &info_list, CPluginManager< objects::CReader >::EEntryPointRequest method)
#define DEFAULT_EXCL_WGS_MASTER
#define DEFAULT_DB_SERVER
void NCBI_EntryPoint_ReaderPubseqos2(CPluginManager< objects::CReader >::TDriverInfoList &info_list, CPluginManager< objects::CReader >::EEntryPointRequest method)
#define CRequestSerializer
#define DEFAULT_OPEN_TIMEOUT
static string s_GetCubbyUserName(const string &web_cookie)
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_OPEN_TIMEOUT
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_EXCL_WGS_MASTER
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_SERVER
#define NCBI_GBLOADER_READER_PUBSEQ2_DRIVER_NAME
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_DRIVER
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_TIMEOUT
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_PASSWORD
#define NCBI_GBLOADER_READER_PUBSEQ2_PARAM_USER
Reader-writer based streams.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
AutoPtr< CDB_Connection > m_Connection
AutoPtr< CObjectIStream > m_Result
static CS_CONTEXT * context