Skip to content

Commit

Permalink
Merge pull request #174 from eraft-io/feature_20230610_vector
Browse files Browse the repository at this point in the history
add meta server
  • Loading branch information
LLiuJJ authored Jun 27, 2023
2 parents b3eb1ac + 0062c51 commit 5e6900f
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 226 deletions.
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,28 @@ target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC
)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC ${eraftkv_INCLUDE_DIR})

# build eraftmeta
set(eraftmeta_sources)
list(APPEND eraftmeta_sources src/eraftkv_server.cc)
list(APPEND eraftmeta_sources src/rocksdb_storage_impl.cc)
list(APPEND eraftmeta_sources src/log_storage_impl.cc)
list(APPEND eraftmeta_sources src/eraftkv.grpc.pb.cc)
list(APPEND eraftmeta_sources src/eraftkv.pb.cc)
list(APPEND eraftmeta_sources src/util.cc)
list(APPEND eraftmeta_sources src/raft_server.cc)
list(APPEND eraftmeta_sources src/log_entry_cache.cc)
list(APPEND eraftmeta_sources src/grpc_network_impl.cc)
list(APPEND eraftmeta_sources src/eraftmeta.cc)

add_executable(eraftmeta ${eraftmeta_sources})
target_link_libraries(eraftmeta PUBLIC
rocksdb
gRPC::grpc++
${Protobuf_LIBRARY}
stdc++fs
)
target_include_directories(eraftmeta PUBLIC ${eraftkv_INCLUDE_DIR})


# build eraftkv_server test
add_executable(eraftkv_server_test
Expand Down
1 change: 1 addition & 0 deletions src/eraftkv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
*/
int main(int argc, char* argv[]) {
ERaftKvServerOptions options_;
options_.svr_role = ServerRoleEnum::DataServer;
options_.svr_id = stoi(std::string(argv[1]));
options_.kv_db_path = std::string(argv[2]);
options_.log_db_path = std::string(argv[3]);
Expand Down
4 changes: 1 addition & 3 deletions src/eraftkv_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

#include <grpcpp/grpcpp.h>

#include "util.h"

RaftServer* ERaftKvServer::raft_context_ = nullptr;

std::map<int, std::condition_variable*> ERaftKvServer::ready_cond_vars_;
Expand Down Expand Up @@ -216,4 +214,4 @@ EStatus ERaftKvServer::BuildAndRunRpcServer() {
std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
server->Wait();
return EStatus::kOk;
}
}
4 changes: 4 additions & 0 deletions src/eraftkv_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ using eraftkv::ERaftKv;
using grpc::ServerContext;
using grpc::Status;


enum ServerRoleEnum { DataServer, MetaServer };

/**
* @brief
*
*/
struct ERaftKvServerOptions {
int64_t svr_id;
uint8_t svr_role;
std::string svr_version;
std::string svr_addr;
std::string peer_addrs;
Expand Down
32 changes: 32 additions & 0 deletions src/eraftmeta.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @file eraftmeta.cc
* @author your name ([email protected])
* @brief
* @version 0.1
* @date 2023-06-26
*
* @copyright Copyright (c) 2023
*
*/

#include "eraftkv_server.h"
#include "raft_server.h"
/**
* @brief
*
* @param argc
* @param argv (eg: eraftmeta 0 /tmp/meta_db0 /tmp/log_db0
* 127.0.0.1:8088,127.0.0.1:8089,127.0.0.1:8090)
* @return int
*/
int main(int argc, char* argv[]) {
ERaftKvServerOptions options_;
options_.svr_role = ServerRoleEnum::MetaServer;
options_.svr_id = stoi(std::string(argv[1]));
options_.kv_db_path = std::string(argv[2]);
options_.log_db_path = std::string(argv[3]);
options_.peer_addrs = std::string(argv[4]);
ERaftKvServer server(options_);
server.BuildAndRunRpcServer();
return 0;
}
222 changes: 0 additions & 222 deletions src/eraftmeta_server.h

This file was deleted.

2 changes: 1 addition & 1 deletion utils/format-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ SRCPATH=$(cd $SCRIPTPATH/..; pwd -P)
clang-format -style=file --sort-includes -i ${SRCPATH}/src/eraftkv_server.cc
clang-format -style=file --sort-includes -i ${SRCPATH}/src/eraftkv_server.h
clang-format -style=file --sort-includes -i ${SRCPATH}/src/eraftkv_server_test.cc
clang-format -style=file --sort-includes -i ${SRCPATH}/src/eraftmeta_server.h
clang-format -style=file --sort-includes -i ${SRCPATH}/src/estatus.h
clang-format -style=file --sort-includes -i ${SRCPATH}/src/grpc_network_impl.cc
clang-format -style=file --sort-includes -i ${SRCPATH}/src/grpc_network_impl.h
Expand All @@ -17,6 +16,7 @@ clang-format -style=file --sort-includes -i ${SRCPATH}/src/log_entry_cache.h
clang-format -style=file --sort-includes -i ${SRCPATH}/src/log_entry_cache_tests.cc
clang-format -style=file --sort-includes -i ${SRCPATH}/src/log_storage_impl.cc
clang-format -style=file --sort-includes -i ${SRCPATH}/src/eraftkv.cc
clang-format -style=file --sort-includes -i ${SRCPATH}/src/eraftmeta.cc
clang-format -style=file --sort-includes -i ${SRCPATH}/src/network.h
clang-format -style=file --sort-includes -i ${SRCPATH}/src/raft_config.h
clang-format -style=file --sort-includes -i ${SRCPATH}/src/raft_log.h
Expand Down
Empty file modified utils/run-vdb-tests.sh
100644 → 100755
Empty file.

0 comments on commit 5e6900f

Please sign in to comment.