SNetStorageRPC::SNetStorageRPC(const TConfig& config, TNetStorageFlags default_flags) : m_DefaultFlags(default_flags), m_Config(config) #ifdef NCBI_GRID_XSITE_CONN_SUPPORT , m_AllowXSiteConnections(false) #endif { m_RequestNumber.Set(0); CJsonNode hello(MkStdRequest("HELLO")); hello.SetString("Client", m_Config.client_name); hello.SetString("Service", m_Config.service); if (!m_Config.metadata.empty()) hello.SetString("Metadata", m_Config.metadata); {{ CMutexGuard guard(CNcbiApplication::GetInstanceMutex()); CNcbiApplication* app = CNcbiApplication::Instance(); if (app != NULL) hello.SetString("Application", app->GetProgramExecutablePath()); }} hello.SetString("ProtocolVersion", NST_PROTOCOL_VERSION); m_Service = new SNetServiceImpl("NetStorageAPI", m_Config.client_name, new CNetStorageServerListener(hello, m_Config.err_mode)); m_Service->Init(this, m_Config.service, NULL, kEmptyStr, s_NetStorageConfigSections); }
void SNetStorage::SConfig::Validate(const string& init_string) { SNetStorage::SLimits::Check<SNetStorage::SLimits::SNamespace>(app_domain); if (client_name.empty()) { CNcbiApplication* app = CNcbiApplication::Instance(); if (app != NULL) { string path; CDirEntry::SplitPath(app->GetProgramExecutablePath(), &path, &client_name); if (NStr::EndsWith(path, CDirEntry::GetPathSeparator())) path.erase(path.length() - 1); string parent_dir; CDirEntry::SplitPath(path, NULL, &parent_dir); if (!parent_dir.empty()) { client_name += '-'; client_name += parent_dir; } } } if (client_name.empty()) { NCBI_THROW_FMT(CNetStorageException, eAuthError, "Client name is required."); } switch (default_storage) { case eUndefined: default_storage = !service.empty() ? eNetStorage : !nc_service.empty() ? eNetCache : eNoCreate; break; case eNetStorage: if (service.empty()) { NCBI_THROW_FMT(CNetStorageException, eInvalidArg, init_string << ": 'nst=' parameter is required " "when 'default_storage=nst'"); } break; case eNetCache: if (nc_service.empty()) { NCBI_THROW_FMT(CNetStorageException, eInvalidArg, init_string << ": 'nc=' parameter is required " "when 'default_storage=nc'"); } break; default: /* eNoCreate */ break; } }