NCBI C++ ToolKit
|
#include "ncbi_ansi_ext.h"
#include "ncbi_comm.h"
#include "ncbi_lb.h"
#include "ncbi_linkerd.h"
#include "ncbi_namerd.h"
#include "ncbi_once.h"
#include "ncbi_priv.h"
#include "parson.h"
#include <connect/ncbi_buffer.h>
#include <connect/ncbi_connutil.h>
#include <connect/ncbi_http_connector.h>
#include <connect/ncbi_memory_connector.h>
#include <connect/ncbi_server_info.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <time.h>
Go to the source code of this file.
Go to the SVN repository for this file.
Classes | |
struct | SNAMERD_Data |
Typedefs | |
typedef CONNECTOR(* | FCreateConnector) (SERV_ITER iter) |
typedef void *(* | FSvcCpy) (void *dst, const void *src, size_t n) |
Enumerations | |
enum | ENAMERD_Subcodes { eNSub_Message = 0 , eNSub_Alloc = 1 , eNSub_BadData = 2 , eNSub_TooLong = 3 , eNSub_Connect = 4 , eNSub_Json = 5 } |
Variables | |
static const SSERV_VTable | kNamerdOp |
static const char * | s_mock_body = 0 |
static FCreateConnector | s_CreateConnector = s_CreateConnectorHttp |
#define DEBUG_PARAM | ( | x | ) | , x |
Definition at line 68 of file ncbi_namerd.c.
#define DEF_NAMERD_API_ARGS "path=/service/" |
Definition at line 121 of file ncbi_namerd.c.
#define DEF_NAMERD_API_HOST "namerd-api.linkerd.ncbi.nlm.nih.gov" |
Definition at line 102 of file ncbi_namerd.c.
#define DEF_NAMERD_API_HTTP_VERSION 0 |
Definition at line 99 of file ncbi_namerd.c.
#define DEF_NAMERD_API_NAMESPACE "default" |
Definition at line 115 of file ncbi_namerd.c.
#define DEF_NAMERD_API_PATH "/api/1/resolve" |
Definition at line 108 of file ncbi_namerd.c.
#define DEF_NAMERD_API_PORT 0/*unsupported*/ |
Definition at line 105 of file ncbi_namerd.c.
#define DEF_NAMERD_API_REQ_METHOD "GET" |
Definition at line 96 of file ncbi_namerd.c.
#define DEF_NAMERD_API_SCHEME "http" |
Definition at line 93 of file ncbi_namerd.c.
#define DEF_NAMERD_DTAB "" |
Definition at line 139 of file ncbi_namerd.c.
#define DEF_NAMERD_PROXY_HOST "linkerd" |
Definition at line 126 of file ncbi_namerd.c.
#define DEF_NAMERD_PROXY_PORT "4140" |
Definition at line 136 of file ncbi_namerd.c.
#define DEF_NAMERD_REG_SECTION "_NAMERD" |
Definition at line 90 of file ncbi_namerd.c.
#define DTAB_HTTP_HEADER_TAG "DTab-Local:" |
Definition at line 148 of file ncbi_namerd.c.
#define FMT_SIZE_T "%zu" |
Definition at line 59 of file ncbi_namerd.c.
#define FMT_TIME_T "%lu" |
Definition at line 60 of file ncbi_namerd.c.
#define NAMERD_DTAB_ARG "dtab" |
Definition at line 141 of file ncbi_namerd.c.
#define NAMERD_LOCAL_BONUS 1.2 |
Definition at line 145 of file ncbi_namerd.c.
#define NCBI_USE_ERRCODE_X Connect_NamerdLinkerd |
Definition at line 64 of file ncbi_namerd.c.
#define REG_NAMERD_API_ARGS REG_CONN_ARGS |
Definition at line 120 of file ncbi_namerd.c.
#define REG_NAMERD_API_ENV "ENV" /*deprecated*/ |
Definition at line 113 of file ncbi_namerd.c.
#define REG_NAMERD_API_HOST REG_CONN_HOST |
Definition at line 101 of file ncbi_namerd.c.
#define REG_NAMERD_API_HTTP_VERSION REG_CONN_HTTP_VERSION |
Definition at line 98 of file ncbi_namerd.c.
#define REG_NAMERD_API_LOCATION "LOCATION" |
Definition at line 116 of file ncbi_namerd.c.
#define REG_NAMERD_API_NAMESPACE "NAMESPACE" |
Definition at line 114 of file ncbi_namerd.c.
#define REG_NAMERD_API_PATH REG_CONN_PATH |
Definition at line 107 of file ncbi_namerd.c.
#define REG_NAMERD_API_PORT REG_CONN_PORT |
Definition at line 104 of file ncbi_namerd.c.
#define REG_NAMERD_API_PROTOCOL "PROTOCOL" |
Definition at line 118 of file ncbi_namerd.c.
#define REG_NAMERD_API_REQ_METHOD REG_CONN_REQ_METHOD |
Definition at line 95 of file ncbi_namerd.c.
#define REG_NAMERD_API_ROLE "ROLE" |
Definition at line 117 of file ncbi_namerd.c.
#define REG_NAMERD_API_SCHEME "SCHEME" |
Definition at line 92 of file ncbi_namerd.c.
#define REG_NAMERD_DTAB "DTAB" |
Definition at line 138 of file ncbi_namerd.c.
#define REG_NAMERD_PROXY_HOST REG_CONN_HTTP_PROXY_HOST |
Definition at line 123 of file ncbi_namerd.c.
#define REG_NAMERD_PROXY_PORT REG_CONN_HTTP_PROXY_PORT |
Definition at line 135 of file ncbi_namerd.c.
Definition at line 189 of file ncbi_namerd.c.
Definition at line 1220 of file ncbi_namerd.c.
enum ENAMERD_Subcodes |
Definition at line 75 of file ncbi_namerd.c.
|
static |
Definition at line 265 of file ncbi_namerd.c.
References CORE_TRACEF, data, FMT_SIZE_T, free(), info, malloc(), n, SERV_EqualInfo(), SERV_NameOfInfo(), and strcasecmp.
Referenced by s_ParseResponse().
Definition at line 955 of file ncbi_namerd.c.
References assert, ConnNetInfo_Destroy(), CORE_TRACEF, SSERV_IterTag::data, data, free(), and SSERV_IterTag::name.
Referenced by SERV_NAMERD_Open().
Definition at line 193 of file ncbi_namerd.c.
References CORE_TRACEF, SSERV_IterTag::data, data, HTTP_CreateConnector(), and SSERV_IterTag::name.
Referenced by SERV_NAMERD_SetConnectorSource().
Definition at line 201 of file ncbi_namerd.c.
References buf, BUF_Append(), BUF_Destroy(), CORE_TRACEF, MEMORY_CreateConnectorEx(), SSERV_IterTag::name, and s_mock_body.
Referenced by SERV_NAMERD_SetConnectorSource().
|
static |
Definition at line 883 of file ncbi_namerd.c.
Referenced by s_GetNextInfo().
|
static |
Definition at line 890 of file ncbi_namerd.c.
References assert, CORE_TRACEF, SSERV_IterTag::data, data, DEBUG_PARAM, info, LB_Select(), n, SNAMERD_Data::n_cand, SSERV_IterTag::name, NAMERD_LOCAL_BONUS, s_GetCandidate(), s_IsUpdateNeeded(), s_RemoveServerInfo(), s_Resolve(), SERV_NameOfInfo(), and SSERV_IterTag::time.
|
static |
Definition at line 860 of file ncbi_namerd.c.
References CORE_TRACEF, data, DEBUG_PARAM, i, info, and s_RemoveServerInfo().
Referenced by s_GetNextInfo().
Definition at line 421 of file ncbi_namerd.c.
References conn, CORE_LOGF_ERRNO_X, CORE_LOGF_X, CORE_TRACEF, SSERV_IterTag::data, data, DEBUG_PARAM, eLOG_Critical, eLOG_Error, eLOG_Trace, eLOG_Warning, eNSub_Alloc, eNSub_BadData, eNSub_Json, SSERV_IterTag::external, FMT_SIZE_T, free(), fSERV_Dns, fSERV_Http, fSERV_Ncbid, fSERV_Standalone, fSERV_Stateless, i, info, int, JSONBoolean, JSONNumber, JSONObject, JSONString, JSONSuccess, LBSM_DEFAULT_RATE, LBSM_DEFAULT_TIME, LBSM_STANDBY_THRESHOLD, local, malloc(), n, SSERV_IterTag::name, out(), SSERV_IterTag::reverse_dns, s_AddServerInfo(), s_ProcessForStandby(), s_ReadFullResponse(), SERV_GetImplicitServerTypeInternal(), SERV_MAXIMAL_RATE, SERV_MINIMAL_RATE, SERV_NameOfInfo(), SERV_ReadInfoEx(), SERV_ReadType(), SERV_TypeStr(), ncbi::grid::netcache::search::fields::size, st(), util::strcmp(), SSERV_IterTag::time, SSERV_IterTag::types, verify, x_json_array_get_count(), x_json_array_get_object(), x_json_object_dotget_boolean(), x_json_object_dotget_number(), x_json_object_dotget_string(), x_json_object_dothas_value_of_type(), x_json_object_get_array(), x_json_object_get_number(), x_json_object_get_string(), x_json_object_has_value_of_type(), x_json_parse_string(), x_json_serialize_to_buffer_pretty(), x_json_value_free(), x_json_value_get_object(), x_json_value_get_type(), and x_ParseExpires().
Referenced by s_Resolve().
|
static |
Definition at line 232 of file ncbi_namerd.c.
References SNAMERD_Data::cand, data, DEBUG_PARAM, i, info, LBSM_STANDBY_THRESHOLD, and s_RemoveServerInfo().
Referenced by s_ParseResponse().
Definition at line 381 of file ncbi_namerd.c.
References assert, buf, BUF_Destroy(), BUF_Read(), BUF_Size(), BUF_Write(), conn, CONN_Read(), CORE_LOGF_ERRNO_X, CORE_TRACEF, eIO_ReadPlain, eIO_Success, eIO_Unknown, eLOG_Critical, eNSub_Alloc, FMT_SIZE_T, IO_StatusStr(), len, malloc(), and verify.
Referenced by s_ParseResponse().
|
static |
Definition at line 215 of file ncbi_namerd.c.
References assert, CORE_TRACEF, data, FMT_SIZE_T, free(), memmove, n, SNAMERD_Data::n_cand, and SERV_NameOfInfo().
Referenced by s_GetNextInfo(), s_IsUpdateNeeded(), and s_ProcessForStandby().
Definition at line 929 of file ncbi_namerd.c.
References assert, CORE_TRACEF, SSERV_IterTag::data, data, FMT_SIZE_T, free(), i, SSERV_IterTag::name, and SERV_NameOfInfo().
Definition at line 825 of file ncbi_namerd.c.
References conn, CONN_Close(), CONN_Create(), CORE_LOGF_X, CORE_TRACEF, SSERV_IterTag::data, SConnectorTag::destroy, eIO_Success, eLOG_Error, eNSub_Connect, IO_StatusStr(), SSERV_IterTag::name, s_CreateConnector, and s_ParseResponse().
Referenced by s_GetNextInfo(), and SERV_NAMERD_Open().
const SSERV_VTable* SERV_NAMERD_Open | ( | SERV_ITER | iter, |
const SConnNetInfo * | net_info, | ||
SSERV_Info ** | info | ||
) |
Definition at line 1489 of file ncbi_namerd.c.
References SSERV_IterTag::arg, SSERV_IterTag::arglen, assert, calloc(), ConnNetInfo_Clone(), ConnNetInfo_ExtendUserHeader(), ConnNetInfo_SetupStandardArgs(), CORE_LOGF_ERRNO_X, CORE_LOGF_X, CORE_TRACEF, SSERV_IterTag::data, data, eFWMode_Adaptive, eLOG_Critical, eLOG_Error, eLOG_Trace, eLOG_Warning, eNSub_Alloc, eNSub_BadData, eNSub_Message, eNSub_TooLong, fSERV_Firewall, fSERV_Standalone, fSERV_Stateless, g_NCBI_ConnectRandomSeed, info, SSERV_IterTag::ismask, kNamerdOp, SSERV_IterTag::name, NCBI_CONNECT_SRAND_ADDEND, NCBI_CXX_TOOLKIT, SNAMERD_Data::net_info, SSERV_IterTag::op, SSERV_IterTag::reverse_dns, s_Close(), s_Resolve(), SSERV_IterTag::time, SSERV_IterTag::types, types, SSERV_IterTag::val, and x_SetupConnectionParams().
Referenced by x_Open(), and x_SetupFromNamerd().
Definition at line 1579 of file ncbi_namerd.c.
References s_CreateConnector, s_CreateConnectorHttp(), s_CreateConnectorMemory(), and s_mock_body.
Definition at line 1044 of file ncbi_namerd.c.
References CORE_TRACEF, DTAB_HTTP_HEADER_TAG, isspace(), strncasecmp, and strndup.
Referenced by x_SetupConnectionParams().
Definition at line 1102 of file ncbi_namerd.c.
Referenced by x_Namespace(), and x_SetupConnectionParams().
Definition at line 1112 of file ncbi_namerd.c.
References buf, ConnNetInfo_GetValueService(), CORE_LOGF_X, CORE_Once, DEF_CONN_REG_SECTION, DEF_NAMERD_API_NAMESPACE, DEF_NAMERD_REG_SECTION, eLOG_Error, eLOG_Warning, eNSub_Message, eNSub_TooLong, len, REG_NAMERD_API_ENV, REG_NAMERD_API_LOCATION, REG_NAMERD_API_NAMESPACE, REG_NAMERD_API_PROTOCOL, REG_NAMERD_API_ROLE, ncbi::grid::netcache::search::fields::size, strlwr, strncasecmp, strnlen, x_memlwrcpy(), and x_ReadLine().
Referenced by x_SetupConnectionParams().
|
static |
Definition at line 316 of file ncbi_namerd.c.
References assert, CORE_LOCK_WRITE, CORE_LOGF_X, CORE_UNLOCK, eLOG_Error, eNSub_Json, ncbi::grid::netcache::search::fields::expires, FMT_SIZE_T, FMT_TIME_T, i, n, and verify.
Referenced by s_ParseResponse().
Definition at line 1084 of file ncbi_namerd.c.
References fp, len, and ncbi::grid::netcache::search::fields::size.
Referenced by x_Namespace().
Definition at line 1224 of file ncbi_namerd.c.
References SSERV_IterTag::arg, SSERV_IterTag::arglen, buf, CONN_PATH_LEN, ConnNetInfo_AddPath(), ConnNetInfo_GetValueService(), ConnNetInfo_OverrideUserHeader(), ConnNetInfo_PreOverrideArg(), ConnNetInfo_SetPath(), CORE_LOGF_ERRNO_X, CORE_LOGF_X, SSERV_IterTag::data, DEBUG_PARAM, DEF_NAMERD_API_ARGS, DEF_NAMERD_API_HOST, DEF_NAMERD_API_HTTP_VERSION, DEF_NAMERD_API_PATH, DEF_NAMERD_API_PORT, DEF_NAMERD_API_REQ_METHOD, DEF_NAMERD_API_SCHEME, DEF_NAMERD_DTAB, DEF_NAMERD_PROXY_HOST, DEF_NAMERD_PROXY_PORT, DEF_NAMERD_REG_SECTION, DTAB_HTTP_HEADER_TAG, eLOG_Critical, eLOG_Error, eNSub_Alloc, eNSub_BadData, eNSub_TooLong, eReqMethod_Any, eReqMethod_Get, eReqMethod_Post, eURL_Http, eURL_Https, eURL_Unspec, SSERV_IterTag::exact, fProxy_Http, free(), SConnNetInfo::host, SConnNetInfo::http_proxy_host, SConnNetInfo::http_proxy_mask, SConnNetInfo::http_proxy_port, SConnNetInfo::http_user_header, SConnNetInfo::http_version, len, n, SSERV_IterTag::name, NCBI_HasSpaces(), SNAMERD_Data::net_info, SConnNetInfo::port, REG_NAMERD_API_ARGS, REG_NAMERD_API_HOST, REG_NAMERD_API_HTTP_VERSION, REG_NAMERD_API_PATH, REG_NAMERD_API_PORT, REG_NAMERD_API_REQ_METHOD, REG_NAMERD_API_SCHEME, REG_NAMERD_DTAB, REG_NAMERD_PROXY_HOST, REG_NAMERD_PROXY_PORT, SConnNetInfo::req_method, SConnNetInfo::scheme, strcasecmp, strupr, SSERV_IterTag::val, SSERV_IterTag::vallen, x_GetDtabFromHeader(), x_memlwrcpy(), x_Namespace(), and x_UpdateDtabInArgs().
Referenced by SERV_NAMERD_Open().
|
static |
Definition at line 973 of file ncbi_namerd.c.
References assert, buf, bufsize, ConnNetInfo_GetArgs(), ConnNetInfo_PostOverrideArg(), CORE_LOGF_ERRNO_X, CORE_LOGF_X, CORE_TRACEF, eLOG_Critical, eLOG_Error, eNSub_Alloc, eNSub_TooLong, free(), malloc(), NAMERD_DTAB_ARG, SNAMERD_Data::net_info, strncasecmp, URL_Encode(), and verify.
Referenced by x_SetupConnectionParams().
|
static |
|
static |
Definition at line 190 of file ncbi_namerd.c.
Referenced by s_Resolve(), and SERV_NAMERD_SetConnectorSource().
|
static |
Definition at line 181 of file ncbi_namerd.c.
Referenced by s_CreateConnectorMemory(), and SERV_NAMERD_SetConnectorSource().