NCBI C++ ToolKit
Public Types | Static Public Member Functions | Private Member Functions | List of all members
CSDBAPI Class Reference

Search Toolkit Book for CSDBAPI

#include <dbapi/simple/sdbapi.hpp>

Public Types

enum  EDriver { eDriver_FTDS100 , eDriver_FTDS14 }
 
enum  EMirrorStatus { eMirror_Steady , eMirror_NewMaster , eMirror_Unavailable }
 

Static Public Member Functions

static bool Init (void)
 Initialize SDBAPI. More...
 
static void SetApplicationName (const CTempString &name)
 Report the specified application name to servers. More...
 
static string GetApplicationName (void)
 Check SDBAPI's application name setting. More...
 
static void UseDriver (EDriver driver)
 Use the specified driver for all connections. More...
 
static EMirrorStatus UpdateMirror (const string &dbservice, list< string > *servers=NULL, string *error_message=NULL)
 Check for master/mirror switch. More...
 
static CBlobStoreDynamicNewBlobStore (const CSDB_ConnectionParam &param, const string &table_name, TNewBlobStoreFlags flags=TNewBlobStoreFlags(0), size_t image_limit=1<< 24)
 Get new CBlobStoreDynamic object (to be owned by caller). More...
 

Private Member Functions

 CSDBAPI (void)
 

Detailed Description

Definition at line 1135 of file sdbapi.hpp.

Member Enumeration Documentation

◆ EDriver

Enumerator
eDriver_FTDS100 
eDriver_FTDS14 

Definition at line 1158 of file sdbapi.hpp.

◆ EMirrorStatus

See also
UpdateMirror
Enumerator
eMirror_Steady 

Mirror is working on the same server as before.

eMirror_NewMaster 

Switched to a new master.

eMirror_Unavailable 

All databases in the mirror are unavailable.

Definition at line 1170 of file sdbapi.hpp.

Constructor & Destructor Documentation

◆ CSDBAPI()

CSDBAPI::CSDBAPI ( void  )
private

Member Function Documentation

◆ GetApplicationName()

string CSDBAPI::GetApplicationName ( void  )
static

Check SDBAPI's application name setting.

See also
SetApplicationName()

Definition at line 1360 of file sdbapi.cpp.

References IDataSource::GetApplicationName(), and s_GetDataSource().

◆ Init()

bool CSDBAPI::Init ( void  )
static

Initialize SDBAPI.

Creates minimum number of connections required for each pool configured in application's configuration file. If openning of some of those connections failed then method will return FALSE, otherwise TRUE.

Definition at line 1327 of file sdbapi.cpp.

References NStr::CompareCase(), ctx, IRegistry::EnumerateSections(), CNcbiApplicationAPI::GetConfig(), impl::CDBConnParamsBase::GetParam(), CNcbiApplication::Instance(), ITERATE, result, s_GetDBContext(), and CSDB_ConnectionParam::x_FillLowerParams().

◆ NewBlobStore()

CBlobStoreDynamic * CSDBAPI::NewBlobStore ( const CSDB_ConnectionParam param,
const string table_name,
TNewBlobStoreFlags  flags = TNewBlobStoreFlags(0),
size_t  image_limit = 1 << 24 
)
static

Get new CBlobStoreDynamic object (to be owned by caller).

Parameters
paramConnection parameters; only Service, Username, and Password apply here, though.
table_nameName of the table holding the blobs (structure to be deduced by inspection).
flagsFlags governing compression and transaction logging.
image_limitMaximum size of a single blob (to be split across columns as needed).

Definition at line 1726 of file sdbapi.cpp.

References CSDB_ConnectionParam::ePassword, ERR_POST_X_ONCE, CSDB_ConnectionParam::eService, CSDB_ConnectionParam::eUsername, flags, fNBS_IsText, CSDB_ConnectionParam::Get(), s_CheckCompressionFlags(), s_GetDBContext(), s_TranslateBlobStoreFlags(), table_name, and Warning().

◆ SetApplicationName()

void CSDBAPI::SetApplicationName ( const CTempString name)
static

Report the specified application name to servers.

By default, this will be the same name reported to AppLog (typically autodetected). Any changes will take effect for subsequent connections, but won't affect preexisting ones.

See also
GetApplicationName()

Definition at line 1355 of file sdbapi.cpp.

References s_GetDataSource(), and IDataSource::SetApplicationName().

◆ UpdateMirror()

CSDBAPI::EMirrorStatus CSDBAPI::UpdateMirror ( const string dbservice,
list< string > *  servers = NULL,
string error_message = NULL 
)
static

Check for master/mirror switch.

If switch is detected or if all databases in the mirror become unavailable, then all connections to the "old" master server will be immediately invalidated, so that any subsequent database operation on them (via objects CQuery and CBulkInsert) would cause an error. The affected CDatabase objects will be automatically invalidated too. User code will have to explicitly re-connect (which will open connection to the new master, if any).

Note
If the database resource is in any way misconfigured, then an exception will be thrown.
Parameters
dbserviceDatabase resource name
serversList of database servers, with the master one first.
error_messageDetailed error message (if any).
Returns
Result code

Definition at line 1480 of file sdbapi.cpp.

References impl::CDriverContext::CloseConnsForPool(), conn, SMirrorInfo::conn_params, IDataSource::CreateConnection(), ds_init, eConnEstablished, eConnInitializing, eConnNotConnected, eMirror_NewMaster, eMirror_Steady, eMirror_Unavailable, ERASE_ITERATE, eRetriable_No, ERR_POST_X, eTakeOwnership, AutoPtr< X, Del >::get(), CDbapiConnMgr::GetConnectionFactory(), impl::CDBConnParamsBase::GetDatabaseName(), impl::CDBConnParamsBase::GetParam(), CRef< C, Locker >::GetPointer(), impl::CDBConnParamsBase::GetServerName(), CDBConnectionFactory::GetServersList(), CDbapiConnMgr::Instance(), ITERATE, kEmptyStr, SMirrorInfo::master, NCBI_THROW, NStr::NumericToString(), AutoPtr< X, Del >::reset(), s_GetDataSource(), s_GetDBContext(), impl::CDriverContext::SatisfyPoolMinimum(), SMirrorInfo::servers, CDBConnParamsBase::SetParam(), CDBConnParamsBase::SetServerName(), state::state(), stmt, Warning(), CDBConnectionFactory::WorkWithSingleServer(), and CSDB_ConnectionParam::x_FillLowerParams().

◆ UseDriver()

void CSDBAPI::UseDriver ( EDriver  driver)
static

Use the specified driver for all connections.

Any call to this method must be the application's very first use of SDBAPI; calling it later is an error, and will result in throwing an exception.

Definition at line 1366 of file sdbapi.cpp.

References eDriver_FTDS100, eDriver_FTDS14, eRetriable_No, NCBI_THROW, NULL, s_DriverName, and strdup.


The documentation for this class was generated from the following files:
Modified on Wed Sep 04 15:02:04 2024 by modify_doxy.py rev. 669887