#include <math.h>
#include <memcached/engine.h>
#include <platform/platform.h>
-#include <cJSON.h>
#include <stdint.h>
#include <stdlib.h>
return is_sorted;
}
-inline const std::string getJSONObjString(const cJSON *i) {
- if (i == NULL) {
- return "";
- }
- if (i->type != cJSON_String) {
- abort();
- }
- return i->valuestring;
-}
-
#endif // SRC_COMMON_H_
case DT_FLOAT:
setParameter(items[ii].key, *items[ii].value.dt_float);
break;
- default:
- abort();
+ case DT_CONFIGFILE:
+ throw std::logic_error("Configuration::parseConfiguration: "
+ "Unexpected DT_CONFIGFILE element after parse_config");
+ break;
}
}
DbInfo info;
errorCode = couchstore_db_info(db, &info);
if (errorCode != COUCHSTORE_SUCCESS) {
- LOG(EXTENSION_LOG_WARNING, "Failed to read DB info for backfill");
closeDatabaseHandle(db);
- abort();
+ throw std::runtime_error("Failed to read DB info for backfill. vb:" +
+ std::to_string(vbid) + " rev:" +
+ std::to_string(rev));
}
uint64_t count = 0;
switch(rv) {
case ADD_NOMEM:
return ENGINE_ENOMEM;
+
case ADD_EXISTS:
case ADD_UNDEL:
case ADD_SUCCESS:
case ADD_TMP_AND_BG_FETCH:
// Since the hashtable bucket is locked, we shouldn't get here
- abort();
+ throw std::logic_error("EventuallyPersistentStore::addTempItemForBgFetch: "
+ "Invalid result from addTempItem: " + std::to_string(rv));
+
case ADD_BG_FETCH:
lock.unlock();
bgFetch(key, vb->getId(), cookie, metadataOnly);
ret = ENGINE_NOT_MY_VBUCKET;
break;
case NEED_BG_FETCH:
- // SET on a non-active vbucket should not require a bg_metadata_fetch.
- abort();
+ throw std::logic_error("EventuallyPersistentStore::addTAPBackfillItem: "
+ "SET on a non-active vbucket should not require a "
+ "bg_metadata_fetch.");
}
return ret;
case ADD_SUCCESS:
case ADD_TMP_AND_BG_FETCH:
// Since the hashtable bucket is locked, we shouldn't get here
- abort();
+ throw std::logic_error("EventuallyPersistentStore::statsVKey: "
+ "Invalid result from unlocked_addTempItem (" +
+ std::to_string(rv) + ")");
+
case ADD_BG_FETCH:
{
++bgFetchQueue;
case NEED_BG_FETCH:
// We already figured out if a bg fetch is requred for a full-evicted
// item above.
- abort();
+ throw std::logic_error("EventuallyPersistentStore::deleteItem: "
+ "Unexpected NEEDS_BG_FETCH from unlocked_softDelete");
}
return ret;
}
*es = &connection->opaqueCommandCode;
*nes = sizeof(connection->opaqueCommandCode);
break;
+
default:
- LOG(EXTENSION_LOG_WARNING,
- "%s Unknown VBucketEvent message type %d\n",
- connection->logHeader(), ev.event);
- abort();
+ throw std::logic_error("EventuallyPersistentEngine::doWalkTapQueue:"
+ " Unknown VBucketEvent message type:" +
+ std::to_string(ev.event) + " for connection:" +
+ connection->logHeader());
}
return ev.event;
}
case stopped:
return false;
}
- // THis should be impossible (unless someone added new states)
- abort();
+ // This should be impossible (unless someone added new states)
+ throw std::logic_error("flusher::validTransition: called with invalid "
+ "from:" + std::to_string(from));
}
const char * Flusher::stateName(enum flusher_state st) const {
char *ptr = NULL;
uint64_t revNum = strtoull(revNumStr.c_str(), &ptr, 10);
if (revNum == 0) {
- LOG(EXTENSION_LOG_WARNING,
- "Invalid revision number obtained for database file");
- abort();
+ throw std::runtime_error("ForestKVStore: Invalid revision (" +
+ std::to_string(revNum) +
+ ") obtained for database file");
}
if (revNum > dbFileRevNum) {
status = fdb_open(&dbFileHandle, dbFile.str().c_str(), &fileConfig);
if (status != FDB_RESULT_SUCCESS) {
- LOG(EXTENSION_LOG_WARNING,
- "Opening the database file instance failed with error: %s\n",
- fdb_error_msg(status));
- abort();
+ throw std::runtime_error(std::string("ForestKVStore: Opening the "
+ "database file instance failed with error:") +
+ fdb_error_msg(status));
}
fdb_kvs_handle *kvsHandle = NULL;
status = fdb_kvs_open_default(dbFileHandle, &vbStateHandle, &kvsConfig);
if (status != FDB_RESULT_SUCCESS) {
- LOG(EXTENSION_LOG_WARNING,
- "Opening the vbucket state KV store instance failed "
- "with error: %s\n", fdb_error_msg(status));
- abort();
+ throw std::runtime_error(std::string("ForestKVStore: Opening the "
+ "vbucket state KV store instance failed with error:") +
+ fdb_error_msg(status));
}
cachedVBStates.reserve(maxVbuckets);
#include "config.h"
+#include <cJSON.h>
#include <cstring>
#include <map>
#include <list>
void *dbHandle;
};
+inline const std::string getJSONObjString(const cJSON *i) {
+ if (i == NULL) {
+ return "";
+ }
+ if (i->type != cJSON_String) {
+ throw std::invalid_argument("getJSONObjString: type of object (" +
+ std::to_string(i->type) +
+ ") is not cJSON_String");
+ }
+ return i->valuestring;
+}
#endif // SRC_KVSTORE_H_
if (GetFileSizeEx(fd, &li)) {
return li.QuadPart;
}
- abort();
+ throw std::system_error(GetLastError(), std::system_category(),
+ "getFileSize: failed");
}
#else
// nothing in particular
break;
default:
- abort();
+ throw std::logic_error("MutationLogHarvester::load: Invalid log "
+ "entry type:" + std::to_string(le->type()));
}
}
return clean;
}
}
- switch (vb->ht.insert(*i, policy, shouldEject(), val.isPartial())) {
+ const auto res = vb->ht.insert(*i, policy, shouldEject(),
+ val.isPartial());
+ switch (res) {
case NOMEM:
if (retry == 2) {
if (hasPurged) {
succeeded = true;
break;
default:
- abort();
+ throw std::logic_error("LoadStorageKVPairCallback::callback: "
+ "Unexpected result from HashTable::insert: " +
+ std::to_string(res));
}
} while (!succeeded && retry-- > 0);
}
void Warmup::step() {
- try {
- switch (state.getState()) {
+ switch (state.getState()) {
case WarmupState::Initialize:
scheduleInitialize();
break;
scheduleCompletion();
break;
default:
- LOG(EXTENSION_LOG_WARNING,
- "Internal error.. Illegal warmup state %d", state.getState());
- abort();
- }
- } catch(std::runtime_error &e) {
- std::stringstream ss;
- ss << "Exception in warmup loop: " << e.what() << std::endl;
- LOG(EXTENSION_LOG_WARNING, "%s", ss.str().c_str());
- abort();
+ throw std::logic_error("Warmup::step: illegal warmup state:" +
+ std::to_string(state.getState()));
}
}