Gossip 1.1
Classes | Public Member Functions | List of all members
gossip::server::GossipPeerNode Class Reference

A client connecting to another gossip node. More...

#include <GossipPeerNode.h>

Classes

struct  AsyncClientCall
 

Public Member Functions

 GossipPeerNode (std::string name, std::string address, SlotVersion version, GossipNode *node)
 
 ~GossipPeerNode ()
 Destructor of GossipPeerNode, it will release thread and grpc channel.
 
std::string name () const
 
std::string address ()
 
SlotVersion version () const
 
void pull (const pf_gossip::SlotUpdate *origin)
 
std::string search (const std::string &key)
 
bool echo ()
 
std::string establishConnection ()
 
void heartBeat ()
 Async. Send a heartbeat request to connected peer node and share slot version.
 
void newNodeNotify (const std::string &name, const std::string &address, SlotVersion version)
 
void newNodeNotify (const pf_gossip::GossipNodeInfo *origin)
 
void deleteNodeNotify (const std::string &name, const std::string &address, SlotVersion version)
 
void deleteNodeNotify (const pf_gossip::GossipNodeInfo *origin)
 
time_t timestamp () const
 
bool isAlive () const
 
void setNotAlive ()
 Set peer node manually. The alive status will also be updated by this class automatically.
 
void receiveResult ()
 GRPC Asynchronous invocation class. More...
 

Detailed Description

A client connecting to another gossip node.

Class GossipPeerNode is a async rpc client of Gossip Service and stores status of peer node.

Constructor & Destructor Documentation

◆ GossipPeerNode()

gossip::server::GossipPeerNode::GossipPeerNode ( std::string  name,
std::string  address,
SlotVersion  version,
GossipNode node 
)
explicit

Constructor of GossipPeerNode.

Parameters
nameThe name of peer node
addressThe ip address of peer node
versionThe version of peer node
nodeThe owner node of this class

Member Function Documentation

◆ address()

std::string gossip::server::GossipPeerNode::address ( )
inline

Get the ip address of peer node.

Returns
The ip address of peer node

◆ deleteNodeNotify() [1/2]

void gossip::server::GossipPeerNode::deleteNodeNotify ( const pf_gossip::GossipNodeInfo origin)

Async. Send a node delete notify request to connected peer node. Peer node will check and delete this node and then propagate this message.

Parameters
originReceived message

◆ deleteNodeNotify() [2/2]

void gossip::server::GossipPeerNode::deleteNodeNotify ( const std::string &  name,
const std::string &  address,
SlotVersion  version 
)

Async. Send a node delete notify request to connected peer node. Peer node will check and delete this node and then propagate this message.

Parameters
nameThe name of deleted node
addressThe address of deleted node
versionThe version of deleted node

◆ echo()

bool gossip::server::GossipPeerNode::echo ( )

Sync. Send a echo request to connected peer node. Message to send is "request,hello", and received should be "echo,hello". If echo succeed, it will update peer node status.

Returns
If echo succeed

◆ establishConnection()

std::string gossip::server::GossipPeerNode::establishConnection ( )

Sync. Send a connect request to connected peer node. If connection is failed, this class should be released or set unhealthy.

Returns
If connection is established, returns {}. Otherwise, returns error information

◆ isAlive()

bool gossip::server::GossipPeerNode::isAlive ( ) const
inline

Get alive status of peer node. If a rpc is not response, the peer node will be set not alive.

Returns
Is peer node alive

◆ name()

std::string gossip::server::GossipPeerNode::name ( ) const
inline

Get the name of peer node.

Returns
The name of peer node

◆ newNodeNotify() [1/2]

void gossip::server::GossipPeerNode::newNodeNotify ( const pf_gossip::GossipNodeInfo origin)

Async. Send a new node notify request to connected peer node. Peer node will check and connect to the new node and then propagate this message.

Parameters
originReceived message

◆ newNodeNotify() [2/2]

void gossip::server::GossipPeerNode::newNodeNotify ( const std::string &  name,
const std::string &  address,
SlotVersion  version 
)

Async. Send a new node notify request to connected peer node. Peer node will check and connect to the new node and then propagate this message.

Parameters
nameThe name of new node
addressThe address of new node
versionThe version of new node

◆ pull()

void gossip::server::GossipPeerNode::pull ( const pf_gossip::SlotUpdate origin)

Async. Send a pull request to connected peer node. The node will check the slot message, if sender has a higher version, it will update slot and then propagate pull request. If pull request is failed because of rpc disconnection, it will retry.

Parameters
originSender's slot information

◆ receiveResult()

void gossip::server::GossipPeerNode::receiveResult ( )

GRPC Asynchronous invocation class.

Handle the async rpc result in daemon thread. If rpc is succeed, the callback of AsyncClientCall will run. Otherwise, the retry function of AsyncClientCall will run.

Note
All AsyncClientCall should be deleted in this function.

◆ search()

std::string gossip::server::GossipPeerNode::search ( const std::string &  key)

Search message on peer node. if message is found, returns the owner slot of this message

Parameters
keyThe key of message
Returns
The slot name of message

◆ timestamp()

time_t gossip::server::GossipPeerNode::timestamp ( ) const
inline

Get last rpc timestamp of peer node.

Returns
Last rpc timestamp

◆ version()

SlotVersion gossip::server::GossipPeerNode::version ( ) const
inline

Get the version of peer node.

Returns
The version of peer node

The documentation for this class was generated from the following files: