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;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// func ini entah dipanggil oleh siapa
|
||||||
ConnectConnection* ConnectConnectionPool::getPrivateConnection(int db)
|
ConnectConnection* ConnectConnectionPool::getPrivateConnection(int db)
|
||||||
{
|
{
|
||||||
FuncCallTimer();
|
FuncCallTimer();
|
||||||
|
|||||||
@ -121,6 +121,7 @@ int Handler::checkServerTimeout(long timeout)
|
|||||||
if (auto req = s->frontRequest()) {
|
if (auto req = s->frontRequest()) {
|
||||||
long elapsed = now - req->createTime();
|
long elapsed = now - req->createTime();
|
||||||
if (elapsed >= timeout) {
|
if (elapsed >= timeout) {
|
||||||
|
logError("ibk: SET_STATUS TIMEOUT ERROR: %d",Connection::TimeoutError);
|
||||||
s->setStatus(Connection::TimeoutError);
|
s->setStatus(Connection::TimeoutError);
|
||||||
addPostEvent(s, Multiplexor::ErrorEvent);
|
addPostEvent(s, Multiplexor::ErrorEvent);
|
||||||
mWaitConnectConns.remove(s);
|
mWaitConnectConns.remove(s);
|
||||||
@ -241,7 +242,7 @@ void Handler::postConnectConnectionEvent()
|
|||||||
if (finished) {
|
if (finished) {
|
||||||
ret = mEventLoop->delEvent(s, Multiplexor::WriteEvent);
|
ret = mEventLoop->delEvent(s, Multiplexor::WriteEvent);
|
||||||
} else {
|
} else {
|
||||||
ret = mEventLoop->addEvent(s, Multiplexor::WriteEvent);
|
ret = mEventLoop->addEvent(s, Multiplexor::WriteEvent); // ibk: add to the epoll
|
||||||
}
|
}
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
s->setStatus(Multiplexor::ErrorEvent);
|
s->setStatus(Multiplexor::ErrorEvent);
|
||||||
@ -259,7 +260,7 @@ void Handler::postConnectConnectionEvent()
|
|||||||
case Socket::EventError:
|
case Socket::EventError:
|
||||||
{
|
{
|
||||||
Server* serv = s->server();
|
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()) {
|
if (serv->fail()) {
|
||||||
logNotice("server %s mark failure", serv->addr().data());
|
logNotice("server %s mark failure", serv->addr().data());
|
||||||
}
|
}
|
||||||
@ -498,6 +499,9 @@ int Handler::checkClientTimeout(long timeout)
|
|||||||
return num;
|
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)
|
void Handler::handleRequest(Request* req)
|
||||||
{
|
{
|
||||||
FuncCallTimer();
|
FuncCallTimer();
|
||||||
@ -533,6 +537,7 @@ void Handler::handleRequest(Request* req)
|
|||||||
if (s->isShared()) {
|
if (s->isShared()) {
|
||||||
mConnPool[serv->id()]->incrPendRequests();
|
mConnPool[serv->id()]->incrPendRequests();
|
||||||
}
|
}
|
||||||
|
// ibk: these three lines only add the event in the corresponding queues
|
||||||
s->send(this, req);
|
s->send(this, req);
|
||||||
addPostEvent(s, Multiplexor::WriteEvent);
|
addPostEvent(s, Multiplexor::WriteEvent);
|
||||||
postHandleRequest(req, s);
|
postHandleRequest(req, s);
|
||||||
@ -1368,6 +1373,7 @@ void Handler::innerResponse(ConnectConnection* s, Request* req, Response* res)
|
|||||||
if (s && res->isPong()) {
|
if (s && res->isPong()) {
|
||||||
Server* serv = s->server();
|
Server* serv = s->server();
|
||||||
if (serv->fail()) {
|
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
|
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",
|
logNotice("h %d s %s %d mark server alive",
|
||||||
id(), s->peer(), s->fd());
|
id(), s->peer(), s->fd());
|
||||||
|
|||||||
@ -106,6 +106,7 @@ public:
|
|||||||
}
|
}
|
||||||
void setFail(bool v)
|
void setFail(bool v)
|
||||||
{
|
{
|
||||||
|
logError("ibk: SET setFail:%d", v);
|
||||||
mFail = v;
|
mFail = v;
|
||||||
}
|
}
|
||||||
bool online() const
|
bool online() const
|
||||||
@ -114,6 +115,7 @@ public:
|
|||||||
}
|
}
|
||||||
void setOnline(bool v)
|
void setOnline(bool v)
|
||||||
{
|
{
|
||||||
|
logError("[ibk: SET_ONLINE SetOnline:%d", v);
|
||||||
mOnline = v;
|
mOnline = v;
|
||||||
}
|
}
|
||||||
bool updating() const
|
bool updating() const
|
||||||
|
|||||||
@ -69,6 +69,7 @@ Server* ServerGroup::getServer(Handler* h, Request* req) const
|
|||||||
return serv;
|
return serv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ibk:get the server for the read operation
|
||||||
Server* ServerGroup::getReadServer(Handler* h) const
|
Server* ServerGroup::getReadServer(Handler* h) const
|
||||||
{
|
{
|
||||||
FuncCallTimer();
|
FuncCallTimer();
|
||||||
@ -80,9 +81,10 @@ Server* ServerGroup::getReadServer(Handler* h) const
|
|||||||
int dprior = 0;
|
int dprior = 0;
|
||||||
int pendRequests = INT_MAX;
|
int pendRequests = INT_MAX;
|
||||||
int cnt = mServs.size();
|
int cnt = mServs.size();
|
||||||
|
|
||||||
for (int i = 0; i < cnt; ++i) {
|
for (int i = 0; i < cnt; ++i) {
|
||||||
Server* s = mServs[i];
|
Server* s = mServs[i];
|
||||||
if (!s->online()) {
|
if (!s->online()) { // make sure it is online
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int rp = 0;
|
int rp = 0;
|
||||||
@ -94,6 +96,8 @@ Server* ServerGroup::getReadServer(Handler* h) const
|
|||||||
if (rp <= 0) {
|
if (rp <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// ibk: if it is fail:
|
||||||
|
// - put into deadServs list and use another server
|
||||||
if (s->fail()) {
|
if (s->fail()) {
|
||||||
if (rp > dprior) {
|
if (rp > dprior) {
|
||||||
dprior = rp;
|
dprior = rp;
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
class Socket
|
class Socket
|
||||||
{
|
{
|
||||||
@ -82,6 +83,7 @@ public:
|
|||||||
const char* statusStr() const;
|
const char* statusStr() const;
|
||||||
void setStatus(int st)
|
void setStatus(int st)
|
||||||
{
|
{
|
||||||
|
logError("ibk: SET_STATUS setStatus %d", st);
|
||||||
mStatus = st;
|
mStatus = st;
|
||||||
}
|
}
|
||||||
int getEvent() const
|
int getEvent() const
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user