New upstream version 8.1.0
This commit is contained in:
17
mon/source/nodes/MetaNodeEx.cpp
Normal file
17
mon/source/nodes/MetaNodeEx.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "MetaNodeEx.h"
|
||||
|
||||
MetaNodeEx::MetaNodeEx(std::shared_ptr<Node> receivedNode) :
|
||||
Node(NODETYPE_Meta, receivedNode->getAlias(), receivedNode->getNumID(),
|
||||
receivedNode->getPortUDP(), receivedNode->getPortTCP(),
|
||||
receivedNode->getConnPool()->getNicList()),
|
||||
isResponding(true)
|
||||
{}
|
||||
|
||||
MetaNodeEx::MetaNodeEx(std::shared_ptr<Node> receivedNode, std::shared_ptr<MetaNodeEx> oldNode) :
|
||||
Node(NODETYPE_Meta, receivedNode->getAlias(), receivedNode->getNumID(),
|
||||
receivedNode->getPortUDP(), receivedNode->getPortTCP(),
|
||||
receivedNode->getConnPool()->getNicList())
|
||||
{
|
||||
setLastStatRequestTime(oldNode->getLastStatRequestTime());
|
||||
setIsResponding(oldNode->getIsResponding());
|
||||
}
|
||||
55
mon/source/nodes/MetaNodeEx.h
Normal file
55
mon/source/nodes/MetaNodeEx.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef METANODEEX_H_
|
||||
#define METANODEEX_H_
|
||||
|
||||
#include <common/nodes/Node.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/threading/RWLockGuard.h>
|
||||
|
||||
struct MetaNodeDataContent
|
||||
{
|
||||
bool isResponding;
|
||||
unsigned indirectWorkListSize;
|
||||
unsigned directWorkListSize;
|
||||
unsigned sessionCount;
|
||||
std::string hostnameid;
|
||||
};
|
||||
|
||||
class MetaNodeEx: public Node
|
||||
{
|
||||
public:
|
||||
MetaNodeEx(std::shared_ptr<Node> receivedNode);
|
||||
MetaNodeEx(std::shared_ptr<Node> receivedNode, std::shared_ptr<MetaNodeEx> oldNode);
|
||||
|
||||
private:
|
||||
mutable RWLock lock;
|
||||
bool isResponding;
|
||||
std::chrono::milliseconds lastStatRequestTime{0};
|
||||
|
||||
public:
|
||||
std::chrono::milliseconds getLastStatRequestTime() const
|
||||
{
|
||||
RWLockGuard safeLock(lock, SafeRWLock_READ);
|
||||
return lastStatRequestTime;
|
||||
}
|
||||
|
||||
void setLastStatRequestTime(const std::chrono::milliseconds& time)
|
||||
{
|
||||
RWLockGuard safeLock(lock, SafeRWLock_WRITE);
|
||||
lastStatRequestTime = time;
|
||||
}
|
||||
|
||||
bool getIsResponding() const
|
||||
{
|
||||
RWLockGuard safeLock(lock, SafeRWLock_READ);
|
||||
return isResponding;
|
||||
}
|
||||
|
||||
void setIsResponding(bool isResponding)
|
||||
{
|
||||
RWLockGuard safeLock(lock, SafeRWLock_WRITE);
|
||||
this->isResponding = isResponding;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /*METANODEEX_H_*/
|
||||
6
mon/source/nodes/MgmtNodeEx.cpp
Normal file
6
mon/source/nodes/MgmtNodeEx.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "MgmtNodeEx.h"
|
||||
|
||||
MgmtNodeEx::MgmtNodeEx(std::string nodeID, NumNodeID nodeNumID, unsigned short portUDP,
|
||||
unsigned short portTCP, NicAddressList& nicList) :
|
||||
Node(NODETYPE_Mgmt, nodeID, nodeNumID, portUDP, portTCP, nicList)
|
||||
{}
|
||||
37
mon/source/nodes/MgmtNodeEx.h
Normal file
37
mon/source/nodes/MgmtNodeEx.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef MGMTNODEEX_H_
|
||||
#define MGMTNODEEX_H_
|
||||
|
||||
#include <common/nodes/Node.h>
|
||||
#include <common/Common.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
struct MgmtdNodeDataContent
|
||||
{
|
||||
bool isResponding;
|
||||
};
|
||||
|
||||
class MgmtNodeEx : public Node
|
||||
{
|
||||
public:
|
||||
MgmtNodeEx(std::string nodeID, NumNodeID nodeNumID, unsigned short portUDP,
|
||||
unsigned short portTCP, NicAddressList& nicList);
|
||||
|
||||
private:
|
||||
MgmtdNodeDataContent data;
|
||||
|
||||
public:
|
||||
MgmtdNodeDataContent getContent()
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
return this->data;
|
||||
}
|
||||
|
||||
void setContent(MgmtdNodeDataContent content)
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
this->data = content;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*MGMTNODEEX_H_*/
|
||||
38
mon/source/nodes/NodeStoreMetaEx.cpp
Normal file
38
mon/source/nodes/NodeStoreMetaEx.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "NodeStoreMetaEx.h"
|
||||
|
||||
#include <common/app/log/Logger.h>
|
||||
#include <nodes/MetaNodeEx.h>
|
||||
|
||||
NodeStoreMetaEx::NodeStoreMetaEx() :
|
||||
NodeStoreServers(NODETYPE_Meta, false)
|
||||
{}
|
||||
|
||||
NodeStoreResult NodeStoreMetaEx::addOrUpdateNodeEx(std::shared_ptr<Node> receivedNode,
|
||||
NumNodeID* outNodeNumID)
|
||||
{
|
||||
// sanity check: don't allow nodeNumID==0 (only mgmtd allows this)
|
||||
if (!receivedNode->getNumID())
|
||||
return NodeStoreResult::Error;
|
||||
|
||||
std::shared_ptr<MetaNodeEx> newNode;
|
||||
auto storedNode =
|
||||
std::static_pointer_cast<MetaNodeEx>(referenceNode(receivedNode->getNumID()));
|
||||
if (!storedNode)
|
||||
{
|
||||
// new node, create StorageNodeEx object with the parameters of the received node info
|
||||
newNode = std::make_shared<MetaNodeEx>(receivedNode);
|
||||
LOG(GENERAL, DEBUG, "Received new meta node.",
|
||||
("nodeNumID", receivedNode->getNumID().val()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// already stored node, create StorageNodeEx object with the parameters of the
|
||||
// received node info and keep the internal data
|
||||
newNode = std::make_shared<MetaNodeEx>(receivedNode, storedNode);
|
||||
LOG(GENERAL, DEBUG, "Received update for meta node.",
|
||||
("nodeNumID", receivedNode->getNumID().val()));
|
||||
}
|
||||
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
return addOrUpdateNodeUnlocked(std::move(newNode), nullptr);
|
||||
}
|
||||
16
mon/source/nodes/NodeStoreMetaEx.h
Normal file
16
mon/source/nodes/NodeStoreMetaEx.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef NODESTOREMETAEX_H_
|
||||
#define NODESTOREMETAEX_H_
|
||||
|
||||
#include <common/nodes/NodeStore.h>
|
||||
|
||||
class NodeStoreMetaEx : public NodeStoreServers
|
||||
{
|
||||
public:
|
||||
NodeStoreMetaEx();
|
||||
|
||||
virtual NodeStoreResult addOrUpdateNodeEx(std::shared_ptr<Node> receivedNode,
|
||||
NumNodeID* outNodeNumID) override;
|
||||
|
||||
};
|
||||
|
||||
#endif /*NODESTOREMETAEX_H_*/
|
||||
29
mon/source/nodes/NodeStoreMgmtEx.cpp
Normal file
29
mon/source/nodes/NodeStoreMgmtEx.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "NodeStoreMgmtEx.h"
|
||||
|
||||
NodeStoreMgmtEx::NodeStoreMgmtEx() :
|
||||
NodeStoreServers(NODETYPE_Mgmt, false)
|
||||
{}
|
||||
|
||||
NodeStoreResult NodeStoreMgmtEx::addOrUpdateNodeEx(std::shared_ptr<Node> node, NumNodeID* outNodeNumID)
|
||||
{
|
||||
std::string nodeID(node->getAlias());
|
||||
NumNodeID nodeNumID = node->getNumID();
|
||||
|
||||
// sanity check: don't allow nodeNumID==0 (only mgmtd allows this)
|
||||
if (!node->getNumID())
|
||||
return NodeStoreResult::Error;
|
||||
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
|
||||
// check if this is a new node
|
||||
auto iter = activeNodes.find(nodeNumID);
|
||||
if (iter == activeNodes.end() )
|
||||
{
|
||||
NicAddressList nicList = node->getNicList();
|
||||
|
||||
node = boost::make_unique<MgmtNodeEx>(nodeID, nodeNumID, node->getPortUDP(),
|
||||
node->getPortTCP(), nicList);
|
||||
}
|
||||
|
||||
return addOrUpdateNodeUnlocked(std::move(node), outNodeNumID);
|
||||
}
|
||||
15
mon/source/nodes/NodeStoreMgmtEx.h
Normal file
15
mon/source/nodes/NodeStoreMgmtEx.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef NODESTOREMGMTDEX_H_
|
||||
#define NODESTOREMGMTDEX_H_
|
||||
|
||||
#include <common/nodes/NodeStore.h>
|
||||
#include <nodes/MgmtNodeEx.h>
|
||||
|
||||
class NodeStoreMgmtEx : public NodeStoreServers
|
||||
{
|
||||
public:
|
||||
NodeStoreMgmtEx();
|
||||
|
||||
virtual NodeStoreResult addOrUpdateNodeEx(std::shared_ptr<Node> node, NumNodeID* outNodeNumID) override;
|
||||
};
|
||||
|
||||
#endif /*NODESTOREMGMTDEX_H_*/
|
||||
38
mon/source/nodes/NodeStoreStorageEx.cpp
Normal file
38
mon/source/nodes/NodeStoreStorageEx.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "NodeStoreStorageEx.h"
|
||||
|
||||
#include <common/app/log/Logger.h>
|
||||
#include <nodes/StorageNodeEx.h>
|
||||
|
||||
NodeStoreStorageEx::NodeStoreStorageEx() :
|
||||
NodeStoreServers(NODETYPE_Storage, false)
|
||||
{}
|
||||
|
||||
NodeStoreResult NodeStoreStorageEx::addOrUpdateNodeEx(std::shared_ptr<Node> receivedNode,
|
||||
NumNodeID* outNodeNumID)
|
||||
{
|
||||
// sanity check: don't allow nodeNumID==0 (only mgmtd allows this)
|
||||
if (!receivedNode->getNumID())
|
||||
return NodeStoreResult::Error;
|
||||
|
||||
std::shared_ptr<StorageNodeEx> newNode;
|
||||
auto storedNode =
|
||||
std::static_pointer_cast<StorageNodeEx>(referenceNode(receivedNode->getNumID()));
|
||||
if (!storedNode)
|
||||
{
|
||||
// new node, create StorageNodeEx object with the parameters of the received node info
|
||||
newNode = std::make_shared<StorageNodeEx>(receivedNode);
|
||||
LOG(GENERAL, DEBUG, "Received new storage node.",
|
||||
("nodeNumID", receivedNode->getNumID().val()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// already stored node, create StorageNodeEx object with the parameters of the
|
||||
// received node info and keep the internal data
|
||||
newNode = std::make_shared<StorageNodeEx>(receivedNode, storedNode);
|
||||
LOG(GENERAL, DEBUG, "Received update for storage node.",
|
||||
("nodeNumID", receivedNode->getNumID().val()));
|
||||
}
|
||||
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
return addOrUpdateNodeUnlocked(std::move(newNode), outNodeNumID);
|
||||
}
|
||||
15
mon/source/nodes/NodeStoreStorageEx.h
Normal file
15
mon/source/nodes/NodeStoreStorageEx.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef NODESTORESTORAGEEX_H_
|
||||
#define NODESTORESTORAGEEX_H_
|
||||
|
||||
#include <common/nodes/NodeStore.h>
|
||||
|
||||
class NodeStoreStorageEx : public NodeStoreServers
|
||||
{
|
||||
public:
|
||||
NodeStoreStorageEx();
|
||||
|
||||
virtual NodeStoreResult addOrUpdateNodeEx(std::shared_ptr<Node> receivedNode,
|
||||
NumNodeID* outNodeNumID) override;
|
||||
};
|
||||
|
||||
#endif /*NODESTORESTORAGEEX_H_*/
|
||||
18
mon/source/nodes/StorageNodeEx.cpp
Normal file
18
mon/source/nodes/StorageNodeEx.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "StorageNodeEx.h"
|
||||
|
||||
StorageNodeEx::StorageNodeEx(std::shared_ptr<Node> receivedNode) :
|
||||
Node(NODETYPE_Storage, receivedNode->getAlias(), receivedNode->getNumID(),
|
||||
receivedNode->getPortUDP(), receivedNode->getPortTCP(),
|
||||
receivedNode->getConnPool()->getNicList()),
|
||||
isResponding(true)
|
||||
{}
|
||||
|
||||
StorageNodeEx::StorageNodeEx(std::shared_ptr<Node> receivedNode,
|
||||
std::shared_ptr<StorageNodeEx> oldNode) :
|
||||
Node(NODETYPE_Storage, receivedNode->getAlias(), receivedNode->getNumID(),
|
||||
receivedNode->getPortUDP(), receivedNode->getPortTCP(),
|
||||
receivedNode->getConnPool()->getNicList())
|
||||
{
|
||||
setLastStatRequestTime(oldNode->getLastStatRequestTime());
|
||||
setIsResponding(oldNode->getIsResponding());
|
||||
}
|
||||
61
mon/source/nodes/StorageNodeEx.h
Normal file
61
mon/source/nodes/StorageNodeEx.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef STORAGENODEEX_H_
|
||||
#define STORAGENODEEX_H_
|
||||
|
||||
#include <common/nodes/Node.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/threading/RWLockGuard.h>
|
||||
|
||||
struct StorageNodeDataContent
|
||||
{
|
||||
bool isResponding;
|
||||
|
||||
unsigned indirectWorkListSize;
|
||||
unsigned directWorkListSize;
|
||||
|
||||
int64_t diskSpaceTotal;
|
||||
int64_t diskSpaceFree;
|
||||
int64_t diskRead;
|
||||
int64_t diskWrite;
|
||||
|
||||
unsigned sessionCount;
|
||||
std::string hostnameid;
|
||||
};
|
||||
|
||||
class StorageNodeEx : public Node
|
||||
{
|
||||
public:
|
||||
StorageNodeEx(std::shared_ptr<Node> receivedNode);
|
||||
StorageNodeEx(std::shared_ptr<Node> receivedNode, std::shared_ptr<StorageNodeEx> oldNode);
|
||||
|
||||
private:
|
||||
mutable RWLock lock;
|
||||
bool isResponding;
|
||||
std::chrono::milliseconds lastStatRequestTime{0};
|
||||
|
||||
public:
|
||||
std::chrono::milliseconds getLastStatRequestTime() const
|
||||
{
|
||||
RWLockGuard safeLock(lock, SafeRWLock_READ);
|
||||
return lastStatRequestTime;
|
||||
}
|
||||
|
||||
void setLastStatRequestTime(const std::chrono::milliseconds& time)
|
||||
{
|
||||
RWLockGuard safeLock(lock, SafeRWLock_READ);
|
||||
lastStatRequestTime = time;
|
||||
}
|
||||
|
||||
bool getIsResponding() const
|
||||
{
|
||||
RWLockGuard safeLock(lock, SafeRWLock_READ);
|
||||
return isResponding;
|
||||
}
|
||||
|
||||
void setIsResponding(bool isResponding)
|
||||
{
|
||||
RWLockGuard safeLock(lock, SafeRWLock_READ);
|
||||
this->isResponding = isResponding;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*STORAGENODEEX_H_*/
|
||||
Reference in New Issue
Block a user