Skip to content

Commit

Permalink
Merge branch 'master' into balancer-client
Browse files Browse the repository at this point in the history
  • Loading branch information
dangleptr authored Jul 15, 2019
2 parents f92944b + 9950b29 commit 79d84d6
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

Expand Down
3 changes: 1 addition & 2 deletions docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```

```
Expand Down
53 changes: 41 additions & 12 deletions src/console/CliManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}
}


Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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";
Expand All @@ -225,6 +251,9 @@ void CliManager::saveHistory() {
void CliManager::loadHistory() {
if (!enableHistroy_) {
return;
}
std::string histfile;
histfile += ::getenv("HOME");
histfile += "/.nebula_history";
Expand Down
2 changes: 2 additions & 0 deletions src/console/CliManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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> cmdProcessor_;
};
Expand Down
2 changes: 2 additions & 0 deletions src/graph/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/kvstore/NebulaStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/meta/ActiveHostsMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ ActiveHostsMan::ActiveHostsMan(int32_t intervalSeconds, int32_t expiredSeconds,
bool ActiveHostsMan::updateHostInfo(const HostAddr& hostAddr, const HostInfo& info) {
std::vector<kvstore::KV> 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());
Expand Down

0 comments on commit 79d84d6

Please sign in to comment.