当前位置: 首页>>代码示例>>C++>>正文


C++ Slave::closeLibrary方法代码示例

本文整理汇总了C++中Slave::closeLibrary方法的典型用法代码示例。如果您正苦于以下问题:C++ Slave::closeLibrary方法的具体用法?C++ Slave::closeLibrary怎么用?C++ Slave::closeLibrary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slave的用法示例。


在下文中一共展示了Slave::closeLibrary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SPEHandler


//.........这里部分代码省略.........
         }
      }

      // if buckets = 0, send back to clients, otherwise deliver to local or network locations
      if ((buckets != 0) && (progress >= 0))
         deliverystatus = self->deliverResult(buckets, result, dest);

      if (deliverystatus < 0)
         progress = SectorError::E_SPEWRITE;
      else
         progress = 100;

      self->m_SectorLog << LogStart(LogLevel::LEVEL_3) << "SPE completed " << progress << " " << ip << " " << ctrlport << LogEnd();

      msg.setData(4, (char*)&progress, 4);

      if (100 == progress)
      {
         msg.m_iDataLength = SectorMsg::m_iHdrSize + 8;
         int id = 0;
         self->m_GMP.sendto(ip.c_str(), ctrlport, id, &msg);

         self->sendResultToClient(buckets, dest.m_piSArray, dest.m_piRArray, result, ip, dataport, transid);
         dest.reset(buckets);

         // report new files
         vector<string> filelist;
         for (set<string>::iterator i = file.m_sstrFiles.begin(); i != file.m_sstrFiles.end(); ++ i)
            filelist.push_back(*i);
         self->report(master_ip, master_port, transid, filelist, +FileChangeType::FILE_UPDATE_NEW);
         self->reportMO(master_ip, master_port, transid);
      }
      else
      {
         msg.setData(8, (char*)&processstatus, 4);
         msg.m_iDataLength = SectorMsg::m_iHdrSize + 12;
         if (output.m_strError.length() > 0)
            msg.setData(12, output.m_strError.c_str(), output.m_strError.length() + 1);
         else if (deliverystatus < 0)
         {
            string tmp = "System Error: data transfer to buckets failed.";
            msg.setData(12, tmp.c_str(), tmp.length() + 1);
         }

         int id = 0;
         self->m_GMP.sendto(ip.c_str(), ctrlport, id, &msg);
      }

      delete [] index;
      delete [] block;
      delete [] output.m_pcResult;
      delete [] output.m_pllIndex;
      delete [] output.m_piBucketID;
      index = NULL;
      block = NULL;
   }

   gettimeofday(&t2, 0);
   int duration = t2.tv_sec - t1.tv_sec;
   self->m_SectorLog << LogStart(LogLevel::LEVEL_3) << "comp server closed " << ip << " " << ctrlport << " " << duration << LogEnd();

   delete [] param;

   vector<Address> bad;

   if (init_success)
   {
      self->closeLibrary(lh);

      multimap<int64_t, Address> sndspd;
      for (int i = 0; i < dest.m_iLocNum; ++ i)
      {
         Address addr;
         addr.m_strIP = dest.m_pcOutputLoc + i * 80;
         addr.m_iPort = *(int32_t*)(dest.m_pcOutputLoc + i * 80 + 64);
         int dataport = *(int32_t*)(dest.m_pcOutputLoc + i * 80 + 68);
         int64_t spd = self->m_DataChn.getRealSndSpeed(addr.m_strIP, dataport);
         if (spd > 0)
            sndspd.insert(pair<int64_t, Address>(spd, addr));
      }
      vector<Address> bad;
      self->checkBadDest(sndspd, bad);
   }
   else
   {
      // this SPE failed to initialize. send the error to the client
      int progress = SectorError::E_SPEUDF;
      msg.setData(4, (char*)&progress, 4);
      msg.m_iDataLength = SectorMsg::m_iHdrSize + 8;
      int id = 0;
      self->m_GMP.sendto(ip.c_str(), ctrlport, id, &msg);
   }

   self->reportSphere(master_ip, master_port, transid, &bad);

   // clear this transaction
   self->m_TransManager.updateSlave(transid, self->m_iSlaveID);

   return NULL;
}
开发者ID:norouzi4d,项目名称:sector,代码行数:101,代码来源:serv_spe.cpp

示例2: SPEShufflerEx


