A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/throttling_8cpp_source.html below:

NCBI C++ ToolKit: src/app/pubseq_gateway/server/throttling.cpp Source File

52

shared_ptr<CPSGS_Reply> reply,

53  const string

& peer_ip,

54  const string

& peer_id,

55  const string

& user_agent)

57  static long

throttling_data_valid_ms =

61  size_t

current_conn_num =

m_HttpDaemon

->NumOfConnections();

67  if

(req.

GetPath

() ==

"/ADMIN/connections_status"

) {

75

shared_ptr<SThrottlingData> throttling_data;

81  if

(chrono::duration_cast<chrono::milliseconds>

119  for

(

auto

& props : throttling_data->m_IdleConnProps) {

120  if

(props.m_CloseIssued) {

124  if

(props.m_PeerID.has_value()) {

125  if

(find(throttling_data->m_PeerIDOverLimit.begin(),

126

throttling_data->m_PeerIDOverLimit.end(),

127

props.m_PeerID.value()) != throttling_data->m_PeerIDOverLimit.end()) {

129

props.m_CloseIssued =

true

;

130  PSG_WARNING

(

"Throttling connection (idle peer ID)." 131  " Worker id: "

+ to_string(props.m_WorkerID) +

132  " Connection id: "

+ to_string(props.m_ConnID));

138  if

(find(throttling_data->m_PeerIPOverLimit.begin(),

139

throttling_data->m_PeerIPOverLimit.end(),

140

props.m_PeerIP) != throttling_data->m_PeerIPOverLimit.end()) {

142

props.m_CloseIssued =

true

;

143  PSG_WARNING

(

"Throttling connection (idle peer IP)." 144  " Worker id: "

+ to_string(props.m_WorkerID) +

145  " Connection id: "

+ to_string(props.m_ConnID));

151  if

(find(throttling_data->m_PeerSiteOverLimit.begin(),

152

throttling_data->m_PeerSiteOverLimit.end(),

153  site

) != throttling_data->m_PeerSiteOverLimit.end()) {

155

props.m_CloseIssued =

true

;

156  PSG_WARNING

(

"Throttling connection (idle peer site)." 157  " Worker id: "

+ to_string(props.m_WorkerID) +

158  " Connection id: "

+ to_string(props.m_ConnID));

163  if

(props.m_UserAgent.has_value()) {

164  if

(find(throttling_data->m_UserAgentOverLimit.begin(),

165

throttling_data->m_UserAgentOverLimit.end(),

166

props.m_UserAgent.value()) != throttling_data->m_UserAgentOverLimit.end()) {

168

props.m_CloseIssued =

true

;

169  PSG_WARNING

(

"Throttling connection (idle user agent)." 170  " Worker id: "

+ to_string(props.m_WorkerID) +

171  " Connection id: "

+ to_string(props.m_ConnID));

180

reply->GetHttpReply()->GetHttpConnection()->GetProperties();

194  if

(!peer_id.empty()) {

195  if

(find(throttling_data->m_PeerIDOverLimit.begin(),

196

throttling_data->m_PeerIDOverLimit.end(),

197

peer_id) != throttling_data->m_PeerIDOverLimit.end()) {

200  PSG_WARNING

(

"Throttling request connection (peer id)"

);

205  if

(find(throttling_data->m_PeerIPOverLimit.begin(),

206

throttling_data->m_PeerIPOverLimit.end(),

207

peer_ip) != throttling_data->m_PeerIPOverLimit.end()) {

210  PSG_WARNING

(

"Throttling request connection (peer ip)"

);

215  if

(find(throttling_data->m_PeerSiteOverLimit.begin(),

216

throttling_data->m_PeerSiteOverLimit.end(),

217  site

) != throttling_data->m_PeerSiteOverLimit.end()) {

220  PSG_WARNING

(

"Throttling request connection (peer site)"

);

224  if

(!user_agent.empty()) {

225  if

(find(throttling_data->m_UserAgentOverLimit.begin(),

226

throttling_data->m_UserAgentOverLimit.end(),

227

user_agent) != throttling_data->m_UserAgentOverLimit.end()) {

230  PSG_WARNING

(

"Throttling request connection (peer user agent)"

);

248

shared_ptr<SThrottlingData> throttling_data;

250  m_HttpDaemon

->PopulateThrottlingData(*throttling_data.get());

260  unsigned int

worker_id,

265  m_HttpDaemon

->CloseThrottledConnection(worker_id, conn_id);

278  "The connection was throttled"

,

283

reply->GetHttpReply()->GetHttpConnection()->CloseThrottledConnection(

void Register(EPSGS_AlertType alert_type, const string &message)

unique_ptr< CHttpDaemon > m_HttpDaemon

bool m_ThrottlingDataInProgress

EPSGS_ThrottlingDecision x_CheckThrottling(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply, const string &peer_ip, const string &peer_id, const string &user_agent)

atomic< bool > m_ThrottlingDataLock

shared_ptr< SThrottlingData > m_ThrottlingData

SPubseqGatewaySettings m_Settings

void x_CloseThrottledConnection(shared_ptr< CPSGS_Reply > reply, unsigned int worker_id, int64_t conn_id)

psg_time_point_t m_ThrottlingDataTimestamp

void x_SendMessageAndCompletionChunks(shared_ptr< CPSGS_Reply > reply, const psg_time_point_t &now, const string &message, CRequestStatus::ECode status, int code, EDiagSev severity)

unique_ptr< CPSGSCounters > m_Counters

void x_RebuildThrottlingData(void)

@ eDiag_Error

Error message.

@ e503_ServiceUnavailable

Defines NCBI C++ diagnostic APIs, classes, and macros.

Multi-threading – classes, functions, and features.

#define PSG_WARNING(message)

psg_clock_t::time_point psg_time_point_t

string GetSiteFromIP(const string &ip_address)

Defines CRequestContext class for NCBI C++ diagnostic API.

int64_t m_NumInitiatedRequests

double m_ThrottlingDataValidSec

size_t m_ConnThrottleThreshold


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