Skip to content
Snippets Groups Projects
Commit 0e7e84b9 authored by dutor's avatar dutor Committed by Sherman The Tank
Browse files

Refactor the source tree (#41)

parent 4768613e
No related branches found
No related tags found
No related merge requests found
Showing
with 438 additions and 274 deletions
...@@ -9,17 +9,17 @@ ...@@ -9,17 +9,17 @@
# CMAKE_C_COMPILER -- Specify the compiler for C language # CMAKE_C_COMPILER -- Specify the compiler for C language
# CMAKE_CXX_COMPILER -- Specify the compiler for C++ language # CMAKE_CXX_COMPILER -- Specify the compiler for C++ language
# FLEX_EXECUTABLE -- Specify the full path of flex executable # FLEX_EXECUTABLE -- Specify the full path of flex executable
# VGRAPH_GPERF_BIN_DIR -- Specify the full path to the directory # NEBULA_GPERF_BIN_DIR -- Specify the full path to the directory
# containing gperf binary # containing gperf binary
# #
# VGRAPH_KRB5_ROOT -- Specify the root directory for KRB5 # NEBULA_KRB5_ROOT -- Specify the root directory for KRB5
# VGRAPH_LIBUNWIND_ROOT -- Specify the root directory for libunwind # NEBULA_LIBUNWIND_ROOT -- Specify the root directory for libunwind
# VGRAPH_OPENSSL_ROOT -- Specify the root directory for openssl # NEBULA_OPENSSL_ROOT -- Specify the root directory for openssl
# VGRAPH_BOOST_ROOT -- Specify the root directory for boost # NEBULA_BOOST_ROOT -- Specify the root directory for boost
# #
cmake_minimum_required(VERSION 3.0.0) cmake_minimum_required(VERSION 3.0.0)
project("vGraph" C CXX) project("Nebula Graph" C CXX)
set(CMAKE_SKIP_RPATH TRUE) set(CMAKE_SKIP_RPATH TRUE)
...@@ -35,6 +35,10 @@ set(CMAKE_CXX_STANDARD 14) ...@@ -35,6 +35,10 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++") set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++")
if (NOT THIRD_PARTY_JOBS)
set(THIRD_PARTY_JOBS 2)
endif(NOT THIRD_PARTY_JOBS)
# Possible values are Debug, Release, RelWithDebInfo, MinSizeRel # Possible values are Debug, Release, RelWithDebInfo, MinSizeRel
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug") set(CMAKE_BUILD_TYPE "Debug")
...@@ -46,39 +50,39 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "_build") ...@@ -46,39 +50,39 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "_build")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "_build") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "_build")
# Set the project home dir # Set the project home dir
set(VGRAPH_HOME ${CMAKE_CURRENT_SOURCE_DIR}) set(NEBULA_HOME ${CMAKE_CURRENT_SOURCE_DIR})
# To include customized FindXXX.cmake modules # To include customized FindXXX.cmake modules
set(CMAKE_MODULE_PATH "${VGRAPH_HOME}/cmake" ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH "${NEBULA_HOME}/cmake" ${CMAKE_MODULE_PATH})
if(NOT ${VGRAPH_KRB5_ROOT} STREQUAL "") if(NOT ${NEBULA_KRB5_ROOT} STREQUAL "")
message(STATUS "Specified VGRAPH_KRB5_ROOT: " ${VGRAPH_KRB5_ROOT}) message(STATUS "Specified NEBULA_KRB5_ROOT: " ${NEBULA_KRB5_ROOT})
list(APPEND CMAKE_INCLUDE_PATH ${VGRAPH_KRB5_ROOT}/include) list(APPEND CMAKE_INCLUDE_PATH ${NEBULA_KRB5_ROOT}/include)
list(APPEND CMAKE_LIBRARY_PATH ${VGRAPH_KRB5_ROOT}/lib) list(APPEND CMAKE_LIBRARY_PATH ${NEBULA_KRB5_ROOT}/lib)
list(APPEND CMAKE_PROGRAM_PATH ${VGRAPH_KRB5_ROOT}/bin) list(APPEND CMAKE_PROGRAM_PATH ${NEBULA_KRB5_ROOT}/bin)
endif() endif()
if(NOT ${VGRAPH_LIBUNWIND_ROOT} STREQUAL "") if(NOT ${NEBULA_LIBUNWIND_ROOT} STREQUAL "")
message(STATUS "Specified VGRAPH_LIBUNWIND_ROOT: " ${VGRAPH_LIBUNWIND_ROOT}) message(STATUS "Specified NEBULA_LIBUNWIND_ROOT: " ${NEBULA_LIBUNWIND_ROOT})
list(APPEND CMAKE_INCLUDE_PATH ${VGRAPH_LIBUNWIND_ROOT}/include) list(APPEND CMAKE_INCLUDE_PATH ${NEBULA_LIBUNWIND_ROOT}/include)
list(APPEND CMAKE_LIBRARY_PATH ${VGRAPH_LIBUNWIND_ROOT}/lib) list(APPEND CMAKE_LIBRARY_PATH ${NEBULA_LIBUNWIND_ROOT}/lib)
endif() endif()
if(NOT ${VGRAPH_OPENSSL_ROOT} STREQUAL "") if(NOT ${NEBULA_OPENSSL_ROOT} STREQUAL "")
message(STATUS "Specified VGRAPH_OPENSSL_ROOT: " ${VGRAPH_OPENSSL_ROOT}) message(STATUS "Specified NEBULA_OPENSSL_ROOT: " ${NEBULA_OPENSSL_ROOT})
list(APPEND CMAKE_INCLUDE_PATH ${VGRAPH_OPENSSL_ROOT}/include) list(APPEND CMAKE_INCLUDE_PATH ${NEBULA_OPENSSL_ROOT}/include)
list(APPEND CMAKE_LIBRARY_PATH ${VGRAPH_OPENSSL_ROOT}/lib) list(APPEND CMAKE_LIBRARY_PATH ${NEBULA_OPENSSL_ROOT}/lib)
endif() endif()
if(NOT ${VGRAPH_BOOST_ROOT} STREQUAL "") if(NOT ${NEBULA_BOOST_ROOT} STREQUAL "")
message(STATUS "Specified VGRAPH_BOOST_ROOT: " ${VGRAPH_BOOST_ROOT}) message(STATUS "Specified NEBULA_BOOST_ROOT: " ${NEBULA_BOOST_ROOT})
list(APPEND CMAKE_INCLUDE_PATH ${VGRAPH_BOOST_ROOT}/include) list(APPEND CMAKE_INCLUDE_PATH ${NEBULA_BOOST_ROOT}/include)
list(APPEND CMAKE_LIBRARY_PATH ${VGRAPH_BOOST_ROOT}/lib) list(APPEND CMAKE_LIBRARY_PATH ${NEBULA_BOOST_ROOT}/lib)
endif() endif()
if(NOT ${VGRAPH_GPERF_BIN_DIR} STREQUAL "") if(NOT ${NEBULA_GPERF_BIN_DIR} STREQUAL "")
message(STATUS "Specified VGRAPH_GPERF_BIN_DIR: " ${VGRAPH_GPERF_BIN_DIR}) message(STATUS "Specified NEBULA_GPERF_BIN_DIR: " ${NEBULA_GPERF_BIN_DIR})
list(APPEND CMAKE_PROGRAM_PATH ${VGRAPH_GPERF_BIN_DIR}) list(APPEND CMAKE_PROGRAM_PATH ${NEBULA_GPERF_BIN_DIR})
endif() endif()
message(STATUS "CMAKE_INCLUDE_PATH: " ${CMAKE_INCLUDE_PATH}) message(STATUS "CMAKE_INCLUDE_PATH: " ${CMAKE_INCLUDE_PATH})
...@@ -98,53 +102,53 @@ find_package(Readline REQUIRED) ...@@ -98,53 +102,53 @@ find_package(Readline REQUIRED)
add_compile_options(-Winvalid-pch) add_compile_options(-Winvalid-pch)
add_compile_options(-Wall) add_compile_options(-Wall)
add_compile_options(-Werror) add_compile_options(-Werror)
add_compile_options(-Wno-error=sign-compare) add_compile_options(-Wunused-parameter)
add_compile_options(-Wshadow) add_compile_options(-Wshadow)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/bzip2/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/bzip2/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/double-conversion/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/double-conversion/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/fatal/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/fatal/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/fbthrift/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/fbthrift/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/folly/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/folly/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/gflags/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/gflags/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/glog/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/glog/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/googletest/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/googletest/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/jemalloc/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/jemalloc/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/libevent/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/libevent/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/mstch/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/mstch/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/proxygen/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/proxygen/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/rocksdb/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/rocksdb/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/snappy/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/snappy/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/wangle/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/wangle/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/zlib/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/zlib/_install/include)
include_directories(SYSTEM ${VGRAPH_HOME}/third-party/zstd/_install/include) include_directories(SYSTEM ${NEBULA_HOME}/third-party/zstd/_install/include)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR}) include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
include_directories(SYSTEM ${KRB5_INCLUDE_DIRS}) include_directories(SYSTEM ${KRB5_INCLUDE_DIRS})
include_directories(SYSTEM ${FLEX_INCLUDE_DIRS}) include_directories(SYSTEM ${FLEX_INCLUDE_DIRS})
include_directories(SYSTEM ${Readline_INCLUDE_DIR}) include_directories(SYSTEM ${Readline_INCLUDE_DIR})
include_directories(AFTER common) include_directories(AFTER ${NEBULA_HOME}/src)
include_directories(AFTER interface) include_directories(AFTER src/common)
include_directories(AFTER ${VGRAPH_HOME}) include_directories(AFTER src/interface)
link_directories( link_directories(
${VGRAPH_HOME}/third-party/bzip2/_install/lib ${NEBULA_HOME}/third-party/bzip2/_install/lib
${VGRAPH_HOME}/third-party/double-conversion/_install/lib ${NEBULA_HOME}/third-party/double-conversion/_install/lib
${VGRAPH_HOME}/third-party/fatal/_install/lib ${NEBULA_HOME}/third-party/fatal/_install/lib
${VGRAPH_HOME}/third-party/fbthrift/_install/lib ${NEBULA_HOME}/third-party/fbthrift/_install/lib
${VGRAPH_HOME}/third-party/folly/_install/lib ${NEBULA_HOME}/third-party/folly/_install/lib
${VGRAPH_HOME}/third-party/gflags/_install/lib ${NEBULA_HOME}/third-party/gflags/_install/lib
${VGRAPH_HOME}/third-party/glog/_install/lib ${NEBULA_HOME}/third-party/glog/_install/lib
${VGRAPH_HOME}/third-party/googletest/_install/lib ${NEBULA_HOME}/third-party/googletest/_install/lib
${VGRAPH_HOME}/third-party/jemalloc/_install/lib ${NEBULA_HOME}/third-party/jemalloc/_install/lib
${VGRAPH_HOME}/third-party/libevent/_install/lib ${NEBULA_HOME}/third-party/libevent/_install/lib
${VGRAPH_HOME}/third-party/mstch/_install/lib ${NEBULA_HOME}/third-party/mstch/_install/lib
${VGRAPH_HOME}/third-party/proxygen/_install/lib ${NEBULA_HOME}/third-party/proxygen/_install/lib
${VGRAPH_HOME}/third-party/rocksdb/_install/lib64 ${NEBULA_HOME}/third-party/rocksdb/_install/lib64
${VGRAPH_HOME}/third-party/snappy/_install/lib ${NEBULA_HOME}/third-party/snappy/_install/lib
${VGRAPH_HOME}/third-party/wangle/_install/lib ${NEBULA_HOME}/third-party/wangle/_install/lib
${VGRAPH_HOME}/third-party/zlib/_install/lib ${NEBULA_HOME}/third-party/zlib/_install/lib
${VGRAPH_HOME}/third-party/zstd/_install/lib ${NEBULA_HOME}/third-party/zstd/_install/lib
${Boost_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS}
${KRB5_LIBRARY_DIRS} ${KRB5_LIBRARY_DIRS}
) )
...@@ -163,22 +167,15 @@ set(THRIFT_LIBRARIES ...@@ -163,22 +167,15 @@ set(THRIFT_LIBRARIES
thrift-core thrift-core
) )
set(ROCKSDB_LIBRARIES ${VGRAPH_HOME}/third-party/rocksdb/_install/lib64/librocksdb.a) set(ROCKSDB_LIBRARIES ${NEBULA_HOME}/third-party/rocksdb/_install/lib64/librocksdb.a)
# All compression libraries # All compression libraries
set(COMPRESSION_LIBRARIES bz2 snappy zstd z) set(COMPRESSION_LIBRARIES bz2 snappy zstd z)
add_subdirectory(third-party) add_subdirectory(third-party)
add_subdirectory(interface) add_subdirectory(src)
add_subdirectory(common) add_subdirectory(etc)
add_subdirectory(meta) add_subdirectory(scripts)
add_subdirectory(dataman)
add_subdirectory(client)
add_subdirectory(vgraphd)
add_subdirectory(console)
add_subdirectory(raftex)
add_subdirectory(storage)
add_subdirectory(parser)
add_dependencies(common third-party) add_dependencies(common third-party)
#add_dependencies(storage_engines common) #add_dependencies(storage_engines common)
......
## Workflow
### Step 1: Fork in the cloud
1. Visit https://github.com/vesoft-inc/vgraph
2. Click `Fork` button (top right) to establish a cloud-based fork.
### Step 2: Clone fork to local storage
Define a local working directory:
```sh
# Define your working directory
working_dir=$HOME/Workspace
```
Set `user` to match your github profile name:
```sh
user={your github profile name}
```
Create your clone:
```sh
mkdir -p $working_dir
cd $working_dir
git clone https://github.com/$user/vgraph.git
# the following is recommended
# or: git clone git@github.com:$user/vgraph.git
cd $working_dir/vgraph
git remote add upstream https://github.com/vesoft-inc/vgraph.git
# or: git remote add upstream git@github.com:vesoft-inc/vgraph.git
# Never push to upstream master since you do not have write access.
git remote set-url --push upstream no_push
# Confirm that your remotes make sense:
# It should look like:
# origin git@github.com:$(user)/vgraph.git (fetch)
# origin git@github.com:$(user)/vgraph.git (push)
# upstream https://github.com/vesoft-inc/vgraph (fetch)
# upstream no_push (push)
git remote -v
```
#### Define a pre-commit hook
Please link the vGraph pre-commit hook into your `.git` directory.
This hook checks your commits for formatting, building, doc generation, etc.
```sh
cd $working_dir/vgraph/.git/hooks
ln -s ../../hooks/pre-commit .
```
Sometime, pre-commit hook can not be executable. In such case, you have to make it executable manually.
```sh
cd $working_dir/vgraph/.git/hooks
chmod +x pre-commit
```
### Step 3: Branch
Get your local master up to date:
```sh
cd $working_dir/vgraph
git fetch upstream
git checkout master
git rebase upstream/master
```
Branch from master:
```sh
git checkout -b myfeature
```
**NOTE**: Because your PR often consists of several commits, which might be squashed while being merged into upstream,
we strongly suggest you open a separate topic branch to make your changes on. After merged,
this topic branch could be just abandoned, thus you could synchronize your master branch with
upstream easily with a rebase like above. Otherwise, if you commit your changes directly into master,
maybe you must use a hard reset on the master branch, like:
```sh
git fetch upstream
git checkout master
git reset --hard upstream/master
git push --force origin master
```
### Step 4: Develop
#### Edit the code
You can now edit the code on the `myfeature` branch. Please follow the coding style guidance [here](docs/cpp-coding-style.md)
#### Run stand-alone mode
If you want to reproduce and investigate an issue, you may need
to run vGraph in stand-alone mode.
```sh
# Build the binary.
make server
# Run in stand-alone mode.
vgraphd
```
Then you can connect the vGraph console to your local server
```sh
vgraph
```
#### Run Test
```sh
# Run unit test to make sure all test passed.
```
### Step 5: Keep your branch in sync
```sh
# While on your myfeature branch.
git fetch upstream
git rebase upstream/master
```
### Step 6: Commit
Commit your changes.
```sh
git commit
```
Likely you'll go back and edit/build/test some more than `commit --amend`
in a few cycles.
### Step 7: Push
When ready to review (or just to establish an offsite backup or your work),
push your branch to your fork on `github.com`:
```sh
git push -f origin myfeature
```
### Step 8: Create a pull request
1. Visit your fork at https://github.com/$user/vgraph (replace `$user` obviously).
2. Click the `Compare & pull request` button next to your `myfeature` branch.
### Step 9: Get a code review
Once your pull request has been opened, it will be assigned to at least one
reviewers. Those reviewers will do a thorough code review, looking for
correctness, bugs, opportunities for improvement, documentation and comments,
and style.
Commit changes made in response to review comments to the same branch on your
fork.
Very small PRs are easy to review. Very large PRs are very difficult to
review.
install(FILES nebula-graphd.conf.default DESTINATION etc)
########## logging ##########
--log_dir=/tmp/nebula-graphd
# 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively
--minloglevel=0
# verbose loging level, 1, 2, 3, 4, the higher of the level, the more verbose of the logging
--v=4
# maximum seconds to buffer the log messages
--logbufsecs=0
# Whether to redirect stdout and stderr to separate output files
--redirect_stdout=true
# Destination filename of stdout and stderr, which will also reside in log_dir.
--stdout_log_file=stdout.log
--stderr_log_file=stderr.log
########## networking ##########
--port=3699
# seconds before we close the idle connections, 0 for infinite
--client_idle_timeout_secs=0
# seconds before we expire the idle sessions, 0 for inifnite
--session_idle_timeout_secs=60000
# number of threads to accept incoming connections
--num_accept_threads=1
# number of networking IO threads, 0 for number of physical CPU cores
--num_netio_threads=0
# turn on SO_REUSEPORT or not
--reuse_port=false
# Backlog of the listen socket, adjust this together with net.core.somaxconn
--listen_backlog=1024
add_subdirectory(common)
add_subdirectory(interface)
add_subdirectory(client)
add_subdirectory(meta)
add_subdirectory(console)
add_subdirectory(raftex)
add_subdirectory(storage)
add_subdirectory(parser)
add_subdirectory(dataman)
add_subdirectory(graph)
add_subdirectory(daemons)
# Overview
...@@ -2,17 +2,17 @@ add_library(console_obj OBJECT CliManager.cpp CmdProcessor.cpp) ...@@ -2,17 +2,17 @@ add_library(console_obj OBJECT CliManager.cpp CmdProcessor.cpp)
add_dependencies(console_obj common) add_dependencies(console_obj common)
add_executable( add_executable(
vgraph nebula
GraphDbConsole.cpp NebulaConsole.cpp
$<TARGET_OBJECTS:console_obj> $<TARGET_OBJECTS:console_obj>
$<TARGET_OBJECTS:client_cpp_obj> $<TARGET_OBJECTS:client_cpp_obj>
$<TARGET_OBJECTS:base_obj> $<TARGET_OBJECTS:base_obj>
$<TARGET_OBJECTS:vgraph_thrift_obj> $<TARGET_OBJECTS:graph_thrift_obj>
$<TARGET_OBJECTS:time_obj> $<TARGET_OBJECTS:time_obj>
$<TARGET_OBJECTS:thread_obj> $<TARGET_OBJECTS:thread_obj>
) )
target_link_libraries( target_link_libraries(
vgraph nebula
thriftcpp2 thriftcpp2
thrift thrift
thrift-core thrift-core
...@@ -44,5 +44,7 @@ target_link_libraries( ...@@ -44,5 +44,7 @@ target_link_libraries(
-pthread -pthread
) )
install(TARGETS nebula DESTINATION bin)
#add_subdirectory(test) #add_subdirectory(test)
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
#include <readline/readline.h> #include <readline/readline.h>
#include <readline/history.h> #include <readline/history.h>
#include "console/CliManager.h" #include "console/CliManager.h"
#include "client/cpp/GraphDbClient.h" #include "client/cpp/GraphClient.h"
namespace vesoft { namespace nebula {
namespace vgraph { namespace graph {
const int32_t kMaxAuthInfoRetries = 3; const int32_t kMaxAuthInfoRetries = 3;
const int32_t kMaxUsernameLen = 16; const int32_t kMaxUsernameLen = 16;
...@@ -61,10 +61,10 @@ bool CliManager::connect(const std::string& addr, ...@@ -61,10 +61,10 @@ bool CliManager::connect(const std::string& addr,
port_ = port; port_ = port;
username_ = user; username_ = user;
auto client = std::make_unique<GraphDbClient>(addr_, port_); auto client = std::make_unique<GraphClient>(addr_, port_);
cpp2::ErrorCode res = client->connect(user, pass); cpp2::ErrorCode res = client->connect(user, pass);
if (res == cpp2::ErrorCode::SUCCEEDED) { if (res == cpp2::ErrorCode::SUCCEEDED) {
std::cerr << "\nWelcome to vGraph (Version 0.1)\n\n"; std::cerr << "\nWelcome to Nebula Graph (Version 0.1)\n\n";
cmdProcessor_ = std::make_unique<CmdProcessor>(std::move(client)); cmdProcessor_ = std::make_unique<CmdProcessor>(std::move(client));
return true; return true;
} else { } else {
...@@ -76,6 +76,7 @@ bool CliManager::connect(const std::string& addr, ...@@ -76,6 +76,7 @@ bool CliManager::connect(const std::string& addr,
void CliManager::batch(const std::string& filename) { void CliManager::batch(const std::string& filename) {
UNUSED(filename);
} }
...@@ -190,5 +191,5 @@ void CliManager::loadHistory() { ...@@ -190,5 +191,5 @@ void CliManager::loadHistory() {
::fclose(file); ::fclose(file);
} }
} // namespace vgraph } // namespace graph
} // namespace vesoft } // namespace nebula
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include "base/Base.h" #include "base/Base.h"
#include "console/CmdProcessor.h" #include "console/CmdProcessor.h"
namespace vesoft { namespace nebula {
namespace vgraph { namespace graph {
class CliManager final { class CliManager final {
public: public:
...@@ -43,6 +43,6 @@ private: ...@@ -43,6 +43,6 @@ private:
std::unique_ptr<CmdProcessor> cmdProcessor_; std::unique_ptr<CmdProcessor> cmdProcessor_;
}; };
} // namespace vgraph } // namespace graph
} // namespace vesoft } // namespace nebula
#endif // CONSOLE_CLIMANAGER_H_ #endif // CONSOLE_CLIMANAGER_H_
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "console/CmdProcessor.h" #include "console/CmdProcessor.h"
#include "time/Duration.h" #include "time/Duration.h"
namespace vesoft { namespace nebula {
namespace vgraph { namespace graph {
#define GET_VALUE_WIDTH(VT, FN, FMT) \ #define GET_VALUE_WIDTH(VT, FN, FMT) \
VT val = col.get_ ## FN(); \ VT val = col.get_ ## FN(); \
...@@ -377,6 +377,6 @@ bool CmdProcessor::process(folly::StringPiece cmd) { ...@@ -377,6 +377,6 @@ bool CmdProcessor::process(folly::StringPiece cmd) {
return true; return true;
} }
} // namespace vgraph } // namespace graph
} // namespace vesoft } // namespace nebula
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
#define CONSOLE_CMDPROCESSOR_H_ #define CONSOLE_CMDPROCESSOR_H_
#include "base/Base.h" #include "base/Base.h"
#include "client/cpp/GraphDbClient.h" #include "client/cpp/GraphClient.h"
namespace vesoft { namespace nebula {
namespace vgraph { namespace graph {
class CmdProcessor final { class CmdProcessor final {
public: public:
explicit CmdProcessor(std::unique_ptr<GraphDbClient> client) explicit CmdProcessor(std::unique_ptr<GraphClient> client)
: client_(std::move(client)) {} : client_(std::move(client)) {}
~CmdProcessor() = default; ~CmdProcessor() = default;
...@@ -26,7 +26,7 @@ public: ...@@ -26,7 +26,7 @@ public:
bool process(folly::StringPiece cmd); bool process(folly::StringPiece cmd);
private: private:
std::unique_ptr<GraphDbClient> client_; std::unique_ptr<GraphClient> client_;
// The method returns true if the given command is a client command // The method returns true if the given command is a client command
// and has been processed. Otherwise, the method returns false // and has been processed. Otherwise, the method returns false
...@@ -47,6 +47,6 @@ private: ...@@ -47,6 +47,6 @@ private:
const std::vector<std::string>& formats) const; const std::vector<std::string>& formats) const;
}; };
} // namespace vgraph } // namespace graph
} // namespace vesoft } // namespace nebula
#endif // CONSOLE_CMDPROCESSOR_H_ #endif // CONSOLE_CMDPROCESSOR_H_
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include "base/Base.h" #include "base/Base.h"
#include "console/CliManager.h" #include "console/CliManager.h"
DEFINE_string(addr, "127.0.0.1", "GraphDB daemon IP address"); DEFINE_string(addr, "127.0.0.1", "Nebula daemon IP address");
DEFINE_int32(port, 34500, "GraphDB daemon listening port"); DEFINE_int32(port, 34500, "Nebula daemon listening port");
DEFINE_string(username, "", "Username used to authenticate"); DEFINE_string(username, "", "Username used to authenticate");
DEFINE_string(password, "", "Password used to authenticate"); DEFINE_string(password, "", "Password used to authenticate");
...@@ -16,7 +16,7 @@ DEFINE_string(password, "", "Password used to authenticate"); ...@@ -16,7 +16,7 @@ DEFINE_string(password, "", "Password used to authenticate");
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
folly::init(&argc, &argv, true); folly::init(&argc, &argv, true);
using namespace vesoft::vgraph; using namespace nebula::graph;
CliManager cli; CliManager cli;
if (!cli.connect(FLAGS_addr, FLAGS_port, FLAGS_username, FLAGS_password)) { if (!cli.connect(FLAGS_addr, FLAGS_port, FLAGS_username, FLAGS_password)) {
......
# Overview
add_executable(
nebula-graphd
GraphDaemon.cpp
$<TARGET_OBJECTS:graph_obj>
$<TARGET_OBJECTS:base_obj>
$<TARGET_OBJECTS:graph_thrift_obj>
$<TARGET_OBJECTS:time_obj>
$<TARGET_OBJECTS:fs_obj>
$<TARGET_OBJECTS:thread_obj>
$<TARGET_OBJECTS:parser_obj>
)
target_link_libraries(
nebula-graphd
${THRIFT_LIBRARIES}
wangle
folly
boost_system
boost_context
${OPENSSL_LIBRARIES}
${KRB5_LIBRARIES}
glog
gflags
event
${COMPRESSION_LIBRARIES}
resolv
double-conversion
dl
-pthread
)
install(TARGETS nebula-graphd DESTINATION bin)
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved
*
* This source code is licensed under Apache 2.0 License
* (found in the LICENSE.Apache file in the root directory)
*/
#include <signal.h>
#include "base/Base.h"
#include "base/Status.h"
#include "fs/FileUtils.h"
#include <thrift/lib/cpp2/server/ThriftServer.h>
#include "graph/GraphService.h"
#include "graph/GraphFlags.h"
using namespace nebula;
using namespace nebula::graph;
using namespace nebula::fs;
static std::unique_ptr<apache::thrift::ThriftServer> gServer;
static void signalHandler(int sig);
static Status setupSignalHandler();
static Status setupLogging();
int main(int argc, char *argv[]) {
folly::init(&argc, &argv, true);
auto status = setupLogging();
if (!status.ok()) {
LOG(ERROR) << status;
return EXIT_FAILURE;
}
status = setupSignalHandler();
if (!status.ok()) {
LOG(ERROR) << status;
return EXIT_FAILURE;
}
auto interface = std::make_shared<GraphService>();
gServer = std::make_unique<apache::thrift::ThriftServer>();
gServer->setInterface(interface);
gServer->setPort(FLAGS_port);
gServer->setReusePort(FLAGS_reuse_port);
gServer->setIdleTimeout(std::chrono::seconds(FLAGS_client_idle_timeout_secs));
// TODO(dutor) This only take effects on NORMAL priority threads
gServer->setNumCPUWorkerThreads(1);
gServer->setCPUWorkerThreadName("executor");
gServer->setNumAcceptThreads(FLAGS_num_accept_threads);
gServer->setListenBacklog(FLAGS_listen_backlog);
gServer->setThreadStackSizeMB(5);
if (FLAGS_num_netio_threads != 0) {
gServer->setNumIOWorkerThreads(FLAGS_num_netio_threads);
}
FLOG_INFO("Starting nebula-graphd on port %d\n", FLAGS_port);
try {
gServer->serve(); // Blocking wait until shut down via gServer->stop()
} catch (const std::exception &e) {
FLOG_ERROR("Exception thrown while starting the RPC server: %s", e.what());
return EXIT_FAILURE;
}
FLOG_INFO("nebula-graphd on port %d has been stopped", FLAGS_port);
return EXIT_SUCCESS;
}
Status setupSignalHandler() {
::signal(SIGPIPE, SIG_IGN);
::signal(SIGINT, signalHandler);
::signal(SIGTERM, signalHandler);
return Status::OK();
}
void signalHandler(int sig) {
switch (sig) {
case SIGINT:
case SIGTERM:
FLOG_INFO("Signal %d(%s) received, stopping this server", sig, ::strsignal(sig));
gServer->stop();
break;
default:
FLOG_ERROR("Signal %d(%s) received but ignored", sig, ::strsignal(sig));
}
}
Status setupLogging() {
auto dup = [] (const std::string &filename, FILE *stream) -> Status {
auto path = FLAGS_log_dir + "/" + filename;
auto fd = ::open(path.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
if (fd == -1) {
return Status::Error("Failed to create or open `%s': %s",
path.c_str(), ::strerror(errno));
}
if (::dup2(fd, ::fileno(stream)) == -1) {
return Status::Error("Failed to ::dup2 from `%s' to stdout: %s",
path.c_str(), ::strerror(errno));
}
::close(fd);
return Status::OK();
};
Status status = Status::OK();
do {
status = dup(FLAGS_stdout_log_file, stdout);
if (!status.ok()) {
break;
}
status = dup(FLAGS_stderr_log_file, stderr);
if (!status.ok()) {
break;
}
} while (false);
return status;
}
# Overview
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved
*
* This source code is licensed under Apache 2.0 License
* (found in the LICENSE.Apache file in the root directory)
*/
#include "base/Base.h"
#include "graph/AlterEdgeExecutor.h"
namespace nebula {
namespace graph {
AlterEdgeExecutor::AlterEdgeExecutor(Sentence *sentence,
ExecutionContext *ectx) : Executor(ectx) {
sentence_ = static_cast<AlterEdgeSentence*>(sentence);
}
Status AlterEdgeExecutor::prepare() {
return Status::OK();
}
void AlterEdgeExecutor::execute() {
if (onFinish_) {
onFinish_();
}
}
} // namespace graph
} // namespace nebula
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved
*
* This source code is licensed under Apache 2.0 License
* (found in the LICENSE.Apache file in the root directory)
*/
#ifndef GRAPH_ALTEREDGEEXECUTOR_H_
#define GRAPH_ALTEREDGEEXECUTOR_H_
#include "base/Base.h"
#include "graph/Executor.h"
namespace nebula {
namespace graph {
class AlterEdgeExecutor final : public Executor {
public:
AlterEdgeExecutor(Sentence *sentence, ExecutionContext *ectx);
const char* name() const override {
return "AlterEdgeExecutor";
}
Status VE_MUST_USE_RESULT prepare() override;
void execute() override;
private:
AlterEdgeSentence *sentence_{nullptr};
};
} // namespace graph
} // namespace nebula
#endif // GRAPH_ALTEREDGEEXECUTOR_H_
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved
*
* This source code is licensed under Apache 2.0 License
* (found in the LICENSE.Apache file in the root directory)
*/
#include "base/Base.h"
#include "graph/AlterTagExecutor.h"
namespace nebula {
namespace graph {
AlterTagExecutor::AlterTagExecutor(Sentence *sentence,
ExecutionContext *ectx) : Executor(ectx) {
sentence_ = static_cast<AlterTagSentence*>(sentence);
}
Status AlterTagExecutor::prepare() {
return Status::OK();
}
void AlterTagExecutor::execute() {
if (onFinish_) {
onFinish_();
}
}
} // namespace graph
} // namespace nebula
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved
*
* This source code is licensed under Apache 2.0 License
* (found in the LICENSE.Apache file in the root directory)
*/
#ifndef GRAPH_ALTERTAGEXECUTOR_H_
#define GRAPH_ALTERTAGEXECUTOR_H_
#include "base/Base.h"
#include "graph/Executor.h"
namespace nebula {
namespace graph {
class AlterTagExecutor final : public Executor {
public:
AlterTagExecutor(Sentence *sentence, ExecutionContext *ectx);
const char* name() const override {
return "AlterTagExecutor";
}
Status VE_MUST_USE_RESULT prepare() override;
void execute() override;
private:
AlterTagSentence *sentence_{nullptr};
};
} // namespace graph
} // namespace nebula
#endif // GRAPH_ALTERTAGEXECUTOR_H_
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment