mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-22 12:05:53 +00:00
More cluster status work.
This commit is contained in:
@@ -81,11 +81,10 @@ message TMHello
|
|||||||
message TMClusterNode
|
message TMClusterNode
|
||||||
{
|
{
|
||||||
required bytes publicKey = 1;
|
required bytes publicKey = 1;
|
||||||
required uint32 reportSeq = 2;
|
required uint32 reportTime = 2;
|
||||||
optional string nodeName = 3;
|
required uint32 nodeLoad = 3;
|
||||||
optional uint32 nodeLoad = 4;
|
optional string nodeName = 4;
|
||||||
optional uint32 lastHeard = 5;
|
optional string address = 5;
|
||||||
optional string address = 6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The status of all nodes in the cluster
|
// The status of all nodes in the cluster
|
||||||
|
|||||||
@@ -8,15 +8,14 @@ class ClusterNodeStatus
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ClusterNodeStatus() : mSeq(0), mLoadFee(0), mReportTime(0)
|
ClusterNodeStatus() : mLoadFee(0), mReportTime(0)
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
ClusterNodeStatus(std::string const& name) : mNodeName(name), mSeq(0), mLoadFee(0), mReportTime(0)
|
ClusterNodeStatus(std::string const& name) : mNodeName(name), mLoadFee(0), mReportTime(0)
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
ClusterNodeStatus(uint32 seq, const std::string& name, uint32 fee, uint32 rtime) :
|
ClusterNodeStatus(const std::string& name, uint32 fee, uint32 rtime) :
|
||||||
mNodeName(name),
|
mNodeName(name),
|
||||||
mSeq(seq),
|
|
||||||
mLoadFee(fee),
|
mLoadFee(fee),
|
||||||
mReportTime(rtime)
|
mReportTime(rtime)
|
||||||
{ ; }
|
{ ; }
|
||||||
@@ -26,11 +25,6 @@ public:
|
|||||||
return mNodeName;
|
return mNodeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 getSeq()
|
|
||||||
{
|
|
||||||
return mSeq;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 getLoadFee()
|
uint32 getLoadFee()
|
||||||
{
|
{
|
||||||
return mLoadFee;
|
return mLoadFee;
|
||||||
@@ -43,9 +37,8 @@ public:
|
|||||||
|
|
||||||
void update(ClusterNodeStatus const& status)
|
void update(ClusterNodeStatus const& status)
|
||||||
{
|
{
|
||||||
if (status.mSeq > mSeq)
|
if (status.mReportTime > mReportTime)
|
||||||
{
|
{
|
||||||
mSeq = status.mSeq;
|
|
||||||
mLoadFee = status.mLoadFee;
|
mLoadFee = status.mLoadFee;
|
||||||
mReportTime = status.mReportTime;
|
mReportTime = status.mReportTime;
|
||||||
if (mNodeName.empty() || !status.mNodeName.empty())
|
if (mNodeName.empty() || !status.mNodeName.empty())
|
||||||
@@ -55,7 +48,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mNodeName;
|
std::string mNodeName;
|
||||||
uint32 mSeq;
|
|
||||||
uint32 mLoadFee;
|
uint32 mLoadFee;
|
||||||
uint32 mReportTime;
|
uint32 mReportTime;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1429,9 +1429,18 @@ void PeerImp::recvCluster (protocol::TMCluster& packet)
|
|||||||
{
|
{
|
||||||
protocol::TMClusterNode const& node = packet.clusternodes(i);
|
protocol::TMClusterNode const& node = packet.clusternodes(i);
|
||||||
|
|
||||||
// Extract RippleAddress and build ClusterNodeStatus
|
std::string name;
|
||||||
// WRITEME
|
if (node.has_nodename())
|
||||||
|
name = node.nodename();
|
||||||
|
ClusterNodeStatus s(name, node.nodeload(), node.reporttime());
|
||||||
|
|
||||||
|
RippleAddress nodePub;
|
||||||
|
nodePub.setNodePublic(node.publickey());
|
||||||
|
|
||||||
|
getApp().getUNL().nodeUpdate(nodePub, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getApp().getFeeTrack().setClusterFee(getApp().getUNL().getClusterFee());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerImp::recvGetValidation (protocol::TMGetValidations& packet)
|
void PeerImp::recvGetValidation (protocol::TMGetValidations& packet)
|
||||||
|
|||||||
@@ -342,6 +342,35 @@ public:
|
|||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
uint32 getClusterFee ()
|
||||||
|
{
|
||||||
|
uint64 totFee = 0;
|
||||||
|
int totCount = 0;
|
||||||
|
|
||||||
|
int thresh = getApp().getOPs().getNetworkTimeNC();
|
||||||
|
if (thresh <= 120)
|
||||||
|
thresh = 1;
|
||||||
|
else
|
||||||
|
thresh -= 120;
|
||||||
|
|
||||||
|
boost::recursive_mutex::scoped_lock sl (mUNLLock);
|
||||||
|
{
|
||||||
|
for (std::map<RippleAddress, ClusterNodeStatus>::iterator it = m_clusterNodes.begin(),
|
||||||
|
end = m_clusterNodes.end(); it != end; ++it)
|
||||||
|
{
|
||||||
|
if (it->second.getReportTime() >= thresh)
|
||||||
|
{
|
||||||
|
++totCount;
|
||||||
|
totFee += it->second.getLoadFee();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (totCount == 0) ? 0 : static_cast<uint32>(totFee / totCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
void nodeBootstrap ()
|
void nodeBootstrap ()
|
||||||
{
|
{
|
||||||
int iDomains = 0;
|
int iDomains = 0;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
virtual bool nodeInCluster (const RippleAddress& naNodePublic, std::string& name) = 0;
|
virtual bool nodeInCluster (const RippleAddress& naNodePublic, std::string& name) = 0;
|
||||||
virtual void nodeUpdate (const RippleAddress& naNodePublic, ClusterNodeStatus const& cnsStatus) = 0;
|
virtual void nodeUpdate (const RippleAddress& naNodePublic, ClusterNodeStatus const& cnsStatus) = 0;
|
||||||
virtual std::map<RippleAddress, ClusterNodeStatus> getClusterStatus () = 0;
|
virtual std::map<RippleAddress, ClusterNodeStatus> getClusterStatus () = 0;
|
||||||
|
virtual uint32 getClusterFee () = 0;
|
||||||
|
|
||||||
virtual void nodeBootstrap () = 0;
|
virtual void nodeBootstrap () = 0;
|
||||||
virtual bool nodeLoad (boost::filesystem::path pConfig) = 0;
|
virtual bool nodeLoad (boost::filesystem::path pConfig) = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user