Skip to content

Commit

Permalink
Add standalone version for nebula (vesoft-inc#424)
Browse files Browse the repository at this point in the history
#### What type of PR is this?
- [ ] bug
- [x] feature
- [ ] enhancement

#### What does this PR do?
Add nebula standalone version, replace rpc with local function call.

#### Which issue(s)/PR(s) this PR relates to?
close vesoft-inc#3160

  
#### Special notes for your reviewer, ex. impact of this fix, etc:
- compile graphd&storaged into one process
- repalce thrift rpc call with local function call

#### Additional context:


#### Checklist:
- [x] Documentation affected (Please add the label if documentation needs to be modified.)
- [ ] Incompatible (If it is incompatible, please describe it and add corresponding label.)
- [ ] Need to cherry-pick (If need to cherry-pick to some branches, please label the destination version(s).)
- [ ] Performance impacted: Consumes more CPU/Memory


#### Release notes:
Please confirm whether to reflect in release notes and how to describe:
>                                                                 `


Migrated from vesoft-inc#3310

Co-authored-by: Alex Xing <90179377+SuperYoko@users.noreply.github.com>
  • Loading branch information
nebula-bots and SuperYoko authored Jan 5, 2022
1 parent b165b6f commit fc3fbf8
Show file tree
Hide file tree
Showing 31 changed files with 1,566 additions and 357 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ option(ENABLE_INCLUDE_WHAT_YOU_USE "Enable include-what-you-use find nouse incl

add_definitions(-DNEBULA_HOME=${CMAKE_SOURCE_DIR})

if(ENABLE_STANDALONE_VERSION)
add_definitions(-DBUILD_STANDALONE)
endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/nebula)

Expand Down
1 change: 1 addition & 0 deletions cmake/nebula/GeneralCMakeOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ option(ENABLE_COMPRESSED_DEBUG_INFO "Compress debug info to reduce binary si
option(ENABLE_CLANG_TIDY "Enable clang-tidy if present" OFF)
option(ENABLE_GDB_SCRIPT_SECTION "Add .debug_gdb_scripts section" OFF)
option(DISABLE_CXX11_ABI "Whether to disable cxx11 abi" OFF)
option(ENABLE_STANDALONE_VERSION "Enable standalone version build" OFF)

get_cmake_property(variable_list VARIABLES)
foreach(_varname ${variable_list})
Expand Down
19 changes: 19 additions & 0 deletions conf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# These configuration files are for reference to generate your own customized ones.
# Thus, they are installed as read-only, even for the owner.

if(NOT ENABLE_STANDALONE_VERSION)

install(
FILES
nebula-graphd.conf.default
Expand Down Expand Up @@ -61,3 +63,20 @@ install(
COMPONENT
drainer
)

else()

install(
FILES
nebula-standalone.conf.default
PERMISSIONS
OWNER_READ
GROUP_READ
WORLD_READ
DESTINATION
etc
COMPONENT
graph
)

endif()
164 changes: 164 additions & 0 deletions conf/nebula-standalone.conf.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
########## basics ##########
# Whether to run as a daemon process
--daemonize=true
# The file to host the process id
--pid_file=pids/nebula-standalone.pid
# Whether to enable optimizer
--enable_optimizer=true
# The default charset when a space is created
--default_charset=utf8
# The defaule collate when a space is created
--default_collate=utf8_bin
# Whether to use the configuration obtained from the configuration file
--local_config=true

########## logging ##########
# The directory to host logging files
--log_dir=logs
# Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively
--minloglevel=0
# Verbose log level, 1, 2, 3, 4, the higher of the level, the more verbose of the logging
--v=0
# 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=standalone-stdout.log
--stderr_log_file=standalone-stderr.log
# Copy log messages at or above this level to stderr in addition to logfiles. The numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively.
--stderrthreshold=2

########## query ##########
# Whether to treat partial success as an error.
# This flag is only used for Read-only access, and Modify access always treats partial success as an error.
--accept_partial_success=false
# Maximum sentence length, unit byte
--max_allowed_query_size=4194304

########## networking ##########
# Comma separated Meta Server Addresses
--meta_server_addrs=127.0.0.1:9559
# Local IP used to identify the nebula-graphd process.
# Change it to an address other than loopback if the service is distributed or
# will be accessed remotely.
--local_ip=127.0.0.1
# Network device to listen on
--listen_netdev=any
# Port to listen on
--port=9669
--meta_port=9559
--storage_port=9779
# To turn on SO_REUSEPORT or not
--reuse_port=false
# Backlog of the listen socket, adjust this together with net.core.somaxconn
--listen_backlog=1024
# The number of seconds Nebula service waits before closing the idle connections
--client_idle_timeout_secs=28800
# The number of seconds before idle sessions expire
# The range should be in [1, 604800]
--session_idle_timeout_secs=28800
# The number of threads to accept incoming connections
--num_accept_threads=1
# The number of networking IO threads, 0 for # of CPU cores
--num_netio_threads=0
# The number of threads to execute user queries, 0 for # of CPU cores
--num_worker_threads=0
# HTTP service ip
--ws_ip=0.0.0.0
# HTTP service port
--ws_http_port=19669
# HTTP2 service port
--ws_h2_port=19670
# storage client timeout
--storage_client_timeout_ms=60000
# Port to listen on Meta with HTTP protocol, it corresponds to ws_http_port in metad's configuration file
--ws_meta_http_port=19559
# HTTP service port
--ws_storage_http_port=19779
# HTTP2 service port
--ws_storage_h2_port=19780
# heartbeat with meta service
--heartbeat_interval_secs=10


########## authentication ##########
# Enable authorization
--enable_authorize=false
# User login authentication type, password for nebula authentication, ldap for ldap authentication, cloud for cloud authentication
--auth_type=password

########## memory ##########
# System memory high watermark ratio
--system_memory_high_watermark_ratio=0.8

########## experimental feature ##########
# if use experimental features
--enable_experimental_feature=false

######### Raft #########
# Raft election timeout
--raft_heartbeat_interval_secs=30
# RPC timeout for raft client (ms)
--raft_rpc_timeout_ms=500
## recycle Raft WAL
--wal_ttl=14400

########## Disk ##########
# Root data path. Split by comma. e.g. --data_path=/disk1/path1/,/disk2/path2/
# One path per Rocksdb instance.
--data_path=data/storage

# Minimum reserved bytes of each data path
--minimum_reserved_bytes=268435456

# The default reserved bytes for one batch operation
--rocksdb_batch_size=4096
# The default block cache size used in BlockBasedTable.
# The unit is MB.
--rocksdb_block_cache=4
# The type of storage engine, `rocksdb', `memory', etc.
--engine_type=rocksdb

# Compression algorithm, options: no,snappy,lz4,lz4hc,zlib,bzip2,zstd
# For the sake of binary compatibility, the default value is snappy.
# Recommend to use:
# * lz4 to gain more CPU performance, with the same compression ratio with snappy
# * zstd to occupy less disk space
# * lz4hc for the read-heavy write-light scenario
--rocksdb_compression=lz4

# Set different compressions for different levels
# For example, if --rocksdb_compression is snappy,
# "no:no:lz4:lz4::zstd" is identical to "no:no:lz4:lz4:snappy:zstd:snappy"
# In order to disable compression for level 0/1, set it to "no:no"
--rocksdb_compression_per_level=

# Whether or not to enable rocksdb's statistics, disabled by default
--enable_rocksdb_statistics=false

# Statslevel used by rocksdb to collection statistics, optional values are
# * kExceptHistogramOrTimers, disable timer stats, and skip histogram stats
# * kExceptTimers, Skip timer stats
# * kExceptDetailedTimers, Collect all stats except time inside mutex lock AND time spent on compression.
# * kExceptTimeForMutex, Collect all stats except the counters requiring to get time inside the mutex lock.
# * kAll, Collect all stats
--rocksdb_stats_level=kExceptHistogramOrTimers

# Whether or not to enable rocksdb's prefix bloom filter, enabled by default.
--enable_rocksdb_prefix_filtering=true
# Whether or not to enable rocksdb's whole key bloom filter, disabled by default.
--enable_rocksdb_whole_key_filtering=false

############## rocksdb Options ##############
# rocksdb DBOptions in json, each name and value of option is a string, given as "option_name":"option_value" separated by comma
--rocksdb_db_options={}
# rocksdb ColumnFamilyOptions in json, each name and value of option is string, given as "option_name":"option_value" separated by comma
--rocksdb_column_family_options={"write_buffer_size":"67108864","max_write_buffer_number":"4","max_bytes_for_level_base":"268435456"}
# rocksdb BlockBasedTableOptions in json, each name and value of option is string, given as "option_name":"option_value" separated by comma
--rocksdb_block_based_table_options={"block_size":"8192"}

############## meta Options ##############
--meta_data_path=data/meta
--default_replica_factor=1
--default_parts_num=100
29 changes: 24 additions & 5 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# This source code is licensed under Apache 2.0 License.

if(NOT ENABLE_STANDALONE_VERSION)

install(
FILES
nebula-storaged.service
Expand Down Expand Up @@ -30,20 +32,37 @@ install(

install(
FILES
nebula.service
nebula-graphd.service
PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
DESTINATION
scripts
COMPONENT
common
graph
)

else()

install(
FILES
utils.sh
nebula-standalone.service
PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
DESTINATION
scripts
COMPONENT
graph
)

endif()

install(
FILES
nebula.service
PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
Expand All @@ -56,15 +75,15 @@ install(

install(
FILES
nebula-graphd.service
utils.sh
PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
DESTINATION
scripts
COMPONENT
graph
common
)

install(
Expand Down
6 changes: 6 additions & 0 deletions scripts/nebula-standalone.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/bash

SCRIPT_PATH=$(readlink -f $0)
SCRIPT_DIR=$(dirname ${SCRIPT_PATH})
export USAGE_INFO="${0} [-v] [-c /path/to/conf] <start|stop|restart|status|kill>"
${SCRIPT_DIR}/nebula.service $@ standalone
12 changes: 11 additions & 1 deletion scripts/nebula.service
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ fi
ACTION=${1}
TARGET=${2}

if [ -e ${INSTALL_ROOT}/bin/nebula-standalone ]
then
ALLTARGET=(standalone)
else
ALLTARGET=(metad graphd storaged)
fi

# Collect the daemons on which we perform the action on
case ${TARGET} in
metad)
Expand All @@ -91,8 +98,11 @@ case ${TARGET} in
drainerd)
TARGETS=(${TARGET})
;;
standalone)
TARGETS=(${TARGET})
;;
all)
TARGETS=(metad graphd storaged)
TARGETS=${ALLTARGET[*]}
;;
*)
ERROR "Unknown daemon \`${DAEMON}'"
Expand Down
56 changes: 56 additions & 0 deletions src/clients/storage/GeneralStorageClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* Copyright (c) 2020 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#ifndef CLIENTS_STORAGE_GENERALSTORAGECLIENT_H_
#define CLIENTS_STORAGE_GENERALSTORAGECLIENT_H_

#include <gtest/gtest_prod.h>

#include "clients/meta/MetaClient.h"
#include "clients/storage/StorageClientBase.h"
#include "common/base/Base.h"
#include "common/datatypes/KeyValue.h"
#include "common/thrift/ThriftClientManager.h"
#include "interface/gen-cpp2/GeneralStorageServiceAsyncClient.h"

namespace nebula {
namespace storage {

/**
* A wrapper class for GeneralStorageServiceAsyncClient thrift API
*
* The class is NOT reentrant
*/
class GeneralStorageClient
: public StorageClientBase<
cpp2::GeneralStorageServiceAsyncClient,
thrift::ThriftClientManager<cpp2::GeneralStorageServiceAsyncClient>> {
using Parent =
StorageClientBase<cpp2::GeneralStorageServiceAsyncClient,
thrift::ThriftClientManager<cpp2::GeneralStorageServiceAsyncClient>>;

public:
GeneralStorageClient(std::shared_ptr<folly::IOThreadPoolExecutor> ioThreadPool,
meta::MetaClient* metaClient)
: Parent(ioThreadPool, metaClient) {}
virtual ~GeneralStorageClient() {}

folly::SemiFuture<StorageRpcResponse<cpp2::KVGetResponse>> get(GraphSpaceID space,
std::vector<std::string>&& keys,
bool returnPartly = false,
folly::EventBase* evb = nullptr);

folly::SemiFuture<StorageRpcResponse<cpp2::ExecResponse>> put(GraphSpaceID space,
std::vector<KeyValue> kvs,
folly::EventBase* evb = nullptr);

folly::SemiFuture<StorageRpcResponse<cpp2::ExecResponse>> remove(GraphSpaceID space,
std::vector<std::string> keys,
folly::EventBase* evb = nullptr);
};

} // namespace storage
} // namespace nebula
#endif // CLIENTS_STORAGE_GENERALSTORAGECLIENT_H_
10 changes: 8 additions & 2 deletions src/clients/storage/InternalStorageClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "clients/storage/StorageClientBase.h"
#include "common/base/Base.h"
#include "common/base/ErrorOr.h"
#include "common/thrift/ThriftClientManager.h"
#include "interface/gen-cpp2/InternalStorageServiceAsyncClient.h"

namespace nebula {
Expand All @@ -21,8 +22,13 @@ namespace storage {
*
* The class is NOT reentrant
*/
class InternalStorageClient : public StorageClientBase<cpp2::InternalStorageServiceAsyncClient> {
using Parent = StorageClientBase<cpp2::InternalStorageServiceAsyncClient>;
class InternalStorageClient
: public StorageClientBase<
cpp2::InternalStorageServiceAsyncClient,
thrift::ThriftClientManager<cpp2::InternalStorageServiceAsyncClient>> {
using Parent =
StorageClientBase<cpp2::InternalStorageServiceAsyncClient,
thrift::ThriftClientManager<cpp2::InternalStorageServiceAsyncClient>>;

public:
InternalStorageClient(std::shared_ptr<folly::IOThreadPoolExecutor> ioThreadPool,
Expand Down
Loading

0 comments on commit fc3fbf8

Please sign in to comment.