|
| RAFTConsensus (Statistics *stats) |
|
void | start (RequestHandler *requestHandler, std::vector< std::pair< std::string, std::string > > ips, bool assumeLeader=false) |
| Starts RAFT. Will try to connect to a set list of IP's where we assume the leaders are. If none of them respond, we will assume we are the first and assume the role of leader. More...
|
|
virtual bool | isLeader () |
| Returns true if this node is the leader in the network.
|
|
virtual std::string | passRequestToLeader (std::string requestType, std::string client, std::string request) |
| Will pass the given request on to the leader of the network. More...
|
|
virtual std::string | connectNewNode (boost::shared_ptr< TcpConnection > connection, std::string request) |
| Will handle a connect request by a new node that wants to join the network. If this node is the leader, we will add it to our list of connections. If we are not the leader, we will return the ip and port of the leader of the network. More...
|
|
virtual std::vector< std::pair< std::string, std::string > > | getIps (std::string file=".env") |
| Reads the given file and gets the ips out of it. More...
|
|
virtual std::vector< std::string > | getCurrentIPs () |
| Returns the ips currently know to this api. More...
|
|
virtual std::string | getMyIP () |
| Gets the ip of this node. More...
|
|
◆ connectNewNode()
std::string RAFTConsensus::connectNewNode |
( |
boost::shared_ptr< TcpConnection > |
connection, |
|
|
std::string |
request |
|
) |
| |
|
virtual |
Will handle a connect request by a new node that wants to join the network. If this node is the leader, we will add it to our list of connections. If we are not the leader, we will return the ip and port of the leader of the network.
- Returns
- If we are the leader, we will return ok and the initial data. If we are not the leader, we will return the leader of the network.
◆ getCurrentIPs()
std::vector< std::string > RAFTConsensus::getCurrentIPs |
( |
| ) |
|
|
virtual |
Returns the ips currently know to this api.
- Returns
- List of ips with port.
◆ getIps()
std::vector< std::pair< std::string, std::string > > RAFTConsensus::getIps |
( |
std::string |
file = ".env" | ) |
|
|
virtual |
Reads the given file and gets the ips out of it.
- Returns
- List of ips with port.
◆ getMyIP()
virtual std::string RAFTConsensus::getMyIP |
( |
| ) |
|
|
inlinevirtual |
Gets the ip of this node.
- Returns
- The own ip address.
◆ passRequestToLeader()
std::string RAFTConsensus::passRequestToLeader |
( |
std::string |
requestType, |
|
|
std::string |
client, |
|
|
std::string |
request |
|
) |
| |
|
virtual |
Will pass the given request on to the leader of the network.
- Returns
- The string that the leader gives back.
◆ start()
void RAFTConsensus::start |
( |
RequestHandler * |
requestHandler, |
|
|
std::vector< std::pair< std::string, std::string > > |
ips, |
|
|
bool |
assumeLeader = false |
|
) |
| |
Starts RAFT. Will try to connect to a set list of IP's where we assume the leaders are. If none of them respond, we will assume we are the first and assume the role of leader.
- Parameters
-
assumeLeader | If set to true, will skip the connect phase and assume that this node is the leader. |
The documentation for this class was generated from the following files:
- SearchSECODatabaseAPI/JobDistribution/RAFTConsensus.h
- SearchSECODatabaseAPI/JobDistribution/RAFTConsensus.cpp