1
0
Fork 0

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

This commit is contained in:
hkernbach 2016-02-24 23:45:46 +01:00
commit e5c1577f89
16 changed files with 64 additions and 237 deletions

View File

@ -27,8 +27,6 @@
#include "vocbase.h"
#include <regex.h>
#include "Aql/QueryCache.h"
#include "Aql/QueryList.h"
#include "Basics/conversions.h"
@ -332,39 +330,15 @@ static bool UnloadCollectionCallback(TRI_collection_t* col, void* data) {
////////////////////////////////////////////////////////////////////////////////
static bool DropCollectionCallback(TRI_collection_t* col, void* data) {
TRI_vocbase_t* vocbase;
regmatch_t matches[4];
regex_t re;
int res;
TRI_vocbase_col_t* collection = static_cast<TRI_vocbase_col_t*>(data);
std::string const name(collection->name());
#ifdef _WIN32
// .........................................................................
// Just thank your lucky stars that there are only 4 backslashes
// .........................................................................
res = regcomp(&re, "^(.*)\\\\collection-([0-9][0-9]*)(-[0-9]+)?$",
REG_ICASE | REG_EXTENDED);
#else
res = regcomp(&re, "^(.*)/collection-([0-9][0-9]*)(-[0-9]+)?$",
REG_ICASE | REG_EXTENDED);
#endif
if (res != 0) {
LOG(ERR) << "unable to complile regular expression";
return false;
}
TRI_EVENTUAL_WRITE_LOCK_STATUS_VOCBASE_COL(collection);
if (collection->_status != TRI_VOC_COL_STATUS_DELETED) {
LOG(ERR) << "someone resurrected the collection '" << name << "'";
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
regfree(&re);
return false;
}
@ -375,7 +349,7 @@ static bool DropCollectionCallback(TRI_collection_t* col, void* data) {
if (collection->_collection != nullptr) {
TRI_document_collection_t* document = collection->_collection;
res = TRI_CloseDocumentCollection(document, false);
int res = TRI_CloseDocumentCollection(document, false);
if (res != TRI_ERROR_NO_ERROR) {
LOG(ERR) << "failed to close collection '" << name
@ -383,8 +357,6 @@ static bool DropCollectionCallback(TRI_collection_t* col, void* data) {
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
regfree(&re);
return true;
}
@ -399,7 +371,7 @@ static bool DropCollectionCallback(TRI_collection_t* col, void* data) {
// remove from list of collections
// .............................................................................
vocbase = collection->_vocbase;
TRI_vocbase_t* vocbase = collection->_vocbase;
{
WRITE_LOCKER(writeLocker, vocbase->_collectionsLock);
@ -420,43 +392,51 @@ static bool DropCollectionCallback(TRI_collection_t* col, void* data) {
// .............................................................................
if (!collection->path().empty()) {
int regExpResult;
std::string const collectionPath = collection->path();
regExpResult = regexec(&re, collection->pathc_str(),
sizeof(matches) / sizeof(matches[0]), matches, 0);
#ifdef _WIN32
size_t pos = collectionPath.find_last_of('\\');
#else
size_t pos = collectionPath.find_last_of('/');
#endif
if (regExpResult == 0) {
char const* first = collection->pathc_str() + matches[1].rm_so;
size_t firstLen = matches[1].rm_eo - matches[1].rm_so;
bool invalid = false;
char const* second = collection->pathc_str() + matches[2].rm_so;
size_t secondLen = matches[2].rm_eo - matches[2].rm_so;
if (pos == std::string::npos || pos + 1 >= collectionPath.size()) {
invalid = true;
}
char* tmp1;
char* tmp2;
char* tmp3;
std::string path;
std::string relName;
if (!invalid) {
// extract path part
if (pos > 0) {
path = collectionPath.substr(0, pos);
}
char* newFilename;
// extract relative filename
relName = collectionPath.substr(pos + 1);
tmp1 = TRI_DuplicateString(first, firstLen);
tmp2 = TRI_DuplicateString(second, secondLen);
tmp3 = TRI_Concatenate2String("deleted-", tmp2);
if (!StringUtils::isPrefix(relName, "collection-") ||
StringUtils::isSuffix(relName, ".tmp")) {
invalid = true;
}
}
TRI_FreeString(TRI_CORE_MEM_ZONE, tmp2);
if (!invalid) {
// prefix the collection name with "deleted-"
newFilename = TRI_Concatenate2File(tmp1, tmp3);
TRI_FreeString(TRI_CORE_MEM_ZONE, tmp1);
TRI_FreeString(TRI_CORE_MEM_ZONE, tmp3);
std::string const newFilename =
FileUtils::buildFilename(path, "deleted-" + relName.substr(std::string("collection-").size()));
// check if target directory already exists
if (TRI_IsDirectory(newFilename)) {
// no need to rename
TRI_RemoveDirectory(newFilename);
if (TRI_IsDirectory(newFilename.c_str())) {
// remove existing target directory
TRI_RemoveDirectory(newFilename.c_str());
}
// perform the rename
res = TRI_RenameFile(collection->pathc_str(), newFilename);
int res = TRI_RenameFile(collection->pathc_str(), newFilename.c_str());
LOG(TRACE) << "renaming collection directory from '"
<< collection->pathc_str() << "' to '" << newFilename << "'";
@ -469,23 +449,19 @@ static bool DropCollectionCallback(TRI_collection_t* col, void* data) {
LOG(DEBUG) << "wiping dropped collection '" << name
<< "' from disk";
res = TRI_RemoveDirectory(newFilename);
res = TRI_RemoveDirectory(newFilename.c_str());
if (res != TRI_ERROR_NO_ERROR) {
LOG(ERR) << "cannot wipe dropped collection '" << name
<< "' from disk: " << TRI_errno_string(res);
}
}
TRI_FreeString(TRI_CORE_MEM_ZONE, newFilename);
} else {
LOG(ERR) << "cannot rename dropped collection '" << name
<< "': unknown path '" << collection->pathc_str() << "'";
}
}
regfree(&re);
return true;
}

View File

@ -1,109 +0,0 @@
# -*- mode: Makefile; -*-
## -----------------------------------------------------------------------------
## --SECTION-- PROGRAM
## -----------------------------------------------------------------------------
################################################################################
### @brief program "arangob"
################################################################################
bin_arangob_CPPFLAGS = \
-I@top_srcdir@/arangosh \
$(AM_CPPFLAGS)
bin_arangob_LDADD = \
lib/libarango_client.a \
lib/libarango.a \
$(LIBS)
bin_arangob_SOURCES = \
lib/Basics/WorkMonitorDummy.cpp \
arangosh/ArangoShell/ArangoClient.cpp \
arangosh/Benchmark/arangob.cpp
################################################################################
### @brief program "arangodump"
################################################################################
bin_arangodump_CPPFLAGS = \
-I@top_srcdir@/arangosh \
$(AM_CPPFLAGS)
bin_arangodump_LDADD = \
lib/libarango_client.a \
lib/libarango.a \
$(LIBS)
bin_arangodump_SOURCES = \
lib/Basics/WorkMonitorDummy.cpp \
arangosh/ArangoShell/ArangoClient.cpp \
arangosh/V8Client/arangodump.cpp
################################################################################
### @brief program "arangoimp"
################################################################################
bin_arangoimp_CPPFLAGS = \
-I@top_srcdir@/arangosh \
$(AM_CPPFLAGS)
bin_arangoimp_LDADD = \
lib/libarango_client.a \
lib/libarango.a \
$(LIBS)
bin_arangoimp_SOURCES = \
lib/Basics/WorkMonitorDummy.cpp \
arangosh/ArangoShell/ArangoClient.cpp \
arangosh/V8Client/ImportHelper.cpp \
arangosh/V8Client/arangoimp.cpp
################################################################################
### @brief program "arangorestore"
################################################################################
bin_arangorestore_CPPFLAGS = \
-I@top_srcdir@/arangosh \
$(AM_CPPFLAGS)
bin_arangorestore_LDADD = \
lib/libarango_client.a \
lib/libarango.a \
$(LIBS)
bin_arangorestore_SOURCES = \
lib/Basics/WorkMonitorDummy.cpp \
arangosh/ArangoShell/ArangoClient.cpp \
arangosh/V8Client/arangorestore.cpp
################################################################################
### @brief program "arangosh"
################################################################################
bin_arangosh_CPPFLAGS = \
-I@top_srcdir@/arangosh \
$(AM_CPPFLAGS)
bin_arangosh_LDADD = \
lib/libarango_v8.a \
lib/libarango_client.a \
lib/libarango.a \
$(LIBS) \
@V8_LIBS@
bin_arangosh_SOURCES = \
lib/Basics/WorkMonitorDummy.cpp \
arangosh/ArangoShell/ArangoClient.cpp \
arangosh/V8Client/ImportHelper.cpp \
arangosh/V8Client/V8ClientConnection.cpp \
arangosh/V8Client/arangosh.cpp
## -----------------------------------------------------------------------------
## --SECTION-- END-OF-FILE
## -----------------------------------------------------------------------------
## Local Variables:
## mode: outline-minor
## outline-regexp: "^\\(### @brief\\|## --SECTION--\\|# -\\*- \\)"
## End:

View File

@ -1,40 +0,0 @@
# -*- mode: Makefile; -*-
## -----------------------------------------------------------------------------
## --SECTION-- CONFIGURATION FILES
## -----------------------------------------------------------------------------
BUILT_SOURCES += \
etc/arangodb/arango-dfdb$(PROGRAM_SUFFIX).conf \
etc/arangodb/arangob$(PROGRAM_SUFFIX).conf \
etc/arangodb/arangod$(PROGRAM_SUFFIX).conf \
etc/arangodb/arangod-docker$(PROGRAM_SUFFIX).conf \
etc/arangodb/arangodump$(PROGRAM_SUFFIX).conf \
etc/arangodb/arangoimp$(PROGRAM_SUFFIX).conf \
etc/arangodb/arangorestore$(PROGRAM_SUFFIX).conf \
etc/arangodb/arangosh$(PROGRAM_SUFFIX).conf \
etc/arangodb/foxx-manager$(PROGRAM_SUFFIX).conf
################################################################################
### @brief config
################################################################################
etc/arangodb/%$(PROGRAM_SUFFIX).conf: etc/arangodb/%.conf.in Makefile
@test -d etc/arangodb || mkdir -p etc/arangodb
sed \
-e 's%@LIBEXECDIR@%${TRI_LIBEXECDIR}%g' \
-e 's%@SBINDIR@%${TRI_SBINDIR}%g' \
-e 's%@LOCALSTATEDIR@%${TRI_LOCALSTATEDIR}%g' \
-e 's%@PKGDATADIR@%${TRI_PKGDATADIR}%g' \
-e 's%@SYSCONFDIR@%${TRI_SYSCONFDIR}%g' \
-e 's%@PROGRAM_SUFFIX@%${PROGRAM_SUFFIX}%g' \
$< > $@
## -----------------------------------------------------------------------------
## --SECTION-- END-OF-FILE
## -----------------------------------------------------------------------------
## Local Variables:
## mode: outline-minor
## outline-regexp: "^\\(### @brief\\|## --SECTION--\\|# -\\*- \\)"
## End:

View File

@ -1081,7 +1081,7 @@ class AssocMulti {
void resizeInternal(UserData* userData, Bucket& b, size_t size) {
std::string const cb(_contextCallback());
LOG(TRACE) << "resizing index " << cb.c_str() << ", target size: " << size;
LOG(TRACE) << "resizing index " << cb << ", target size: " << size;
LOG_TOPIC(TRACE, Logger::PERFORMANCE) <<
"index-resize " << cb << ", target size: " << size;
@ -1158,7 +1158,7 @@ class AssocMulti {
delete[] oldTable;
LOG(TRACE) << "resizing index " << cb.c_str() << " done";
LOG(TRACE) << "resizing index " << cb << " done";
LOG_TOPIC(TRACE, Logger::PERFORMANCE) << "[timer] " << Logger::DURATION(TRI_microtime() - start) << " s, index-resize, " << cb << ", target size: " << size;
}

View File

@ -190,7 +190,7 @@ class AssocUnique {
// entries
static uint64_t const NotificationSizeThreshold = 131072;
LOG(TRACE) << "resizing index " << cb.c_str() << ", target size: " << targetSize;
LOG(TRACE) << "resizing index " << cb << ", target size: " << targetSize;
double start = TRI_microtime();
if (targetSize > NotificationSizeThreshold) {
@ -249,7 +249,7 @@ class AssocUnique {
delete[] oldTable;
LOG(TRACE) << "resizing index " << cb.c_str() << " done";
LOG(TRACE) << "resizing index " << cb << " done";
LOG_TOPIC(TRACE, Logger::PERFORMANCE) << "[timer] " << Logger::DURATION(TRI_microtime() - start) << " s, index-resize, " << cb << ", target size: " << targetSize;
}

View File

@ -116,7 +116,7 @@ void throwFileReadError(int fd, std::string const& filename) {
std::string message("read failed for file '" + filename + "': " +
strerror(res));
LOG(TRACE) << "" << message.c_str();
LOG(TRACE) << "" << message;
THROW_ARANGO_EXCEPTION(TRI_ERROR_SYS_ERROR);
}
@ -131,7 +131,7 @@ void throwFileWriteError(int fd, std::string const& filename) {
std::string message("write failed for file '" + filename + "': " +
strerror(res));
LOG(TRACE) << "" << message.c_str();
LOG(TRACE) << "" << message;
THROW_ARANGO_EXCEPTION(TRI_ERROR_SYS_ERROR);
}

View File

@ -261,7 +261,7 @@ bool Thread::start(ConditionVariable* finishedCondition) {
} else {
_state.store(ThreadState::STOPPED);
LOG_TOPIC(ERR, Logger::THREADS) << "could not start thread '"
<< _name.c_str()
<< _name
<< "': " << strerror(errno);
return false;
@ -328,20 +328,20 @@ void Thread::runMe() {
_state.store(ThreadState::STOPPED);
} catch (Exception const& ex) {
LOG_TOPIC(ERR, Logger::THREADS) << "exception caught in thread '"
<< _name.c_str() << "': " << ex.what();
<< _name << "': " << ex.what();
Logger::flush();
_state.store(ThreadState::STOPPED);
throw;
} catch (std::exception const& ex) {
LOG_TOPIC(ERR, Logger::THREADS) << "exception caught in thread '"
<< _name.c_str() << "': " << ex.what();
<< _name << "': " << ex.what();
Logger::flush();
_state.store(ThreadState::STOPPED);
throw;
} catch (...) {
if (!isSilent()) {
LOG_TOPIC(ERR, Logger::THREADS) << "exception caught in thread '"
<< _name.c_str() << "'";
<< _name << "'";
Logger::flush();
}
_state.store(ThreadState::STOPPED);

View File

@ -67,12 +67,12 @@ SSL_CTX* arangodb::basics::sslContext(protocol_e protocol,
// load our keys and certificates
if (!SSL_CTX_use_certificate_chain_file(sslctx, keyfile.c_str())) {
LOG(ERR) << "cannot read certificate from '" << keyfile.c_str() << "': " << arangodb::basics::lastSSLError().c_str();
LOG(ERR) << "cannot read certificate from '" << keyfile << "': " << arangodb::basics::lastSSLError();
return nullptr;
}
if (!SSL_CTX_use_PrivateKey_file(sslctx, keyfile.c_str(), SSL_FILETYPE_PEM)) {
LOG(ERR) << "cannot read key from '" << keyfile.c_str() << "': " << arangodb::basics::lastSSLError().c_str();
LOG(ERR) << "cannot read key from '" << keyfile << "': " << arangodb::basics::lastSSLError();
return nullptr;
}

View File

@ -234,7 +234,7 @@ TRI_socket_t EndpointIp::connect(double connectTimeout, double requestTimeout) {
TRI_socket_t listenSocket;
TRI_invalidatesocket(&listenSocket);
LOG(DEBUG) << "connecting to ip endpoint '" << _specification.c_str() << "'";
LOG(DEBUG) << "connecting to ip endpoint '" << _specification << "'";
TRI_ASSERT(!TRI_isvalidsocket(_socket));
TRI_ASSERT(!_connected);
@ -306,7 +306,7 @@ TRI_socket_t EndpointIp::connect(double connectTimeout, double requestTimeout) {
TRI_socket_t listenSocket;
TRI_invalidatesocket(&listenSocket);
LOG(DEBUG) << "connecting to ip endpoint '" << _specification.c_str() << "'";
LOG(DEBUG) << "connecting to ip endpoint '" << _specification << "'";
TRI_ASSERT(!TRI_isvalidsocket(_socket));
TRI_ASSERT(!_connected);

View File

@ -223,7 +223,7 @@ void EndpointList::dump() const {
for (auto& it : _endpoints) {
Endpoint const* ep = it.second.first;
LOG(INFO) << "using endpoint '" << it.first.c_str() << "' for " << getEncryptionName(ep->getEncryption()).c_str() << " requests";
LOG(INFO) << "using endpoint '" << it.first << "' for " << getEncryptionName(ep->getEncryption()) << " requests";
}
}

View File

@ -65,21 +65,21 @@ TRI_socket_t EndpointUnixDomain::connect(double connectTimeout,
TRI_socket_t listenSocket;
TRI_invalidatesocket(&listenSocket);
LOG(DEBUG) << "connecting to unix endpoint '" << _specification.c_str() << "'";
LOG(DEBUG) << "connecting to unix endpoint '" << _specification << "'";
TRI_ASSERT(!TRI_isvalidsocket(_socket));
TRI_ASSERT(!_connected);
if (_type == ENDPOINT_SERVER && FileUtils::exists(_path)) {
// socket file already exists
LOG(WARN) << "socket file '" << _path.c_str() << "' already exists.";
LOG(WARN) << "socket file '" << _path << "' already exists.";
int error = 0;
// delete previously existing socket file
if (FileUtils::remove(_path, &error)) {
LOG(WARN) << "deleted previously existing socket file '" << _path.c_str() << "'";
LOG(WARN) << "deleted previously existing socket file '" << _path << "'";
} else {
LOG(ERR) << "unable to delete previously existing socket file '" << _path.c_str() << "'";
LOG(ERR) << "unable to delete previously existing socket file '" << _path << "'";
return listenSocket;
}
@ -166,7 +166,7 @@ void EndpointUnixDomain::disconnect() {
if (_type == ENDPOINT_SERVER) {
int error = 0;
if (!FileUtils::remove(_path, &error)) {
LOG(TRACE) << "unable to remove socket file '" << _path.c_str() << "'";
LOG(TRACE) << "unable to remove socket file '" << _path << "'";
}
}
}

View File

@ -147,7 +147,7 @@ SimpleHttpResult* SimpleHttpClient::retryRequest(
}
if (!_retryMessage.empty() && (_maxRetries - tries) > 0) {
LOG(WARN) << "" << _retryMessage.c_str() << " - retries left: " << (_maxRetries - tries);
LOG(WARN) << "" << _retryMessage << " - retries left: " << (_maxRetries - tries);
}
#ifdef _WIN32

View File

@ -195,7 +195,7 @@ class SimpleHttpClient {
_errorMessage = message;
if (_warn || forceWarn) {
LOG(WARN) << "" << _errorMessage.c_str();
LOG(WARN) << "" << _errorMessage;
}
}

View File

@ -121,7 +121,7 @@ std::string const& ScriptLoader::findScript(std::string const& name) {
char* result = TRI_SlurpFile(TRI_CORE_MEM_ZONE, filename, nullptr);
if (result == nullptr && (i == parts.size() - 1)) {
LOG(ERR) << "cannot locate file '" << StringUtils::correctPath(name).c_str() << "': " << TRI_last_error();
LOG(ERR) << "cannot locate file '" << StringUtils::correctPath(name) << "': " << TRI_last_error();
}
TRI_FreeString(TRI_CORE_MEM_ZONE, filename);

View File

@ -53,7 +53,7 @@ v8::Handle<v8::Value> JSLoader::executeGlobalScript(
if (i == _scripts.end()) {
// correct the path/name
LOG(ERR) << "unknown script '" << StringUtils::correctPath(name).c_str() << "'";
LOG(ERR) << "unknown script '" << StringUtils::correctPath(name) << "'";
return v8::Undefined(isolate);
}
@ -92,7 +92,7 @@ JSLoader::eState JSLoader::loadScript(v8::Isolate* isolate,
if (i == _scripts.end()) {
// correct the path/name
LOG(ERR) << "unknown script '" << StringUtils::correctPath(name).c_str() << "'";
LOG(ERR) << "unknown script '" << StringUtils::correctPath(name) << "'";
return eFailLoad;
}

View File

@ -757,8 +757,8 @@ static void JS_Download(v8::FunctionCallbackInfo<v8::Value> const& args) {
TRI_V8_THROW_SYNTAX_ERROR("unsupported URL specified");
}
LOG(TRACE) << "downloading file. endpoint: " << endpoint.c_str()
<< ", relative URL: " << url.c_str();
LOG(TRACE) << "downloading file. endpoint: " << endpoint
<< ", relative URL: " << url;
std::unique_ptr<Endpoint> ep(Endpoint::clientFactory(endpoint));
@ -3793,7 +3793,7 @@ void TRI_LogV8Exception(v8::Isolate* isolate, v8::TryCatch* tryCatch) {
if (*sourceline) {
std::string l = *sourceline;
LOG(ERR) << "!" << l.c_str();
LOG(ERR) << "!" << l;
if (1 < start) {
l = std::string(start - 1, ' ');
@ -3803,7 +3803,7 @@ void TRI_LogV8Exception(v8::Isolate* isolate, v8::TryCatch* tryCatch) {
l += std::string((size_t)(end - start + 1), '^');
LOG(ERR) << "!" << l.c_str();
LOG(ERR) << "!" << l;
}
}
}