73 #define NCBI_USE_ERRCODE_X Objtools_Reader_Id2
78 #define DEFAULT_SERVICE "ID2"
79 #define DEFAULT_NUM_CONN 3
80 #define MAX_MT_CONN 256
83 #define GENBANK_ID2_RANDOM_FAILS_FREQUENCY 20
84 #define GENBANK_ID2_RANDOM_FAILS_RECOVER 10
86 #ifdef GENBANK_ID2_RANDOM_FAILS
98 static int fail_counter = 0;
111 stream.setstate(ios::badbit);
115 # define SetRandomFail(stream, conn) do{}while(0)
138 const string& driver_name)
146 if ( service_name.empty() ) {
149 if ( service_name.empty() ) {
150 service_name =
NCBI_PARAM_TYPE(GENBANK,ID2_SERVICE_NAME)::GetDefault();
152 if ( service_name.empty() ) {
198 s <<
"Closing ID2 connection";
203 s <<
"Closed ID2 connection";
252 if ( stream.bad() ) {
267 "connection initialization failed: "+
271 if ( stream.bad() ) {
273 "connection initialization failed: "+
289 #define MConnFormat MSerial_AsnBinary
299 packet.
Set().push_back(
Ref(&req));
312 s <<
" ID2-Request-Packet";
321 "failed to send init request: "+
326 s <<
"Sent ID2-Request-Packet.";
330 "failed to send init request: "+
340 s <<
"Receiving ID2-Reply...";
355 "failed to receive init reply: "+
363 "bad init reply: 'discard' is set: "+
368 "bad init reply: 'error' is set: "+
373 "bad init reply: 'end-of-reply' is not set: "+
378 "bad init reply: 'reply' is not 'init': "+
401 "failed to receive reply: "+
443 objects::CReader* drv = 0;
449 drv =
new objects::CId2Reader(params, driver);
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
Base class, inherited from "std::iostream", does both input and output, using the specified CONNECTOR...
virtual void x_ReceiveReply(TConn conn, CID2_Reply &reply)=0
void x_SetContextData(CID2_Request &request)
static int GetDebugLevel(void)
Class factory for ID2 reader.
objects::CReader * CreateInstance(const string &driver=kEmptyStr, CVersionInfo version=NCBI_INTERFACE_VERSION(objects::CReader), const TPluginManagerParamTree *params=0) const
Create instance of TDriver.
CSimpleClassFactoryImpl< objects::CReader, objects::CId2Reader > TParent
virtual void x_DisconnectAtSlot(TConn conn, bool failed)
CConn_IOStream * x_GetCurrentConnection(TConn conn) const
virtual void x_AddConnectionSlot(TConn conn)
virtual void x_RemoveConnectionSlot(TConn conn)
virtual void x_SendPacket(TConn conn, const CID2_Request_Packet &packet)
void x_InitConnection(CConn_IOStream &stream, TConn conn)
CReaderServiceConnector m_Connector
CId2Reader(int max_connections=0)
int GetMaximumConnectionsLimit(void) const
TConnections m_Connections
virtual void x_ReceiveReply(TConn conn, CID2_Reply &reply)
virtual void x_ConnectAtSlot(TConn conn)
virtual string x_ConnDescription(TConn conn) const
CConn_IOStream * x_GetConnection(TConn conn)
Data loader exceptions, used by GenBank loader.
CObjectIStreamAsnBinary –.
void RememberIfBad(SConnInfo &conn_info)
void SetTimeoutTo(STimeout *tmout) const
void InitTimeouts(CConfig &conf, const string &driver_name)
SConnInfo Connect(int error_count=0)
string GetConnDescription(CConn_IOStream &stream) const
const string & GetServiceName(void) const
void SetServiceName(const string &service_name)
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)
int SetMaximumConnections(int max)
Template class helps to implement one driver class factory.
definition of a Culling tree
container_type::const_iterator const_iterator
const_iterator end() const
const_iterator find(const key_type &key) const
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.
EIO_Status CONN_SetTimeout(CONN conn, EIO_Event event, const STimeout *timeout)
Specify timeout for the connection I/O, including "Connect" (aka "Open") and "Close".
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define NCBI_RETHROW(prev_exception, exception_class, err_code, message)
Generic macro to re-throw an exception.
#define MSerial_AsnText
I/O stream manipulators –.
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 ...
@ eErr_NoThrow
Return default value on error.
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
@ eParam_NoThread
Do not use per-thread values.
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.
IO_PREFIX::iostream CNcbiIostream
Portable alias for iostream.
void SetValue(TValue *value, FCleanup cleanup=0, void *cleanup_data=0, CTlsBase::ENativeThreadCleanup native=CTlsBase::eSkipCleanup)
unsigned int usec
microseconds (modulo 1,000,000)
@ eIO_ReadWrite
eIO_Read | eIO_Write (also, eCONN_OnFlush)
@ eIO_Close
also serves as an error indicator in SOCK_Poll
@ 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...
unsigned int
A callback function used to compare two keys in a database.
const string version
version string
const GenericPointer< typename T::ValueType > T2 value
Parameters initialization model.
Multi-threading – mutexes; rw-locks; semaphore.
std::istream & in(std::istream &in_, double &x_)
Helper classes and templates to implement plugins.
#define GENBANK_ID2_RANDOM_FAILS_RECOVER
NCBI_PARAM_DECL(string, GENBANK, ID2_CGI_NAME)
#define GENBANK_ID2_RANDOM_FAILS_FREQUENCY
NCBI_PARAM_DEF_EX(string, GENBANK, ID2_CGI_NAME, "", eParam_NoThread, GENBANK_ID2_CGI_NAME)
#define SetRandomFail(stream, conn)
void NCBI_EntryPoint_Id2Reader(CPluginManager< objects::CReader >::TDriverInfoList &info_list, CPluginManager< objects::CReader >::EEntryPointRequest method)
void GenBankReaders_Register_Id2(void)
void NCBI_EntryPoint_xreader_id2(CPluginManager< objects::CReader >::TDriverInfoList &info_list, CPluginManager< objects::CReader >::EEntryPointRequest method)
#define NCBI_GBLOADER_READER_ID2_PARAM_SERVICE_NAME
#define NCBI_GBLOADER_READER_ID2_DRIVER_NAME
AutoPtr< CConn_IOStream > m_Stream