(port == 1433 || (port >= 2131 && port <= 2198));
94cmd_desc->SetUsageContext(
GetArguments().GetProgramBasename(),
95 "Simple database-centric load-balancer client");
97unique_ptr<CArgDescriptions> arg_desc;
101cmd_desc->AddCommand(
"lookup", arg_desc.release());
105cmd_desc->AddCommand(
"whatis", arg_desc.release());
109cmd_desc->AddCommand(
"whereis", arg_desc.release());
118 static constTRunnerPair kRunners[] = {
126TRunnerMap::const_iterator it
127= sc_Runners.find(
GetArgs().GetCommand().c_str());
128 _ASSERT(it != sc_Runners.end());
129 return(this->*it->second)();
137(
"service",
"Service",
138 "Desired service name; use -url to supply a full DBAPI URL.",
140arg_desc.
AddKey(
"url",
"URL",
141 "DBAPI URL consolidating all of the above",
147 "Username for confirming usability",
151 "Password corresponding to username",
154arg_desc.
AddOptionalKey(
"database",
"Name",
"Database name to try using",
157arg_desc.
AddFlag(
"kerberos",
158 "Authenticate via existing Kerberos credentials");
164arg_desc.
AddDefaultKey(
"limit",
"N",
"Maximum number of servers to return",
173 booluse_kerberos = args[
"kerberos"].HasValue();
175TDbapi_CanUseKerberos::SetDefault(
true);
180param.
Set(args[
"url"].AsString());
182param.
Set(args[
"service"].AsString());
183 if( !use_kerberos && args[
"username"].
HasValue()) {
185args[
"username"].AsString());
187 if( !use_kerberos && args[
"password"].
HasValue()) {
189args[
"password"].AsString());
191 if(args[
"database"].
HasValue()) {
193args[
"database"].AsString());
214 if(mapper !=
NULL) {
221server.
Reset(pref);
223cout << *server <<
'\n';
239 const string& name = args[
"name"].AsString();
248 if(serv_info ==
NULL) {
250}
else if((types_seen & serv_info->
type) != 0) {
253types_seen |= serv_info->
type;
263 NcbiCout<< name <<
" is a database service.\n";
267 NcbiCout<< name <<
" is a service (type " 274 if(serv_info !=
NULL) {
275types_seen |= serv_info->
type;
278 if(hostname.empty()) {
281 NcbiCout<< name <<
" is a registered database server alias on " 282<< hostname <<
".\n";
284 NcbiCout<< name <<
" is a \"DNS\" service record.\n";
291}
else if(types_seen == 0) {
292 NcbiCout<< name <<
" is unknown to LBSM or DNS.\n";
302 "List all instances of a load-balanced service");
305(
"type",
"Type",
"Service type (case-insensitive)",
307unique_ptr<CArgAllow_Strings> type_strings
311 if(name ==
NULL|| name[0] ==
'\0') {
314type_strings->Allow(name);
319arg_desc.
AddFlag(
"stateless",
"Stateless servers only");
320arg_desc.
AddFlag(
"reverse-dns",
"LB-DNS translation");
321arg_desc.
AddFlag(
"include-down",
"Include instances that are down");
322arg_desc.
AddFlag(
"include-standby",
"Include instances on standby");
323arg_desc.
AddFlag(
"include-reserved",
"Include reserved instances");
324arg_desc.
AddFlag(
"include-suppressed",
"Include suppressed instances");
325arg_desc.
AddFlag(
"include-inactive",
"Include inactive instances");
326arg_desc.
AddFlag(
"include-private",
"Include private instances");
327arg_desc.
AddFlag(
"promiscuous",
"Include all of the above");
336 const string& service = args[
"service"].AsString();
337 const string& type_str = args[
"type"].AsString();
351 NcbiCout<< *ref <<
"\t# type=DBLB\n";
352mapper->
Exclude(service, ref);
378 if(serv_info ==
NULL) {
383serv_info->
host, serv_info->
port);
384 if(serv_info->
rate<= 0.0) {
398.GetRuntimeData(
kEmptyStr).GetDBServiceMapper());
409 int main(
intargc,
const char** argv)
CCommandArgDescriptions â.
int Run(void)
Run the application.
void Init(void)
Initialize the application.
IDBServiceMapper * x_GetServiceMapper(void)
void x_InitLookup(CArgDescriptions &arg_desc)
void x_InitWhereIs(CArgDescriptions &arg_desc)
void x_InitWhatIs(CArgDescriptions &arg_desc)
Uint2 GetPort(void) const
const string & GetName(void) const
Uint4 GetHost(void) const
Database connection object.
void Connect(void)
Explicitly (re)connect to the database server.
CQuery NewQuery(void)
Get new CQuery object for this database.
CRef< IDBConnectionFactory > GetConnectionFactory(void) const
Retrieve a connection factory.
static CDbapiConnMgr & Instance(void)
Get access to the class instance.
Guard for collecting diag messages (affects the current thread only).
Object used to execute queries and stored procedures on the database server and retrieve result sets.
Convenience class to initialize database connection parameters from URL-like strings and/or applicati...
CSDB_ConnectionParam & Set(EParam param, const string &value, TSetFlags flags=0)
Set one of the "essential" database connection parameters, unless overridden in a configuration file.
@ eService
Named service, interfaces-file alias, or raw server name, per http://ncbi.github.io/cxx-toolkit/pages...
string Get(EParam param, EWithOverrides with_overrides=eWithoutOverrides) const
Get one of the "essential" database connection parameters.
Exception class used throughout the API.
const string & GetServerName(void) const
class CStaticArrayMap<> provides access to a static array in much the same way as CStaticArraySet<>,...
virtual TSvrRef GetServer(const string &service)=0
Map a service to a server.
virtual void SetPreference(const string &service, const TSvrRef &preferred_server, double preference=100)=0
Set up mapping preferences for a service preference - value between 0 and 100 (0 means *no particular...
virtual void Exclude(const string &service, const TSvrRef &server)
Exclude a server from the mapping for a service.
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 ...
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
element_type * get(void) const
Get pointer.
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
void AddFlag(const string &name, const string &comment, CBoolEnum< EFlagValue > set_value=eFlagHasValueIfSet, TFlags flags=0)
Add description for flag argument.
void SetConstraint(const string &name, const CArgAllow *constraint, EConstraintNegate negate=eConstraint)
Set additional user defined constraint on argument value.
void SetDependency(const string &arg1, EDependency dep, const string &arg2)
Define a dependency.
void AddKey(const string &name, const string &synopsis, const string &comment, EType type, TFlags flags=0)
Add description for mandatory key.
void SetUsageContext(const string &usage_name, const string &usage_description, bool usage_sort_args=false, SIZE_TYPE usage_width=78)
Set extra info to be used by PrintUsage().
void AddPositional(const string &name, const string &comment, EType type, TFlags flags=0)
Add description for mandatory positional argument.
void AddOptionalKey(const string &name, const string &synopsis, const string &comment, EType type, TFlags flags=0)
Add description for optional key without default value.
void AddDefaultKey(const string &name, const string &synopsis, const string &comment, EType type, const string &default_value, TFlags flags=0, const string &env_var=kEmptyStr, const char *display_value=nullptr)
Add description for optional key with default value.
@ eRequires
One argument requires another.
@ eExcludes
One argument excludes another.
@ eString
An arbitrary string.
@ eInteger
Convertible into an integer number (int or Int8)
void SetAction(EAction action)
Specify on-destroy action.
@ ePrint
Print all collected messages as is.
@ eDiscard
Discard collected messages, default.
@ eDiag_Info
Informational message.
@ eDiag_Fatal
Fatal error â guarantees exit(or abort)
void Reset(void)
Reset reference object.
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty â pointing to an object and has a non-null value.
bool Empty(void) const THROWS_NONE
Check if CRef is empty â not pointing to any object, which means having a null value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
SSERV_InfoCPtr SERV_GetNextInfo(SERV_ITER iter)
Same as "SERV_GetNextInfoEx(., 0)" â i.e.
void SERV_Close(SERV_ITER iter)
Deallocate the iterator.
const char * SERV_ReadType(const char *str, ESERV_Type *type)
const char * SERV_TypeStr(ESERV_Type type)
SERV_ITER SERV_Open(const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info)
Same as "SERV_OpenEx(., ., ., ., 0, 0)" â i.e.
unsigned int TSERV_Type
Bitwise OR of ESERV_Type[Special].
@ fSERV_ReverseDns
LB-DNS translation.
@ fSERV_IncludeSuppressed
@ fSERV_All
Server type mask.
@ fSERV_Stateless
Stateless servers only.
@ fSERV_Promiscuous
Evrthng and the kitchen sink.
static CNCBI_IPAddr gethostbyname(const string &host, ESwitch log=eOff)
Return 0 or empty address on error.
static string gethostbyaddr(const CNCBI_IPAddr &addr, ESwitch log=eOff)
Return empty string on error.
static string ntoa(const CNCBI_IPAddr &addr)
BSD-like API.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
@ eNocase
Case insensitive compare.
SConnNetInfo * ConnNetInfo_Create(const char *service)
void ConnNetInfo_Destroy(SConnNetInfo *net_info)
unsigned int
A callback function used to compare two keys in a database.
int main(int argc, const char **argv)
CNcbiOstream & operator<<(CNcbiOstream &os, CDBServer &server)
static bool s_IsDBPort(unsigned short port)
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
#define DEFINE_STATIC_ARRAY_MAP(Type, Var, Array)
static void Delete(SConnNetInfo *info)
static void Delete(SERV_ITER iter)
Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...
CArgAllow_Regexp â regexp based constraint for argument value.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4