rippled
ResourceManager.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_RESOURCE_MANAGER_H_INCLUDED
21 #define RIPPLE_RESOURCE_MANAGER_H_INCLUDED
22 
23 #include <ripple/json/json_value.h>
24 #include <ripple/resource/Consumer.h>
25 #include <ripple/resource/Gossip.h>
26 #include <ripple/beast/insight/Collector.h>
27 #include <ripple/beast/net/IPEndpoint.h>
28 #include <ripple/beast/utility/Journal.h>
29 #include <ripple/beast/utility/PropertyStream.h>
30 #include <boost/utility/string_view.hpp>
31 
32 namespace ripple {
33 namespace Resource {
34 
37 {
38 protected:
39  Manager ();
40 
41 public:
42  virtual ~Manager() = 0;
43 
46  virtual Consumer newInboundEndpoint (beast::IP::Endpoint const& address) = 0;
47  virtual Consumer newInboundEndpoint (beast::IP::Endpoint const& address,
48  bool const proxy, boost::string_view const& forwardedFor) = 0;
49 
51  virtual Consumer newOutboundEndpoint (beast::IP::Endpoint const& address) = 0;
52 
55  beast::IP::Endpoint const& address) = 0;
56 
58  virtual Gossip exportConsumers () = 0;
59 
61  virtual Json::Value getJson () = 0;
62  virtual Json::Value getJson (int threshold) = 0;
63 
67  virtual void importConsumers (std::string const& origin, Gossip const& gossip) = 0;
68 };
69 
70 //------------------------------------------------------------------------------
71 
73  beast::insight::Collector::ptr const& collector,
74  beast::Journal journal);
75 
76 }
77 }
78 
79 #endif
ripple::Resource::Manager::newInboundEndpoint
virtual Consumer newInboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by inbound IP address or the forwarded IP if proxied.
ripple::Resource::Manager::newOutboundEndpoint
virtual Consumer newOutboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by outbound IP address and port.
ripple::Resource::Manager::getJson
virtual Json::Value getJson()=0
Extract consumer information for reporting.
std::string
STL class.
std::shared_ptr
STL class.
ripple::Resource::Gossip
Data format for exchanging consumption information across peers.
Definition: Gossip.h:29
beast::PropertyStream::Source
Subclasses can be called to write to a stream and have children.
Definition: PropertyStream.h:274
ripple::Resource::Manager::exportConsumers
virtual Gossip exportConsumers()=0
Extract packaged consumer information for export.
ripple::Resource::Manager::importConsumers
virtual void importConsumers(std::string const &origin, Gossip const &gossip)=0
Import packaged consumer information.
ripple::forwardedFor
boost::string_view forwardedFor(http_request_type const &request)
Definition: Role.cpp:112
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:60
ripple::Resource::Manager::Manager
Manager()
Definition: ResourceManager.cpp:156
ripple::Resource::Manager
Tracks load and resource consumption.
Definition: ResourceManager.h:36
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::Resource::make_Manager
std::unique_ptr< Manager > make_Manager(beast::insight::Collector::ptr const &collector, beast::Journal journal)
Definition: ResourceManager.cpp:165
ripple::Resource::Manager::newUnlimitedEndpoint
virtual Consumer newUnlimitedEndpoint(beast::IP::Endpoint const &address)=0
Create a new unlimited endpoint keyed by forwarded IP.
ripple::Resource::Consumer
An endpoint that consumes resources.
Definition: Consumer.h:33
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:39
std::unique_ptr
STL class.
ripple::Resource::Manager::~Manager
virtual ~Manager()=0
Json::Value
Represents a JSON value.
Definition: json_value.h:141