mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Create a new ClusterNodeStatus class and hook it up.
This commit is contained in:
@@ -174,6 +174,7 @@ namespace ripple
|
|||||||
#include "src/cpp/ripple/ripple_RippleState.h"
|
#include "src/cpp/ripple/ripple_RippleState.h"
|
||||||
#include "src/cpp/ripple/SerializedValidation.h"
|
#include "src/cpp/ripple/SerializedValidation.h"
|
||||||
#include "src/cpp/ripple/AccountSetTransactor.h"
|
#include "src/cpp/ripple/AccountSetTransactor.h"
|
||||||
|
#include "src/cpp/ripple/ripple_ClusterNodeStatus.h"
|
||||||
#include "src/cpp/ripple/TrustSetTransactor.h"
|
#include "src/cpp/ripple/TrustSetTransactor.h"
|
||||||
#include "src/cpp/ripple/WSConnection.h"
|
#include "src/cpp/ripple/WSConnection.h"
|
||||||
#include "src/cpp/ripple/ripple_WSHandler.h"
|
#include "src/cpp/ripple/ripple_WSHandler.h"
|
||||||
|
|||||||
@@ -81,9 +81,11 @@ message TMHello
|
|||||||
message TMClusterNode
|
message TMClusterNode
|
||||||
{
|
{
|
||||||
required bytes publicKey = 1;
|
required bytes publicKey = 1;
|
||||||
optional string nodeName = 2;
|
required uint32 reportSeq = 2;
|
||||||
optional uint32 nodeLoad = 3;
|
optional string nodeName = 3;
|
||||||
optional uint32 lastHeard = 4;
|
optional uint32 nodeLoad = 4;
|
||||||
|
optional uint32 lastHeard = 5;
|
||||||
|
optional string address = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The status of all nodes in the cluster
|
// The status of all nodes in the cluster
|
||||||
|
|||||||
60
src/cpp/ripple/ripple_ClusterNodeStatus.h
Normal file
60
src/cpp/ripple/ripple_ClusterNodeStatus.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef RIPPLE_CLUSTERNODESTATUS_H
|
||||||
|
#define RIPPLE_CLUSTERNODESTATUS_H
|
||||||
|
|
||||||
|
class ClusterNodeStatus
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
ClusterNodeStatus(std::string const& name) : mNodeName(name), mSeq(0), mLoadFee(0), mReportTime(0)
|
||||||
|
{ ; }
|
||||||
|
|
||||||
|
ClusterNodeStatus(uint32 seq, const std::string& name, uint32 fee, uint32 rtime) :
|
||||||
|
mNodeName(name),
|
||||||
|
mSeq(seq),
|
||||||
|
mLoadFee(fee),
|
||||||
|
mReportTime(rtime)
|
||||||
|
{ ; }
|
||||||
|
|
||||||
|
std::string const& getName()
|
||||||
|
{
|
||||||
|
return mNodeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 getSeq()
|
||||||
|
{
|
||||||
|
return mSeq;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 getLoadFee()
|
||||||
|
{
|
||||||
|
return mLoadFee;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 getReportTime()
|
||||||
|
{
|
||||||
|
return mReportTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(ClusterNodeStatus const& status)
|
||||||
|
{
|
||||||
|
if (status.mSeq > mSeq)
|
||||||
|
{
|
||||||
|
mSeq = status.mSeq;
|
||||||
|
mLoadFee = status.mLoadFee;
|
||||||
|
mReportTime = status.mReportTime;
|
||||||
|
if (mNodeName.empty() || !status.mNodeName.empty())
|
||||||
|
mNodeName = status.mNodeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string mNodeName;
|
||||||
|
uint32 mSeq;
|
||||||
|
uint32 mLoadFee;
|
||||||
|
uint32 mReportTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -311,12 +311,12 @@ public:
|
|||||||
bool nodeInCluster (const RippleAddress& naNodePublic, std::string& name)
|
bool nodeInCluster (const RippleAddress& naNodePublic, std::string& name)
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock sl (mUNLLock);
|
boost::recursive_mutex::scoped_lock sl (mUNLLock);
|
||||||
std::map<RippleAddress, std::string>::iterator it = m_clusterNodes.find (naNodePublic);
|
std::map<RippleAddress, ClusterNodeStatus>::iterator it = m_clusterNodes.find (naNodePublic);
|
||||||
|
|
||||||
if (it == m_clusterNodes.end ())
|
if (it == m_clusterNodes.end ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
name = it->second;
|
name = it->second.getName();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,7 +600,7 @@ private:
|
|||||||
RippleAddress a = RippleAddress::createNodePublic (match[1]);
|
RippleAddress a = RippleAddress::createNodePublic (match[1]);
|
||||||
|
|
||||||
if (a.isValid ())
|
if (a.isValid ())
|
||||||
m_clusterNodes.insert (std::make_pair (a, match[2]));
|
m_clusterNodes.insert (std::make_pair (a, ClusterNodeStatus(match[2])));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WriteLog (lsWARNING, UniqueNodeList) << "Entry in cluster list invalid: '" << c << "'";
|
WriteLog (lsWARNING, UniqueNodeList) << "Entry in cluster list invalid: '" << c << "'";
|
||||||
@@ -1971,7 +1971,7 @@ private:
|
|||||||
boost::posix_time::ptime mtpFetchNext; // Time of to start next fetch.
|
boost::posix_time::ptime mtpFetchNext; // Time of to start next fetch.
|
||||||
DeadlineTimer m_fetchTimer; // Timer to start fetching.
|
DeadlineTimer m_fetchTimer; // Timer to start fetching.
|
||||||
|
|
||||||
std::map<RippleAddress, std::string> m_clusterNodes;
|
std::map<RippleAddress, ClusterNodeStatus> m_clusterNodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
UniqueNodeList* UniqueNodeList::New ()
|
UniqueNodeList* UniqueNodeList::New ()
|
||||||
|
|||||||
Reference in New Issue
Block a user