diff --git a/docs/README.md b/docs/README.md index f21ec364291..ee53ae076e5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,7 +13,7 @@ * SQL-like query language ## How can I get Nebula ## -**Nebula Graph** source code is available here on [GitHub](https://github.com/vesoft-inc/nebula). The currently release is version 0.1. +**Nebula Graph** source code is available here on [GitHub](https://github.com/vesoft-inc/nebula). The currently release is version R1910_alpha. You can also download [Docker ](https://www.docker.com/get-started)image to try it. More details on how to get Nebula image click [Get Started](get-started/). diff --git a/docs/get-started.md b/docs/get-started.md index cfba201fe33..bd1b8ef9280 100644 --- a/docs/get-started.md +++ b/docs/get-started.md @@ -350,8 +350,7 @@ nebula> INSERT VERTEX student(name, age, gender) VALUES 201:("Mike", 18, "male") nebula> INSERT VERTEX student(name, age, gender) VALUES 202:("Jane", 17, "female"); nebula> INSERT VERTEX course(name, credits),building(name) VALUES 101:("Math", 3, "No5"); nebula> INSERT VERTEX course(name, credits),building(name) VALUES 102:("English", 6, "No11"); -======= -nebula> CREATE space myspace(partition_num=1, replica_factor=1) + ``` ``` diff --git a/src/console/CliManager.cpp b/src/console/CliManager.cpp index 35ff79b86e4..58c70634398 100644 --- a/src/console/CliManager.cpp +++ b/src/console/CliManager.cpp @@ -16,6 +16,7 @@ DECLARE_string(u); DECLARE_string(p); +DEFINE_bool(enable_history, false, "Whether to force saving the command history"); namespace nebula { namespace graph { @@ -26,8 +27,22 @@ const int32_t kMaxPasswordLen = 24; const int32_t kMaxCommandLineLen = 1024; CliManager::CliManager() { - ::using_history(); - initAutoCompletion(); + if (!fs::FileUtils::isStdinTTY()) { + enableHistroy_ = false; + isInteractive_ = false; + } + + if (FLAGS_enable_history) { + enableHistroy_ = true; + } + + if (enableHistroy_) { + ::using_history(); + } + + if (isInteractive_) { + initAutoCompletion(); + } } @@ -146,16 +161,21 @@ void CliManager::loop() { bool CliManager::readLine(std::string &line, bool linebreak) { auto ok = true; char prompt[256]; - static auto color = 0u; - ::snprintf(prompt, sizeof(prompt), - "\001" // RL_PROMPT_START_IGNORE - "\033[1;%um" // color codes start - "\002" // RL_PROMPT_END_IGNORE - "nebula> " // prompt - "\001" // RL_PROMPT_START_IGNORE - "\033[0m" // restore color code - "\002", // RL_PROMPT_END_IGNORE - color++ % 6 + 31); + if (isInteractive_) { + static auto color = 0u; + ::snprintf(prompt, sizeof(prompt), + "\001" // RL_PROMPT_START_IGNORE + "\033[1;%um" // color codes start + "\002" // RL_PROMPT_END_IGNORE + "nebula> " // prompt + "\001" // RL_PROMPT_START_IGNORE + "\033[0m" // restore color code + "\002", // RL_PROMPT_END_IGNORE + color++ % 6 + 31); + } else { + prompt[0] = '\0'; // prompt + } + auto *input = ::readline(linebreak ? "": prompt); do { @@ -184,6 +204,9 @@ bool CliManager::readLine(std::string &line, bool linebreak) { void CliManager::updateHistory(const char *line) { + if (!enableHistroy_) { + return; + } auto **hists = ::history_list(); auto i = 0; // Search in history @@ -208,6 +231,9 @@ void CliManager::updateHistory(const char *line) { void CliManager::saveHistory() { + if (!enableHistroy_) { + return; + } std::string histfile; histfile += ::getenv("HOME"); histfile += "/.nebula_history"; @@ -225,6 +251,9 @@ void CliManager::saveHistory() { void CliManager::loadHistory() { + if (!enableHistroy_) { + return; + } std::string histfile; histfile += ::getenv("HOME"); histfile += "/.nebula_history"; diff --git a/src/console/CliManager.h b/src/console/CliManager.h index 0af4e31ed1b..8d4d55cc0e9 100644 --- a/src/console/CliManager.h +++ b/src/console/CliManager.h @@ -42,6 +42,8 @@ class CliManager final { std::string addr_; uint16_t port_; std::string username_; + bool enableHistroy_{true}; + bool isInteractive_{true}; std::unique_ptr cmdProcessor_; }; diff --git a/src/graph/test/CMakeLists.txt b/src/graph/test/CMakeLists.txt index cc489f6c1fd..f10195cc5e4 100644 --- a/src/graph/test/CMakeLists.txt +++ b/src/graph/test/CMakeLists.txt @@ -30,6 +30,8 @@ add_library(graph_test_common_obj OBJECT TestBase.cpp ) +add_dependencies(graph_test_common_obj meta_thrift_obj graph_thrift_obj) + add_executable( session_manager_test diff --git a/src/kvstore/NebulaStore.cpp b/src/kvstore/NebulaStore.cpp index 54abe1f71aa..12820378594 100644 --- a/src/kvstore/NebulaStore.cpp +++ b/src/kvstore/NebulaStore.cpp @@ -274,8 +274,6 @@ void NebulaStore::removePart(GraphSpaceID spaceId, PartitionID partId) { if (partIt != spaceIt->second->parts_.end()) { auto* e = partIt->second->engine(); CHECK_NOTNULL(e); - // Stop the raft - partIt->second->stop(); raftService_->removePartition(partIt->second); spaceIt->second->parts_.erase(partId); e->removePart(partId); diff --git a/src/meta/ActiveHostsMan.cpp b/src/meta/ActiveHostsMan.cpp index 4c35988e457..a965f07ae4e 100644 --- a/src/meta/ActiveHostsMan.cpp +++ b/src/meta/ActiveHostsMan.cpp @@ -34,10 +34,9 @@ ActiveHostsMan::ActiveHostsMan(int32_t intervalSeconds, int32_t expiredSeconds, bool ActiveHostsMan::updateHostInfo(const HostAddr& hostAddr, const HostInfo& info) { std::vector data; { - folly::RWSpinLock::ReadHolder rh(&lock_); + folly::RWSpinLock::WriteHolder wh(&lock_); auto it = hostsMap_.find(hostAddr); if (it == hostsMap_.end()) { - folly::RWSpinLock::UpgradedHolder uh(&lock_); hostsMap_.emplace(hostAddr, std::move(info)); data.emplace_back(MetaServiceUtils::hostKey(hostAddr.first, hostAddr.second), MetaServiceUtils::hostValOnline());