New upstream version 8.1.0
This commit is contained in:
125
fsck/source/net/message/NetMessageFactory.cpp
Normal file
125
fsck/source/net/message/NetMessageFactory.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
// control messages
|
||||
#include <common/net/message/control/GenericResponseMsg.h>
|
||||
|
||||
// fsck messages
|
||||
#include <common/net/message/fsck/AdjustChunkPermissionsRespMsg.h>
|
||||
#include <common/net/message/fsck/CreateDefDirInodesRespMsg.h>
|
||||
#include <common/net/message/fsck/CreateEmptyContDirsRespMsg.h>
|
||||
#include <common/net/message/fsck/DeleteChunksRespMsg.h>
|
||||
#include <common/net/message/fsck/DeleteDirEntriesRespMsg.h>
|
||||
#include <common/net/message/fsck/FetchFsckChunkListRespMsg.h>
|
||||
#include <common/net/message/fsck/FsckSetEventLoggingRespMsg.h>
|
||||
#include <common/net/message/fsck/FixInodeOwnersInDentryRespMsg.h>
|
||||
#include <common/net/message/fsck/FixInodeOwnersRespMsg.h>
|
||||
#include <common/net/message/fsck/FsckSetEventLoggingRespMsg.h>
|
||||
#include <common/net/message/fsck/LinkToLostAndFoundRespMsg.h>
|
||||
#include <common/net/message/fsck/MoveChunkFileRespMsg.h>
|
||||
#include <common/net/message/fsck/RecreateDentriesRespMsg.h>
|
||||
#include <common/net/message/fsck/RecreateFsIDsRespMsg.h>
|
||||
#include <common/net/message/fsck/RemoveInodesRespMsg.h>
|
||||
#include <common/net/message/fsck/RetrieveDirEntriesRespMsg.h>
|
||||
#include <common/net/message/fsck/RetrieveFsIDsRespMsg.h>
|
||||
#include <common/net/message/fsck/RetrieveInodesRespMsg.h>
|
||||
#include <common/net/message/fsck/UpdateDirAttribsRespMsg.h>
|
||||
#include <common/net/message/fsck/UpdateFileAttribsRespMsg.h>
|
||||
#include <net/message/fsck/FsckModificationEventMsgEx.h>
|
||||
#include <common/net/message/fsck/CheckAndRepairDupInodeRespMsg.h>
|
||||
|
||||
// nodes messages
|
||||
#include <common/net/message/nodes/GetMirrorBuddyGroupsRespMsg.h>
|
||||
#include <common/net/message/nodes/GetNodesRespMsg.h>
|
||||
#include <common/net/message/nodes/GetTargetMappingsRespMsg.h>
|
||||
#include <common/net/message/nodes/GetTargetStatesRespMsg.h>
|
||||
#include <common/net/message/nodes/SetTargetConsistencyStatesRespMsg.h>
|
||||
#include <net/message/nodes/HeartbeatMsgEx.h>
|
||||
|
||||
// storage messages
|
||||
#include <common/net/message/storage/attribs/GetEntryInfoRespMsg.h>
|
||||
#include <common/net/message/storage/attribs/SetLocalAttrRespMsg.h>
|
||||
#include <common/net/message/storage/attribs/StatRespMsg.h>
|
||||
#include <common/net/message/storage/creating/MkDirRespMsg.h>
|
||||
#include <common/net/message/storage/creating/RmDirEntryRespMsg.h>
|
||||
#include <common/net/message/storage/creating/UnlinkFileRespMsg.h>
|
||||
#include <common/net/message/storage/listing/ListDirFromOffsetRespMsg.h>
|
||||
#include <common/net/message/storage/lookup/FindOwnerRespMsg.h>
|
||||
#include <common/net/message/storage/StatStoragePathRespMsg.h>
|
||||
#include <common/net/message/storage/creating/MoveFileInodeRespMsg.h>
|
||||
|
||||
// general includes
|
||||
#include <common/net/message/SimpleMsg.h>
|
||||
#include <net/message/testing/DummyMsgEx.h>
|
||||
|
||||
#include "NetMessageFactory.h"
|
||||
|
||||
/**
|
||||
* @return NetMessage that must be deleted by the caller
|
||||
* (msg->msgType is NETMSGTYPE_Invalid on error)
|
||||
*/
|
||||
std::unique_ptr<NetMessage> NetMessageFactory::createFromMsgType(unsigned short msgType) const
|
||||
{
|
||||
NetMessage* msg;
|
||||
|
||||
switch(msgType)
|
||||
{
|
||||
// The following lines are grouped by "type of the message" and ordered alphabetically inside
|
||||
// the groups. There should always be one message per line to keep a clear layout (although
|
||||
// this might lead to lines that are longer than usual)
|
||||
|
||||
// control messages
|
||||
case NETMSGTYPE_GenericResponse: { msg = new GenericResponseMsg(); } break;
|
||||
|
||||
// nodes messages
|
||||
case NETMSGTYPE_GetNodesResp: { msg = new GetNodesRespMsg(); } break;
|
||||
case NETMSGTYPE_Heartbeat: { msg = new HeartbeatMsgEx(); } break;
|
||||
case NETMSGTYPE_GetMirrorBuddyGroupsResp: { msg = new GetMirrorBuddyGroupsRespMsg(); } break;
|
||||
case NETMSGTYPE_GetTargetMappingsResp: { msg = new GetTargetMappingsRespMsg(); } break;
|
||||
case NETMSGTYPE_GetTargetStatesResp: { msg = new GetTargetStatesRespMsg(); } break;
|
||||
case NETMSGTYPE_SetTargetConsistencyStatesResp: { msg = new SetTargetConsistencyStatesRespMsg(); } break;
|
||||
|
||||
// storage messages
|
||||
case NETMSGTYPE_FindOwnerResp: { msg = new FindOwnerRespMsg(); } break;
|
||||
case NETMSGTYPE_ListDirFromOffsetResp: { msg = new ListDirFromOffsetRespMsg(); } break;
|
||||
case NETMSGTYPE_RmDirEntryResp: { msg = new RmDirEntryRespMsg(); } break;
|
||||
case NETMSGTYPE_GetEntryInfoResp: { msg = new GetEntryInfoRespMsg(); } break;
|
||||
case NETMSGTYPE_StatResp: { msg = new StatRespMsg(); } break;
|
||||
case NETMSGTYPE_StatStoragePathResp: { msg = new StatStoragePathRespMsg(); } break;
|
||||
case NETMSGTYPE_MkDirResp: { msg = new MkDirRespMsg(); } break;
|
||||
case NETMSGTYPE_SetLocalAttrResp: { msg = new SetLocalAttrRespMsg(); } break;
|
||||
case NETMSGTYPE_UnlinkFileResp: { msg = new UnlinkFileRespMsg(); } break;
|
||||
case NETMSGTYPE_MoveFileInodeResp: {msg = new MoveFileInodeRespMsg(); } break;
|
||||
|
||||
//fsck
|
||||
case NETMSGTYPE_RetrieveDirEntriesResp: { msg = new RetrieveDirEntriesRespMsg(); } break;
|
||||
case NETMSGTYPE_RetrieveInodesResp: { msg = new RetrieveInodesRespMsg(); } break;
|
||||
case NETMSGTYPE_RetrieveFsIDsResp: { msg = new RetrieveFsIDsRespMsg(); } break;
|
||||
case NETMSGTYPE_DeleteDirEntriesResp: { msg = new DeleteDirEntriesRespMsg(); } break;
|
||||
case NETMSGTYPE_CreateDefDirInodesResp: { msg = new CreateDefDirInodesRespMsg(); } break;
|
||||
case NETMSGTYPE_FixInodeOwnersResp: { msg = new FixInodeOwnersRespMsg(); } break;
|
||||
case NETMSGTYPE_FixInodeOwnersInDentryResp: { msg = new FixInodeOwnersInDentryRespMsg(); } break;
|
||||
case NETMSGTYPE_LinkToLostAndFoundResp : { msg = new LinkToLostAndFoundRespMsg(); } break;
|
||||
case NETMSGTYPE_DeleteChunksResp: { msg = new DeleteChunksRespMsg(); } break;
|
||||
case NETMSGTYPE_CreateEmptyContDirsResp: { msg = new CreateEmptyContDirsRespMsg(); } break;
|
||||
case NETMSGTYPE_UpdateFileAttribsResp: { msg = new UpdateFileAttribsRespMsg(); } break;
|
||||
case NETMSGTYPE_UpdateDirAttribsResp: { msg = new UpdateDirAttribsRespMsg(); } break;
|
||||
case NETMSGTYPE_RecreateFsIDsResp: { msg = new RecreateFsIDsRespMsg(); } break;
|
||||
case NETMSGTYPE_RecreateDentriesResp: { msg = new RecreateDentriesRespMsg(); } break;
|
||||
case NETMSGTYPE_FsckSetEventLoggingResp: { msg = new FsckSetEventLoggingRespMsg(); } break;
|
||||
case NETMSGTYPE_FsckModificationEvent: { msg = new FsckModificationEventMsgEx(); } break;
|
||||
case NETMSGTYPE_AdjustChunkPermissionsResp: { msg = new AdjustChunkPermissionsRespMsg(); } break;
|
||||
case NETMSGTYPE_FetchFsckChunkListResp: { msg = new FetchFsckChunkListRespMsg(); } break;
|
||||
case NETMSGTYPE_MoveChunkFileResp: { msg = new MoveChunkFileRespMsg(); } break;
|
||||
case NETMSGTYPE_RemoveInodesResp: { msg = new RemoveInodesRespMsg(); } break;
|
||||
case NETMSGTYPE_CheckAndRepairDupInodeResp: { msg = new CheckAndRepairDupInodeRespMsg(); } break;
|
||||
|
||||
//testing
|
||||
case NETMSGTYPE_Dummy: { msg = new DummyMsgEx(); } break;
|
||||
|
||||
default:
|
||||
{
|
||||
msg = new SimpleMsg(NETMSGTYPE_Invalid);
|
||||
} break;
|
||||
}
|
||||
|
||||
return std::unique_ptr<NetMessage>(msg);
|
||||
}
|
||||
|
||||
16
fsck/source/net/message/NetMessageFactory.h
Normal file
16
fsck/source/net/message/NetMessageFactory.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef NETMESSAGEFACTORY_H_
|
||||
#define NETMESSAGEFACTORY_H_
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/net/message/AbstractNetMessageFactory.h>
|
||||
|
||||
class NetMessageFactory : public AbstractNetMessageFactory
|
||||
{
|
||||
public:
|
||||
NetMessageFactory() {}
|
||||
|
||||
protected:
|
||||
virtual std::unique_ptr<NetMessage> createFromMsgType(unsigned short msgType) const override;
|
||||
} ;
|
||||
|
||||
#endif /*NETMESSAGEFACTORY_H_*/
|
||||
26
fsck/source/net/message/fsck/FsckModificationEventMsgEx.cpp
Normal file
26
fsck/source/net/message/fsck/FsckModificationEventMsgEx.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <program/Program.h>
|
||||
|
||||
#include "FsckModificationEventMsgEx.h"
|
||||
|
||||
bool FsckModificationEventMsgEx::processIncoming(ResponseContext& ctx)
|
||||
{
|
||||
LogContext log("FsckModificationEventMsg incoming");
|
||||
|
||||
App* app = Program::getApp();
|
||||
ModificationEventHandler *eventHandler = app->getModificationEventHandler();
|
||||
|
||||
StringList& entryIDList = this->getEntryIDList();
|
||||
|
||||
bool addRes = eventHandler->add(getModificationEventTypeList(), entryIDList);
|
||||
if (!addRes)
|
||||
{
|
||||
log.logErr("Unable to add modification event to database");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ackRes = acknowledge(ctx);
|
||||
if (!ackRes)
|
||||
log.logErr("Unable to send ack to metadata server");
|
||||
|
||||
return true;
|
||||
}
|
||||
12
fsck/source/net/message/fsck/FsckModificationEventMsgEx.h
Normal file
12
fsck/source/net/message/fsck/FsckModificationEventMsgEx.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef FSCKMODIFICATIONEVENTMSGEX_H
|
||||
#define FSCKMODIFICATIONEVENTMSGEX_H
|
||||
|
||||
#include <common/net/message/fsck/FsckModificationEventMsg.h>
|
||||
|
||||
class FsckModificationEventMsgEx : public FsckModificationEventMsg
|
||||
{
|
||||
public:
|
||||
virtual bool processIncoming(ResponseContext& ctx);
|
||||
};
|
||||
|
||||
#endif /*FSCKMODIFICATIONEVENTMSGEX_H*/
|
||||
102
fsck/source/net/message/nodes/HeartbeatMsgEx.cpp
Normal file
102
fsck/source/net/message/nodes/HeartbeatMsgEx.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
#include <common/net/sock/NetworkInterfaceCard.h>
|
||||
#include <program/Program.h>
|
||||
#include "HeartbeatMsgEx.h"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
bool HeartbeatMsgEx::processIncoming(ResponseContext& ctx)
|
||||
{
|
||||
LogContext log("Heartbeat incoming");
|
||||
|
||||
App* app = Program::getApp();
|
||||
|
||||
bool isNodeNew;
|
||||
|
||||
// construct node
|
||||
NicAddressList& nicList = getNicList();
|
||||
|
||||
auto node = std::make_shared<Node>(getNodeType(), getNodeID(), getNodeNumID(), getPortUDP(),
|
||||
getPortTCP(), nicList);
|
||||
|
||||
// set local nic capabilities
|
||||
Node& localNode = app->getLocalNode();
|
||||
NicAddressList localNicList(localNode.getNicList());
|
||||
NicListCapabilities localNicCaps;
|
||||
|
||||
NetworkInterfaceCard::supportedCapabilities(&localNicList, &localNicCaps);
|
||||
node->getConnPool()->setLocalNicList(localNicList, localNicCaps);
|
||||
|
||||
std::string nodeIDWithTypeStr = node->getNodeIDWithTypeStr();
|
||||
|
||||
|
||||
// add/update node in store
|
||||
NodeStore* nodes = NULL;
|
||||
|
||||
switch(getNodeType() )
|
||||
{
|
||||
case NODETYPE_Meta:
|
||||
nodes = app->getMetaNodes(); break;
|
||||
|
||||
case NODETYPE_Storage:
|
||||
nodes = app->getStorageNodes(); break;
|
||||
|
||||
|
||||
case NODETYPE_Mgmt:
|
||||
nodes = app->getMgmtNodes(); break;
|
||||
|
||||
default:
|
||||
{
|
||||
LOG(GENERAL, ERR, "Invalid node type.",
|
||||
("Node Type", getNodeType()),
|
||||
("Sender", ctx.peerName()),
|
||||
("NodeID", getNodeNumID()),
|
||||
("Port (UDP)", getPortUDP()),
|
||||
("Port (TCP)", getPortTCP())
|
||||
);
|
||||
|
||||
goto ack_resp;
|
||||
} break;
|
||||
}
|
||||
|
||||
|
||||
isNodeNew = (nodes->addOrUpdateNode(std::move(node)) == NodeStoreResult::Added);
|
||||
if(isNodeNew)
|
||||
{
|
||||
bool supportsRDMA = NetworkInterfaceCard::supportsRDMA(&nicList);
|
||||
|
||||
log.log(Log_WARNING, std::string("New node: ") +
|
||||
nodeIDWithTypeStr + "; " +
|
||||
std::string(supportsRDMA ? "RDMA; " : "") +
|
||||
std::string("Source: ") + ctx.peerName() );
|
||||
|
||||
log.log(Log_DEBUG, std::string("Number of nodes in the system: ") +
|
||||
StringTk::intToStr(nodes->getSize() ) +
|
||||
std::string(" (Type: ") + boost::lexical_cast<std::string>(getNodeType()) + ")");
|
||||
}
|
||||
|
||||
|
||||
processIncomingRoot();
|
||||
|
||||
ack_resp:
|
||||
acknowledge(ctx);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the contained root information.
|
||||
*/
|
||||
void HeartbeatMsgEx::processIncomingRoot()
|
||||
{
|
||||
LogContext log("Heartbeat incoming");
|
||||
|
||||
// check whether root info is defined
|
||||
if( (getNodeType() != NODETYPE_Meta) || !getRootNumID() )
|
||||
return;
|
||||
|
||||
// try to apply the contained root info
|
||||
if(Program::getApp()->getMetaRoot().setIfDefault(getRootNumID(), getRootIsBuddyMirrored()))
|
||||
{
|
||||
log.log(Log_CRITICAL, "Root (by Heartbeat): " + getRootNumID().str() );
|
||||
}
|
||||
}
|
||||
15
fsck/source/net/message/nodes/HeartbeatMsgEx.h
Normal file
15
fsck/source/net/message/nodes/HeartbeatMsgEx.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef HEARTBEATMSGEX_H_
|
||||
#define HEARTBEATMSGEX_H_
|
||||
|
||||
#include <common/net/message/nodes/HeartbeatMsg.h>
|
||||
|
||||
class HeartbeatMsgEx : public HeartbeatMsg
|
||||
{
|
||||
public:
|
||||
virtual bool processIncoming(ResponseContext& ctx);
|
||||
|
||||
private:
|
||||
void processIncomingRoot();
|
||||
};
|
||||
|
||||
#endif /*HEARTBEATMSGEX_H_*/
|
||||
9
fsck/source/net/message/testing/DummyMsgEx.cpp
Normal file
9
fsck/source/net/message/testing/DummyMsgEx.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <program/Program.h>
|
||||
#include "DummyMsgEx.h"
|
||||
|
||||
bool DummyMsgEx::processIncoming(ResponseContext& ctx)
|
||||
{
|
||||
ctx.sendResponse(DummyMsg() );
|
||||
|
||||
return true;
|
||||
}
|
||||
20
fsck/source/net/message/testing/DummyMsgEx.h
Normal file
20
fsck/source/net/message/testing/DummyMsgEx.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef DUMMYMSGEX_H
|
||||
#define DUMMYMSGEX_H
|
||||
|
||||
#include <common/net/message/control/DummyMsg.h>
|
||||
|
||||
/*
|
||||
* this is intended for testing purposes only
|
||||
* just sends another DummyMsg back to the sender
|
||||
*/
|
||||
|
||||
class DummyMsgEx : public DummyMsg
|
||||
{
|
||||
public:
|
||||
virtual bool processIncoming(ResponseContext& ctx);
|
||||
|
||||
private:
|
||||
void processIncomingRoot();
|
||||
};
|
||||
|
||||
#endif /*DUMMYMSGEX_H*/
|
||||
Reference in New Issue
Block a user