本文整理汇总了C++中Metadata::deserialize方法的典型用法代码示例。如果您正苦于以下问题:C++ Metadata::deserialize方法的具体用法?C++ Metadata::deserialize怎么用?C++ Metadata::deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Metadata
的用法示例。
在下文中一共展示了Metadata::deserialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connect
//.........这里部分代码省略.........
int32_t size = m_strHomeDir.length() + 1;
secconn.send((char*)&size, 4);
secconn.send(m_strHomeDir.c_str(), size);
int32_t res = -1;
secconn.recv((char*)&res, 4);
if (res < 0)
{
cerr << "slave join rejected. code: " << res << endl;
return res;
}
secconn.send((char*)&m_iLocalPort, 4);
secconn.send((char*)&m_iDataPort, 4);
secconn.send((char*)&(availdisk), 8);
secconn.send((char*)&(m_iSlaveID), 4);
if (first)
m_iSlaveID = res;
struct stat s;
stat((m_strHomeDir + ".tmp/metadata.dat").c_str(), &s);
size = s.st_size;
secconn.send((char*)&size, 4);
secconn.sendfile((m_strHomeDir + ".tmp/metadata.dat").c_str(), 0, size);
if (!first)
{
secconn.close();
continue;
}
// move out-of-date files to the ".attic" directory
size = 0;
secconn.recv((char*)&size, 4);
if (size > 0)
{
secconn.recvfile((m_strHomeDir + ".tmp/metadata.left.dat").c_str(), 0, size);
Metadata* attic = NULL;
if (m_SysConfig.m_MetaType == DISK)
attic = new Index2;
else
attic = new Index;
attic->init(m_strHomeDir + ".tmp/metadata.left");
attic->deserialize("/", m_strHomeDir + ".tmp/metadata.left.dat", NULL);
unlink((m_strHomeDir + ".tmp/metadata.left.dat").c_str());
vector<string> fl;
attic->list_r("/", fl);
for (vector<string>::iterator i = fl.begin(); i != fl.end(); ++ i)
move(*i, ".attic", "");
attic->clear();
delete attic;
m_SectorLog.insert("WARNING: certain files have been moved to ./attic due to conflicts.");
}
int id = 0;
secconn.recv((char*)&id, 4);
Address addr;
addr.m_strIP = mip;
addr.m_iPort = mport;
m_Routing.insert(id, addr);
int num;
secconn.recv((char*)&num, 4);
for (int i = 0; i < num; ++ i)
{
char ip[64];
size = 0;
secconn.recv((char*)&id, 4);
secconn.recv((char*)&size, 4);
secconn.recv(ip, size);
addr.m_strIP = ip;
secconn.recv((char*)&addr.m_iPort, 4);
m_Routing.insert(id, addr);
masters.insert(addr);
}
first = false;
secconn.close();
}
SSLTransport::destroy();
unlink((m_strHomeDir + ".tmp/metadata.dat").c_str());
// initialize slave statistics
m_SlaveStat.init();
cout << "This Sector slave is successfully initialized and running now.\n";
return 1;
}