Skip to content

Commit

Permalink
issue=baidu#1271 Add mock zk adapter for test
Browse files Browse the repository at this point in the history
  • Loading branch information
yangce committed Jun 9, 2017
1 parent 4e62477 commit 8d93699
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/master/master_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,12 @@ MasterImpl::~MasterImpl() {
bool MasterImpl::Init() {
if (FLAGS_tera_zk_enabled) {
zk_adapter_.reset(new MasterZkAdapter(this, local_addr_));
} else if (FLAGS_tera_mock_zk_enabled) {
zk_adapter_.reset(new MockMasterZkAdapter(this, local_addr_));
} else if (FLAGS_tera_ins_enabled) {
LOG(INFO) << "ins mode" ;
zk_adapter_.reset(new InsMasterZkAdapter(this, local_addr_));
} else if (FLAGS_tera_mock_zk_enabled) {
LOG(INFO) << "mock zk mode" ;
zk_adapter_.reset(new MockMasterZkAdapter(this, local_addr_));
} else if (FLAGS_tera_mock_ins_enabled) {
LOG(INFO) << "mock ins mode" ;
zk_adapter_.reset(new MockInsMasterZkAdapter(this, local_addr_));
Expand Down
10 changes: 5 additions & 5 deletions src/sdk/sdk_zk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ bool FakeZkClusterFinder::ReadNode(const std::string& name, std::string* value)
}

ClusterFinder* NewClusterFinder() {
if (FLAGS_tera_ins_enabled) {
if (FLAGS_tera_zk_enabled) {
return new sdk::FakeZkClusterFinder(FLAGS_tera_fake_zk_path_prefix);
} else if (FLAGS_tera_ins_enabled) {
return new sdk::InsClusterFinder(FLAGS_tera_ins_root_path, FLAGS_tera_ins_addr_list);
} else if (FLAGS_tera_mock_ins_enabled) {
return new sdk::MockInsClusterFinder(FLAGS_tera_ins_root_path, FLAGS_tera_ins_addr_list);
} else if (FLAGS_tera_mock_zk_enabled) {
return new sdk::MockZkClusterFinder(FLAGS_tera_zk_root_path, FLAGS_tera_zk_addr_list);
} else if (!FLAGS_tera_zk_enabled) {
return new sdk::FakeZkClusterFinder(FLAGS_tera_fake_zk_path_prefix);
} else if (FLAGS_tera_mock_ins_enabled) {
return new sdk::MockInsClusterFinder(FLAGS_tera_ins_root_path, FLAGS_tera_ins_addr_list);
} else {
return new sdk::ZkClusterFinder(FLAGS_tera_zk_root_path, FLAGS_tera_zk_addr_list);
}
Expand Down
5 changes: 3 additions & 2 deletions src/tabletnode/tabletnode_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,12 @@ TabletNodeImpl::~TabletNodeImpl() {
bool TabletNodeImpl::Init() {
if (FLAGS_tera_zk_enabled) {
zk_adapter_.reset(new TabletNodeZkAdapter(this, local_addr_));
} else if (FLAGS_tera_mock_zk_enabled) {
zk_adapter_.reset(new MockTabletNodeZkAdapter(this, local_addr_));
} else if(FLAGS_tera_ins_enabled) {
LOG(INFO) << "ins mode!";
zk_adapter_.reset(new InsTabletNodeZkAdapter(this, local_addr_));
} else if (FLAGS_tera_mock_zk_enabled) {
LOG(INFO) << "mock zk mode!";
zk_adapter_.reset(new MockTabletNodeZkAdapter(this, local_addr_));
} else if (FLAGS_tera_mock_ins_enabled) {
LOG(INFO) << "mock ins mode!";
zk_adapter_.reset(new MockInsTabletNodeZkAdapter(this, local_addr_));
Expand Down

0 comments on commit 8d93699

Please sign in to comment.