mirror of
https://github.com/joyieldInc/predixy.git
synced 2025-12-24 22:46:41 +08:00
add some notes
This commit is contained in:
parent
b8ca3d67de
commit
da80f33ae5
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
src/*.o
|
||||
.idea/
|
||||
.vscode/
|
||||
src/predixy
|
||||
@ -59,6 +59,7 @@ ConnectConnection* ConnectConnectionPool::getShareConnection(int db)
|
||||
return c;
|
||||
}
|
||||
|
||||
// func ini entah dipanggil oleh siapa
|
||||
ConnectConnection* ConnectConnectionPool::getPrivateConnection(int db)
|
||||
{
|
||||
FuncCallTimer();
|
||||
|
||||
@ -121,6 +121,7 @@ int Handler::checkServerTimeout(long timeout)
|
||||
if (auto req = s->frontRequest()) {
|
||||
long elapsed = now - req->createTime();
|
||||
if (elapsed >= timeout) {
|
||||
logError("ibk: SET_STATUS TIMEOUT ERROR: %d",Connection::TimeoutError);
|
||||
s->setStatus(Connection::TimeoutError);
|
||||
addPostEvent(s, Multiplexor::ErrorEvent);
|
||||
mWaitConnectConns.remove(s);
|
||||
@ -241,7 +242,7 @@ void Handler::postConnectConnectionEvent()
|
||||
if (finished) {
|
||||
ret = mEventLoop->delEvent(s, Multiplexor::WriteEvent);
|
||||
} else {
|
||||
ret = mEventLoop->addEvent(s, Multiplexor::WriteEvent);
|
||||
ret = mEventLoop->addEvent(s, Multiplexor::WriteEvent); // ibk: add to the epoll
|
||||
}
|
||||
if (!ret) {
|
||||
s->setStatus(Multiplexor::ErrorEvent);
|
||||
@ -259,7 +260,7 @@ void Handler::postConnectConnectionEvent()
|
||||
case Socket::EventError:
|
||||
{
|
||||
Server* serv = s->server();
|
||||
serv->incrFail(); // increase fail counter only for EventError
|
||||
serv->incrFail(); // ibk:increase fail counter only for EventError, mark as failed if exceed threshold
|
||||
if (serv->fail()) {
|
||||
logNotice("server %s mark failure", serv->addr().data());
|
||||
}
|
||||
@ -498,6 +499,9 @@ int Handler::checkClientTimeout(long timeout)
|
||||
return num;
|
||||
}
|
||||
|
||||
// when entering this function, predixy already split multi keys command into multiple commands
|
||||
// e.g. client send : mget a b
|
||||
// this func will receive `mget a` and `mget b`
|
||||
void Handler::handleRequest(Request* req)
|
||||
{
|
||||
FuncCallTimer();
|
||||
@ -533,6 +537,7 @@ void Handler::handleRequest(Request* req)
|
||||
if (s->isShared()) {
|
||||
mConnPool[serv->id()]->incrPendRequests();
|
||||
}
|
||||
// ibk: these three lines only add the event in the corresponding queues
|
||||
s->send(this, req);
|
||||
addPostEvent(s, Multiplexor::WriteEvent);
|
||||
postHandleRequest(req, s);
|
||||
@ -1368,6 +1373,7 @@ void Handler::innerResponse(ConnectConnection* s, Request* req, Response* res)
|
||||
if (s && res->isPong()) {
|
||||
Server* serv = s->server();
|
||||
if (serv->fail()) {
|
||||
logError("ibk: MARK SERVER NOT FAIL BASED ON THE PING");
|
||||
serv->setFail(false); // if server respond to ping, mark fail as false. TODO: add for other case like loading
|
||||
logNotice("h %d s %s %d mark server alive",
|
||||
id(), s->peer(), s->fd());
|
||||
|
||||
@ -106,6 +106,7 @@ public:
|
||||
}
|
||||
void setFail(bool v)
|
||||
{
|
||||
logError("ibk: SET setFail:%d", v);
|
||||
mFail = v;
|
||||
}
|
||||
bool online() const
|
||||
@ -114,6 +115,7 @@ public:
|
||||
}
|
||||
void setOnline(bool v)
|
||||
{
|
||||
logError("[ibk: SET_ONLINE SetOnline:%d", v);
|
||||
mOnline = v;
|
||||
}
|
||||
bool updating() const
|
||||
|
||||
@ -69,6 +69,7 @@ Server* ServerGroup::getServer(Handler* h, Request* req) const
|
||||
return serv;
|
||||
}
|
||||
|
||||
// ibk:get the server for the read operation
|
||||
Server* ServerGroup::getReadServer(Handler* h) const
|
||||
{
|
||||
FuncCallTimer();
|
||||
@ -80,9 +81,10 @@ Server* ServerGroup::getReadServer(Handler* h) const
|
||||
int dprior = 0;
|
||||
int pendRequests = INT_MAX;
|
||||
int cnt = mServs.size();
|
||||
|
||||
for (int i = 0; i < cnt; ++i) {
|
||||
Server* s = mServs[i];
|
||||
if (!s->online()) {
|
||||
if (!s->online()) { // make sure it is online
|
||||
continue;
|
||||
}
|
||||
int rp = 0;
|
||||
@ -94,6 +96,8 @@ Server* ServerGroup::getReadServer(Handler* h) const
|
||||
if (rp <= 0) {
|
||||
continue;
|
||||
}
|
||||
// ibk: if it is fail:
|
||||
// - put into deadServs list and use another server
|
||||
if (s->fail()) {
|
||||
if (rp > dprior) {
|
||||
dprior = rp;
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include "Exception.h"
|
||||
#include "Logger.h"
|
||||
|
||||
class Socket
|
||||
{
|
||||
@ -82,6 +83,7 @@ public:
|
||||
const char* statusStr() const;
|
||||
void setStatus(int st)
|
||||
{
|
||||
logError("ibk: SET_STATUS setStatus %d", st);
|
||||
mStatus = st;
|
||||
}
|
||||
int getEvent() const
|
||||
|
||||
Loading…
Reference in New Issue
Block a user