Skip to content

Commit

Permalink
fix rebase conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
liwenhui-soul committed Dec 27, 2021
1 parent 3ba80d8 commit f2db882
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 57 deletions.
6 changes: 3 additions & 3 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,9 +1217,9 @@ folly::Future<StatusOr<bool>> MetaClient::alterSpace(const std::string& spaceNam
meta::cpp2::AlterSpaceOp op,
const std::vector<std::string>& paras) {
cpp2::AlterSpaceReq req;
req.set_op(op);
req.set_space_name(spaceName);
req.set_paras(paras);
req.op_ref() = op;
req.space_name_ref() = spaceName;
req.paras_ref() = paras;
folly::Promise<StatusOr<bool>> promise;
auto future = promise.getFuture();
getResponse(
Expand Down
12 changes: 9 additions & 3 deletions src/graph/planner/plan/Admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,17 @@ class AlterSpace final : public SingleDependencyNode {
const std::vector<std::string>& paras) {
return qctx->objPool()->add(new AlterSpace(qctx, input, spaceName, op, paras));
}
const std::string& getSpaceName() const { return spaceName_; }
const std::string& getSpaceName() const {
return spaceName_;
}

meta::cpp2::AlterSpaceOp getAlterSpaceOp() const { return op_; }
meta::cpp2::AlterSpaceOp getAlterSpaceOp() const {
return op_;
}

const std::vector<std::string>& getParas() const { return paras_; }
const std::vector<std::string>& getParas() const {
return paras_;
}

private:
AlterSpace(QueryContext* qctx,
Expand Down
8 changes: 6 additions & 2 deletions src/graph/validator/AdminValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ Status CreateSpaceAsValidator::toPlan() {
return Status::OK();
}

Status AlterSpaceValidator::validateImpl() { return Status::OK(); }
Status AlterSpaceValidator::validateImpl() {
return Status::OK();
}

Status AlterSpaceValidator::toPlan() {
auto sentence = static_cast<AlterSpaceSentence *>(sentence_);
Expand All @@ -174,7 +176,9 @@ Status AlterSpaceValidator::toPlan() {
return Status::OK();
}

Status DescSpaceValidator::validateImpl() { return Status::OK(); }
Status DescSpaceValidator::validateImpl() {
return Status::OK();
}

Status DescSpaceValidator::toPlan() {
auto sentence = static_cast<DescribeSpaceSentence *>(sentence_);
Expand Down
8 changes: 6 additions & 2 deletions src/meta/processors/job/BalanceJobExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ struct Host {
struct Zone {
Zone() = default;
explicit Zone(const std::string name) : zoneName_(name) {}
bool hasHost(const HostAddr& ha) { return hosts_.find(ha) != hosts_.end(); }
bool hasHost(const HostAddr& ha) {
return hosts_.find(ha) != hosts_.end();
}
int32_t calPartNum();
bool partExist(PartitionID partId);

Expand Down Expand Up @@ -65,7 +67,9 @@ class BalanceJobExecutor : public MetaJobExecutor {
protected:
nebula::cpp2::ErrorCode save(const std::string& k, const std::string& v);

virtual Status buildBalancePlan() { return Status::OK(); }
virtual Status buildBalancePlan() {
return Status::OK();
}

protected:
std::unique_ptr<BalancePlan> plan_;
Expand Down
32 changes: 24 additions & 8 deletions src/meta/processors/job/MetaJobExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ DECLARE_uint32(expired_time_factor);

namespace nebula {
namespace meta {
bool MetaJobExecutor::check() { return true; }
bool MetaJobExecutor::check() {
return true;
}

// Prepare the Job info from the arguments.
nebula::cpp2::ErrorCode MetaJobExecutor::prepare() { return nebula::cpp2::ErrorCode::SUCCEEDED; }
nebula::cpp2::ErrorCode MetaJobExecutor::prepare() {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

// The skeleton to run the job.
// You should rewrite the executeInternal to trigger the calling.
Expand All @@ -31,15 +35,25 @@ nebula::cpp2::ErrorCode MetaJobExecutor::execute() {
}

// Stop the job when the user cancel it.
nebula::cpp2::ErrorCode MetaJobExecutor::stop() { return nebula::cpp2::ErrorCode::SUCCEEDED; }
nebula::cpp2::ErrorCode MetaJobExecutor::stop() {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

nebula::cpp2::ErrorCode MetaJobExecutor::finish(bool) { return nebula::cpp2::ErrorCode::SUCCEEDED; }
nebula::cpp2::ErrorCode MetaJobExecutor::finish(bool) {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

void MetaJobExecutor::setSpaceId(GraphSpaceID spaceId) { space_ = spaceId; }
void MetaJobExecutor::setSpaceId(GraphSpaceID spaceId) {
space_ = spaceId;
}

bool MetaJobExecutor::isMetaJob() { return true; }
bool MetaJobExecutor::isMetaJob() {
return true;
}

nebula::cpp2::ErrorCode MetaJobExecutor::recovery() { return nebula::cpp2::ErrorCode::SUCCEEDED; }
nebula::cpp2::ErrorCode MetaJobExecutor::recovery() {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

void MetaJobExecutor::setFinishCallBack(
std::function<nebula::cpp2::ErrorCode(meta::cpp2::JobStatus)> func) {
Expand All @@ -50,7 +64,9 @@ nebula::cpp2::ErrorCode MetaJobExecutor::saveSpecialTaskStatus(const cpp2::Repor
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

folly::Future<Status> MetaJobExecutor::executeInternal() { return Status::OK(); }
folly::Future<Status> MetaJobExecutor::executeInternal() {
return Status::OK();
}

} // namespace meta
} // namespace nebula
28 changes: 21 additions & 7 deletions src/meta/processors/job/StorageJobExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ class StorageJobExecutor : public JobExecutor {
virtual ~StorageJobExecutor() = default;

// Check the arguments about the job.
bool check() override { return true; }
bool check() override {
return true;
}

// Prepare the Job info from the arguments.
nebula::cpp2::ErrorCode prepare() override { return nebula::cpp2::ErrorCode::SUCCEEDED; }
nebula::cpp2::ErrorCode prepare() override {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

// The skeleton to run the job.
// You should rewrite the executeInternal to trigger the calling.
Expand All @@ -45,19 +49,29 @@ class StorageJobExecutor : public JobExecutor {
void interruptExecution(JobID jobId);

// Stop the job when the user cancel it.
nebula::cpp2::ErrorCode stop() override { return nebula::cpp2::ErrorCode::SUCCEEDED; }
nebula::cpp2::ErrorCode stop() override {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

nebula::cpp2::ErrorCode finish(bool) override { return nebula::cpp2::ErrorCode::SUCCEEDED; }
nebula::cpp2::ErrorCode finish(bool) override {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

void setSpaceId(GraphSpaceID spaceId) override { space_ = spaceId; }
void setSpaceId(GraphSpaceID spaceId) override {
space_ = spaceId;
}

nebula::cpp2::ErrorCode saveSpecialTaskStatus(const cpp2::ReportTaskReq&) override {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

bool isMetaJob() override { return false; }
bool isMetaJob() override {
return false;
}

nebula::cpp2::ErrorCode recovery() override { return nebula::cpp2::ErrorCode::SUCCEEDED; }
nebula::cpp2::ErrorCode recovery() override {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

protected:
ErrOrHosts getTargetHost(GraphSpaceID space);
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/job/ZoneBalanceJobExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ nebula::cpp2::ErrorCode ZoneBalanceJobExecutor::updateMeta() {
for (auto& zoneMapEntry : spaceInfo_.zones_) {
zones.emplace_back(zoneMapEntry.first);
}
properties.set_zone_names(std::move(zones));
properties.zone_names_ref() = std::move(zones);
std::vector<kvstore::KV> data;
data.emplace_back(MetaKeyUtils::spaceKey(spaceInfo_.spaceId_),
MetaKeyUtils::spaceVal(properties));
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/parts/AlterSpaceProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ nebula::cpp2::ErrorCode AlterSpaceProcessor::addZones(const std::string& spaceNa
}
newZones.emplace_back(z);
}
properties.set_zone_names(newZones);
properties.zone_names_ref() = newZones;
std::vector<kvstore::KV> data;
data.emplace_back(MetaKeyUtils::spaceKey(spaceId), MetaKeyUtils::spaceVal(properties));
folly::Baton<true, std::atomic> baton;
Expand Down
2 changes: 1 addition & 1 deletion src/meta/test/BalancerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ TEST(BalanceTest, LeaderBalanceWithLargerZoneTest) {
}
}

TEST(BalanceTest, DISABLED_LeaderBalanceWithComplexZoneTest) {
TEST(BalanceTest, LeaderBalanceWithComplexZoneTest) {
fs::TempDir rootPath("/tmp/LeaderBalanceWithComplexZoneTest.XXXXXX");
auto store = MockCluster::initMetaKV(rootPath.path());
auto* kv = dynamic_cast<kvstore::KVStore*>(store.get());
Expand Down
10 changes: 5 additions & 5 deletions src/meta/test/GetStatsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ struct JobCallBack {
req.task_id_ref() = taskId_;

cpp2::StatsItem item;
item.set_tag_vertices({{"t1", n_}, {"t2", n_}});
item.set_edges({{"e1", n_}, {"e2", n_}});
item.set_space_vertices(2 * n_);
item.set_space_edges(2 * n_);
req.set_stats(item);
item.tag_vertices_ref() = {{"t1", n_}, {"t2", n_}};
item.edges_ref() = {{"e1", n_}, {"e2", n_}};
item.space_vertices_ref() = 2 * n_;
item.space_edges_ref() = 2 * n_;
req.stats_ref() = item;
jobMgr_->muJobFinished_.unlock();
jobMgr_->reportTaskFinish(req);
return folly::Future<Status>(Status::OK());
Expand Down
24 changes: 12 additions & 12 deletions src/meta/test/ProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3653,9 +3653,9 @@ TEST(ProcessorTest, AlterSpaceTest) {
{
AlterSpaceProcessor* processor = AlterSpaceProcessor::instance(kv);
meta::cpp2::AlterSpaceReq req;
req.set_space_name("test_space");
req.set_op(meta::cpp2::AlterSpaceOp::ADD_ZONE);
req.set_paras({"12"});
req.space_name_ref() = "test_space";
req.op_ref() = meta::cpp2::AlterSpaceOp::ADD_ZONE;
req.paras_ref() = {"12"};
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
Expand All @@ -3664,9 +3664,9 @@ TEST(ProcessorTest, AlterSpaceTest) {
{
AlterSpaceProcessor* processor = AlterSpaceProcessor::instance(kv);
meta::cpp2::AlterSpaceReq req;
req.set_space_name("aaa");
req.set_op(meta::cpp2::AlterSpaceOp::ADD_ZONE);
req.set_paras({"9"});
req.space_name_ref() = "aaa";
req.op_ref() = meta::cpp2::AlterSpaceOp::ADD_ZONE;
req.paras_ref() = {"9"};
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
Expand All @@ -3675,9 +3675,9 @@ TEST(ProcessorTest, AlterSpaceTest) {
{
AlterSpaceProcessor* processor = AlterSpaceProcessor::instance(kv);
meta::cpp2::AlterSpaceReq req;
req.set_space_name("test_space");
req.set_op(meta::cpp2::AlterSpaceOp::ADD_ZONE);
req.set_paras({"8"});
req.space_name_ref() = "test_space";
req.op_ref() = meta::cpp2::AlterSpaceOp::ADD_ZONE;
req.paras_ref() = {"8"};
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
Expand All @@ -3686,9 +3686,9 @@ TEST(ProcessorTest, AlterSpaceTest) {
{
AlterSpaceProcessor* processor = AlterSpaceProcessor::instance(kv);
meta::cpp2::AlterSpaceReq req;
req.set_space_name("test_space");
req.set_op(meta::cpp2::AlterSpaceOp::ADD_ZONE);
req.set_paras({"9", "10", "11"});
req.space_name_ref() = "test_space";
req.op_ref() = meta::cpp2::AlterSpaceOp::ADD_ZONE;
req.paras_ref() = {"9", "10", "11"};
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
Expand Down
8 changes: 4 additions & 4 deletions src/meta/test/TestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ class TestUtils {
int32_t zoneNum,
int32_t totalHost) {
cpp2::SpaceDesc properties;
properties.set_space_name("test_space");
properties.set_partition_num(partitionNum);
properties.set_replica_factor(replica);
properties.space_name_ref() = "test_space";
properties.partition_num_ref() = partitionNum;
properties.replica_factor_ref() = replica;
auto spaceVal = MetaKeyUtils::spaceVal(properties);
std::vector<nebula::kvstore::KV> data;
data.emplace_back(MetaKeyUtils::indexSpaceKey("test_space"),
Expand All @@ -230,7 +230,7 @@ class TestUtils {
zonePartNum[std::to_string(i + 1)] = 0;
zoneNames.push_back(std::to_string(i + 1));
}
properties.set_zone_names(zoneNames);
properties.zone_names_ref() = zoneNames;
data.emplace_back(MetaKeyUtils::spaceKey(id), MetaKeyUtils::spaceVal(properties));
std::vector<HostAddr> allHosts;
for (int32_t i = 0; i < totalHost; i++) {
Expand Down
16 changes: 12 additions & 4 deletions src/parser/AdminSentences.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,21 @@ class AlterSpaceSentence final : public Sentence {
: op_(op), spaceName_(spaceName) {
kind_ = Kind::kAlterSpace;
}
void addPara(const std::string& para) { paras_.push_back(para); }
void addPara(const std::string& para) {
paras_.push_back(para);
}

std::string spaceName() const { return *spaceName_; }
std::string spaceName() const {
return *spaceName_;
}

const std::vector<std::string>& paras() const { return paras_; }
const std::vector<std::string>& paras() const {
return paras_;
}

meta::cpp2::AlterSpaceOp alterSpaceOp() const { return op_; }
meta::cpp2::AlterSpaceOp alterSpaceOp() const {
return op_;
}

std::string toString() const override;

Expand Down
8 changes: 4 additions & 4 deletions src/parser/test/ParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2016,22 +2016,22 @@ TEST_F(ParserTest, BalanceOperation) {
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "BALANCE DATA";
std::string query = "BALANCE IN ZONE";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "BALANCE DATA 1234567890";
std::string query = "BALANCE ACROSS ZONE";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "BALANCE DATA REMOVE 192.168.0.1:50000,192.168.0.1:50001";
std::string query = "BALANCE IN ZONE REMOVE 192.168.0.1:50000,192.168.0.1:50001";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "BALANCE DATA REMOVE 192.168.0.1:50000,\"localhost\":50001";
std::string query = "BALANCE IN ZONE REMOVE 192.168.0.1:50000,\"localhost\":50001";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
Expand Down

0 comments on commit f2db882

Please sign in to comment.