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


C++ DataObjectRef类代码示例

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


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

示例1: createRoutingInformationDataObject

DataObjectRef Forwarder::createRoutingInformationDataObject()
{
	// No need to have a reference in this function because it won't be 
	// visible outside until this function is done with it.
	DataObjectRef dObj = DataObject::create();
	
	if (!dObj)
		return NULL;

	HAGGLE_DBG2("Creating routing info data object\n");

	dObj->setPersistent(false);
	dObj->addAttribute("Forwarding", getName());
	
	// Add the metric data to the forwarding section:
	Metadata *md = dObj->getMetadata()->addMetadata(getManager()->getName());
	
	md = md->addMetadata(getName());
	md->setParameter("node_id", getKernel()->getThisNode()->getIdStr());
	
	if (!addRoutingInformation(dObj, md)) {
        // SW: ERR->DBG, this is not fatal, we return false when we don't want
        // to add routing data.
	        // HAGGLE_DBG("Could not add routing information\n");
		return NULL;
	}

	return dObj;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:29,代码来源:Forwarder.cpp

示例2:

// CBMEN, HL, Begin
int
ReplicationOptimizer::getCost(DataObjectRef dObj, string node_id)
{
    int dataLen = 0;
    {
        dataLen = (int) dObj->getDataLen();
        // include metadata size
        Metadata *m = dObj->getMetadata();
        if (!m) {
            errorCount++;
            HAGGLE_ERR("Missing metadata.\n");
            return 0;
        }
        dataLen += m->getContent().size();
    }

    {
        node_map_t::iterator it = node_map.find(node_id);
        if (it == node_map.end()) {
            errorCount++;
            HAGGLE_ERR("Missing node: %s\n", node_id.c_str());
            return 0;
        }
    }

    return dataLen;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:28,代码来源:ReplicationOptimizer.cpp

示例3: signDataObject

bool SecurityHelper::signDataObject(DataObjectRef& dObj, RSA *key)
{
	unsigned char *signature;
	
	if (!key || !dObj) 
		return false;
	
	unsigned int siglen = RSA_size(key);
	
	signature = (unsigned char *)malloc(siglen);
	
	if (!signature)
		return false;

	printf("signing data object, siglen=%u\n", siglen);

	memset(signature, 0, siglen);
	
	if (RSA_sign(NID_sha1, dObj->getId(), sizeof(DataObjectId_t), signature, &siglen, key) != 1) {
		free(signature);
		return false;
	}
	
	dObj->setSignature(getManager()->getKernel()->getThisNode()->getIdStr(), signature, siglen);
	
	// Assume that our own signature is valid
	dObj->setSignatureStatus(DataObject::SIGNATURE_VALID);
	
	// Do not free the allocated signature as it is now owned by the data object...
	
	return true;
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:32,代码来源:SecurityManager.cpp

示例4: while

void Manager::_onConfig(Event *e)
{
	DataObjectRefList& dObjs = e->getDataObjectList();

	while (dObjs.size()) {
                DataObjectRef dObj = dObjs.pop();

		// Get the metadata matching the manager
		Metadata *m = dObj->getMetadata()->getMetadata(this->getName());

		if (m) {
			onConfig(m);
		}
	}
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:15,代码来源:Manager.cpp

示例5: Event

void
DataManager::handleVerifiedDataObject(DataObjectRef& dObj)
{
    if (!dObj) {
        HAGGLE_ERR ("Handle verified object received null object.\n");
        return;
    }

        if(networkCodingConfiguration->isNetworkCodingEnabled(dObj,NULL) &&
	   !networkCodingConfiguration->isForwardingEnabled()) {
	  if(networkCodingDataObjectUtility->isNetworkCodedDataObject(dObj)) {
	    if (dObj->isDuplicate()) {
	      HAGGLE_DBG("Data object %s is a duplicate! Not generating DATAOBJECT_NEW event\n", dObj->getIdStr());
	    } else {
	      kernel->addEvent(new Event(EVENT_TYPE_DATAOBJECT_NEW, dObj));
	      return;
	    }
	  }
	}

        if(fragmentationConfiguration->isFragmentationEnabled(dObj,NULL) &&
	   !fragmentationConfiguration->isForwardingEnabled()) {
	  if(fragmentationDataObjectUtility->isFragmentationDataObject(dObj)) {
	    if (dObj->isDuplicate()) {
	      HAGGLE_DBG("Data object %s is a duplicate! Not generating DATAOBJECT_NEW event\n", dObj->getIdStr());
	    } else {
	      kernel->addEvent(new Event(EVENT_TYPE_DATAOBJECT_NEW, dObj));
	      return;
	    }
	  }
	}

    // MOS - add data object to Bloomfilter to cover the case 
    // where there was no incoming event (e.g. encrypting data object from local app)
    if (dObj->getABEStatus() != DataObject::ABE_NOT_NEEDED && !localBF->has(dObj)) {
      localBF->add(dObj);
      HAGGLE_DBG("Adding encrypted data object [%s] to our bloomfilter, #objs=%d\n", DataObject::idString(dObj).c_str(), localBF->numObjects());
      kernel->getThisNode()->getBloomfilter()->add(dObj); // MOS
    }

    if (cacheStrategy && !cacheStrategy->isDone() && cacheStrategy->isResponsibleForDataObject(dObj)) {
        cacheStrategy->handleNewDataObject(dObj);
    }
    else {
        //default action for dObj's that are NOT handled by cache strat code
        insertDataObjectIntoDataStore (dObj);
    }
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:48,代码来源:DataManager.cpp

示例6: isNetworkCodingEnabled

bool NetworkCodingConfiguration::isNetworkCodingEnabled(DataObjectRef dataObject, NodeRef targetNodeToNetworkCodeFor) {
	// if network coding turned on doesn't matter about dataobjects or targetnoderefids
	if( NetworkCodingConfiguration::isNetworkCodingTurnedOn ) {
		return true;
	}

	if( !targetNodeToNetworkCodeFor ) {
		return false;
	}

	string targetNodeId = targetNodeToNetworkCodeFor->getName();
    string dataObjectId;
    if (dataObject)
        dataObjectId = dataObject->getIdStr();

    string key = dataObjectId + "|" + targetNodeId;
    {
        Mutex::AutoLocker l(NetworkCodingConfiguration::contextAwareMutex); // needs to be fine grained
        contextawarecodingtracker_t::iterator it = NetworkCodingConfiguration::contextawaretracker.find(key);
        if (it != NetworkCodingConfiguration::contextawaretracker.end()) {
            return true;
        }

        key = "|" + targetNodeId;
        it = NetworkCodingConfiguration::contextawaretracker.find(key);
        if (it != NetworkCodingConfiguration::contextawaretracker.end()) {
            HAGGLE_DBG("context aware coding is enabled for targetnoderefid=%s, saving status for dataobject=%s\n", targetNodeId.c_str(), dataObjectId.c_str());
            NetworkCodingConfiguration::contextawaretracker.insert(make_pair(dataObjectId + "|" + targetNodeId, true));
            return true;
        }
    }

	return false;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:34,代码来源:NetworkCodingConfiguration.cpp

示例7: addRoutingInformation

/**
 Add routing information to a data object.
 The parameter "parent" is the location in the data object where the routing 
 information should be inserted.
 */ 
bool ForwarderRank::addRoutingInformation(DataObjectRef& dObj, Metadata *parent)
{
	if (!dObj || !parent)
		return false;
	
	// Add first our own node ID.
	parent->setParameter("node_id", kernel->getThisNode()->getIdStr());
	
	Metadata *mm = parent->addMetadata("Metric", myNodeStr);
	
	mm->setParameter("hostid",hostname);
	
	mm->setParameter("label", myLabel);
	
	char tmp[32];
	sprintf(tmp,"%ld",myRank);
	mm->setParameter("rank", tmp);
	
	HAGGLE_DBG("HAGGLE_DBG: Sending metric node:%s label:%s rank:%s \n",parent->getParameter("node_id"),
	mm->getParameter("label"),mm->getParameter("rank"));
				
	dObj->setCreateTime(rib_timestamp);
	
	return true;
}
开发者ID:eikoyoneki,项目名称:haggle-cambridge,代码行数:30,代码来源:ForwarderRank.cpp

示例8: onFindRepositoryKey

void DebugManager::onFindRepositoryKey(Event *e)
{
	if (!e || !e->hasData())
		return;
	
	DataStoreQueryResult *qr = static_cast < DataStoreQueryResult * >(e->getData());
	
	RepositoryEntryRef re = qr->detachFirstRepositoryEntry();
	
	if (!re) {
		// No repository entry: no data object.
		DataObjectRef dObj;

		// Name the log so that the files are more easily readable on the 
		// machine that receives them:
		char filename[128];
		sprintf(filename, "log-%s.txt", kernel->getThisNode()->getIdStr());

		// Create data object:
		
		// Empty at first:
		dObj = DataObject::create(LogTrace::ltrace.getFile(), filename);
		
		if (!dObj) {
			HAGGLE_ERR("Could not create data object\n");
			return;
		}
		// Add log file attribute:
		Attribute a("Log file","Trace");
		dObj->addAttribute(a);
		
		// Add node id of local node, to make sure that two logs from different 
		// nodes don't clash:
		Attribute b("Node id", kernel->getThisNode()->getIdStr());
		dObj->addAttribute(b);
		
		// Insert data object:
		kernel->getDataStore()->insertDataObject(dObj);
		
		// Insert a repository entry to show the data object exists:
		kernel->getDataStore()->insertRepository(new RepositoryEntry("DebugManager", "has saved log file data object", "yes"));
	}
	
	delete qr;
}
开发者ID:eikoyoneki,项目名称:haggle-label,代码行数:45,代码来源:DebugManager.cpp

示例9: updateInfoDataObject

void EvictStrategyLRFU::updateInfoDataObject(DataObjectRef &dObj, unsigned int count, Timeval time) 
{

    ScratchpadManager *pad = getKernel()->getDataStore()->getScratchpadManager();
    //create scratchpad keys
    string paramNameF0=name;
    paramNameF0.append("_LRU_F0");
    double c_now = 0.0;
    double c_old = 0.0;
    double lastTime = 0.0;
    double paramValueF0 = 0.0;
    double paramValueLastk = 0.0;
    string paramName_c_now=name;
    paramName_c_now.append("_c_now");
    string paramNameLastk=name;
    paramNameLastk.append("_LRU_last_k");
    
    if (countType == EVICT_STRAT_LRFU_COUNT_TYPE_TIME) {
	paramValueLastk = time.getTimeAsMilliSecondsDouble();
    } else {  //otherwise count
	paramValueLastk = (double) count; 
    }

    bool has_attr = pad->hasScratchpadAttributeDouble(dObj, paramNameF0);
    if (has_attr) {
        paramValueF0 = pad->getScratchpadAttributeDouble(dObj, paramNameF0);
	c_now = pad->getScratchpadAttributeDouble(dObj, paramName_c_now);
	c_old = c_now;
       	lastTime = pad->getScratchpadAttributeDouble(dObj, paramNameLastk);
        c_now *= fx_calc(paramValueLastk-lastTime);
        c_now += paramValueF0; 
       	HAGGLE_DBG("%s f(x) = %f + G(%f - %f)*%f = %f\n", dObj->getIdStr() ,paramValueF0 , (float) count, lastTime, c_old,  c_now);

    } else {
	c_now = 1.0; //fx_calc(paramValueLastk);
       	pad->setScratchpadAttributeDouble(dObj, paramNameF0, c_now);
       	HAGGLE_DBG("%s f(0) = g(%f) = %f\n", dObj->getIdStr(), paramValueLastk, c_now);
    }

   //set current values
   pad->setScratchpadAttributeDouble(dObj, paramName_c_now, c_now);
   pad->setScratchpadAttributeDouble(dObj, paramNameLastk, paramValueLastk);
   

}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:45,代码来源:EvictStrategyLRFU.cpp

示例10: verifyDataObject

bool SecurityHelper::verifyDataObject(DataObjectRef& dObj, CertificateRef& cert) const
{
	RSA *key;
	
	// Cannot verify without signature
	if (!dObj->getSignature()) {
		HAGGLE_ERR("No signature in data object, cannot verify\n");
		return false;
	}	
	writeErrors("(not this): ");
	
	key = cert->getPubKey();

	if (RSA_verify(NID_sha1, dObj->getId(), sizeof(DataObjectId_t), 
		       const_cast<unsigned char *>(dObj->getSignature()), dObj->getSignatureLength(), key) != 1) {
		char *raw;
		size_t len;
		writeErrors("");
		dObj->getRawMetadataAlloc((unsigned char **)&raw, &len);
		if (raw) {
			HAGGLE_DBG("Signature is invalid:\n%s\n", raw);
			free(raw);
		}
		dObj->setSignatureStatus(DataObject::SIGNATURE_INVALID);

		return false;
	}
	
	HAGGLE_DBG("Signature is valid\n");
	dObj->setSignatureStatus(DataObject::SIGNATURE_VALID);

	return true;
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:33,代码来源:SecurityManager.cpp

示例11: RANDOM_INT

/**
* This routine was taken from the benchmark manager, to create Dataobjects in code.
* It is used for the self test.    Depending on compile options, benchmark manager
* may not be included, so the relevant code is copied here to be always available.
*
* @see BenchmarkManager::createDataObject
*
*/
DataObjectRef CacheStrategyUtility::createDataObject(unsigned int numAttr)
{
	char name[128];
	char value[128];
	unsigned int r;

	unsigned char macaddr[6];
	macaddr[0] = (unsigned char) RANDOM_INT(255);
	macaddr[1] = (unsigned char) RANDOM_INT(255);
	macaddr[2] = (unsigned char) RANDOM_INT(255);
	macaddr[3] = (unsigned char) RANDOM_INT(255);
	macaddr[4] = (unsigned char) RANDOM_INT(255);
	macaddr[5] = (unsigned char) RANDOM_INT(255);
	
	unsigned char macaddr2[6];
	macaddr2[0] = (unsigned char) RANDOM_INT(255);
	macaddr2[1] = (unsigned char) RANDOM_INT(255);
	macaddr2[2] = (unsigned char) RANDOM_INT(255);
	macaddr2[3] = (unsigned char) RANDOM_INT(255);
	macaddr2[4] = (unsigned char) RANDOM_INT(255);
	macaddr2[5] = (unsigned char) RANDOM_INT(255);
	
	EthernetAddress addr(macaddr);
	EthernetAddress addr2(macaddr2);
	InterfaceRef localIface = Interface::create<EthernetInterface>(macaddr, "eth", addr, 0);		
	InterfaceRef remoteIface = Interface::create<EthernetInterface>(macaddr2, "eth2", addr2, 0);		
	DataObjectRef dObj = DataObject::create(NULL, 0, localIface, remoteIface);

	for (unsigned int i = 0; i < numAttr; i++) {
		int tries = 0;
		do {
			r = RANDOM_INT(32000);
			sprintf(name, "name");
			sprintf(value, "value %d", r);
			if (tries++ > 10) {
				HAGGLE_ERR("WARNING: Cannot generate unique attributes in data object... check attribute pool size!\n");
				break;
			}
		} while (dObj->getAttribute(name, value));

		dObj->addAttribute(name, value, 1); //r);
	}

	return dObj;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:53,代码来源:CacheStrategyUtility.cpp

示例12: HAGGLE_DBG

void NetworkCodingEncoderManagerModuleProcessor::encode(NetworkCodingEncoderTaskRef networkCodingEncoderTask) {

    const DataObjectRef originalDataObjectRef =
            networkCodingEncoderTask->getDataObject();
    const NodeRefList nodeRefList = networkCodingEncoderTask->getNodeRefList();

    HAGGLE_DBG("Perform network coding for data object %s\n", originalDataObjectRef->getIdStr());

    DataObjectRef networkCodedDataObject =
            this->networkCodingEncoderService->encodeDataObject(originalDataObjectRef);
    if(networkCodedDataObject) { // MOS
      HAGGLE_DBG("Generated block %s for data object %s\n", networkCodedDataObject->getIdStr(), originalDataObjectRef->getIdStr());

      Event* sendEvent = new Event(EVENT_TYPE_DATAOBJECT_SEND,
				   networkCodedDataObject, nodeRefList);
      this->haggleKernel->addEvent(sendEvent);
    }
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:18,代码来源:NetworkCodingEncoderManagerModuleProcessor.cpp

示例13: onVerifiedDataObject

/*
	public event handler on verified DataObject
 
	means that the DataObject is verified by the SecurityManager
*/ 
void DataManager::onVerifiedDataObject(Event *e)
{
	if (!e || !e->hasData())
		return;

	DataObjectRef dObj = e->getDataObject();
	
	if (!dObj) {
		HAGGLE_DBG("Verified data object event without data object!\n");
		return;
	}

	if (dataObjectsReceived.size() >= MAX_DATAOBJECTS_LISTED) {
		dataObjectsReceived.pop_front();
	}
	dataObjectsReceived.push_back(dObj->getIdStr());

	HAGGLE_DBG("%s Received data object [%s]\n", getName(), dObj->getIdStr());

#ifdef DEBUG
	// dObj->print(NULL); // MOS - NULL means print to debug trace
#endif
	if (dObj->getSignatureStatus() == DataObject::SIGNATURE_INVALID) {
		// This data object had a bad signature, we should remove
		// it from the bloomfilter
		HAGGLE_DBG("Data object [%s] had bad signature, removing from bloomfilter\n", dObj->getIdStr());
		localBF->remove(dObj);
		kernel->getThisNode()->setBloomfilter(*localBF, setCreateTimeOnBloomfilterUpdate);
		return;
	}

	if (dObj->getDataState() == DataObject::DATA_STATE_VERIFIED_BAD) {
		HAGGLE_ERR("Data in data object flagged as bad! -- discarding\n");
		if (localBF->has(dObj)) {
			// Remove the data object from the bloomfilter since it was bad.
			localBF->remove(dObj);
			kernel->getThisNode()->setBloomfilter(*localBF, setCreateTimeOnBloomfilterUpdate);
		}
		return;
	} else if (dObj->getDataState() == DataObject::DATA_STATE_NOT_VERIFIED && helper) {
		// Call our helper to verify the data in the data object.
                if (dObj->dataIsVerifiable()) {
                        helper->addTask(new DataTask(DATA_TASK_VERIFY_DATA, dObj));
                        return;
                }
	}
	
	handleVerifiedDataObject(dObj);
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:54,代码来源:DataManager.cpp

示例14: onSendDataObject

/*
	On send events, the security manager 
 
 */
void SecurityManager::onSendDataObject(Event *e)
{
	if (!e || !e->hasData())
		return;

	DataObjectRef dObj = e->getDataObject();
	
	if (dObj->isThisNodeDescription()) {
		// This is our node description. Piggy-back our certificate.
		if (myCert) {
			Metadata *m;

			m = dObj->getMetadata()->getMetadata("Security");
			
			if (m) {
				HAGGLE_ERR("Node description already has a Security tag!\n");
			} else {
				m = dObj->getMetadata()->addMetadata("Security");
				
				if (m) {
					m->addMetadata(myCert->toMetadata());
				}
			}
		}
	}
	
	// In most cases the data object is already signed here (e.g., if it is generated by a local
	// application, or was received from another node). The only reason to check if we should
	// sign the data object here, is if a data object was generated internally by Haggle -- in
	// which case the data object might not have a signature (e.g., the data object is a node
	// description).
	InterfaceRef iface = dObj->getRemoteInterface();
	
	if (dObj->shouldSign() && !(iface && iface->getType() == Interface::TYPE_APPLICATION_PORT)) {
		// FIXME: data objects should really be signed in the SecurityHelper thread since
		// it is a potentially CPU intensive operation. But it is currently not possible
		// to ensure that the signing operation has finished in the helper thread before
		// the data object is actually sent on the wire by the protocol manager.
		// To handle this situation, we probably need to add a new public event for 
		// security related operations, after which the security manager generates the
		// real send event.
		
		if (helper->signDataObject(dObj, privKey)) {
			HAGGLE_DBG("Successfully signed data object %s\n", dObj->getIdStr());
		} else {
			HAGGLE_DBG("Signing of data object %s failed!\n", dObj->getIdStr());
		}
	}	
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:53,代码来源:SecurityManager.cpp

示例15: initializationCallback

    void initializationCallback(Event *e) 
    {
        DataObjectRefList dObjs = e->getDataObjectList();
        
        for (DataObjectRefList::iterator it = dObjs.begin(); it != dObjs.end(); it++) {
            DataObjectRef dObj = *it;
            if (!purger->isResponsibleForDataObject(dObj)) {
                continue;
            }
            double now = (Timeval::now()).getTimeAsSecondsDouble();
            double then = (dObj->getReceiveOrCreateTime()).getTimeAsSecondsDouble();
		    const Attribute *attr = dObj->getAttribute(purger->getMetricField(), "*", 1);
            double ttl = atof(attr->getValue().c_str()); 

            if (now < (then + ttl + purger->getMinDBTimeS())) {
                purger->schedulePurge(dObj);
            } 
            else {
                kernel->getDataStore()->deleteDataObject(dObj, purger->getKeepInBloomfilter());
            }
        }
    }
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:22,代码来源:CachePurgerRelTTL.cpp


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