本文整理汇总了C++中DataObjectRef::putData方法的典型用法代码示例。如果您正苦于以下问题:C++ DataObjectRef::putData方法的具体用法?C++ DataObjectRef::putData怎么用?C++ DataObjectRef::putData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectRef
的用法示例。
在下文中一共展示了DataObjectRef::putData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: receiveDataObjectNoControl
ProtocolEvent ProtocolUDPGeneric::receiveDataObjectNoControl()
{
ProtocolEvent pEvent;
size_t len;
pEvent = receiveData(buffer, bufferSize, MSG_DONTWAIT, &len);
if (pEvent != PROT_EVENT_SUCCESS) {
return pEvent;
}
buffer[bufferSize-1] = '\0';
if (len == 0) {
HAGGLE_DBG("%s Received zero-length message\n", getName());
return PROT_EVENT_ERROR;
}
if(lastReceivedSessionNo == lastValidReceivedSessionNo && lastReceivedSeqNo == lastValidReceivedSeqNo) {
HAGGLE_DBG("%s Ignoring duplicate message - session no %s sequence no %d\n", getName(), DataObject::idString(lastValidReceivedSessionNo).c_str(), lastReceivedSeqNo);
return PROT_EVENT_SUCCESS;
}
memcpy(lastValidReceivedSessionNo, lastReceivedSessionNo, sizeof(DataObjectId_t));
lastValidReceivedSeqNo = lastReceivedSeqNo;
// MOS - fastpath based on session id = data object id
if (getKernel()->getThisNode()->getBloomfilter()->has(lastValidReceivedSessionNo)) {
HAGGLE_DBG("%s Data object (session no %s) already in bloom filter - no event generated\n", getName(), DataObject::idString(lastValidReceivedSessionNo).c_str());
dataObjectsNotReceived += 1; // MOS
return PROT_EVENT_SUCCESS;
}
// MOS - quickly add to Bloom filter to reduce redundant processing in other procotols
getKernel()->getThisNode()->getBloomfilter()->add(lastValidReceivedSessionNo);
DataObjectRef dObj = DataObject::create_for_putting(localIface,
peerIface,
getKernel()->getStoragePath());
if (!dObj) {
HAGGLE_DBG("%s Could not create data object\n", getName());
return PROT_EVENT_ERROR;
}
size_t bytesRemaining = DATAOBJECT_METADATA_PENDING;
ssize_t bytesPut = dObj->putData(buffer, len, &bytesRemaining, true);
if (bytesPut < 0) {
HAGGLE_ERR("%s Could not put data\n", getName());
return PROT_EVENT_ERROR;
}
if(bytesRemaining != len - bytesPut) {
HAGGLE_ERR("%s Received data object not complete - discarding\n", getName());
return PROT_EVENT_ERROR;
}
HAGGLE_DBG("%s Metadata header received [%s].\n", getName(), dObj->getIdStr());
dObj->setReceiveTime(Timeval::now());
// MOS - the following was happening after posting INCOMING but that distorts the statistics
HAGGLE_DBG("%s %ld bytes data received (including header), %ld bytes put\n", getName(), len, bytesPut);
dataObjectsIncoming += 1; // MOS
if(!dObj->isControlMessage()) dataObjectsIncomingNonControl += 1; // MOS
dataObjectBytesIncoming += len; // MOS
HAGGLE_DBG("%s Received data object [%s] from node %s\n", getName(),
DataObject::idString(dObj).c_str(), peerDescription().c_str());
// MOS - removed interface due to locking issue
if (getKernel()->getThisNode()->getBloomfilter()->hasParentDataObject(dObj)) {
HAGGLE_DBG("%s Data object [%s] already in bloom filter - no event generated\n", getName(), DataObject::idString(dObj).c_str());
dataObjectsNotReceived += 1; // MOS
return PROT_EVENT_SUCCESS;
}
NodeRef node = Node::create(dObj);
if (node && (node == getKernel()->getThisNode())) {
HAGGLE_DBG("%s Received own node description, discarding early.\n", getName());
dataObjectsNotReceived += 1; // MOS
return PROT_EVENT_SUCCESS;
}
// MOS - this now happens even before xml parsing
// getKernel()->getThisNode()->getBloomfilter()->add(dObj);
if(bytesRemaining > 0) {
ssize_t bytesPut2 = dObj->putData(buffer + bytesPut, len - bytesPut, &bytesRemaining, false);
HAGGLE_DBG("%s processing payload - %ld bytes put\n", getName(), bytesPut2);
if (bytesPut2 < 0) {
HAGGLE_ERR("%s Could not put data\n", getName());
return PROT_EVENT_ERROR;
}
if(bytesRemaining != 0) {
HAGGLE_ERR("%s Received data object not complete - discarding\n", getName());
return PROT_EVENT_ERROR;
}
//.........这里部分代码省略.........