mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
New ResourceManager for managing server load.
* Track abusive endpoints * Gossip across cluster. * Use resource manager's gossip support to share load reporting across a cluster * Swtich from legacy fees to new Resource::Charge fees. * Connect RPC to the new resource manager. * Set load levels where needed in RPC/websocket commands. * Disconnect abusive peer endpoints. * Don't start conversations with abusive peer endpoints. * Move Resource::Consumer to InfoSub and remove LoadSource * Remove port from inbound Consumer keys * Add details in getJson * Fix doAccountCurrencies for the new resource manager.
This commit is contained in:
committed by
Vinnie Falco
parent
a05f33f6a7
commit
58f07a573f
@@ -18,8 +18,9 @@
|
||||
//==============================================================================
|
||||
|
||||
|
||||
RPCServerHandler::RPCServerHandler (NetworkOPs& networkOPs)
|
||||
RPCServerHandler::RPCServerHandler (NetworkOPs& networkOPs, Resource::Manager& resourceManager)
|
||||
: m_networkOPs (networkOPs)
|
||||
, m_resourceManager (resourceManager)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -52,6 +53,16 @@ std::string RPCServerHandler::processRequest (std::string const& request, std::s
|
||||
|
||||
Config::Role const role (getConfig ().getAdminRole (jvRequest, remoteAddress));
|
||||
|
||||
Resource::Consumer usage;
|
||||
|
||||
if (role == Config::ADMIN)
|
||||
usage = m_resourceManager.newAdminEndpoint (remoteAddress);
|
||||
else
|
||||
usage = m_resourceManager.newInboundEndpoint (IPAddress::from_string (remoteAddress));
|
||||
|
||||
if (usage.disconnect ())
|
||||
return createResponse (503, "Server is overloaded");
|
||||
|
||||
// Parse id now so errors from here on will have the id
|
||||
//
|
||||
// VFALCO NOTE Except that "id" isn't included in the following errors...
|
||||
@@ -107,10 +118,11 @@ std::string RPCServerHandler::processRequest (std::string const& request, std::s
|
||||
|
||||
RPCHandler rpcHandler (&m_networkOPs);
|
||||
|
||||
LoadType loadType = LT_RPCReference;
|
||||
Resource::Charge loadType = Resource::feeReferenceRPC;
|
||||
|
||||
Json::Value const result = rpcHandler.doRpcCommand (strMethod, params, role, &loadType);
|
||||
// VFALCO NOTE We discard loadType since there is no endpoint to punish
|
||||
Json::Value const result = rpcHandler.doRpcCommand (strMethod, params, role, loadType);
|
||||
|
||||
usage.charge (loadType);
|
||||
|
||||
WriteLog (lsDEBUG, RPCServer) << "Reply: " << result;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user