Пример #1
0
// We intercept the `handleVerifiedDataObject` call to now call
// into the cache strat, if it exists. The cache strat module
// will then call `insertDataObjectIntoDataStore` if the new object
// should be inserted
void
DataManager::insertDataObjectIntoDataStore(DataObjectRef& dObj)
{
    if (!dObj) {
        HAGGLE_ERR ("Trying to insert null data object into DB.\n");
        return;
    }

    // insert into database (including filtering)
    if (dObj->isPersistent ()) {
        kernel->getDataStore ()->insertDataObject (dObj,
            onInsertedDataObjectCallback);
    }
    else {
        // do not expect a callback for a non-persistent data object,
        // but we still call insertDataObject in order to filter the data object.
        kernel->getDataStore ()->insertDataObject (dObj, NULL);
    }
}
Пример #2
0
/*
 * Returns true iff 
 */
bool 
CacheStrategyUtility::isResponsibleForDataObject(
    DataObjectRef &dObj)
{
    string id = string(dObj->getIdStr());
/*
    // THIS IS NOT THREAD SAFE!! added getOrigSize
    // to grab unaltered file size.
    if (utilMetadata.find(id) != utilMetadata.end()) {
        return true;
    }
*/

    if (dObj->isDuplicate()) {
        return false;
    }

    // SW: TODO: NOTE: this might not be the best way to check if it's from
    // a local application, but it works for now...
    bool isLocal = dObj->getRemoteInterface() && dObj->getRemoteInterface()->isApplication();

    bool notResponsible = dObj->isControlMessage() || dObj->isNodeDescription();
    bool isResponsible = !notResponsible;

    if (!handle_zero_size) {
        isResponsible = isResponsible && (dObj->getOrigDataLen() > 0);
    }

    if (!manage_locally_sent_files) {
        isResponsible = isResponsible && dObj->isPersistent();
    }

    if (stats_replacement_strat && stats_replacement_strat->isResponsibleForDataObject(dObj)) {
        isResponsible = true;
    } else if (manage_only_remote_files) {
        isResponsible = isResponsible && !isLocal;
    }
    return isResponsible;
}