1
0
Fork 0

Merge branch 'devel' of ssh://github.com/ArangoDB/ArangoDB into devel

This commit is contained in:
Max Neunhoeffer 2016-05-09 11:16:30 +02:00
commit e3abdeb73c
5 changed files with 134 additions and 21 deletions

View File

@ -73,12 +73,69 @@ endif()
set(ROCKSDB_PLATFORM_POSIX 1)
################################################################################
## OPERATION SYSTEM
################################################################################
set(OS_DEFINE "")
if (WIN32)
set(WINDOWS TRUE)
set(MSBUILD TRUE)
set(OS_DEFINE "OS_WIN")
elseif (UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
set(LINUX TRUE)
set(OS_DEFINE "OS_LINUX")
elseif (CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
set(FREEBSD TRUE)
set(OS_DEFINE "OS_FREEBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
set(NETBSD TRUE)
set(OS_DEFINE "OS_FREEBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
set(OPENBSD TRUE)
set(OS_DEFINE "OS_OPENBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
set(GNU TRUE)
set(OS_DEFINE "OS_LINUX")
elseif (CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
set(BSDI TRUE)
set(OS_DEFINE "OS_FREEBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
set(FREEBSD TRUE)
set(OS_DEFINE "OS_FREEBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
set(SYSV5 TRUE)
set(OS_DEFINE "OS_FREEBSD")
elseif ((CMAKE_SYSTEM_NAME MATCHES "Solaris.*") OR (CMAKE_SYSTEM_NAME MATCHES "SunOS.*"))
set(SOLARIS TRUE)
set(OS_DEFINE "OS_SOLARIS")
elseif (CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
set(HPUX TRUE)
set(OS_DEFINE "OS_SOLARIS")
elseif (CMAKE_SYSTEM_NAME MATCHES "AIX.*")
set(AIX TRUE)
set(OS_DEFINE "OS_SOLARIS")
elseif (CMAKE_SYSTEM_NAME MATCHES "Minix.*")
set(MINIX TRUE)
set(OS_DEFINE "OS_FREEBSD")
endif ()
elseif (APPLE)
if (CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
set(DARWIN TRUE)
set(OS_DEFINE "OS_MACOSX")
elseif (CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
set(MACOSX TRUE)
set(OS_DEFINE "OS_MACOSX")
endif ()
endif ()
if (CMAKE_COMPILER_IS_GNUCC)
if (VERBOSE)
message(STATUS "Compiler type GNU: ${CMAKE_CXX_COMPILER}")
endif ()
set(BASE_FLAGS "${BASE_FLAGS} -W -Wextra -Wall -Wsign-compare -Wshadow -Wno-unused-parameter -fno-omit-frame-pointer -momit-leaf-frame-pointer -fno-builtin-memcmp -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -DROCKSDB_FALLOCATE_PRESENT -DSNAPPY -DZLIB -DROCKSDB_MALLOC_USABLE_SIZE -march=native -isystem -fPIC")
set(BASE_FLAGS "${BASE_FLAGS} -W -Wextra -Wall -Wsign-compare -Wshadow -Wno-unused-parameter -fno-omit-frame-pointer -momit-leaf-frame-pointer -fno-builtin-memcmp -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -DROCKSDB_FALLOCATE_PRESENT -DSNAPPY -DZLIB -DROCKSDB_MALLOC_USABLE_SIZE -march=native -isystem -fPIC -D${OS_DEFINE}")
set(CMAKE_C_FLAGS "-g" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -Werror" CACHE INTERNAL "C debug flags")
@ -97,7 +154,7 @@ elseif (CMAKE_COMPILER_IS_CLANG)
message(STATUS "Compiler type CLANG: ${CMAKE_CXX_COMPILER}")
endif ()
set(BASE_FLAGS "${BASE_FLAGS} -Wall -Wextra -Wno-unused-parameter")
set(BASE_FLAGS "${BASE_FLAGS} -Wall -Wextra -Wno-unused-parameter -D${OS_DEFINE}")
set(CMAKE_C_FLAGS "-g" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "C debug flags")
@ -113,7 +170,7 @@ elseif (CMAKE_COMPILER_IS_CLANG)
elseif (MSVC)
if (VERBOSE)
message(STATUS "Compiler type MSVC: ${CMAKE_CXX_COMPILER}")
message(STATUS "Compiler type MSVC: ${CMAKE_CXX_COMPILER} -D${OS_DEFINE}")
endif ()
set(CMAKE_C_FLAGS "/MTd" CACHE INTERNAL "default C++ compiler flags")
@ -145,7 +202,7 @@ else ()
# unknown compiler
message(STATUS "Compiler type UNKNOWN: ${CMAKE_CXX_COMPILER}")
set(BASE_FLAGS "${BASE_FLAGS} -Wall")
set(BASE_FLAGS "${BASE_FLAGS} -Wall -D${OS_DEFINE}")
set(CMAKE_C_FLAGS "-g" CACHE INTERNAL "default C compiler flags")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "C debug flags")

View File

@ -118,7 +118,7 @@ std::vector<arangodb::consensus::index_t> State::log (
_log.push_back(log_t(idx[j], term, lid, buf)); // log to RAM
persist(idx[j], term, lid, i[0]); // log to disk
if (idx[j] > 0 && (idx[j] % _compaction_step) == 0) {
compact(idx[j]);
//compact(idx[j]);
}
++j;
}
@ -145,7 +145,7 @@ bool State::log(query_t const& queries, term_t term,
_log.push_back(log_t(idx, term, lid, buf));
persist(idx, term, lid, i.get("query")); // to disk
if (idx > 0 && (idx % _compaction_step) == 0) {
compact(idx);
//compact(idx);
}
} catch (std::exception const& e) {
LOG(ERR) << e.what();
@ -321,8 +321,56 @@ bool State::find (arangodb::consensus::index_t prevIndex, term_t prevTerm) {
bool State::compact (arangodb::consensus::index_t cind) {
if (checkCollection("compact")) {
bool saved = persistSpearhead(cind);
if (saved) {
compactPersistedState(cind);
compactVolatileState(cind);
return true;
} else {
return false;
}
}
bool State::compactVolatileState (arangodb::consensus::index_t cind) {
_log.erase(_log.begin(), _log.begin()+_compaction_step-1);
_cur = _log.begin()->index;
return true;
}
bool State::compactPersistedState (arangodb::consensus::index_t cind) {
auto bindVars = std::make_shared<VPackBuilder>();
bindVars->openObject();
bindVars->close();
std::string const aql(
std::string(
"FOR l IN log FILTER u._key < 'deleted' REMOVE l IN log"));
arangodb::aql::Query query(false, _vocbase,
aql.c_str(), aql.size(), bindVars, nullptr,
arangodb::aql::PART_MAIN);
auto queryResult = query.execute(QueryRegistryFeature::QUERY_REGISTRY);
if (queryResult.code != TRI_ERROR_NO_ERROR) {
THROW_ARANGO_EXCEPTION_MESSAGE(queryResult.code, queryResult.details);
}
VPackSlice result = queryResult.result->slice();
LOG(INFO) << result.toJson();
return true;
}
bool State::persistSpearhead (arangodb::consensus::index_t cind) {
if (checkCollection("compact")) {
Builder store;
store.openObject();
store.add("spearhead", VPackValue(VPackValueType::Array));
@ -348,10 +396,8 @@ bool State::compact (arangodb::consensus::index_t cind) {
auto result = trx.insert("compact", store.slice(), _options);
res = trx.finish(result.code);
/*if (res == TRI_ERROR_NO_ERROR) {
_log.erase(_log.begin(), _log.begin()+_compaction_step-1);
_cur = _log.begin()->index;
}*/
return (res == TRI_ERROR_NO_ERROR);
}
LOG_TOPIC (ERR, Logger::AGENCY) << "Compaction failed!";

View File

@ -134,6 +134,10 @@ private:
bool compact (arangodb::consensus::index_t cind);
bool compactPersistedState (arangodb::consensus::index_t cind);
bool compactVolatileState (arangodb::consensus::index_t cind);
bool persistSpearhead (arangodb::consensus::index_t cind);
Agent* _agent;
TRI_vocbase_t* _vocbase;

View File

@ -92,10 +92,15 @@ std::vector<check_t> Supervision::check (std::string const& path) {
continue;
} else {
query_t report = std::make_shared<Builder>();
report->openArray(); report->openArray(); report->openObject();
report->openArray(); report->openArray();
report->add(std::string("/arango/Supervision/Health/" + serverID),
VPackValue(VPackValueType::Object));
report->add("Status", VPackValue("GOOD"));
report->close(); report->close(); report->close();
report->add("LastHearbeat", VPackValue("GOOD"));
report->close();
report->close(); report->close();
LOG(DEBUG) << "GOOD:" << serverID<< it->second->serverTimestamp << ":" << it->second->serverStatus;
LOG(INFO) << report->toJson();
it->second->update(lastHeartbeatStatus,lastHeartbeatTime);
}
} else { // New server
@ -128,7 +133,8 @@ void Supervision::run() {
CONDITION_LOCKER(guard, _cv);
TRI_ASSERT(_agent!=nullptr);
bool timedout = false;
/*
while (!this->isStopping()) {
if (_agent->leading()) {
@ -139,7 +145,7 @@ void Supervision::run() {
doChecks(timedout);
}
}*/
}

View File

@ -720,8 +720,8 @@ function ahuacatlListTestSuite () {
assertEqual(actual.length, 1);
actual = actual[0];
assertEqual(actual.length, 10);
var actual = actual.sort(function(l, r) { if (l._key < r._key) { return -1;} else if (l._key > r._key) { return 1;} return 0; });
for (var i = 0; i < 10; ++i) {
actual = actual.sort(function(l, r) { if (l._key < r._key) { return -1;} else if (l._key > r._key) { return 1;} return 0; });
for (i = 0; i < 10; ++i) {
assertEqual(actual[i]._key, "test"+i);
}
},
@ -735,8 +735,8 @@ function ahuacatlListTestSuite () {
assertEqual(actual.length, 1);
actual = actual[0];
assertEqual(actual.length, 10);
var actual = actual.sort(function(l, r) { if (l._key < r._key) { return -1;} else if (l._key > r._key) { return 1;} return 0; });
for (var i = 0; i < 10; ++i) {
actual = actual.sort(function(l, r) { if (l._key < r._key) { return -1;} else if (l._key > r._key) { return 1;} return 0; });
for (i = 0; i < 10; ++i) {
assertEqual(actual[i]._key, "test"+i);
}
},
@ -750,8 +750,8 @@ function ahuacatlListTestSuite () {
assertEqual(actual.length, 1);
actual = actual[0];
assertEqual(actual.length, 10);
var actual = actual.sort(function(l, r) { if (l < r) { return -1;} else if (l > r) { return 1;} return 0; });
for (var i = 0; i < 10; ++i) {
actual = actual.sort(function(l, r) { if (l < r) { return -1;} else if (l > r) { return 1;} return 0; });
for (i = 0; i < 10; ++i) {
assertEqual(actual[i], collectionName + "/test"+i);
}
},