1
0
Fork 0

some fixes

This commit is contained in:
Simon Grätzer 2018-08-22 14:01:24 +02:00
parent c3d950f1d6
commit feaeac12bd
3 changed files with 15 additions and 6 deletions

View File

@ -75,16 +75,18 @@ V8ClientConnection::~V8ClientConnection() {
void V8ClientConnection::createConnection() { void V8ClientConnection::createConnection() {
_connection = _builder.connect(_loop); auto newConnection = _builder.connect(_loop);
fuerte::StringMap params{{"details","true"}}; fuerte::StringMap params{{"details","true"}};
auto req = fuerte::createRequest(fuerte::RestVerb::Get, "/_api/version", params); auto req = fuerte::createRequest(fuerte::RestVerb::Get, "/_api/version", params);
req->header.database = _databaseName; req->header.database = _databaseName;
req->timeout(std::chrono::seconds(30));
try { try {
auto res = _connection->sendRequest(std::move(req)); auto res = newConnection->sendRequest(std::move(req));
_lastHttpReturnCode = res->statusCode(); _lastHttpReturnCode = res->statusCode();
if (_lastHttpReturnCode == 200) { if (_lastHttpReturnCode == 200) {
_connection = std::move(newConnection);
std::shared_ptr<VPackBuilder> parsedBody; std::shared_ptr<VPackBuilder> parsedBody;
VPackSlice body; VPackSlice body;
if (res->contentType() == fuerte::ContentType::VPack) { if (res->contentType() == fuerte::ContentType::VPack) {
@ -139,7 +141,10 @@ void V8ClientConnection::setInterrupted(bool interrupted) {
} }
bool V8ClientConnection::isConnected() { bool V8ClientConnection::isConnected() {
return _connection->state() == fuerte::Connection::State::Connected; if (_connection) {
return _connection->state() == fuerte::Connection::State::Connected;
}
return false;
} }
std::string V8ClientConnection::endpointSpecification() const { std::string V8ClientConnection::endpointSpecification() const {
@ -177,6 +182,9 @@ void V8ClientConnection::reconnect(ClientFeature* client) {
_builder.authenticationType(fuerte::AuthenticationType::Jwt); _builder.authenticationType(fuerte::AuthenticationType::Jwt);
} }
try { try {
if (_connection) {
_connection->cancel();
}
createConnection(); createConnection();
} catch (...) { } catch (...) {
std::string errorMessage = "error in '" + client->endpoint() + "'"; std::string errorMessage = "error in '" + client->endpoint() + "'";

View File

@ -553,7 +553,8 @@ function MovingShardsWithViewSuite (options) {
v[i].drop(); v[i].drop();
c[i].drop(); c[i].drop();
} }
c = [], v = []; c = [];
v = [];
resetCleanedOutServers(); resetCleanedOutServers();
}, },

View File

@ -200,7 +200,7 @@ function SynchronousReplicationWithViewSuite () {
viewOperations("assert", null, function assert() { viewOperations("assert", null, function assert() {
assertEqual( assertEqual(
viewOperations("query", { query: "FOR d IN @@vn COLLECT WITH COUNT into iCount RETURN iCount", viewOperations("query", { query: "FOR d IN @@vn COLLECT WITH COUNT into iCount RETURN iCount",
bind: '{ "@vn" : name }' }).toArray()[0], 1) } ); bind: '{ "@vn" : name }' }).toArray()[0], 1); } );
if (healing.place === 1) { healFailure(healing); } if (healing.place === 1) { healFailure(healing); }
if (failure.place === 2) { makeFailure(failure); } if (failure.place === 2) { makeFailure(failure); }