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:
David Schwartz
2013-10-29 17:35:47 -07:00
committed by Vinnie Falco
parent a05f33f6a7
commit 58f07a573f
48 changed files with 665 additions and 759 deletions

View File

@@ -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;