Esempio n. 1
0
bool GetNodeInfoMsgEx::processIncoming(struct sockaddr_in* fromAddr, Socket* sock, char* respBuf,
   size_t bufLen, HighResolutionStats* stats)
{
   LogContext log("GetNodeInfoMsg incoming");

   std::string peer = fromAddr ? Socket::ipaddrToStr(&fromAddr->sin_addr) : sock->getPeername();
   LOG_DEBUG_CONTEXT(log, 4, std::string("Received a GetNodeInfoMsg") + peer);

   GeneralNodeInfo info;

   App *app = Program::getApp();

   getCPUInfo(&(info.cpuName), &(info.cpuSpeed), &(info.cpuCount));
   getMemInfo(&(info.memTotal), &(info.memFree));
   info.logFilePath = app->getConfig()->getLogStdFile();

   Node *localNode = app->getLocalNode();
   std::string nodeID = localNode->getID();
   uint16_t nodeNumID = localNode->getNumID();

   GetNodeInfoRespMsg getNodeInfoRespMsg(nodeID.c_str(), nodeNumID, info);
   getNodeInfoRespMsg.serialize(respBuf, bufLen);
   sock->sendto(respBuf, getNodeInfoRespMsg.getMsgLength(), 0, (struct sockaddr*) fromAddr,
      sizeof(struct sockaddr_in));

   LOG_DEBUG_CONTEXT(log, 5, std::string("Sent a message with type: " ) + StringTk::uintToStr(
         getNodeInfoRespMsg.getMsgType() ) + std::string(" to admon"));

   app->getClientOpStats()->updateNodeOp(sock->getPeerIP(), MetaOpCounter_GETNODEINFO);

   return true;
}
bool StatStoragePathMsgEx::processIncoming(struct sockaddr_in* fromAddr, Socket* sock,
   char* respBuf, size_t bufLen, HighResolutionStats* stats)
{
   LogContext log("StatStoragePathMsgEx incoming");

   std::string peer = fromAddr ? Socket::ipaddrToStr(&fromAddr->sin_addr) : sock->getPeername(); 
   LOG_DEBUG_CONTEXT(log, 4, std::string("Received a StatStoragePathMsg from: ") + peer);

   int64_t sizeTotal = 0;
   int64_t sizeFree = 0;
   int64_t inodesTotal = 0;
   int64_t inodesFree = 0;
   
   FhgfsOpsErr statRes = statStoragePath(&sizeTotal, &sizeFree, &inodesTotal, &inodesFree);

   StatStoragePathRespMsg respMsg(statRes, sizeTotal, sizeFree, inodesTotal, inodesFree);
   respMsg.serialize(respBuf, bufLen);
   sock->sendto(respBuf, respMsg.getMsgLength(), 0,
      (struct sockaddr*)fromAddr, sizeof(struct sockaddr_in) );

   App* app = Program::getApp();
   app->getClientOpStats()->updateNodeOp(sock->getPeerIP(), MetaOpCounter_STATFS);

   return true;      
}
Esempio n. 3
0
bool GetEntryInfoMsgEx::processIncoming(struct sockaddr_in* fromAddr, Socket* sock,
   char* respBuf, size_t bufLen, HighResolutionStats* stats)
{
   #ifdef FHGFS_DEBUG
      const char* logContext = "GetEntryInfoMsg incoming";

      std::string peer = fromAddr ? Socket::ipaddrToStr(&fromAddr->sin_addr) : sock->getPeername();
      LOG_DEBUG(logContext, 4, std::string("Received a GetEntryInfoMsg from: ") + peer);
   #endif // FHGFS_DEBUG

   EntryInfo* entryInfo = this->getEntryInfo();
   LOG_DEBUG(logContext, 5, std::string("ParentEntryID: ") + entryInfo->getParentEntryID() +
      " entryID: " + entryInfo->getParentEntryID() );
   
   StripePattern* pattern = NULL;   
   FhgfsOpsErr getInfoRes;

   
   if(entryInfo->getEntryID().length() == 0 ) // FIXME Bernd: Test
   { // special case: get info for root directory
      getInfoRes = getInfoRoot(&pattern);
   }
   else
   {
      getInfoRes = getInfoRec(entryInfo, &pattern);
   }
   
   
   if(getInfoRes != FhgfsOpsErr_SUCCESS)
   { // error occurred => create a dummy pattern
      UInt16Vector dummyStripeNodes;
      pattern = new Raid0Pattern(1, dummyStripeNodes);
   }

   
   GetEntryInfoRespMsg respMsg(getInfoRes, pattern);
   respMsg.serialize(respBuf, bufLen);
   sock->sendto(respBuf, respMsg.getMsgLength(), 0,
      (struct sockaddr*)fromAddr, sizeof(struct sockaddr_in) );

   // cleanup
   delete(pattern);

   App* app = Program::getApp();
   app->getClientOpStats()->updateNodeOp(sock->getPeerIP(), MetaOpCounter_GETENTRYINFO);

   return true;      
}