//.........这里部分代码省略.........
      while (bq->empty())
         bqcond->wait(*bqlock);
      Bucket b = bq->front();
      bq->pop();
      *pendingSize -= b.totalsize;
      bqlock->release();

      if (b.totalnum == -1)
         break;

      string speip = b.src_ip;
      int dataport = b.src_dataport;
      int session = b.session;

      for (int i = 0; i < b.totalnum; ++ i)
      {
         int bucket = 0;
         if (self->m_DataChn.recv4(speip, dataport, session, bucket) < 0)
            continue;

         fileid.insert(bucket);

         char* tmp = new char[self->m_strHomeDir.length() + path.length() + localfile.length() + 64];
         sprintf(tmp, "%s.%d", (self->m_strHomeDir + path + "/" + localfile).c_str(), bucket);
         fstream datafile(tmp, ios::out | ios::binary | ios::app);
         sprintf(tmp, "%s.%d.idx", (self->m_strHomeDir + path + "/" + localfile).c_str(), bucket);
         fstream indexfile(tmp, ios::out | ios::binary | ios::app);
         delete [] tmp;
         int64_t start = offset[bucket];
         if (0 == start)
            indexfile.write((char*)&start, 8);

         int32_t len;
         char* data = NULL;
         if (self->m_DataChn.recv(speip, dataport, session, data, len) < 0)
            continue;
         datafile.write(data, len);
         delete [] data;

         tmp = NULL;
         if (self->m_DataChn.recv(speip, dataport, session, tmp, len) < 0)
            continue;
         int64_t* index = (int64_t*)tmp;
         for (int j = 0; j < len / 8; ++ j)
            index[j] += start;
         offset[bucket] = index[len / 8 - 1];
         indexfile.write(tmp, len);
         delete [] tmp;

         datafile.close();
         indexfile.close();
      }

      // update total received data
      self->m_SlaveStat.updateIO(speip, b.totalsize, +SlaveStat::SYS_IN);
   }

   // sort and reduce
   if (type == 1)
   {
      void* lh = NULL;
      self->openLibrary(key, function, lh);

      if (NULL != lh)
      {
         MR_COMPARE comp = NULL;
         MR_REDUCE reduce = NULL;
         self->getReduceFunc(lh, function, comp, reduce);

         if (NULL != comp)
         {
            char* tmp = new char[self->m_strHomeDir.length() + path.length() + localfile.length() + 64];
            for (set<int>::iterator i = fileid.begin(); i != fileid.end(); ++ i)
            {
               sprintf(tmp, "%s.%d", (self->m_strHomeDir + path + "/" + localfile).c_str(), *i);
               self->sort(tmp, comp, reduce);
            }
            delete [] tmp;
         }

         self->closeLibrary(lh);
      }
   }

   // report sphere output files
   char* tmp = new char[path.length() + localfile.length() + 64];
   vector<string> filelist;
   for (set<int>::iterator i = fileid.begin(); i != fileid.end(); ++ i)
   {
      sprintf(tmp, "%s.%d", (path + "/" + localfile).c_str(), *i);
      filelist.push_back(tmp);
      sprintf(tmp, "%s.%d.idx", (path + "/" + localfile).c_str(), *i);
      filelist.push_back(tmp);
   }
   delete [] tmp;

   self->report(master_ip, master_port, transid, filelist, 1);

   return NULL;
}
开发者ID:norouzi4d,项目名称:sector,代码行数:101,代码来源:serv_spe.cpp

示例3: SPEShufflerEx


//.........这里部分代码省略.........

         char* tmp = new char[self->m_strHomeDir.length() + path.length() + localfile.length() + 64];
         sprintf(tmp, "%s.%d", (self->m_strHomeDir + path + "/" + localfile).c_str(), bucket);
         fstream datafile(tmp, ios::out | ios::binary | ios::app);
         sprintf(tmp, "%s.%d.idx", (self->m_strHomeDir + path + "/" + localfile).c_str(), bucket);
         fstream indexfile(tmp, ios::out | ios::binary | ios::app);
         delete [] tmp;
         int64_t start = offset[bucket];
         if (0 == start)
            indexfile.write((char*)&start, 8);

         int32_t len;
         char* data = NULL;
         if (self->m_DataChn.recv(speip, dataport, session, data, len) < 0)
            continue;
         datafile.write(data, len);
         delete [] data;

         tmp = NULL;
         if (self->m_DataChn.recv(speip, dataport, session, tmp, len) < 0)
            continue;
         int64_t* index = (int64_t*)tmp;
         for (int j = 0; j < len / 8; ++ j)
            index[j] += start;
         offset[bucket] = index[len / 8 - 1];
         indexfile.write(tmp, len);
         delete [] tmp;

         datafile.close();
         indexfile.close();
      }

      // update total received data
      self->m_SlaveStat.updateIO(speip, b.totalsize, 0);
   }

   pthread_mutex_destroy(bqlock);
   pthread_cond_destroy(bqcond);
   delete bqlock;
   delete bqcond;
   delete pendingSize;

   // sort and reduce
   if (type == 1)
   {
      void* lh = NULL;
      self->openLibrary(key, function, lh);
      //if (NULL == lh)
      //   break;

      MR_COMPARE comp = NULL;
      MR_REDUCE reduce = NULL;
      self->getReduceFunc(lh, function, comp, reduce);

      if (NULL != comp)
      {
         char* tmp = new char[self->m_strHomeDir.length() + path.length() + localfile.length() + 64];
         for (set<int>::iterator i = fileid.begin(); i != fileid.end(); ++ i)
         {
            sprintf(tmp, "%s.%d", (self->m_strHomeDir + path + "/" + localfile).c_str(), *i);
            self->sort(tmp, comp, reduce);
         }
         delete [] tmp;
      }

      self->closeLibrary(lh);
   }


   // report sphere output files
   char* tmp = new char[path.length() + localfile.length() + 64];
   vector<string> filelist;
   for (set<int>::iterator i = fileid.begin(); i != fileid.end(); ++ i)
   {
      sprintf(tmp, "%s.%d", (path + "/" + localfile).c_str(), *i);
      filelist.push_back(tmp);
      sprintf(tmp, "%s.%d.idx", (path + "/" + localfile).c_str(), *i);
      filelist.push_back(tmp);
   }
   delete [] tmp;

   self->report(master_ip, master_port, transid, filelist, 1);

   self->reportSphere(master_ip, master_port, transid);

   // cout << "bucket completed 100 " << client_ip << " " << client_port << endl;
   SectorMsg msg;
   msg.setType(1); // success, return result
   msg.setData(0, (char*)&(bucketid), 4);
   int progress = 100;
   msg.setData(4, (char*)&progress, 4);
   msg.m_iDataLength = SectorMsg::m_iHdrSize + 8;
   int id = 0;
   self->m_GMP.sendto(client_ip.c_str(), client_port, id, &msg);

   //remove this client data channel
   self->m_DataChn.remove(client_ip, client_data_port);

   return NULL;
}
开发者ID:heshucheng,项目名称:sector,代码行数:101,代码来源:serv_spe.cpp


注:本文中的Slave::closeLibrary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。