void FawnKVServerHandler::remove(const std::string& key, const int64_t continuation, const int32_t cid) { // Generating unique server-side continuation int64_t ss_continuation = reqNumber++; ClientData *cd = get_client(cid); cd->addContinuation(continuation, ss_continuation); req_client_map[ss_continuation] = cd; pthread_mutex_lock(p_mutex); frontend->remove(key, ss_continuation); pthread_mutex_unlock(p_mutex); }
void FawnKVServerHandler::put(const std::string& key, const std::string& value, const int64_t continuation, const int32_t cid) { pthread_mutex_lock(p_mutex); // Generating unique server-side continuation int64_t ss_continuation = reqNumber++; //cout << "Put from CID: " << cid << " continuation: " << continuation << " reqNumber: " << ss_continuation << endl; ClientData *cd = get_client(cid); cd->addContinuation(continuation, ss_continuation); req_client_map[ss_continuation] = cd; string v = value; frontend->put(key, value, ss_continuation); DBID dkey(key); if (cache) cache->insert(dkey, value); //cout << "Put Done for CID: " << cid << " continuation: " << continuation << " reqNumber: " << ss_continuation << endl; pthread_mutex_unlock(p_mutex); }
void FawnKVServerHandler::get(const std::string& key, const int64_t continuation, const int32_t cid) { pthread_mutex_lock(p_mutex); // Generating unique server-side continuation //cout << reqNumber << endl; int64_t ss_continuation = reqNumber++; ClientData *cd = get_client(cid); DBID dkey(key); string value; if ((cache) && (cache->lookup(dkey, value))){ cd->fc->get_response(value, continuation); } else { //cout << "Get from CID: " << cid << " continuation: " << continuation << " reqNumber: " << ss_continuation << endl; cd->addContinuation(continuation, ss_continuation); req_client_map[ss_continuation] = cd; frontend->get(key, ss_continuation); //cout << "Get Done for CID: " << cid << " continuation: " << continuation << " reqNumber: " << ss_continuation << endl; } if ((reqNumber % 2000) == 0) { // if (1) { gettimeofday(&tim, NULL); t = tim.tv_sec + (tim.tv_usec/1000000.0); if ((t_since > 0) && (t-t_since > 0)) { double rr = (reqNumber - reqSince)/1000.00/(t-t_since); r = 0.8 * r + 0.2 * rr; cout << r << "k query/sec " ; //<< t - t_since << endl; if (cache) cout << "hit_ratio " << cache->hit_ratio() << " cache_size " << cache->size() << endl; else cout << "hit_ratio " << 0 << endl; } t_since = t; reqSince = reqNumber; } pthread_mutex_unlock(p_mutex); }