コード例 #1
0
//this function tells us if there are any ids that have waited long enough for it to be safe to query for the again.
void CraqObjectSegmentation::checkNotFoundData()
{
    if (mStopping)
        return;

    //look at the first element of the queue.  if the time hasn't been sufficiently long, return.  if the time has been sufficiently long, then go ahead and directly request asyncCraq to perform another lookup.

    if (mNfData.size() == 0)
        return;

    std::cout<<"\n\nGOT NOT FOUND\n\n";

    Duration tmpDur = Time::local() - Time::epoch();


    bool queueDataOldEnough = true;
    NotFoundData* nfd;

    while (queueDataOldEnough)
    {
        nfd = mNfData.front();
        queueDataOldEnough = false;

        if ((tmpDur.toMilliseconds() - nfd->dur.toMilliseconds()) > CRAQ_NOT_FOUND_SIT_OUT) //we wait 500 ms.
        {
            queueDataOldEnough = true;

            //perform a direct craq get call
            std::string indexer = "";
            indexer.append(1,myUniquePrefixKey);
            indexer.append(nfd->obj_id.rawHexData());

            CraqDataSetGet cdSetGet (indexer,CraqEntry(NullServerID,0),false,CraqDataSetGet::GET); //bftm modified
            craqDhtGet1.get(cdSetGet, nfd->traceToken); //calling the craqDht to do a get.

            mNfData.pop(); //remove the item from the queue.

            delete nfd; //memory managment
        }
        queueDataOldEnough = queueDataOldEnough && (mNfData.size() > 0);  //don't keep going if you're out of objects.
    }
}
コード例 #2
0
/*
  If we get a message to move an object that our server holds, then we add the object's id to mInTransit.
  Whatever calls this must verify that the object is on this server.
  I can do the check in the function by querrying bambooDht as well
*/
void CraqObjectSegmentation::migrateObject(const UUID& obj_id, const OSegEntry& new_server_id)
{
    if (mStopping)
        return;

    //log the message.
    CONTEXT_SPACETRACE(objectBeginMigrate,
                       obj_id,mContext->id(),
                       new_server_id.server());

    InTransitMap::const_iterator transIter = mInTransitOrLookup.find(obj_id);

    TransLookup tmpTransLookup;
    tmpTransLookup.sID = CraqEntry(new_server_id);

    Duration tmpDurer = Time::local() - Time::epoch();

    tmpTransLookup.timeAdmitted = (int)tmpDurer.toMilliseconds();

    mInTransitOrLookup[obj_id] = tmpTransLookup;

    //erases the local copy of obj_id
    UUID tmp_id = obj_id; //note: can probably delete this line

    //erase the local copy of the object.
    size_t num_erased = mObjects.erase(obj_id);
#ifdef CRAQ_DEBUG
    if (num_erased == 0)
    {
        std::cout<<"\n\nThe object clearly wasn't registered on this server.  This is obj id:  " <<  obj_id.toString() <<  ".  This is time:   " <<mContext->simTime().raw() << " Oh no.   ";

        if (clearToMigrate(obj_id))
            std::cout<<"  Likely a problem with clear to migrate\n\n";
        else
            std::cout<<"\n\n clear to migrate is fine migration is being called from somewhere besides server.cpp\n\n";
    }
#endif
}