mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-05 08:48:03 +00:00
ELB support. Client servers can remove themselves from an ELB pool if loaded
or otherwise broken. Clients won't join an ELB pool until they're stable.
This commit is contained in:
@@ -507,4 +507,36 @@ bool Application::loadOldLedger(const std::string& l)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool serverOkay(std::string& reason)
|
||||||
|
{
|
||||||
|
if (!theConfig.ELB_SUPPORT)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!theApp)
|
||||||
|
{
|
||||||
|
reason = "Server has not started";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theApp->getOPs().isNeedNetworkLedger())
|
||||||
|
{
|
||||||
|
reason = "Not synchronized with network yet";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theApp->getOPs().getOperatingMode() < NetworkOPs::omSYNCING)
|
||||||
|
{
|
||||||
|
reason = "Not synchronized with network";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theApp->getFeeTrack().isLoaded())
|
||||||
|
{
|
||||||
|
reason = "Too much load";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#define SECTION_CLUSTER_NODES "cluster_nodes"
|
#define SECTION_CLUSTER_NODES "cluster_nodes"
|
||||||
#define SECTION_DATABASE_PATH "database_path"
|
#define SECTION_DATABASE_PATH "database_path"
|
||||||
#define SECTION_DEBUG_LOGFILE "debug_logfile"
|
#define SECTION_DEBUG_LOGFILE "debug_logfile"
|
||||||
|
#define SECTION_ELB_SUPPORT "elb_support"
|
||||||
#define SECTION_FEE_DEFAULT "fee_default"
|
#define SECTION_FEE_DEFAULT "fee_default"
|
||||||
#define SECTION_FEE_NICKNAME_CREATE "fee_nickname_create"
|
#define SECTION_FEE_NICKNAME_CREATE "fee_nickname_create"
|
||||||
#define SECTION_FEE_OFFER "fee_offer"
|
#define SECTION_FEE_OFFER "fee_offer"
|
||||||
@@ -253,6 +254,7 @@ Config::Config()
|
|||||||
NODE_DB = "sqlite";
|
NODE_DB = "sqlite";
|
||||||
|
|
||||||
LDB_IMPORT = false;
|
LDB_IMPORT = false;
|
||||||
|
ELB_SUPPORT = false;
|
||||||
RUN_STANDALONE = false;
|
RUN_STANDALONE = false;
|
||||||
START_UP = NORMAL;
|
START_UP = NORMAL;
|
||||||
}
|
}
|
||||||
@@ -389,6 +391,9 @@ void Config::load()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sectionSingleB(secConfig, SECTION_ELB_SUPPORT, strTemp))
|
||||||
|
ELB_SUPPORT = boost::lexical_cast<bool>(strTemp);
|
||||||
|
|
||||||
(void) sectionSingleB(secConfig, SECTION_WEBSOCKET_IP, WEBSOCKET_IP);
|
(void) sectionSingleB(secConfig, SECTION_WEBSOCKET_IP, WEBSOCKET_IP);
|
||||||
|
|
||||||
if (sectionSingleB(secConfig, SECTION_WEBSOCKET_PORT, strTemp))
|
if (sectionSingleB(secConfig, SECTION_WEBSOCKET_PORT, strTemp))
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public:
|
|||||||
boost::filesystem::path VALIDATORS_FILE; // As specifed in rippled.cfg.
|
boost::filesystem::path VALIDATORS_FILE; // As specifed in rippled.cfg.
|
||||||
std::string NODE_DB; // Database to use for nodes
|
std::string NODE_DB; // Database to use for nodes
|
||||||
bool LDB_IMPORT; // Import into LevelDB
|
bool LDB_IMPORT; // Import into LevelDB
|
||||||
|
bool ELB_SUPPORT; // Support Amazon ELB
|
||||||
|
|
||||||
std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet.
|
std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet.
|
||||||
std::string VALIDATORS_URI; // URI of validators.txt.
|
std::string VALIDATORS_URI; // URI of validators.txt.
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
extern void initSSLContext(boost::asio::ssl::context& context,
|
extern void initSSLContext(boost::asio::ssl::context& context,
|
||||||
std::string key_file, std::string cert_file, std::string chain_file);
|
std::string key_file, std::string cert_file, std::string chain_file);
|
||||||
|
|
||||||
|
extern bool serverOkay(std::string& reason);
|
||||||
|
|
||||||
template <typename endpoint_type>
|
template <typename endpoint_type>
|
||||||
class WSConnection;
|
class WSConnection;
|
||||||
|
|
||||||
@@ -274,11 +276,18 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Respond to http requests.
|
// Respond to http requests.
|
||||||
void http(connection_ptr cpClient)
|
bool http(connection_ptr cpClient)
|
||||||
{
|
{
|
||||||
|
std::string reason;
|
||||||
|
if (!serverOkay(reason))
|
||||||
|
{
|
||||||
|
cpClient->set_body(std::string("<HTML><BODY>Server cannot accept clients: ") + reason + "</BODY></HTML>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
cpClient->set_body(
|
cpClient->set_body(
|
||||||
"<!DOCTYPE html><html><head><title>" SYSTEM_NAME " Test</title></head>"
|
"<!DOCTYPE html><html><head><title>" SYSTEM_NAME " Test</title></head>"
|
||||||
"<body><h1>" SYSTEM_NAME " Test</h1><p>This page shows http(s) connectivity is working.</p></body></html>");
|
"<body><h1>" SYSTEM_NAME " Test</h1><p>This page shows http(s) connectivity is working.</p></body></html>");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ public:
|
|||||||
virtual bool on_ping(connection_ptr con,std::string) {return true;}
|
virtual bool on_ping(connection_ptr con,std::string) {return true;}
|
||||||
virtual void on_pong(connection_ptr con,std::string) {}
|
virtual void on_pong(connection_ptr con,std::string) {}
|
||||||
virtual void on_pong_timeout(connection_ptr con,std::string) {}
|
virtual void on_pong_timeout(connection_ptr con,std::string) {}
|
||||||
virtual void http(connection_ptr con) {}
|
virtual bool http(connection_ptr con) { return true; }
|
||||||
|
|
||||||
virtual void on_send_empty(connection_ptr con) {}
|
virtual void on_send_empty(connection_ptr con) {}
|
||||||
};
|
};
|
||||||
@@ -744,9 +744,10 @@ void server<endpoint>::connection<connection_type>::handle_read_request(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// continue as HTTP?
|
// continue as HTTP?
|
||||||
m_endpoint.get_handler()->http(m_connection.shared_from_this());
|
if (m_endpoint.get_handler()->http(m_connection.shared_from_this()))
|
||||||
|
m_response.set_status(http::status_code::OK);
|
||||||
m_response.set_status(http::status_code::OK);
|
else
|
||||||
|
m_response.set_status(http::status_code::INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
} catch (const http::exception& e) {
|
} catch (const http::exception& e) {
|
||||||
m_endpoint.m_elog->at(log::elevel::RERROR) << e.what() << log::endl;
|
m_endpoint.m_elog->at(log::elevel::RERROR) << e.what() << log::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user