static void rsp_forward_stats(struct context *ctx, struct server *server, struct msg *msg) { ASSERT(!msg->request); if (msg->is_read) { stats_server_incr(ctx, server, read_responses); stats_server_incr_by(ctx, server, read_response_bytes, msg->mlen); } else { stats_server_incr(ctx, server, write_responses); stats_server_incr_by(ctx, server, write_response_bytes, msg->mlen); } }
static void req_forward_stats(struct context *ctx, struct msg *msg) { ASSERT(msg->request); if (msg->is_read) { stats_server_incr(ctx, read_requests); stats_server_incr_by(ctx, read_request_bytes, msg->mlen); } else { stats_server_incr(ctx, write_requests); stats_server_incr_by(ctx, write_request_bytes, msg->mlen); } }
void req_server_enqueue_imsgq(struct context *ctx, struct conn *conn, struct msg *msg) { ASSERT(msg->request); ASSERT((!conn->client && !conn->proxy) || (!conn->dnode_client && !conn->dnode_server)); /* * timeout clock starts ticking the instant the message is enqueued into * the server in_q; the clock continues to tick until it either expires * or the message is dequeued from the server out_q * * noreply request are free from timeouts because client is not interested * in the reponse anyway! */ if (!msg->noreply) { msg_tmo_insert(msg, conn); } TAILQ_INSERT_TAIL(&conn->imsg_q, msg, s_tqe); if (!conn->dyn_mode) { stats_server_incr(ctx, conn->owner, in_queue); stats_server_incr_by(ctx, conn->owner, in_queue_bytes, msg->mlen); } else { struct server_pool *pool = (struct server_pool *) array_get(&ctx->pool, 0); stats_pool_incr(ctx, pool, peer_in_queue); stats_pool_incr_by(ctx, pool, peer_in_queue_bytes, msg->mlen); } }
static void req_forward_stats(struct context *ctx, struct server *server, struct msg *msg) { ASSERT(msg->request); stats_server_incr(ctx, server, requests); stats_server_incr_by(ctx, server, request_bytes, msg->mlen); }
static void rsp_forward_stats(struct context *ctx, struct server *server, struct msg *msg, uint32_t msgsize) { ASSERT(!msg->request); stats_server_incr(ctx, server, responses); stats_server_incr_by(ctx, server, response_bytes, msgsize); }
static void req_forward_stats(struct context *ctx, struct server *server, struct msg *msg) { ASSERT(msg->request); stats_server_incr(ctx, server, requests); //STATS_SERVER_requests自增 stats_server_incr_by(ctx, server, request_bytes, msg->mlen);//STATS_SERVER_requests自增msg->mlen字节 客户端请求字节数 }
void req_server_enqueue_omsgq(struct context *ctx, struct conn *conn, struct msg *msg) { ASSERT(msg->request); ASSERT(!conn->client && !conn->proxy); TAILQ_INSERT_TAIL(&conn->omsg_q, msg, s_tqe); stats_server_incr(ctx, conn->owner, out_queue); stats_server_incr_by(ctx, conn->owner, out_queue_bytes, msg->mlen); }
void req_server_enqueue_imsgq_head(struct context *ctx, struct conn *conn, struct msg *msg) { ASSERT(msg->request); ASSERT(!conn->client && !conn->proxy); /* * timeout clock starts ticking the instant the message is enqueued into * the server in_q; the clock continues to tick until it either expires * or the message is dequeued from the server out_q * * noreply request are free from timeouts because client is not intrested * in the reponse anyway! */ if (!msg->noreply) { msg_tmo_insert(msg, conn); } TAILQ_INSERT_HEAD(&conn->imsg_q, msg, s_tqe); stats_server_incr(ctx, conn->owner, in_queue); stats_server_incr_by(ctx, conn->owner, in_queue_bytes, msg->mlen); }
//接收的客户端msg信息通过req_server_enqueue_imsgq添加到该队列 在req_send_next中发往后端真实服务器 //msg数据添加到conn->imsg_q队列入队,在req_send_next中发往后端真实服务器 void //req_server_enqueue_imsgq添加到队列尾部,req_server_enqueue_imsgq_head添加到队列头部 req_server_enqueue_imsgq(struct context *ctx, struct conn *conn, struct msg *msg) {//req_forward中执行 req_forward->req_server_enqueue_imsgq ASSERT(msg->request); ASSERT(!conn->client && !conn->proxy); /* * timeout clock starts ticking the instant the message is enqueued into * the server in_q; the clock continues to tick until it either expires * or the message is dequeued from the server out_q * * noreply request are free from timeouts because client is not intrested * in the response anyway! */ if (!msg->noreply) { //该msg需要得到应答,添加到红黑树超时定时器 //该定时器在core_timeout中删除 msg_tmo_insert(msg, conn); //添加到tmo_rbt 该msg需要发往后端真实服务器,并且需要等待对方应答 } TAILQ_INSERT_TAIL(&conn->imsg_q, msg, s_tqe);//在core_core中的写事件把imsg_q中的msg发送出去 stats_server_incr(ctx, conn->owner, in_queue); stats_server_incr_by(ctx, conn->owner, in_queue_bytes, msg->mlen); }
static void rsp_forward_stats(struct context *ctx, struct msg *msg, struct conn *s_conn, struct conn *c_conn) { struct msg *pmsg; struct server *server; ASSERT(!s_conn->client && !s_conn->proxy); ASSERT(c_conn->client && !c_conn->proxy); ASSERT(!msg->request && msg->peer != NULL); server = s_conn->owner; pmsg = msg->peer; stats_server_incr(ctx, server, responses); stats_server_incr_by(ctx, server, response_bytes, msg->mlen); switch (msg->type) { case MSG_RSP_NUM: stats_server_incr(ctx, server, num); break; case MSG_RSP_STORED: stats_server_incr(ctx, server, stored); break; case MSG_RSP_NOT_STORED: stats_server_incr(ctx, server, not_stored); break; case MSG_RSP_EXISTS: stats_server_incr(ctx, server, exists); break; case MSG_RSP_NOT_FOUND: stats_server_incr(ctx, server, not_found); break; case MSG_RSP_END: stats_server_incr(ctx, server, end); break; case MSG_RSP_VALUE: stats_server_incr(ctx, server, value); break; case MSG_RSP_DELETED: stats_server_incr(ctx, server, deleted); break; case MSG_RSP_ERROR: log_debug(LOG_INFO, "rsp error type %d from s %d for req %"PRIu64" " "type %d from c %d", msg->type, s_conn->sd, pmsg->id, pmsg->type, c_conn->sd); stats_server_incr(ctx, server, error); break; case MSG_RSP_CLIENT_ERROR: log_debug(LOG_INFO, "rsp error type %d from s %d for req %"PRIu64" " "type %d from c %d", msg->type, s_conn->sd, pmsg->id, pmsg->type, c_conn->sd); stats_server_incr(ctx, server, client_error); break; case MSG_RSP_SERVER_ERROR: log_debug(LOG_INFO, "rsp error type %d from s %d for req %"PRIu64" " "type %d from c %d", msg->type, s_conn->sd, pmsg->id, pmsg->type, c_conn->sd); stats_server_incr(ctx, server, server_error); break; default: NOT_REACHED(); } }