NCBI C++ ToolKit
|
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 CBlobStoreDynamic * | NewBlobStore (const CSDB_ConnectionParam ¶m, 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) | |
Definition at line 1135 of file sdbapi.hpp.
enum CSDBAPI::EDriver |
Enumerator | |
---|---|
eDriver_FTDS100 | |
eDriver_FTDS14 |
Definition at line 1158 of file sdbapi.hpp.
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.
|
private |
|
static |
Check SDBAPI's application name setting.
Definition at line 1360 of file sdbapi.cpp.
References IDataSource::GetApplicationName(), and s_GetDataSource().
|
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().
|
static |
Get new CBlobStoreDynamic object (to be owned by caller).
param | Connection parameters; only Service, Username, and Password apply here, though. |
table_name | Name of the table holding the blobs (structure to be deduced by inspection). |
flags | Flags governing compression and transaction logging. |
image_limit | Maximum 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().
|
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.
Definition at line 1355 of file sdbapi.cpp.
References s_GetDataSource(), and IDataSource::SetApplicationName().
|
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).
dbservice | Database resource name |
servers | List of database servers, with the master one first. |
error_message | Detailed error message (if any). |
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().
|
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.