1
0
Fork 0

Merge branch 'spdvpk' of github.com:arangodb/arangodb into spdvpk

This commit is contained in:
Michael Hackstein 2016-03-24 16:43:34 +01:00
commit 91c98d479d
11 changed files with 45 additions and 54 deletions

View File

@ -139,13 +139,13 @@ void Agent::reportIn (id_t id, index_t index) {
if (index > _confirmed[id]) // progress this follower?
_confirmed[id] = index;
if(index > _last_commit_index) { // progress last commit?
size_t n = 0;
for (size_t i = 0; i < size(); ++i) {
n += (_confirmed[i]>=index);
}
if (n>size()/2) { // catch up read database and commit index
LOG_TOPIC(INFO, Logger::AGENCY) << "Critical mass for commiting " <<
_last_commit_index+1 << " through " << index << " to read db";
@ -195,8 +195,7 @@ bool Agent::recvAppendEntriesRPC (term_t term, id_t leaderId, index_t prevIndex,
}
append_entries_t Agent::sendAppendEntriesRPC (
id_t slave_id/*, collect_ret_t const& entries*/) {
append_entries_t Agent::sendAppendEntriesRPC (id_t slave_id) {
index_t last_confirmed = _confirmed[slave_id];
std::vector<log_t> unconfirmed = _state.get(last_confirmed);
@ -224,6 +223,9 @@ append_entries_t Agent::sendAppendEntriesRPC (
}
builder.close();
LOG_TOPIC(WARN,Logger::AGENCY) << _config.end_points[slave_id] << path.str();
LOG_TOPIC(WARN,Logger::AGENCY) << builder.slice().toJson();
// Send
if (unconfirmed.size() > 1) {
LOG_TOPIC(INFO, Logger::AGENCY) << "Appending " << unconfirmed.size() << " entries up to index "

View File

@ -36,7 +36,7 @@ using namespace arangodb::rest;
ApplicationAgency::ApplicationAgency()
: ApplicationFeature("agency"), _size(1), _min_election_timeout(0.1),
_max_election_timeout(1.0), _election_call_rate_mul(0.85),
_max_election_timeout(1.0), _election_call_rate_mul(0.85), _notify(false),
_agent_id(std::numeric_limits<uint32_t>::max()) {
}
@ -79,7 +79,8 @@ bool ApplicationAgency::prepare() {
if (_size % 2 == 0) {
LOG_TOPIC(ERR, Logger::AGENCY) << "AGENCY: agency must have odd number of members";
LOG_TOPIC(ERR, Logger::AGENCY)
<< "AGENCY: agency must have odd number of members";
return false;
}
@ -89,20 +90,24 @@ bool ApplicationAgency::prepare() {
}
if (_min_election_timeout <= 0.) {
LOG_TOPIC(ERR, Logger::AGENCY) << "agency.election-timeout-min must not be negative!";
LOG_TOPIC(ERR, Logger::AGENCY)
<< "agency.election-timeout-min must not be negative!";
return false;
} else if (_min_election_timeout < .15) {
LOG(WARN) << "very short agency.election-timeout-min!";
LOG_TOPIC(WARN, Logger::AGENCY)
<< "very short agency.election-timeout-min!";
}
if (_max_election_timeout <= _min_election_timeout) {
LOG_TOPIC(ERR, Logger::AGENCY) << "agency.election-timeout-max must not be shorter than or"
<< "equal to agency.election-timeout-min.";
LOG_TOPIC(ERR, Logger::AGENCY)
<< "agency.election-timeout-max must not be shorter than or"
<< "equal to agency.election-timeout-min.";
return false;
}
if (_max_election_timeout <= 2*_min_election_timeout) {
LOG_TOPIC(WARN, Logger::AGENCY) << "agency.election-timeout-max should probably be chosen longer!";
LOG_TOPIC(WARN, Logger::AGENCY)
<< "agency.election-timeout-max should probably be chosen longer!";
}
_agency_endpoints.resize(_size);
@ -121,7 +126,6 @@ bool ApplicationAgency::start() {
if (_disabled) {
return true;
}
_agent->start();
return true;
}

View File

@ -452,7 +452,7 @@ bool Store::read (VPackSlice const& query, Builder& ret) const {
return false;
}
query_strs.sort(); // sort paths
// Remove double ranges (inclusion / identity)
for (auto i = query_strs.begin(), j = i; i != query_strs.end(); ++i) {
if (i!=j && i->compare(0,j->size(),*j)==0) {
@ -463,7 +463,7 @@ bool Store::read (VPackSlice const& query, Builder& ret) const {
}
auto cut = std::remove_if(query_strs.begin(), query_strs.end(), Empty());
query_strs.erase (cut,query_strs.end());
// Create response tree
Node copy("copy");
for (auto i = query_strs.begin(); i != query_strs.end(); ++i) {
@ -471,7 +471,7 @@ bool Store::read (VPackSlice const& query, Builder& ret) const {
copy(*i) = (*this)(*i);
} catch (StoreException const&) {}
}
// Assemble builder from response tree
if (query.type() == VPackValueType::String &&
copy(*query_strs.begin()).type() == LEAF) {

View File

@ -1640,7 +1640,7 @@ int InitialSyncer::handleCollection(VPackSlice const& parameters,
return TRI_ERROR_REPLICATION_APPLIER_STOPPED;
}
if (!parameters.isObject() || !indexes.isObject()) {
if (!parameters.isObject() || !indexes.isArray()) {
return TRI_ERROR_REPLICATION_INVALID_RESPONSE;
}

View File

@ -44,7 +44,7 @@ class ExplicitTransaction : public Transaction {
ExplicitTransaction(std::shared_ptr<V8TransactionContext> transactionContext,
std::vector<std::string> const& readCollections,
std::vector<std::string> const& writeCollections,
double lockTimeout, bool waitForSync, bool embed,
double lockTimeout, bool waitForSync,
bool allowImplicitCollections)
: Transaction(transactionContext, 0) {
this->addHint(TRI_TRANSACTION_HINT_LOCK_ENTIRELY, false);

View File

@ -24,7 +24,6 @@
#ifndef ARANGOD_V8_SERVER_V8_TRAVERSER_H
#define ARANGOD_V8_SERVER_V8_TRAVERSER_H 1
#include "Utils/ExplicitTransaction.h"
#include "VocBase/ExampleMatcher.h"
#include "VocBase/Traverser.h"

View File

@ -28,21 +28,20 @@
#include "Aql/QueryList.h"
#include "Aql/QueryRegistry.h"
#include "Basics/conversions.h"
#include "Basics/json-utilities.h"
#include "Basics/MutexLocker.h"
#include "Basics/ScopeGuard.h"
#include "Basics/tri-strings.h"
#include "Basics/Utf8Helper.h"
#include "Cluster/AgencyComm.h"
#include "Cluster/ClusterComm.h"
#include "Cluster/ClusterInfo.h"
#include "Cluster/ClusterMethods.h"
#include "Cluster/ServerState.h"
#include "Indexes/Index.h"
#include "HttpServer/ApplicationEndpointServer.h"
#include "RestServer/ConsoleThread.h"
#include "RestServer/VocbaseContext.h"
#include "Rest/Version.h"
#include "Utils/ExplicitTransaction.h"
#include "Utils/V8TransactionContext.h"
#include "V8/JSLoader.h"
#include "V8/v8-conv.h"
#include "V8/v8-utils.h"
@ -339,11 +338,11 @@ static void JS_Transaction(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_THROW_EXCEPTION_PARAMETER(actionError);
}
auto transactionContext = std::make_shared<V8TransactionContext>(vocbase, false);
auto transactionContext = std::make_shared<V8TransactionContext>(vocbase, embed);
// start actual transaction
ExplicitTransaction trx(transactionContext, readCollections, writeCollections,
lockTimeout, waitForSync, embed,
lockTimeout, waitForSync,
allowImplicitCollections);
int res = trx.begin();
@ -1756,13 +1755,12 @@ static ExplicitTransaction* BeginTransaction(
// IHHF isCoordinator
double lockTimeout =
(double)(TRI_TRANSACTION_DEFAULT_LOCK_TIMEOUT / 1000000ULL);
bool embed = true;
bool waitForSync = false;
// Start Transaction to collect all parts of the path
auto trx = std::make_unique<ExplicitTransaction>(
transactionContext, readCollections, writeCollections, lockTimeout, waitForSync,
embed, true);
true);
int res = trx->begin();
if (res != TRI_ERROR_NO_ERROR) {

View File

@ -611,16 +611,12 @@ struct EdgeCrudTest : public BenchmarkOperation {
size_t const mod = globalCounter % 4;
if (mod == 0) {
return std::string("/_api/edge?collection=" + ARANGOB->collection() +
"&from=" + ARANGOB->collection() + "%2Ftestfrom" +
StringUtils::itoa(globalCounter) + "&to=" +
ARANGOB->collection() + "%2Ftestto" +
StringUtils::itoa(globalCounter));
return std::string("/_api/document?collection=" + ARANGOB->collection());
} else {
size_t keyId = (size_t)(globalCounter / 4);
std::string const key = "testkey" + StringUtils::itoa(keyId);
return std::string("/_api/edge/" + ARANGOB->collection() + "/" + key);
return std::string("/_api/document/" + ARANGOB->collection() + "/" + key);
}
}
@ -666,6 +662,19 @@ struct EdgeCrudTest : public BenchmarkOperation {
TRI_AppendStringStringBuffer(buffer, key.c_str());
TRI_AppendStringStringBuffer(buffer, "\"");
if (mod == 0) {
// append edge information
TRI_AppendStringStringBuffer(buffer, ",\"_from\":\"");
TRI_AppendStringStringBuffer(buffer, ARANGOB->collection().c_str());
TRI_AppendStringStringBuffer(buffer, "/testfrom");
TRI_AppendUInt64StringBuffer(buffer, globalCounter);
TRI_AppendStringStringBuffer(buffer, "\",\"_to\":\"");
TRI_AppendStringStringBuffer(buffer, ARANGOB->collection().c_str());
TRI_AppendStringStringBuffer(buffer, "/testto");
TRI_AppendUInt64StringBuffer(buffer, globalCounter);
TRI_AppendStringStringBuffer(buffer, "\"");
}
for (uint64_t i = 1; i <= n; ++i) {
TRI_AppendStringStringBuffer(buffer, ",\"value");
TRI_AppendUInt64StringBuffer(buffer, i);

View File

@ -1,5 +1,5 @@
/*jshint globalstrict:false, strict:false */
/*global assertEqual, assertTypeOf, assertNotEqual, assertTrue, assertFalse, assertNull, assertUndefined, fail */
/*global assertEqual, assertTypeOf, assertNotEqual, assertTrue, assertFalse, assertUndefined, fail */
////////////////////////////////////////////////////////////////////////////////
/// @brief test the collection interface
@ -36,7 +36,6 @@ var internal = require("internal");
var ArangoCollection = arangodb.ArangoCollection;
var db = arangodb.db;
var ERRORS = arangodb.errors;
var testHelper = require("@arangodb/test-helper").Helper;
var compareStringIds = function (l, r) {
var i;

View File

@ -30,8 +30,6 @@
var jsunity = require("jsunity");
var internal = require("internal");
var errors = internal.errors;
var testHelper = require("@arangodb/test-helper").Helper;
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite: Creation
@ -42,22 +40,6 @@ function HashIndexSuite() {
var cn = "UnitTestsCollectionHash";
var collection = null;
var sorter = function (l, r) {
var i;
if (l.length !== r.length) {
return l.length - r.length < 0 ? -1 : 1;
}
// length is equal
for (i = 0; i < l.length; ++i) {
if (l[i] !== r[i]) {
return l[i] < r[i] ? -1 : 1;
}
}
return 0;
};
return {
////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
/*jshint globalstrict:false, strict:false */
/*global fail, assertEqual, assertNotNull, assertNull, assertTrue, assertMatch,
/*global assertEqual, assertNotNull, assertNull, assertTrue, assertMatch,
assertFalse */
////////////////////////////////////////////////////////////////////////////////
@ -2099,7 +2099,6 @@ function SimpleQuerySparseRangeSuite () {
var collection = null;
var age = function(d) { return d.age; };
var ageSort = function(l, r) { if (l !== r) { if (l < r) { return -1; } return 1; } return 0; };
var errors = require("@arangodb").errors;
return {
@ -2235,7 +2234,6 @@ function SimpleQueryUniqueSparseRangeSuite () {
var collection = null;
var age = function(d) { return d.age; };
var ageSort = function(l, r) { if (l !== r) { if (l < r) { return -1; } return 1; } return 0; };
var errors = require("@arangodb").errors;
return {