Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (44 sloc) 1.869 kb
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include "config.h"
#include <functional>
#include "vbucket.hh"
const vbucket_state_t VBucket::ACTIVE = static_cast<vbucket_state_t>(htonl(active));
const vbucket_state_t VBucket::REPLICA = static_cast<vbucket_state_t>(htonl(replica));
const vbucket_state_t VBucket::PENDING = static_cast<vbucket_state_t>(htonl(pending));
const vbucket_state_t VBucket::DEAD = static_cast<vbucket_state_t>(htonl(dead));
void VBucket::fireAllOps(SERVER_CORE_API *core, ENGINE_ERROR_CODE code) {
if (pendingOpsStart > 0) {
hrtime_t now = gethrtime();
if (now > pendingOpsStart) {
hrtime_t d = (now - pendingOpsStart) / 1000;
stats.pendingOpsMaxDuration.setIfBigger(d);
}
}
pendingOpsStart = 0;
stats.pendingOps.decr(pendingOps.size());
stats.pendingOpsMax.setIfBigger(pendingOps.size());
std::for_each(pendingOps.begin(), pendingOps.end(),
std::bind2nd(std::ptr_fun(core->notify_io_complete), code));
pendingOps.clear();
getLogger()->log(EXTENSION_LOG_INFO, NULL,
"Fired pendings ops for vbucket %d in state %s\n",
id, VBucket::toString(state));
}
void VBucket::fireAllOps(SERVER_CORE_API *core) {
LockHolder lh(pendingOpLock);
if (state == active) {
fireAllOps(core, ENGINE_SUCCESS);
} else if (state == pending) {
// Nothing
} else {
fireAllOps(core, ENGINE_NOT_MY_VBUCKET);
}
}
void VBucket::setState(vbucket_state_t to, SERVER_CORE_API *core) {
assert(core);
vbucket_state_t oldstate(state);
getLogger()->log(EXTENSION_LOG_DEBUG, NULL,
"transitioning vbucket %d from %s to %s\n",
id, VBucket::toString(oldstate), VBucket::toString(to));
state = to;
}
Jump to Line
Something went wrong with that request. Please try again.