1
0
Fork 0

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

This commit is contained in:
Kaveh Vahedipour 2016-03-16 16:27:53 +01:00
commit 7355cde795
64 changed files with 4109 additions and 3465 deletions

View File

@ -17,19 +17,17 @@ if (GO_FOUND)
set (ETCD_BUILD_COMMAND ./build)
endif ()
ExternalProject_Add(etcd_build
SOURCE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/etcd
ExternalProject_Add(etcd
CONFIGURE_COMMAND
""
URL
"${CMAKE_CURRENT_SOURCE_DIR}/etcd"
BUILD_IN_SOURCE
TRUE
1
BUILD_COMMAND
"${ETCD_BUILD_COMMAND}"
INSTALL_COMMAND
"cp"
${CMAKE_CURRENT_SOURCE_DIR}/etcd/bin/etcd
${CMAKE_BINARY_DIR}/bin/etcd-arango
cp bin/etcd ${CMAKE_BINARY_DIR}/bin/etcd-arango
)
endif ()

4
3rdParty/linenoise-ng/.clang-format vendored Normal file
View File

@ -0,0 +1,4 @@
BasedOnStyle: Google
DerivePointerAlignment: false
PointerAlignment: Left
Standard: Cpp11

View File

@ -1,4 +1,12 @@
CMakeCache.txt
CMakeFiles
Makefile
build
cmake_install.cmake
install_manifest.txt
example
linenoise_example
liblinenoise.a
*.dSYM
history.txt
*.o

View File

@ -29,27 +29,42 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BASE_COMPILER_OPTIONS} -O3 -fomit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${BASE_COMPILER_OPTIONS} -O3 -g")
elseif(CMAKE_COMPILER_IS_CLANGCXX)
elseif(CMAKE_COMPILER_IS_CLANGCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# using regular Clang or AppleClang
message(STATUS "Compiler type CLANG: ${CMAKE_CXX_COMPILER}")
set(BASE_COMPILER_OPTIONS "-std=c++11 -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILER_COMPTIONS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILER_OPTIONS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${BASE_COMPILER_OPTIONS} -O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${BASE_COMPILER_OPTIONS} -Os")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BASE_COMPILER_OPTIONS} -O3 -fomit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${BASE_COMPILER_OPTIONS} -O3 -g")
elseif(MSVC)
elseif(MSVC)
message(STATUS "Compiler type MSVC: ${CMAKE_CXX_COMPILER}")
add_definitions("-D_CRT_SECURE_NO_WARNINGS=1")
set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} /MT")
set(${CMAKE_CXX_FLAGS_DEBUG} "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
# hard-coded target platform to x64. does not link otherwise
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MACHINE:x64 /SUBSYSTEM:CONSOLE /LTCG /SAFESEH:NO /ignore:4099")
foreach (flag_var
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if (flag_var MATCHES "DEBUG")
set(${flag_var} "${${flag_var}} /MTd")
else ()
set(${flag_var} "${${flag_var}} /MT")
endif ()
endforeach()
# https://msdn.microsoft.com/en-us/library/aa267384%28VS.60%29.aspx
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO /SUBSYSTEM:CONSOLE /LTCG /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SUBSYSTEM:CONSOLE /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SUBSYSTEM:CONSOLE /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SUBSYSTEM:CONSOLE /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
else()
# unknown compiler
message(STATUS "Compiler type UNKNOWN: ${CMAKE_CXX_COMPILER}")
set(BASE_COMPILER_OPTIONS "-std=c++11 -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILER_COMPTIONS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILER_OPTIONS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${BASE_COMPILER_OPTIONS} -O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${BASE_COMPILER_OPTIONS} -Os")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BASE_COMPILER_OPTIONS} -O3 -fomit-frame-pointer")
@ -68,6 +83,12 @@ add_library(
src/wcwidth.cpp
)
# install
install(TARGETS linenoise DESTINATION lib)
# headers
install(FILES include/linenoise.h DESTINATION include)
# build example
add_executable(
example

View File

@ -1,25 +1,66 @@
Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
linenoise.cpp
=============
Copyright (c) 2010, Salvatore Sanfilippo <antirez at gmail dot com>
Copyright (c) 2010, Pieter Noordhuis <pcnoordhuis at gmail dot com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Redis nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
wcwidth.cpp
===========
Markus Kuhn -- 2007-05-26 (Unicode 5.0)
Permission to use, copy, modify, and distribute this software
for any purpose and without fee is hereby granted. The author
disclaims all warranties with regard to this software.
ConvertUTF.cpp
==============
Copyright 2001-2004 Unicode, Inc.
Disclaimer
This source code is provided as is by Unicode, Inc. No claims are
made as to fitness for any particular purpose. No warranties of any
kind are expressed or implied. The recipient agrees to determine
applicability of information provided. If this file has been
purchased on magnetic or optical media from Unicode, Inc., the
sole remedy for any claim will be exchange of defective media
within 90 days of receipt.
Limitations on Rights to Redistribute This Code
Unicode, Inc. hereby grants the right to freely use the information
supplied in this file in the creation of products supporting the
Unicode Standard, and to make copies of this file in any form
for internal or external distribution as long as this notice
remains attached.

View File

@ -1,23 +1,87 @@
# Linenoise Next Generation
A linenoise implementation based on the work by Salvatore Sanfilippo,
10gen Inc and others. They goal is to create a zero-config, BSD
A small, portable GNU readline replacement for Linux, Windows and
MacOS which is capable of handling UTF-8 characters. Unlike GNU
readline, which is GPL, this library uses a BSD license and can be
used in any kind of program.
## Origin
This linenoise implementation is based on the work by
[Salvatore Sanfilippo](https://github.com/antirez/linenoise) and
10gen Inc. The goal is to create a zero-config, BSD
licensed, readline replacement usable in Apache2 or BSD licensed
programs.
* single and multi line editing mode with the usual key bindings implemented
## Features
* single-line and multi-line editing mode with the usual key bindings implemented
* history handling
* completion
* BSD license source code
* Only uses a subset of VT100 escapes (ANSI.SYS compatible)
* UTF8 aware
* support for linux, MacOS and Windows
* support for Linux, MacOS and Windows
It deviates from Salvatore's original goal to have a minimal readline
replacement for the sake of supporting UTF8 and Windows. It deviates
from 10gen Inc. goal to create a C++ interface, we stick to a pure
C interface. However, the library itself uses C++11 unicode strings
internally.
from 10gen Inc.'s goal to create a C++ interface to linenoise. This
library uses C++ internally, but to the user it provides a pure C
interface that is compatible with the original linenoise API.
C interface.
## Requirements
To build this library, you will need a C++11-enabled compiler and
some recent version of CMake.
## Build instructions
To build this library on Linux, first create a build directory
```bash
mkdir -p build
```
and then build the library:
```bash
(cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make)
```
To build and install the library at the default target location, use
```bash
(cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make && sudo make install)
```
The default installation location can be adjusted by setting the `DESTDIR`
variable when invoking `make install`:
```bash
(cd build && make DESTDIR=/tmp install)
```
To build the library on Windows, use these commands in an MS-DOS command
prompt:
```
md build
cd build
```
After that, invoke the appropriate command to create the files for your
target environment:
* 32 bit: `cmake -G "Visual Studio 12 2013" -DCMAKE_BUILD_TYPE=Release ..`
* 64 bit: `cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_BUILD_TYPE=Release ..`
After that, open the generated file `linenoise.sln` from the `build`
subdirectory with Visual Studio.
*note: the following sections of the README.md are from the original
linenoise repository and are partly outdated*
## Can a line editing library be 20k lines of code?
@ -79,12 +143,14 @@ use both in free software and commercial software.
* FreeBSD xterm ($TERM = xterm)
* ANSI.SYS
* Emacs comint mode ($TERM = dumb)
* Windows
Please test it everywhere you can and report back!
## Let's push this forward!
Patches should be provided in the respect of linenoise sensibility for
small easy to understand code that. They must be submitted under the
Apache2 license using the supplied Apache2 contributor license
agreement.
small and easy to understand code that and the license
restrictions. Extensions must be submitted under a BSD license-style.
A contributor license is required for contributions.

11
3rdParty/linenoise-ng/appveyor.yml vendored Normal file
View File

@ -0,0 +1,11 @@
version: 1.0.{build}
branches:
only:
- master
configuration: Release
build:
build_script:
- md build
- cd %APPVEYOR_BUILD_FOLDER%\build
- cmake -G "Visual Studio 12 Win64" -DCMAKE_BUILD_TYPE=Release ..
- cmake --build . --config Release

View File

@ -44,21 +44,25 @@
extern "C" {
#endif
typedef struct linenoiseCompletions linenoiseCompletions;
typedef struct linenoiseCompletions linenoiseCompletions;
typedef void(linenoiseCompletionCallback)(const char*, linenoiseCompletions*);
void linenoiseSetCompletionCallback(linenoiseCompletionCallback* fn);
void linenoiseAddCompletion(linenoiseCompletions* lc, const char* str);
typedef void(linenoiseCompletionCallback)(const char*, linenoiseCompletions*);
void linenoiseSetCompletionCallback(linenoiseCompletionCallback* fn);
void linenoiseAddCompletion(linenoiseCompletions* lc, const char* str);
char* linenoise(const char* prompt);
void linenoisePreloadBuffer(const char* preloadText);
int linenoiseHistoryAdd(const char* line);
int linenoiseHistorySetMaxLen(int len);
int linenoiseHistorySave(const char* filename);
int linenoiseHistoryLoad(const char* filename);
void linenoiseHistoryFree(void);
void linenoiseClearScreen(void);
int linenoiseInstallWindowChangeHandler(void);
char* linenoise(const char* prompt);
void linenoisePreloadBuffer(const char* preloadText);
int linenoiseHistoryAdd(const char* line);
int linenoiseHistorySetMaxLen(int len);
char* linenoiseHistoryLine(int index);
int linenoiseHistorySave(const char* filename);
int linenoiseHistoryLoad(const char* filename);
void linenoiseHistoryFree(void);
void linenoiseClearScreen(void);
void linenoiseSetMultiLine(int ml);
void linenoisePrintKeyCodes(void);
/* the following is extension to the original linenoise API */
int linenoiseInstallWindowChangeHandler(void);
#ifdef __cplusplus
}

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,18 @@ void completionHook (char const* prefix, linenoiseCompletions* lc) {
}
}
int main () {
int main (int argc, char** argv) {
linenoiseInstallWindowChangeHandler();
while(argc > 1) {
argc--;
argv++;
if (!strcmp(*argv, "--keycodes")) {
linenoisePrintKeyCodes();
exit(0);
}
}
const char* file = "./history";
linenoiseHistoryLoad(file);
@ -26,13 +37,21 @@ int main () {
printf("starting...\n");
char const* prompt = "linenoise> ";
char const* prompt = "\x1b[1;32mlinenoise\x1b[0m> ";
while (1) {
char* result = linenoise(prompt);
if (result == NULL) {
break;
} else if (!strncmp(result, "/history", 8)) {
/* Display the current history. */
for (int index = 0; ; ++index) {
char* hist = linenoiseHistoryLine(index);
if (hist == NULL) break;
printf("%4d: %s\n", index, hist);
free(hist);
}
}
if (*result == '\0') {
free(result);
@ -43,7 +62,7 @@ int main () {
linenoiseHistoryAdd(result);
free(result);
}
linenoiseHistorySave(file);
linenoiseHistoryFree();
}

1508
CHANGELOG

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
set(ARANGODB_VERSION_MAJOR "3")
set(ARANGODB_VERSION_MINOR "0")
set(ARANGODB_VERSION_REVISION "0-devel")
set(ARANGODB_VERSION_REVISION "x-devel")
set(ARANGODB_VERSION
"${ARANGODB_VERSION_MAJOR}.${ARANGODB_VERSION_MINOR}.${ARANGODB_VERSION_REVISION}")
@ -357,6 +357,14 @@ if (USE_TCMALLOC)
find_package(tcmalloc)
endif ()
################################################################################
## LIBRARY RESOLV
################################################################################
if (NOT WINDOWS)
set(NET_LIBS ${NET_LIBS} resolv)
endif ()
################################################################################
## FLAGS
################################################################################
@ -703,6 +711,7 @@ list(INSERT SYSTEM_LIBRARIES 0
${BASE_LIBS}
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
${NET_LIBS}
)
add_subdirectory(lib)

View File

@ -1,5 +1,15 @@
# -*- mode: CMAKE; -*-
# swagger
add_custom_target (swagger
COMMAND ${PYTHON_EXECUTABLE}
${PROJECT_SOURCE_DIR}/Documentation/Scripts/generateSwagger.py
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/js/apps/system/_admin/aardvark/APP/api-docs api-docs
${PROJECT_SOURCE_DIR}/Documentation/DocuBlocks/Rest/
> ${PROJECT_SOURCE_DIR}/js/apps/system/_admin/aardvark/APP/api-docs.json)
# manual pages
if (USE_MAINTAINER_MODE)
set(MAN_NAMES
man1/arangob.1

View File

@ -1 +1 @@
3.0.0-devel
3.0.x-devel

View File

@ -2309,7 +2309,7 @@ AqlValue$ Functions::ConcatVPack(arangodb::aql::Query* query,
size_t length = buffer.length();
try {
std::shared_ptr<VPackBuilder> builder = query->getSharedBuilder();
std::string res(buffer.steal(), length);
std::string res(buffer.c_str(), length);
builder->add(VPackValue(std::move(res)));
return AqlValue$(builder.get());
} catch (...) {

View File

@ -20,7 +20,7 @@
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#include "ArangobFeature.h"
#include "BenchFeature.h"
#include <iostream>
@ -48,12 +48,12 @@ using namespace arangodb::rest;
/// We use an evil global pointer here.
////////////////////////////////////////////////////////////////////////////////
ArangobFeature* ARANGOB;
BenchFeature* ARANGOB;
#include "Benchmark/test-cases.h"
ArangobFeature::ArangobFeature(application_features::ApplicationServer* server,
BenchFeature::BenchFeature(application_features::ApplicationServer* server,
int* result)
: ApplicationFeature(server, "ArangobFeature"),
: ApplicationFeature(server, "Bench"),
_async(false),
_concurreny(1),
_operations(1000),
@ -69,12 +69,12 @@ ArangobFeature::ArangobFeature(application_features::ApplicationServer* server,
_result(result) {
requiresElevatedPrivileges(false);
setOptional(false);
startsAfter("ClientFeature");
startsAfter("ConfigFeature");
startsAfter("LoggerFeature");
startsAfter("Client");
startsAfter("Config");
startsAfter("Logger");
}
void ArangobFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
void BenchFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::collectOptions";
options->addSection(
@ -143,23 +143,23 @@ void ArangobFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
new BooleanParameter(&_quiet, false));
}
void ArangobFeature::status(std::string const& value) {
void BenchFeature::status(std::string const& value) {
if (!_quiet) {
std::cout << value << std::endl;
}
}
std::atomic<int> ArangobFeature::_started;
std::atomic<int> BenchFeature::_started;
void ArangobFeature::updateStartCounter() { ++_started; }
void BenchFeature::updateStartCounter() { ++_started; }
int ArangobFeature::getStartCounter() { return _started; }
int BenchFeature::getStartCounter() { return _started; }
void ArangobFeature::start() {
void BenchFeature::start() {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
ClientFeature* client =
dynamic_cast<ClientFeature*>(server()->feature("ClientFeature"));
dynamic_cast<ClientFeature*>(server()->feature("Client"));
client->setRetries(3);
client->setWarn(true);
@ -206,7 +206,7 @@ void ArangobFeature::start() {
endpoints.push_back(endpoint);
BenchmarkThread* thread = new BenchmarkThread(
benchmark.get(), &startCondition, &ArangobFeature::updateStartCounter,
benchmark.get(), &startCondition, &BenchFeature::updateStartCounter,
i, (unsigned long)_batchSize, &operationsCounter, client, _keepAlive,
_async, _verbose);
@ -321,7 +321,7 @@ void ArangobFeature::start() {
*_result = ret;
}
void ArangobFeature::stop() {
void BenchFeature::stop() {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::stop";
ARANGOB = nullptr;

View File

@ -26,9 +26,9 @@
#include "ApplicationFeatures/ApplicationFeature.h"
namespace arangodb {
class ArangobFeature final : public application_features::ApplicationFeature {
class BenchFeature final : public application_features::ApplicationFeature {
public:
ArangobFeature(application_features::ApplicationServer* server, int* result);
BenchFeature(application_features::ApplicationServer* server, int* result);
public:
void collectOptions(std::shared_ptr<options::ProgramOptions>) override;

View File

@ -28,7 +28,7 @@
#include "ApplicationFeatures/LoggerFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/TempFeature.h"
#include "Benchmark/ArangobFeature.h"
#include "Benchmark/BenchFeature.h"
#include "ProgramOptions2/ProgramOptions.h"
#include "Rest/InitializeRest.h"
@ -56,8 +56,8 @@ int main(int argc, char* argv[]) {
server.addFeature(new TempFeature(&server, "arangob"));
server.addFeature(new ConfigFeature(&server, "arangob"));
server.addFeature(new ClientFeature(&server));
server.addFeature(new ArangobFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, "ArangobFeature"));
server.addFeature(new BenchFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, "Bench"));
server.run(argc, argv);

View File

@ -23,7 +23,7 @@ endif ()
add_executable(${BIN_ARANGOB}
${ProductVersionFiles_arangob}
${PROJECT_SOURCE_DIR}/lib/Basics/WorkMonitorDummy.cpp
Benchmark/ArangobFeature.cpp
Benchmark/BenchFeature.cpp
Benchmark/arangob.cpp
)
@ -65,7 +65,7 @@ endif ()
add_executable(${BIN_ARANGODUMP}
${ProductVersionFiles_arangodump}
${PROJECT_SOURCE_DIR}/lib/Basics/WorkMonitorDummy.cpp
Dump/ArangodumpFeature.cpp
Dump/DumpFeature.cpp
Dump/arangodump.cpp
V8Client/ArangoClientHelper.cpp
)
@ -108,7 +108,7 @@ endif ()
add_executable(${BIN_ARANGOIMP}
${ProductVersionFiles_arangoimp}
${PROJECT_SOURCE_DIR}/lib/Basics/WorkMonitorDummy.cpp
Import/ArangoimpFeature.cpp
Import/ImportFeature.cpp
Import/ImportHelper.cpp
Import/arangoimp.cpp
V8Client/ArangoClientHelper.cpp
@ -152,7 +152,7 @@ endif ()
add_executable(${BIN_ARANGORESTORE}
${ProductVersionFiles_arangorestore}
${PROJECT_SOURCE_DIR}/lib/Basics/WorkMonitorDummy.cpp
Restore/ArangorestoreFeature.cpp
Restore/RestoreFeature.cpp
Restore/arangorestore.cpp
V8Client/ArangoClientHelper.cpp
)
@ -196,7 +196,7 @@ add_executable(${BIN_ARANGOSH}
${ProductVersionFiles_arangosh}
${PROJECT_SOURCE_DIR}/lib/Basics/WorkMonitorDummy.cpp
Import/ImportHelper.cpp
Shell/ArangoshFeature.cpp
Shell/ShellFeature.cpp
Shell/V8ClientConnection.cpp
Shell/V8ShellFeature.cpp
Shell/arangosh.cpp

View File

@ -20,7 +20,7 @@
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#include "ArangodumpFeature.h"
#include "DumpFeature.h"
#include <iostream>
@ -47,9 +47,9 @@ using namespace arangodb::httpclient;
using namespace arangodb::options;
using namespace arangodb::rest;
ArangodumpFeature::ArangodumpFeature(
DumpFeature::DumpFeature(
application_features::ApplicationServer* server, int* result)
: ApplicationFeature(server, "ArangodumpFeature"),
: ApplicationFeature(server, "Dump"),
_collections(),
_chunkSize(1024 * 1024 * 2),
_maxChunkSize(1024 * 1024 * 12),
@ -66,14 +66,14 @@ ArangodumpFeature::ArangodumpFeature(
_clusterMode(false) {
requiresElevatedPrivileges(false);
setOptional(false);
startsAfter("ClientFeature");
startsAfter("LoggerFeature");
startsAfter("Client");
startsAfter("Logger");
_outputDirectory =
FileUtils::buildFilename(FileUtils::currentDirectory(), "dump");
}
void ArangodumpFeature::collectOptions(
void DumpFeature::collectOptions(
std::shared_ptr<options::ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::collectOptions";
@ -120,7 +120,7 @@ void ArangodumpFeature::collectOptions(
new UInt64Parameter(&_tickEnd));
}
void ArangodumpFeature::validateOptions(
void DumpFeature::validateOptions(
std::shared_ptr<options::ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::validateOptions";
@ -157,7 +157,7 @@ void ArangodumpFeature::validateOptions(
}
}
void ArangodumpFeature::prepare() {
void DumpFeature::prepare() {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::prepare";
bool isDirectory = false;
@ -204,7 +204,7 @@ void ArangodumpFeature::prepare() {
}
// start a batch
int ArangodumpFeature::startBatch(std::string DBserver, std::string& errorMsg) {
int DumpFeature::startBatch(std::string DBserver, std::string& errorMsg) {
std::string const url = "/_api/replication/batch";
std::string const body = "{\"ttl\":300}";
@ -254,7 +254,7 @@ int ArangodumpFeature::startBatch(std::string DBserver, std::string& errorMsg) {
}
// prolongs a batch
void ArangodumpFeature::extendBatch(std::string DBserver) {
void DumpFeature::extendBatch(std::string DBserver) {
TRI_ASSERT(_batchId > 0);
std::string const url =
@ -272,7 +272,7 @@ void ArangodumpFeature::extendBatch(std::string DBserver) {
}
// end a batch
void ArangodumpFeature::endBatch(std::string DBserver) {
void DumpFeature::endBatch(std::string DBserver) {
TRI_ASSERT(_batchId > 0);
std::string const url =
@ -291,7 +291,7 @@ void ArangodumpFeature::endBatch(std::string DBserver) {
}
/// @brief dump a single collection
int ArangodumpFeature::dumpCollection(int fd, std::string const& cid,
int DumpFeature::dumpCollection(int fd, std::string const& cid,
std::string const& name, uint64_t maxTick,
std::string& errorMsg) {
uint64_t chunkSize = _chunkSize;
@ -402,7 +402,7 @@ int ArangodumpFeature::dumpCollection(int fd, std::string const& cid,
}
// execute a WAL flush request
void ArangodumpFeature::flushWal() {
void DumpFeature::flushWal() {
std::string const url =
"/_admin/wal/flush?waitForSync=true&waitForCollector=true";
@ -418,7 +418,7 @@ void ArangodumpFeature::flushWal() {
}
// dump data from server
int ArangodumpFeature::runDump(std::string& dbName, std::string& errorMsg) {
int DumpFeature::runDump(std::string& dbName, std::string& errorMsg) {
std::string const url =
"/_api/replication/inventory?includeSystem=" +
std::string(_includeSystemCollections ? "true" : "false");
@ -665,7 +665,7 @@ int ArangodumpFeature::runDump(std::string& dbName, std::string& errorMsg) {
}
/// @brief dump a single shard, that is a collection on a DBserver
int ArangodumpFeature::dumpShard(int fd, std::string const& DBserver,
int DumpFeature::dumpShard(int fd, std::string const& DBserver,
std::string const& name,
std::string& errorMsg) {
std::string const baseUrl = "/_api/replication/dump?DBserver=" + DBserver +
@ -761,7 +761,7 @@ int ArangodumpFeature::dumpShard(int fd, std::string const& DBserver,
}
// dump data from cluster via a coordinator
int ArangodumpFeature::runClusterDump(std::string& errorMsg) {
int DumpFeature::runClusterDump(std::string& errorMsg) {
int res;
std::string const url =
@ -973,11 +973,11 @@ int ArangodumpFeature::runClusterDump(std::string& errorMsg) {
return TRI_ERROR_NO_ERROR;
}
void ArangodumpFeature::start() {
void DumpFeature::start() {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
ClientFeature* client =
dynamic_cast<ClientFeature*>(server()->feature("ClientFeature"));
dynamic_cast<ClientFeature*>(server()->feature("Client"));
int ret = EXIT_SUCCESS;
*_result = ret;

View File

@ -31,10 +31,10 @@ namespace httpclient {
class SimpleHttpResult;
}
class ArangodumpFeature final : public application_features::ApplicationFeature,
class DumpFeature final : public application_features::ApplicationFeature,
public ArangoClientHelper {
public:
ArangodumpFeature(application_features::ApplicationServer* server,
DumpFeature(application_features::ApplicationServer* server,
int* result);
public:

View File

@ -27,7 +27,7 @@
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/LoggerFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "Dump/ArangodumpFeature.h"
#include "Dump/DumpFeature.h"
#include "ProgramOptions2/ProgramOptions.h"
#include "Rest/InitializeRest.h"
@ -52,8 +52,8 @@ int main(int argc, char* argv[]) {
server.addFeature(new LoggerFeature(&server));
server.addFeature(new ConfigFeature(&server, "arangodump"));
server.addFeature(new ClientFeature(&server));
server.addFeature(new ArangodumpFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, "ArangodumpFeature"));
server.addFeature(new DumpFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, "Dump"));
server.run(argc, argv);

View File

@ -20,7 +20,7 @@
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#include "ArangoimpFeature.h"
#include "ImportFeature.h"
#include "ApplicationFeatures/ClientFeature.h"
#include "Basics/StringUtils.h"
@ -36,9 +36,9 @@ using namespace arangodb::basics;
using namespace arangodb::httpclient;
using namespace arangodb::options;
ArangoimpFeature::ArangoimpFeature(
ImportFeature::ImportFeature(
application_features::ApplicationServer* server, int* result)
: ApplicationFeature(server, "ArangoimpFeature"),
: ApplicationFeature(server, "Import"),
_filename(""),
_useBackslash(false),
_chunkSize(1024 * 1024 * 16),
@ -54,12 +54,12 @@ ArangoimpFeature::ArangoimpFeature(
_result(result) {
requiresElevatedPrivileges(false);
setOptional(false);
startsAfter("ClientFeature");
startsAfter("ConfigFeature");
startsAfter("LoggerFeature");
startsAfter("Client");
startsAfter("Config");
startsAfter("Logger");
}
void ArangoimpFeature::collectOptions(
void ImportFeature::collectOptions(
std::shared_ptr<options::ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::collectOptions";
@ -131,7 +131,7 @@ void ArangoimpFeature::collectOptions(
new DiscreteValuesParameter<StringParameter>(&_typeImport, actions));
}
void ArangoimpFeature::validateOptions(
void ImportFeature::validateOptions(
std::shared_ptr<options::ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::validateOptions";
@ -147,11 +147,11 @@ void ArangoimpFeature::validateOptions(
}
}
void ArangoimpFeature::start() {
void ImportFeature::start() {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
ClientFeature* client =
dynamic_cast<ClientFeature*>(server()->feature("ClientFeature"));
dynamic_cast<ClientFeature*>(server()->feature("Client"));
int ret = EXIT_SUCCESS;
*_result = ret;

View File

@ -33,10 +33,10 @@ class SimpleHttpClient;
class SimpleHttpResult;
}
class ArangoimpFeature final : public application_features::ApplicationFeature,
class ImportFeature final : public application_features::ApplicationFeature,
public ArangoClientHelper {
public:
ArangoimpFeature(application_features::ApplicationServer* server,
ImportFeature(application_features::ApplicationServer* server,
int* result);
public:

View File

@ -28,7 +28,7 @@
#include "ApplicationFeatures/LoggerFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/TempFeature.h"
#include "Import/ArangoimpFeature.h"
#include "Import/ImportFeature.h"
#include "ProgramOptions2/ProgramOptions.h"
#include "Rest/InitializeRest.h"
@ -54,8 +54,8 @@ int main(int argc, char* argv[]) {
server.addFeature(new TempFeature(&server, "arangoimp"));
server.addFeature(new ConfigFeature(&server, "arangoimp"));
server.addFeature(new ClientFeature(&server));
server.addFeature(new ArangoimpFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, "ArangoimpFeature"));
server.addFeature(new ImportFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, "Import"));
server.run(argc, argv);

View File

@ -20,7 +20,7 @@
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#include "ArangorestoreFeature.h"
#include "RestoreFeature.h"
#include <iostream>
@ -48,9 +48,9 @@ using namespace arangodb::httpclient;
using namespace arangodb::options;
using namespace arangodb::rest;
ArangorestoreFeature::ArangorestoreFeature(
RestoreFeature::RestoreFeature(
application_features::ApplicationServer* server, int* result)
: ApplicationFeature(server, "ArangorestoreFeature"),
: ApplicationFeature(server, "Restore"),
_collections(),
_chunkSize(1024 * 1024 * 8),
_includeSystemCollections(false),
@ -67,14 +67,14 @@ ArangorestoreFeature::ArangorestoreFeature(
_result(result) {
requiresElevatedPrivileges(false);
setOptional(false);
startsAfter("ClientFeature");
startsAfter("LoggerFeature");
startsAfter("Client");
startsAfter("Logger");
_inputDirectory =
FileUtils::buildFilename(FileUtils::currentDirectory(), "dump");
}
void ArangorestoreFeature::collectOptions(
void RestoreFeature::collectOptions(
std::shared_ptr<options::ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::collectOptions";
@ -126,7 +126,7 @@ void ArangorestoreFeature::collectOptions(
new BooleanParameter(&_force, false));
}
void ArangorestoreFeature::validateOptions(
void RestoreFeature::validateOptions(
std::shared_ptr<options::ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::validateOptions";
@ -147,7 +147,7 @@ void ArangorestoreFeature::validateOptions(
}
}
void ArangorestoreFeature::prepare() {
void RestoreFeature::prepare() {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::prepare";
if (!_inputDirectory.empty() &&
@ -174,7 +174,7 @@ void ArangorestoreFeature::prepare() {
}
}
int ArangorestoreFeature::tryCreateDatabase(ClientFeature* client,
int RestoreFeature::tryCreateDatabase(ClientFeature* client,
std::string const& name) {
arangodb::basics::Json json(arangodb::basics::Json::Object);
json("name", arangodb::basics::Json(name));
@ -216,7 +216,7 @@ int ArangorestoreFeature::tryCreateDatabase(ClientFeature* client,
return TRI_ERROR_INTERNAL;
}
int ArangorestoreFeature::sendRestoreCollection(VPackSlice const& slice,
int RestoreFeature::sendRestoreCollection(VPackSlice const& slice,
std::string const& name,
std::string& errorMsg) {
std::string url =
@ -264,7 +264,7 @@ int ArangorestoreFeature::sendRestoreCollection(VPackSlice const& slice,
return TRI_ERROR_NO_ERROR;
}
int ArangorestoreFeature::sendRestoreIndexes(VPackSlice const& slice,
int RestoreFeature::sendRestoreIndexes(VPackSlice const& slice,
std::string& errorMsg) {
std::string const url = "/_api/replication/restore-indexes?force=" +
std::string(_force ? "true" : "false");
@ -294,7 +294,7 @@ int ArangorestoreFeature::sendRestoreIndexes(VPackSlice const& slice,
return TRI_ERROR_NO_ERROR;
}
int ArangorestoreFeature::sendRestoreData(std::string const& cname,
int RestoreFeature::sendRestoreData(std::string const& cname,
char const* buffer, size_t bufferSize,
std::string& errorMsg) {
std::string const url = "/_api/replication/restore-data?collection=" +
@ -347,7 +347,7 @@ static bool SortCollections(VPackSlice const& l, VPackSlice const& r) {
return strcasecmp(leftName.c_str(), rightName.c_str()) < 0;
}
int ArangorestoreFeature::processInputDirectory(std::string& errorMsg) {
int RestoreFeature::processInputDirectory(std::string& errorMsg) {
// create a lookup table for collections
std::map<std::string, bool> restrictList;
for (size_t i = 0; i < _collections.size(); ++i) {
@ -630,11 +630,11 @@ int ArangorestoreFeature::processInputDirectory(std::string& errorMsg) {
return TRI_ERROR_NO_ERROR;
}
void ArangorestoreFeature::start() {
void RestoreFeature::start() {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
ClientFeature* client =
dynamic_cast<ClientFeature*>(server()->feature("ClientFeature"));
dynamic_cast<ClientFeature*>(server()->feature("Client"));
int ret = EXIT_SUCCESS;
*_result = ret;

View File

@ -34,11 +34,11 @@ namespace httpclient {
class SimpleHttpResult;
}
class ArangorestoreFeature final
class RestoreFeature final
: public application_features::ApplicationFeature,
public ArangoClientHelper {
public:
ArangorestoreFeature(application_features::ApplicationServer* server,
RestoreFeature(application_features::ApplicationServer* server,
int* result);
public:

View File

@ -28,7 +28,7 @@
#include "ApplicationFeatures/LoggerFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/TempFeature.h"
#include "Restore/ArangorestoreFeature.h"
#include "Restore/RestoreFeature.h"
#include "ProgramOptions2/ProgramOptions.h"
#include "Rest/InitializeRest.h"
@ -54,8 +54,8 @@ int main(int argc, char* argv[]) {
server.addFeature(new TempFeature(&server, "arangorestore"));
server.addFeature(new ConfigFeature(&server, "arangorestore"));
server.addFeature(new ClientFeature(&server));
server.addFeature(new ArangorestoreFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, "ArangorestoreFeature"));
server.addFeature(new RestoreFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, "Restore"));
server.run(argc, argv);

View File

@ -20,7 +20,7 @@
/// @author Dr. Frank Celler
////////////////////////////////////////////////////////////////////////////////
#include "ArangoshFeature.h"
#include "ShellFeature.h"
#include "ApplicationFeatures/ClientFeature.h"
#include "Logger/Logger.h"
@ -31,21 +31,21 @@ using namespace arangodb;
using namespace arangodb::basics;
using namespace arangodb::options;
ArangoshFeature::ArangoshFeature(
ShellFeature::ShellFeature(
application_features::ApplicationServer* server, int* result)
: ApplicationFeature(server, "ArangoshFeature"),
: ApplicationFeature(server, "Shell"),
_jslint(),
_result(result),
_runMode(RunMode::INTERACTIVE) {
requiresElevatedPrivileges(false);
setOptional(false);
startsAfter("ConfigFeature");
startsAfter("LanguageFeature");
startsAfter("LoggerFeature");
startsAfter("V8ShellFeature");
startsAfter("Config");
startsAfter("Language");
startsAfter("Logger");
startsAfter("V8Shell");
}
void ArangoshFeature::collectOptions(
void ShellFeature::collectOptions(
std::shared_ptr<options::ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::collectOptions";
@ -74,17 +74,17 @@ void ArangoshFeature::collectOptions(
new VectorParameter<StringParameter>(&_unitTests));
}
void ArangoshFeature::validateOptions(
void ShellFeature::validateOptions(
std::shared_ptr<options::ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::validateOptions";
_positionals = options->processingResult()._positionals;
ClientFeature* client =
dynamic_cast<ClientFeature*>(server()->feature("ClientFeature"));
dynamic_cast<ClientFeature*>(server()->feature("Client"));
ConsoleFeature* console =
dynamic_cast<ConsoleFeature*>(server()->feature("ConsoleFeature"));
dynamic_cast<ConsoleFeature*>(server()->feature("Console"));
if (client->endpoint() == "none") {
client->disable();
@ -134,13 +134,13 @@ void ArangoshFeature::validateOptions(
}
}
void ArangoshFeature::start() {
void ShellFeature::start() {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
*_result = EXIT_FAILURE;
V8ShellFeature* shell =
dynamic_cast<V8ShellFeature*>(server()->feature("V8ShellFeature"));
dynamic_cast<V8ShellFeature*>(server()->feature("V8Shell"));
bool ok = false;

View File

@ -26,9 +26,9 @@
#include "ApplicationFeatures/ApplicationFeature.h"
namespace arangodb {
class ArangoshFeature final : public application_features::ApplicationFeature {
class ShellFeature final : public application_features::ApplicationFeature {
public:
ArangoshFeature(application_features::ApplicationServer* server, int* result);
ShellFeature(application_features::ApplicationServer* server, int* result);
public:
void collectOptions(std::shared_ptr<options::ProgramOptions>) override;

View File

@ -374,7 +374,7 @@ static void ClientConnection_reconnect(
if (args.Length() < 4) {
ConsoleFeature* console = dynamic_cast<ConsoleFeature*>(
ApplicationServer::lookupFeature("ConsoleFeature"));
ApplicationServer::lookupFeature("Console"));
if (console == nullptr || !console->isEnabled()) {
std::cout << "Please specify a password: " << std::flush;

View File

@ -48,7 +48,7 @@ using namespace arangodb::rest;
V8ShellFeature::V8ShellFeature(application_features::ApplicationServer* server,
std::string const& name)
: ApplicationFeature(server, "V8ShellFeature"),
: ApplicationFeature(server, "V8Shell"),
_startupDirectory("js"),
_currentModuleDirectory(true),
_gcInterval(10),
@ -58,9 +58,9 @@ V8ShellFeature::V8ShellFeature(application_features::ApplicationServer* server,
requiresElevatedPrivileges(false);
setOptional(false);
startsAfter("LoggerFeature");
startsAfter("ConsoleFeature");
startsAfter("V8PlatformFeature");
startsAfter("Logger");
startsAfter("Console");
startsAfter("V8Platform");
}
void V8ShellFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
@ -98,7 +98,7 @@ void V8ShellFeature::validateOptions(
void V8ShellFeature::start() {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
_console = dynamic_cast<ConsoleFeature*>(server()->feature("ConsoleFeature"));
_console = dynamic_cast<ConsoleFeature*>(server()->feature("Console"));
_isolate = v8::Isolate::New();
@ -137,6 +137,13 @@ void V8ShellFeature::stop() {
{
v8::Locker locker{_isolate};
v8::Isolate::Scope isolate_scope{_isolate};
TRI_v8_global_t* v8g = \
static_cast<TRI_v8_global_t*>(_isolate->GetData(V8DataSlot));
_isolate->SetData(V8DataSlot, nullptr);
delete v8g;
_context.Reset();
}
@ -232,7 +239,7 @@ V8ClientConnection* V8ShellFeature::setup(
ClientFeature* client = nullptr;
if (createConnection) {
client = dynamic_cast<ClientFeature*>(server()->feature("ClientFeature"));
client = dynamic_cast<ClientFeature*>(server()->feature("Client"));
if (client != nullptr && client->isEnabled()) {
auto connection = client->createConnection();
@ -245,14 +252,14 @@ V8ClientConnection* V8ShellFeature::setup(
}
}
initMode(ArangoshFeature::RunMode::INTERACTIVE, positionals);
initMode(ShellFeature::RunMode::INTERACTIVE, positionals);
if (createConnection && client != nullptr) {
v8connection->initServer(_isolate, context, client);
}
bool pe = printHello(v8connection.get());
loadModules(ArangoshFeature::RunMode::INTERACTIVE);
loadModules(ShellFeature::RunMode::INTERACTIVE);
if (promptError != nullptr) {
*promptError = pe;
@ -274,6 +281,7 @@ int V8ShellFeature::runShell(std::vector<std::string> const& positionals) {
bool promptError;
auto v8connection = setup(context, true, positionals, &promptError);
std::unique_ptr<V8ClientConnection> guard(v8connection);
V8LineEditor v8LineEditor(_isolate, context, "." + _name + ".history");
@ -288,7 +296,7 @@ int V8ShellFeature::runShell(std::vector<std::string> const& positionals) {
uint64_t nrCommands = 0;
ClientFeature* client =
dynamic_cast<ClientFeature*>(server()->feature("ClientFeature"));
dynamic_cast<ClientFeature*>(server()->feature("Client"));
if (!client->isEnabled()) {
client = nullptr;
@ -400,7 +408,8 @@ bool V8ShellFeature::runScript(std::vector<std::string> const& files,
v8::Context::Scope context_scope{context};
setup(context, execute, positionals);
auto v8connection = setup(context, execute, positionals);
std::unique_ptr<V8ClientConnection> guard(v8connection);
bool ok = true;
@ -477,7 +486,8 @@ bool V8ShellFeature::runString(std::vector<std::string> const& strings,
v8::Context::Scope context_scope{context};
setup(context, true, positionals);
auto v8connection = setup(context, true, positionals);
std::unique_ptr<V8ClientConnection> guard(v8connection);
bool ok = true;
@ -580,7 +590,8 @@ bool V8ShellFeature::runUnitTests(std::vector<std::string> const& files,
v8::Context::Scope context_scope{context};
setup(context, true, positionals);
auto v8connection = setup(context, true, positionals);
std::unique_ptr<V8ClientConnection> guard(v8connection);
bool ok = true;
@ -812,7 +823,7 @@ void V8ShellFeature::initGlobals() {
}
}
void V8ShellFeature::initMode(ArangoshFeature::RunMode runMode,
void V8ShellFeature::initMode(ShellFeature::RunMode runMode,
std::vector<std::string> const& positionals) {
auto context = _isolate->GetCurrentContext();
@ -830,29 +841,29 @@ void V8ShellFeature::initMode(ArangoshFeature::RunMode runMode,
TRI_AddGlobalVariableVocbase(
_isolate, context, TRI_V8_ASCII_STRING2(_isolate, "IS_EXECUTE_SCRIPT"),
v8::Boolean::New(_isolate,
runMode == ArangoshFeature::RunMode::EXECUTE_SCRIPT));
runMode == ShellFeature::RunMode::EXECUTE_SCRIPT));
TRI_AddGlobalVariableVocbase(
_isolate, context, TRI_V8_ASCII_STRING2(_isolate, "IS_EXECUTE_STRING"),
v8::Boolean::New(_isolate,
runMode == ArangoshFeature::RunMode::EXECUTE_STRING));
runMode == ShellFeature::RunMode::EXECUTE_STRING));
TRI_AddGlobalVariableVocbase(
_isolate, context, TRI_V8_ASCII_STRING2(_isolate, "IS_CHECK_SCRIPT"),
v8::Boolean::New(_isolate,
runMode == ArangoshFeature::RunMode::CHECK_SYNTAX));
runMode == ShellFeature::RunMode::CHECK_SYNTAX));
TRI_AddGlobalVariableVocbase(
_isolate, context, TRI_V8_ASCII_STRING2(_isolate, "IS_UNIT_TESTS"),
v8::Boolean::New(_isolate,
runMode == ArangoshFeature::RunMode::UNIT_TESTS));
runMode == ShellFeature::RunMode::UNIT_TESTS));
TRI_AddGlobalVariableVocbase(
_isolate, context, TRI_V8_ASCII_STRING2(_isolate, "IS_JS_LINT"),
v8::Boolean::New(_isolate, runMode == ArangoshFeature::RunMode::JSLINT));
v8::Boolean::New(_isolate, runMode == ShellFeature::RunMode::JSLINT));
}
void V8ShellFeature::loadModules(ArangoshFeature::RunMode runMode) {
void V8ShellFeature::loadModules(ShellFeature::RunMode runMode) {
auto context = _isolate->GetCurrentContext();
JSLoader loader;
@ -879,7 +890,7 @@ void V8ShellFeature::loadModules(ArangoshFeature::RunMode runMode) {
files.push_back(
"common/bootstrap/modules.js"); // must come last before patches
if (runMode != ArangoshFeature::RunMode::JSLINT) {
if (runMode != ShellFeature::RunMode::JSLINT) {
files.push_back("common/bootstrap/monkeypatches.js");
}

View File

@ -29,7 +29,7 @@
#include <libplatform/libplatform.h>
#include "ApplicationFeatures/ConsoleFeature.h"
#include "Shell/ArangoshFeature.h"
#include "Shell/ShellFeature.h"
namespace arangodb {
class ConsoleFeature;
@ -65,8 +65,8 @@ class V8ShellFeature final : public application_features::ApplicationFeature {
private:
bool printHello(V8ClientConnection*);
void initGlobals();
void initMode(ArangoshFeature::RunMode, std::vector<std::string> const&);
void loadModules(ArangoshFeature::RunMode);
void initMode(ShellFeature::RunMode, std::vector<std::string> const&);
void loadModules(ShellFeature::RunMode);
V8ClientConnection* setup(v8::Local<v8::Context>& context, bool,
std::vector<std::string> const&,
bool* promptError = nullptr);

View File

@ -34,7 +34,7 @@
#include "Basics/files.h"
#include "ProgramOptions2/ProgramOptions.h"
#include "Rest/InitializeRest.h"
#include "Shell/ArangoshFeature.h"
#include "Shell/ShellFeature.h"
#include "Shell/V8ShellFeature.h"
using namespace arangodb;
@ -65,8 +65,8 @@ int main(int argc, char* argv[]) {
server.addFeature(new ConsoleFeature(&server));
server.addFeature(new V8PlatformFeature(&server));
server.addFeature(new V8ShellFeature(&server, name));
server.addFeature(new ArangoshFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, "ArangoshFeature"));
server.addFeature(new ShellFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, "Shell"));
server.run(argc, argv);

View File

@ -396,7 +396,7 @@ set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CMakeCPackOptions.cmake")
install(
FILES ${PROJECT_SOURCE_DIR}/Installation/debian/arangodb.init
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION /etc/init.d
DESTINATION etc/init.d
RENAME arangodb
COMPONENT debian-extras
)
@ -404,15 +404,6 @@ install(
# Custom targets ----------------------------------------------------------------
# swagger
add_custom_target (swagger
COMMAND ${PYTHON_EXECUTABLE}
${PROJECT_SOURCE_DIR}/Documentation/Scripts/generateSwagger.py
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/js/apps/system/_admin/aardvark/APP/api-docs api-docs
${PROJECT_SOURCE_DIR}/Documentation/DocuBlocks/Rest/
> ${PROJECT_SOURCE_DIR}/js/apps/system/_admin/aardvark/APP/api-docs.json)
# love
add_custom_target (love
COMMENT "ArangoDB loves you."

View File

@ -106,7 +106,7 @@ var AqlHighlightRules = function() {
"date_minute|date_second|date_millisecond|date_dayofyear|date_isoweek|date_leapyear|date_quarter|date_days_in_month|" +
"date_add|date_subtract|date_diff|date_compare|date_format|fail|passthru|sleep|not_null|" +
"first_list|first_document|parse_identifier|current_user|current_database|" +
"collections|document|union|union_distinct|intersection|flatten|" +
"collections|document|union|union_distinct|intersection|flatten|is_same_collection|" +
"ltrim|rtrim|find_first|find_last|split|substitute|md5|sha1|random_token|AQL_LAST_ENTRY)"
);

View File

@ -1,12 +1,9 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// @brief JavaScript base module
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
@ -21,20 +18,18 @@
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
var internal = require("internal");
var common = require("@arangodb/common");
Object.keys(common).forEach(function (key) {
Object.keys(common).forEach(function(key) {
exports[key] = common[key];
});
////////////////////////////////////////////////////////////////////////////////
/// @brief isServer
////////////////////////////////////////////////////////////////////////////////
@ -90,8 +85,7 @@ if (typeof internal.arango !== 'undefined') {
exports.arango = internal.arango;
exports.db = new exports.ArangoDatabase(internal.arango);
internal.db = exports.db; // TODO remove
}
catch (err) {
} catch (err) {
internal.print("cannot connect to server: " + String(err));
}
}
@ -103,17 +97,20 @@ if (typeof internal.arango !== 'undefined') {
exports.plainServerVersion = function() {
if (internal.arango) {
let version = internal.arango.getVersion();
let devel = version.match(/(.*)-((alpha|beta|devel|rc)[0-9]*)$/);
let devel = version.match(/(.*)\.x-devel/);
if (devel !== null) {
version = devel[1];
version = devel[1] + ".0";
} else {
devel = version.match(/(.*)-((alpha|beta|devel|rc)[0-9]*)$/);
if (devel !== null) {
version = devel[1];
}
}
return version;
}
else {
} else {
return undefined;
}
};

View File

@ -85,7 +85,7 @@ function startReadingQuery (endpoint, collName, timeout) {
}
catch (err) {
console.error("startReadingQuery: Bad response body from",
"/_api/query/current", r);
"/_api/query/current", r, JSON.stringify(err));
continue;
}
for (var i = 0; i < r.length; i++) {
@ -1116,7 +1116,7 @@ function setupReplication () {
}
}
catch (err) {
console.error("Could not set up replication for database ", database);
console.error("Could not set up replication for database ", database, JSON.stringify(err));
ok = false;
}
}

View File

@ -30,8 +30,6 @@
/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
const _ = require('lodash');
const fs = require('fs');
const joi = require('joi');

View File

@ -1,12 +1,9 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// @brief JavaScript base module
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
@ -21,17 +18,16 @@
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
module.isSystem = true;
var common = require("@arangodb/common");
Object.keys(common).forEach(function (key) {
Object.keys(common).forEach(function(key) {
exports[key] = common[key];
});
@ -39,7 +35,6 @@ var internal = require("internal"); // OK: db
var ShapedJson = require("@arangodb/shaped-json").ShapedJson;
////////////////////////////////////////////////////////////////////////////////
/// @brief isServer
////////////////////////////////////////////////////////////////////////////////
@ -91,13 +86,17 @@ exports.db = internal.db;
exports.plainServerVersion = function() {
let version = internal.version;
let devel = version.match(/(.*)-((alpha|beta|devel|rc)[0-9]*)$/);
let devel = version.match(/(.*)\.x-devel/);
if (devel !== null) {
version = devel[1];
version = devel[1] + ".0";
} else {
devel = version.match(/(.*)-((alpha|beta|devel|rc)[0-9]*)$/);
if (devel !== null) {
version = devel[1];
}
}
return version;
};

View File

@ -39,7 +39,7 @@ using namespace arangodb::rest;
ClientFeature::ClientFeature(application_features::ApplicationServer* server,
double connectionTimeout, double requestTimeout)
: ApplicationFeature(server, "ClientFeature"),
: ApplicationFeature(server, "Client"),
_databaseName("_system"),
_authentication(true),
_endpoint(Endpoint::getDefaultEndpoint()),
@ -53,7 +53,7 @@ ClientFeature::ClientFeature(application_features::ApplicationServer* server,
_warn(false) {
setOptional(true);
requiresElevatedPrivileges(false);
startsAfter("LoggerFeature");
startsAfter("Logger");
}
void ClientFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
@ -137,7 +137,7 @@ void ClientFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
!options->processingResult().touched(_section + ".password")) {
usleep(10 * 1000);
ConsoleFeature* console = dynamic_cast<ConsoleFeature*>(ApplicationServer::lookupFeature("ConsoleFeature"));
ConsoleFeature* console = dynamic_cast<ConsoleFeature*>(ApplicationServer::lookupFeature("Console"));
if (console != nullptr) {
_password = console->readPassword("Please specify a password: ");

View File

@ -35,12 +35,12 @@ using namespace arangodb::options;
ConfigFeature::ConfigFeature(application_features::ApplicationServer* server,
std::string const& progname)
: ApplicationFeature(server, "ConfigFeature"),
: ApplicationFeature(server, "Config"),
_file(""),
_progname(progname) {
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("LoggerFeature");
startsAfter("Logger");
}
void ConfigFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {

View File

@ -38,10 +38,11 @@ using namespace arangodb::options;
#ifdef _WIN32
static const int FOREGROUND_WHITE = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
static const int BACKGROUND_WHITE = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
static const int INTENSITY = FOREGROUND_INTENSITY | BACKGROUND_INTENSITY;
#endif
ConsoleFeature::ConsoleFeature(application_features::ApplicationServer* server)
: ApplicationFeature(server, "ConsoleFeature"),
: ApplicationFeature(server, "Console"),
#ifdef _WIN32
_codePage(-1),
_cygwinShell(false),
@ -60,7 +61,7 @@ ConsoleFeature::ConsoleFeature(application_features::ApplicationServer* server)
_toAuditFile(nullptr) {
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("LoggerFeature");
startsAfter("Logger");
if (!_supportsColors) {
_colors = false;
@ -73,7 +74,7 @@ ConsoleFeature::ConsoleFeature(application_features::ApplicationServer* server)
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
_defaultAttribute = info.wAttributes & (FOREGROUND_INTENSITY | BACKGROUND_INTENSITY);
_defaultAttribute = info.wAttributes & INTENSITY;
_defaultColor = info.wAttributes & FOREGROUND_WHITE;
_defaultBackground = info.wAttributes & BACKGROUND_WHITE;
@ -85,12 +86,15 @@ ConsoleFeature::ConsoleFeature(application_features::ApplicationServer* server)
void ConsoleFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::collectOptions";
options->addSection(Section("console", "Configure the console",
"console options", false, false));
options->addSection(
Section("", "Global configuration", "global options", false, false));
options->addOption("--quiet", "silent startup",
new BooleanParameter(&_quiet, false));
options->addSection(Section("console", "Configure the console",
"console options", false, false));
options->addOption("--console.colors", "enable color support",
new BooleanParameter(&_colors));
@ -210,7 +214,7 @@ void ConsoleFeature::_print(std::string const& s) {
case 1: // BOLD
case 5: // BLINK
_consoleAttribute = FOREGROUND_INTENSITY;
_consoleAttribute = (_defaultAttribute ^ FOREGROUND_INTENSITY) & INTENSITY;
break;
case 30:

View File

@ -32,7 +32,7 @@ using namespace arangodb::options;
DatabaseFeature::DatabaseFeature(
application_features::ApplicationServer* server,
uint64_t maximalJournalSize)
: ApplicationFeature(server, "DatabaseFeature"),
: ApplicationFeature(server, "Database"),
_directory(""),
_maximalJournalSize(maximalJournalSize),
_queryTracking(true),
@ -40,7 +40,7 @@ DatabaseFeature::DatabaseFeature(
_queryCacheEntries(128) {
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("LoggerFeature");
startsAfter("Logger");
}
void DatabaseFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {

View File

@ -33,16 +33,19 @@ using namespace arangodb::options;
LanguageFeature::LanguageFeature(
application_features::ApplicationServer* server)
: ApplicationFeature(server, "LanguageFeature") {
: ApplicationFeature(server, "Language") {
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("LoggerFeature");
startsAfter("Logger");
}
void LanguageFeature::collectOptions(
std::shared_ptr<options::ProgramOptions> options) {
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::collectOptions";
options->addSection(
Section("", "Global configuration", "global options", false, false));
options->addHiddenOption("--default-language", "ISO-639 language code",
new StringParameter(&_language));
}

View File

@ -30,7 +30,7 @@ using namespace arangodb;
using namespace arangodb::options;
LoggerFeature::LoggerFeature(application_features::ApplicationServer* server)
: ApplicationFeature(server, "LoggerFeature"),
: ApplicationFeature(server, "Logger"),
_output(),
_levels(),
_useLocalTime(false),

View File

@ -31,10 +31,10 @@ using namespace arangodb::options;
ShutdownFeature::ShutdownFeature(
application_features::ApplicationServer* server, std::string const& feature)
: ApplicationFeature(server, "ShutdownFeature") {
: ApplicationFeature(server, "Shutdown") {
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("LoggerFeature");
startsAfter("Logger");
startsAfter(feature);
}

View File

@ -31,7 +31,7 @@ using namespace arangodb;
using namespace arangodb::options;
SslFeature::SslFeature(application_features::ApplicationServer* server)
: ApplicationFeature(server, "SslFeature"),
: ApplicationFeature(server, "Ssl"),
_cafile(),
_keyfile(),
_sessionCache(false),
@ -41,7 +41,7 @@ SslFeature::SslFeature(application_features::ApplicationServer* server)
(long)(SSL_OP_TLS_ROLLBACK_BUG | SSL_OP_CIPHER_SERVER_PREFERENCE)) {
setOptional(true);
requiresElevatedPrivileges(true);
startsAfter("LoggerFeature");
startsAfter("Logger");
}
void SslFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {

View File

@ -32,10 +32,10 @@ using namespace arangodb::options;
TempFeature::TempFeature(application_features::ApplicationServer* server,
std::string const& appname)
: ApplicationFeature(server, "TempFeature"), _path(), _appname(appname) {
: ApplicationFeature(server, "Temp"), _path(), _appname(appname) {
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("LoggerFeature");
startsAfter("Logger");
}
void TempFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {

View File

@ -48,10 +48,10 @@ class BufferAllocator : public v8::ArrayBuffer::Allocator {
V8PlatformFeature::V8PlatformFeature(
application_features::ApplicationServer* server)
: ApplicationFeature(server, "V8PlatformFeature") {
: ApplicationFeature(server, "V8Platform") {
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("LoggerFeature");
startsAfter("Logger");
}
void V8PlatformFeature::collectOptions(

View File

@ -59,6 +59,10 @@ SSL_CTX* arangodb::sslContext(protocol_e protocol, std::string const& keyfile) {
meth = TLSv1_method();
break;
case TLS_V12:
meth = TLSv1_2_method();
break;
default:
LOG(ERR) << "unknown SSL protocol method";
return nullptr;
@ -104,6 +108,9 @@ std::string arangodb::protocolName(protocol_e protocol) {
case TLS_V1:
return "TLSv1";
case TLS_V12:
return "TLSv12";
default:
return "unknown";
}

View File

@ -40,6 +40,7 @@ enum protocol_e {
SSL_V23 = 2,
SSL_V3 = 3,
TLS_V1 = 4,
TLS_V12 = 5,
SSL_LAST
};

View File

@ -96,6 +96,7 @@ else ()
Basics/terminal-utils-posix.cpp
Basics/threads-posix.cpp
Rest/EndpointUnixDomain.cpp
Rest/EndpointSrv.cpp
)
endif ()

View File

@ -32,6 +32,7 @@
#endif
#include "Rest/EndpointIpV4.h"
#include "Rest/EndpointIpV6.h"
#include "Rest/EndpointSrv.h"
using namespace arangodb::basics;
using namespace arangodb::rest;
@ -40,8 +41,7 @@ using namespace arangodb::rest;
/// @brief create an endpoint
////////////////////////////////////////////////////////////////////////////////
Endpoint::Endpoint(Endpoint::EndpointType type,
Endpoint::DomainType domainType,
Endpoint::Endpoint(Endpoint::EndpointType type, Endpoint::DomainType domainType,
Endpoint::EncryptionType encryption,
std::string const& specification, int listenBacklog)
: _connected(false),
@ -94,25 +94,18 @@ std::string Endpoint::getUnifiedForm(std::string const& specification) {
return "";
}
#endif
else if (!StringUtils::isPrefix(copy, "ssl://") &&
!StringUtils::isPrefix(copy, "tcp://")) {
else if (StringUtils::isPrefix(copy, "srv://")) {
return copy;
} else if (!StringUtils::isPrefix(copy, "ssl://") &&
!StringUtils::isPrefix(copy, "tcp://")) {
// invalid type
return "";
}
size_t found;
/*
// turn "localhost" into "127.0.0.1"
// technically this is not always correct, but circumvents obvious problems
// when the configuration contains both "127.0.0.1" and "localhost" endpoints
found = copy.find("localhost");
if (found != string::npos && found >= 6 && found < 10) {
copy = copy.replace(found, strlen("localhost"), "127.0.0.1");
}
*/
// tcp/ip or ssl
size_t found;
std::string temp = copy.substr(6, copy.length()); // strip tcp:// or ssl://
if (temp[0] == '[') {
// ipv6
found = temp.find("]:", 1);
@ -221,6 +214,14 @@ Endpoint* Endpoint::factory(const Endpoint::EndpointType type,
}
#endif
else if (StringUtils::isPrefix(domainType, "srv://")) {
if (type != ENDPOINT_CLIENT) {
return nullptr;
}
return new EndpointSrv(specification.substr(6));
}
else if (!StringUtils::isPrefix(domainType, "tcp://")) {
// invalid type
return nullptr;
@ -307,7 +308,8 @@ bool Endpoint::setSocketFlags(TRI_socket_t s) {
bool ok = TRI_SetNonBlockingSocket(s);
if (!ok) {
LOG(ERR) << "cannot switch to non-blocking: " << errno << " (" << strerror(errno) << ")";
LOG(ERR) << "cannot switch to non-blocking: " << errno << " ("
<< strerror(errno) << ")";
return false;
}
@ -316,7 +318,8 @@ bool Endpoint::setSocketFlags(TRI_socket_t s) {
ok = TRI_SetCloseOnExecSocket(s);
if (!ok) {
LOG(ERR) << "cannot set close-on-exit: " << errno << " (" << strerror(errno) << ")";
LOG(ERR) << "cannot set close-on-exit: " << errno << " (" << strerror(errno)
<< ")";
return false;
}

View File

@ -44,216 +44,64 @@
namespace arangodb {
namespace rest {
////////////////////////////////////////////////////////////////////////////////
/// @brief endpoint specification
////////////////////////////////////////////////////////////////////////////////
class Endpoint {
public:
//////////////////////////////////////////////////////////////////////////////
/// @brief endpoint types
//////////////////////////////////////////////////////////////////////////////
enum EndpointType { ENDPOINT_SERVER, ENDPOINT_CLIENT };
//////////////////////////////////////////////////////////////////////////////
/// @brief endpoint types
//////////////////////////////////////////////////////////////////////////////
enum DomainType { DOMAIN_UNKNOWN = 0, DOMAIN_UNIX, DOMAIN_IPV4, DOMAIN_IPV6 };
//////////////////////////////////////////////////////////////////////////////
/// @brief encryption used when talking to endpoint
//////////////////////////////////////////////////////////////////////////////
enum DomainType {
DOMAIN_UNKNOWN = 0,
DOMAIN_UNIX,
DOMAIN_IPV4,
DOMAIN_IPV6,
DOMAIN_SRV
};
enum EncryptionType { ENCRYPTION_NONE = 0, ENCRYPTION_SSL };
protected:
//////////////////////////////////////////////////////////////////////////////
/// @brief creates an endpoint
//////////////////////////////////////////////////////////////////////////////
Endpoint(EndpointType, DomainType, EncryptionType,
std::string const&, int);
Endpoint(EndpointType, DomainType, EncryptionType, std::string const&, int);
public:
//////////////////////////////////////////////////////////////////////////////
/// @brief destroys an endpoint
//////////////////////////////////////////////////////////////////////////////
virtual ~Endpoint();
public:
//////////////////////////////////////////////////////////////////////////////
/// @brief return the endpoint specification in a unified form
//////////////////////////////////////////////////////////////////////////////
static std::string getUnifiedForm(std::string const&);
//////////////////////////////////////////////////////////////////////////////
/// @brief creates a server endpoint from a string value
//////////////////////////////////////////////////////////////////////////////
static Endpoint* serverFactory(std::string const&, int, bool reuseAddress);
//////////////////////////////////////////////////////////////////////////////
/// @brief creates a client endpoint from a string value
//////////////////////////////////////////////////////////////////////////////
static Endpoint* clientFactory(std::string const&);
//////////////////////////////////////////////////////////////////////////////
/// @brief creates an endpoint from a string value
//////////////////////////////////////////////////////////////////////////////
static Endpoint* factory(const EndpointType type, std::string const&, int,
bool);
//////////////////////////////////////////////////////////////////////////////
/// @brief compare two endpoints
//////////////////////////////////////////////////////////////////////////////
bool operator==(Endpoint const&) const;
//////////////////////////////////////////////////////////////////////////////
/// @brief return the default endpoint
//////////////////////////////////////////////////////////////////////////////
static std::string const getDefaultEndpoint();
//////////////////////////////////////////////////////////////////////////////
/// @brief connect the endpoint
//////////////////////////////////////////////////////////////////////////////
virtual TRI_socket_t connect(double, double) = 0;
//////////////////////////////////////////////////////////////////////////////
/// @brief disconnect the endpoint
//////////////////////////////////////////////////////////////////////////////
virtual void disconnect() = 0;
//////////////////////////////////////////////////////////////////////////////
/// @brief init an incoming connection
//////////////////////////////////////////////////////////////////////////////
virtual bool initIncoming(TRI_socket_t) = 0;
//////////////////////////////////////////////////////////////////////////////
/// @brief set socket timeout
//////////////////////////////////////////////////////////////////////////////
virtual bool setTimeout(TRI_socket_t, double);
//////////////////////////////////////////////////////////////////////////////
/// @brief initialize socket flags
//////////////////////////////////////////////////////////////////////////////
virtual bool setSocketFlags(TRI_socket_t);
//////////////////////////////////////////////////////////////////////////////
/// @brief return whether the endpoint is connected
//////////////////////////////////////////////////////////////////////////////
bool isConnected() const { return _connected; }
//////////////////////////////////////////////////////////////////////////////
/// @brief get the type of an endpoint
//////////////////////////////////////////////////////////////////////////////
public:
bool operator==(Endpoint const&) const;
EndpointType getType() const { return _type; }
//////////////////////////////////////////////////////////////////////////////
/// @brief get the domain type of an endpoint
//////////////////////////////////////////////////////////////////////////////
DomainType getDomainType() const { return _domainType; }
//////////////////////////////////////////////////////////////////////////////
/// @brief get the encryption used
//////////////////////////////////////////////////////////////////////////////
EncryptionType getEncryption() const { return _encryption; }
//////////////////////////////////////////////////////////////////////////////
/// @brief get the original endpoint specification
//////////////////////////////////////////////////////////////////////////////
std::string getSpecification() const { return _specification; }
//////////////////////////////////////////////////////////////////////////////
/// @brief get endpoint domain
//////////////////////////////////////////////////////////////////////////////
public:
virtual TRI_socket_t connect(double, double) = 0;
virtual void disconnect() = 0;
virtual bool initIncoming(TRI_socket_t) = 0;
virtual bool setTimeout(TRI_socket_t, double);
virtual bool isConnected() const { return _connected; }
virtual bool setSocketFlags(TRI_socket_t);
virtual DomainType getDomainType() const { return _domainType; }
virtual int getDomain() const = 0;
//////////////////////////////////////////////////////////////////////////////
/// @brief get port number
//////////////////////////////////////////////////////////////////////////////
virtual int getPort() const = 0;
//////////////////////////////////////////////////////////////////////////////
/// @brief get host name
//////////////////////////////////////////////////////////////////////////////
virtual std::string getHost() const = 0;
//////////////////////////////////////////////////////////////////////////////
/// @brief get address
//////////////////////////////////////////////////////////////////////////////
virtual std::string getHostString() const = 0;
public:
//////////////////////////////////////////////////////////////////////////////
/// @brief error message if failure occurred
//////////////////////////////////////////////////////////////////////////////
std::string _errorMessage;
protected:
//////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the endpoint is connected
//////////////////////////////////////////////////////////////////////////////
bool _connected;
//////////////////////////////////////////////////////////////////////////////
/// @brief the actual socket
//////////////////////////////////////////////////////////////////////////////
TRI_socket_t _socket;
//////////////////////////////////////////////////////////////////////////////
/// @brief endpoint type
//////////////////////////////////////////////////////////////////////////////
EndpointType _type;
//////////////////////////////////////////////////////////////////////////////
/// @brief endpoint domain type
//////////////////////////////////////////////////////////////////////////////
DomainType _domainType;
//////////////////////////////////////////////////////////////////////////////
/// @brief encryption used
//////////////////////////////////////////////////////////////////////////////
EncryptionType _encryption;
//////////////////////////////////////////////////////////////////////////////
/// @brief original endpoint specification
//////////////////////////////////////////////////////////////////////////////
std::string _specification;
//////////////////////////////////////////////////////////////////////////////
/// @brief listen backlog size
//////////////////////////////////////////////////////////////////////////////
int _listenBacklog;
};
}

View File

@ -93,6 +93,7 @@ TRI_socket_t EndpointIp::connectSocket(const struct addrinfo* aip,
#ifdef _WIN32
char windowsErrorBuf[256];
#endif
// set address and port
char host[NI_MAXHOST];
char serv[NI_MAXSERV];

255
lib/Rest/EndpointSrv.cpp Normal file
View File

@ -0,0 +1,255 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2016 ArangoDB GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2016, ArangoDB GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#include "EndpointSrv.h"
#ifndef _WIN32
#define BIND_4_COMPAT 1 // LINUX
#define BIND_8_COMPAT 1 // MACOSX
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include "Basics/StringUtils.h"
#include "Logger/Logger.h"
#include "Rest/EndpointIp.h"
using namespace arangodb;
using namespace arangodb::basics;
using namespace arangodb::rest;
#if PACKETSZ > 1024
#define MAXPACKET PACKETSZ
#else
#define MAXPACKET 1024
#endif
union QueryBuffer {
::HEADER header;
unsigned char buffer[MAXPACKET];
};
struct SrvRecord {
int priority;
int weight;
int port;
std::string name;
};
std::vector<SrvRecord> srvRecords(std::string specification) {
res_init();
char const* dname = specification.c_str();
int nclass = ns_c_in;
int type = ns_t_srv;
QueryBuffer answer;
int anslen = sizeof(answer);
int n = res_search(dname, nclass, type, answer.buffer, anslen);
std::vector<SrvRecord> services;
if (n != -1) {
HEADER* hp = &answer.header;
int qdcount = ntohs(hp->qdcount);
int ancount = ntohs(hp->ancount);
unsigned char* msg = answer.buffer;
unsigned char* eom = msg + n;
unsigned char* cp = msg + sizeof(HEADER);
unsigned char hostbuf[256];
while (0 < qdcount-- && cp < eom) {
n = dn_expand(msg, eom, cp, (char*)hostbuf, 256);
if (n < 0) {
LOG(WARN) << "DNS record for '" << specification << "' is corrupt";
return {};
}
cp += n + QFIXEDSZ;
}
// loop through the answer buffer and extract SRV records
while (0 < ancount-- && cp < eom) {
n = dn_expand(msg, eom, cp, (char*)hostbuf, 256);
if (n < 0) {
LOG(WARN) << "DNS record for '" << specification << "' is corrupt";
return {};
}
cp += n;
int type;
GETSHORT(type, cp);
int nclass;
GETSHORT(nclass, cp);
int ttl;
GETLONG(ttl, cp);
int dlen;
GETSHORT(dlen, cp);
int priority;
GETSHORT(priority, cp);
int weight;
GETSHORT(weight, cp);
int port;
GETSHORT(port, cp);
n = dn_expand(msg, eom, cp, (char*)hostbuf, 256);
if (n < 0) {
LOG(WARN) << "DNS record for '" << specification << "' is corrupt";
break;
}
cp += n;
LOG(TRACE) << "DNS record for '" << specification << "': type " << type
<< ", class " << nclass << ", ttl " << ttl << ", len " << dlen
<< ", prio " << priority << ", weight " << weight << ", port "
<< port << ", host '" << hostbuf << "'";
if (type != T_SRV) {
continue;
}
SrvRecord srv;
srv.weight = weight;
srv.priority = priority;
srv.port = port;
srv.name = (char*)hostbuf;
services.push_back(srv);
}
} else {
LOG(WARN) << "DNS record for '" << specification << "' not found";
}
std::sort(services.begin(), services.end(),
[](SrvRecord const& lhs, SrvRecord const& rhs) {
if (lhs.priority != rhs.priority) {
return lhs.priority < rhs.priority;
}
return lhs.weight > rhs.weight;
});
return services;
}
#else
std::vector<SrvRecord> srvRecords(std::string specification) { return {}; }
#endif
EndpointSrv::EndpointSrv(std::string const& specification)
: Endpoint(ENDPOINT_CLIENT, DOMAIN_SRV, ENCRYPTION_NONE, specification, 0) {
}
EndpointSrv::~EndpointSrv() {}
bool EndpointSrv::isConnected() const {
if (_endpoint != nullptr) {
return _endpoint->isConnected();
}
return false;
}
TRI_socket_t EndpointSrv::connect(double connectTimeout,
double requestTimeout) {
auto services = srvRecords(_specification);
TRI_socket_t res;
for (auto service : services) {
std::string spec =
"tcp://" + service.name + ":" + StringUtils::itoa(service.port);
_endpoint.reset(Endpoint::clientFactory(spec));
res = _endpoint->connect(connectTimeout, requestTimeout);
if (_endpoint->isConnected()) {
return res;
}
}
TRI_invalidatesocket(&res);
return res;
}
void EndpointSrv::disconnect() {
if (_endpoint != nullptr) {
_endpoint->disconnect();
}
}
bool EndpointSrv::initIncoming(TRI_socket_t) { return false; }
int EndpointSrv::getDomain() const {
if (_endpoint != nullptr) {
return _endpoint->getDomain();
}
return -1;
}
int EndpointSrv::getPort() const {
if (_endpoint != nullptr) {
return _endpoint->getPort();
}
return -1;
}
std::string EndpointSrv::getHost() const {
if (_endpoint != nullptr) {
return _endpoint->getHost();
}
return "";
}
std::string EndpointSrv::getHostString() const {
if (_endpoint != nullptr) {
return _endpoint->getHostString();
}
return "";
}

53
lib/Rest/EndpointSrv.h Normal file
View File

@ -0,0 +1,53 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2016 ArangoDB GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2016, ArangoDB GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGODB_REST_ENDPOINT_SRV_H
#define ARANGODB_REST_ENDPOINT_SRV_H 1
#include "Rest/Endpoint.h"
namespace arangodb {
namespace rest {
class EndpointSrv final : public Endpoint {
public:
explicit EndpointSrv(std::string const&);
~EndpointSrv();
public:
bool isConnected() const override;
TRI_socket_t connect(double, double) override;
void disconnect() override;
bool initIncoming(TRI_socket_t) override;
int getDomain() const override;
int getPort() const override;
std::string getHost() const override;
std::string getHostString() const override;
private:
std::unique_ptr<Endpoint> _endpoint;
};
}
}
#endif

View File

@ -227,6 +227,7 @@ TRI_v8_global_t* TRI_CreateV8Globals(v8::Isolate* isolate) {
TRI_v8_global_t* TRI_GetV8Globals(v8::Isolate* isolate) {
TRI_GET_GLOBALS();
if (v8g == nullptr) {
v8g = TRI_CreateV8Globals(isolate);
}

View File

@ -50,6 +50,7 @@ static const uint32_t V8DataSlot = 0;
#define TRI_V8_TRY_CATCH_BEGIN(isolateVar) \
auto isolateVar = args.GetIsolate(); \
try {
////////////////////////////////////////////////////////////////////////////////
/// @brief macro to terminate a try-catch sequence for V8 callbacks
////////////////////////////////////////////////////////////////////////////////

View File

@ -744,7 +744,21 @@ static void JS_Download(v8::FunctionCallbackInfo<v8::Value> const& args) {
endpoint = endpoint + ":443";
}
endpoint = "ssl://" + endpoint;
} else if (!url.empty() && url[0] == '/') {
}
else if (url.substr(0, 6) == "srv://") {
size_t found = url.find('/', 6);
relative = "/";
if (found != std::string::npos) {
relative.append(url.substr(found + 1));
endpoint = url.substr(6, found - 6);
}
else {
endpoint = url.substr(6);
}
endpoint = "srv://" + endpoint;
}
else if (! url.empty() && url[0] == '/') {
// relative URL. prefix it with last endpoint
relative = url;
url = lastEndpoint + url;

View File

@ -1 +0,0 @@
run

60
utils/generateExamples Executable file
View File

@ -0,0 +1,60 @@
#!/bin/bash
export PID=$$
if test -n "$ORIGINAL_PATH"; then
# running in cygwin...
PS='\'
export EXT=".exe"
else
export EXT=""
PS='/'
fi;
SCRIPT="utils${PS}generateExamples.js"
LOGFILE="out${PS}log-$PID"
DBDIR="out${PS}data-$PID"
mkdir -p ${DBDIR}
echo Database has its data in ${DBDIR}
echo Logfile is in ${LOGFILE}
if [ -z "${ARANGOD}" ]; then
if [ -x build/bin/arangod ]; then
ARANGOD=build/bin/arangod
elif [ -x bin/arangosh ]; then
ARANGOD=bin/arangod
else
echo "$0: cannot locate arangod"
fi
fi
${ARANGOD} \
--configuration none \
--cluster.agent-path bin${PS}etcd-arango${EXT} \
--cluster.arangod-path bin${PS}arangod \
--cluster.coordinator-config etc${PS}relative${PS}arangod-coordinator.conf \
--cluster.dbserver-config etc${PS}relative${PS}arangod-dbserver.conf \
--cluster.disable-dispatcher-frontend false \
--cluster.disable-dispatcher-kickstarter false \
--cluster.data-path cluster \
--cluster.log-path cluster \
--database.directory ${DBDIR} \
--log.file ${LOGFILE} \
--server.endpoint tcp://127.0.0.1:$PORT \
--javascript.startup-directory js \
--javascript.app-path js${PS}apps \
--javascript.script $SCRIPT \
--no-server \
--temp-path ${PS}var${PS}tmp \
"${ARGS[@]}" \
if test $? -eq 0; then
echo "removing ${LOGFILE} ${DBDIR}"
rm -rf ${LOGFILE} ${DBDIR}
else
echo "failed - don't remove ${LOGFILE} ${DBDIR} - here's the logfile:"
cat ${LOGFILE}
fi
echo Server has terminated.

View File

@ -18,17 +18,12 @@ var PortFinder = require("@arangodb/cluster").PortFinder;
var documentationSourceDirs = [
fs.join(fs.makeAbsolute(''), "Documentation/Examples/setup-arangosh.js"),
fs.join(fs.makeAbsolute(''), "Documentation/Books/Users"),
fs.join(fs.makeAbsolute(''), "js/actions"),
fs.join(fs.makeAbsolute(''), "js/client"),
fs.join(fs.makeAbsolute(''), "js/common"),
fs.join(fs.makeAbsolute(''), "js/server"),
fs.join(fs.makeAbsolute(''), "js/apps/system/_api/gharial/APP"),
fs.join(fs.makeAbsolute(''), "Documentation/Books/Users"),
fs.join(fs.makeAbsolute(''), "arangod/RestHandler"),
fs.join(fs.makeAbsolute(''), "arangod/V8Server")];
fs.join(fs.makeAbsolute(''), "js/apps/system/_api/gharial/APP")];
var theScript = 'Documentation/Scripts/generateExamples.py';