Skip to content

Commit

Permalink
Reorganize the code
Browse files Browse the repository at this point in the history
  • Loading branch information
jievince committed Nov 22, 2021
1 parent 4ddeea0 commit 846f11b
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 70 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ modules

# IDE
.vscode/

# Coredump
core.*
2 changes: 1 addition & 1 deletion examples/SessionExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <nebula/client/Config.h>
#include <nebula/client/ConnectionPool.h>
#include <nebula/client/Init.h>
#include <common/Init.h>

int main(int argc, char* argv[]) {
nebula::init(&argc, &argv);
Expand Down
File renamed without changes.
75 changes: 51 additions & 24 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ set(NEBULA_CLIENT_OBJS
$<TARGET_OBJECTS:graph_thrift_obj>
)

set(NEBULA_MCLIENT_OBJS
$<TARGET_OBJECTS:common_thrift_obj>
$<TARGET_OBJECTS:meta_thrift_obj>
)

set(NEBULA_SCLIENT_OBJS
$<TARGET_OBJECTS:common_thrift_obj>
$<TARGET_OBJECTS:meta_thrift_obj>
$<TARGET_OBJECTS:storage_thrift_obj>
)

set(NEBULA_CLIENT_SOURCES
client/Connection.cpp
client/Init.cpp
client/ConnectionPool.cpp
client/Session.cpp
client/SSLConfig.cpp
set(NEBULA_COMMON_SOURCES
datatypes/Date.cpp
datatypes/Edge.cpp
datatypes/Geography.cpp
Expand All @@ -34,29 +34,27 @@ set(NEBULA_CLIENT_SOURCES
geo/io/wkt/WKTWriter.cpp
geo/io/wkb/WKBWriter.cpp
geo/io/wkb/ByteOrderDataIOStream.cpp
Init.cpp
)

set(NEBULA_SCLIENT_SOURCES
set(NEBULA_CLIENT_SOURCES
client/Connection.cpp
client/ConnectionPool.cpp
client/Session.cpp
client/SSLConfig.cpp
)

set(NEBULA_MCLIENT_SOURCES
mclient/MetaClient.cpp
)

set(NEBULA_SCLIENT_SOURCES
${NEBULA_MCLIENT_SOURCES}
sclient/StorageClient.cpp
sclient/ScanEdgeIter.cpp
sclient/Init.cpp
datatypes/Date.cpp
datatypes/Edge.cpp
datatypes/Geography.cpp
datatypes/HostAddr.cpp
datatypes/List.cpp
datatypes/Map.cpp
datatypes/Path.cpp
datatypes/Set.cpp
datatypes/Value.cpp
datatypes/Vertex.cpp
geo/io/wkt/WKTWriter.cpp
geo/io/wkb/WKBWriter.cpp
geo/io/wkb/ByteOrderDataIOStream.cpp
)

set(NEBULA_CLIENT_LIBRARIES
set(NEBULA_THIRD_PARTY_LIBRARIES
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
${THRIFT_LIBRARIES}
Expand Down Expand Up @@ -94,39 +92,68 @@ nebula_add_library(
nebula_graph_client SHARED
${NEBULA_CLIENT_OBJS}
${NEBULA_CLIENT_SOURCES}
${NEBULA_COMMON_SOURCES}
)

nebula_add_library(
nebula_meta_client SHARED
${NEBULA_MCLIENT_OBJS}
${NEBULA_MCLIENT_SOURCES}
${NEBULA_COMMON_SOURCES}
)

nebula_add_library(
nebula_storage_client SHARED
${NEBULA_SCLIENT_OBJS}
${NEBULA_SCLIENT_SOURCES}
${NEBULA_COMMON_SOURCES}
)

target_link_libraries(
nebula_graph_client
${NEBULA_CLIENT_LIBRARIES}
${NEBULA_THIRD_PARTY_LIBRARIES}
)

target_link_libraries(
nebula_meta_client
${NEBULA_THIRD_PARTY_LIBRARIES}
)

target_link_libraries(
nebula_storage_client
${NEBULA_CLIENT_LIBRARIES}
${NEBULA_THIRD_PARTY_LIBRARIES}
)

install(
TARGETS nebula_graph_client
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(
TARGETS nebula_meta_client
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(
TARGETS nebula_storage_client
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

nebula_add_library(
nebula_common_obj OBJECT
${NEBULA_COMMON_SOURCES}
)

nebula_add_library(
nebula_graph_client_obj OBJECT
${NEBULA_CLIENT_SOURCES}
)

nebula_add_library(
nebula_meta_client_obj OBJECT
${NEBULA_MCLIENT_SOURCES}
)

nebula_add_library(
nebula_storage_client_obj OBJECT
${NEBULA_SCLIENT_SOURCES}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/client/tests/AddressTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* This source code is licensed under Apache 2.0 License.
*/

#include <common/Init.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <gtest/gtest_prod.h>
#include <nebula/client/ConnectionPool.h>
#include <nebula/client/Init.h>
#include <nebula/client/Session.h>

#include "../../ClientTest.h"
Expand Down
14 changes: 9 additions & 5 deletions src/client/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# $<TARGET_OBJECTS:nebula_graph_client_obj>
# LIBRARIES
# gtest
# ${NEBULA_CLIENT_LIBRARIES}
# ${NEBULA_THIRD_PARTY_LIBRARIES}
# )

nebula_add_test(
Expand All @@ -23,10 +23,11 @@ nebula_add_test(
SessionTest.cpp
OBJECTS
${NEBULA_CLIENT_OBJS}
$<TARGET_OBJECTS:nebula_common_obj>
$<TARGET_OBJECTS:nebula_graph_client_obj>
LIBRARIES
gtest
${NEBULA_CLIENT_LIBRARIES}
${NEBULA_THIRD_PARTY_LIBRARIES}
)

nebula_add_test(
Expand All @@ -36,10 +37,11 @@ nebula_add_test(
AddressTest.cpp
OBJECTS
${NEBULA_CLIENT_OBJS}
$<TARGET_OBJECTS:nebula_common_obj>
$<TARGET_OBJECTS:nebula_graph_client_obj>
LIBRARIES
gtest
${NEBULA_CLIENT_LIBRARIES}
${NEBULA_THIRD_PARTY_LIBRARIES}
)

nebula_add_test(
Expand All @@ -49,10 +51,11 @@ nebula_add_test(
ConfigTest.cpp
OBJECTS
${NEBULA_CLIENT_OBJS}
$<TARGET_OBJECTS:nebula_common_obj>
$<TARGET_OBJECTS:nebula_graph_client_obj>
LIBRARIES
gtest
${NEBULA_CLIENT_LIBRARIES}
${NEBULA_THIRD_PARTY_LIBRARIES}
)

nebula_add_test(
Expand All @@ -62,8 +65,9 @@ nebula_add_test(
TimezoneConversionTest.cpp
OBJECTS
${NEBULA_CLIENT_OBJS}
$<TARGET_OBJECTS:nebula_common_obj>
$<TARGET_OBJECTS:nebula_graph_client_obj>
LIBRARIES
gtest
${NEBULA_CLIENT_LIBRARIES}
${NEBULA_THIRD_PARTY_LIBRARIES}
)
2 changes: 1 addition & 1 deletion src/client/tests/ConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* This source code is licensed under Apache 2.0 License.
*/

#include <common/Init.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <gtest/gtest_prod.h>
#include <nebula/client/ConnectionPool.h>
#include <nebula/client/Init.h>
#include <nebula/client/Session.h>

#include "../../ClientTest.h"
Expand Down
2 changes: 1 addition & 1 deletion src/client/tests/ConnectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* This source code is licensed under Apache 2.0 License.
*/

#include <common/Init.h>
#include <folly/json.h>
#include <folly/synchronization/Baton.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <nebula/client/Connection.h>
#include <nebula/client/Init.h>

#include "../../ClientTest.h"

Expand Down
2 changes: 1 addition & 1 deletion src/client/tests/SessionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* This source code is licensed under Apache 2.0 License.
*/

#include <common/Init.h>
#include <common/datatypes/Geography.h>
#include <folly/json.h>
#include <folly/synchronization/Baton.h>
Expand All @@ -11,7 +12,6 @@
#include <gtest/gtest_prod.h>
#include <nebula/client/Config.h>
#include <nebula/client/ConnectionPool.h>
#include <nebula/client/Init.h>
#include <nebula/client/Session.h>

#include <atomic>
Expand Down
2 changes: 1 addition & 1 deletion src/client/tests/TimezoneConversionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* This source code is licensed under Apache 2.0 License.
*/

#include <common/Init.h>
#include <folly/synchronization/Baton.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <gtest/gtest_prod.h>
#include <nebula/client/ConnectionPool.h>
#include <nebula/client/Init.h>
#include <nebula/client/Session.h>

#include <atomic>
Expand Down
9 changes: 6 additions & 3 deletions src/mclient/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ nebula_add_test(
SOURCES
MetaClientTest.cpp
OBJECTS
${NEBULA_SCLIENT_OBJS}
$<TARGET_OBJECTS:nebula_storage_client_obj>
${NEBULA_MCLIENT_OBJS}
$<TARGET_OBJECTS:graph_thrift_obj>
$<TARGET_OBJECTS:nebula_common_obj>
$<TARGET_OBJECTS:nebula_graph_client_obj>
$<TARGET_OBJECTS:nebula_meta_client_obj>
LIBRARIES
gtest
${NEBULA_CLIENT_LIBRARIES}
${NEBULA_THIRD_PARTY_LIBRARIES}
)
39 changes: 20 additions & 19 deletions src/mclient/tests/MetaClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* This source code is licensed under Apache 2.0 License.
*/

#include <common/Init.h>
#include <folly/synchronization/Baton.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <nebula/client/Config.h>
#include <nebula/client/ConnectionPool.h>
#include <nebula/client/Session.h>
#include <nebula/mclient/MetaClient.h>
#include <nebula/sclient/Init.h>
// #include <nebula/client/Config.h>
// #include <nebula/client/ConnectionPool.h>
// #include <nebula/client/Init.h>
// #include <nebula/client/Session.h>

#include "../../ClientTest.h"
#include "common/datatypes/HostAddr.h"
Expand All @@ -23,21 +23,22 @@

class MetaClientTest : public ClientTest {
protected:
// static void prepare() {
// nebula::ConnectionPool pool;
// pool.init({kServerHost ":38996"}, nebula::Config{});
// auto session = pool.getSession("root", "nebula");
// ASSERT_TRUE(session.valid());
// // ping
// EXPECT_TRUE(session.ping());
// // execute
// auto result = session.execute("CREATE SPACE meta_client_test(vid_type=FIXED_STRING(8),
// partition_num=3);USE meta_client_test"); ASSERT_EQ(result.errorCode,
// nebula::ErrorCode::SUCCEEDED);
static void prepare() {
nebula::ConnectionPool pool;
pool.init({kServerHost ":38996"}, nebula::Config{});
auto session = pool.getSession("root", "nebula");
ASSERT_TRUE(session.valid());
// ping
EXPECT_TRUE(session.ping());
// execute
auto result = session.execute(
"CREATE SPACE meta_client_test(vid_type=FIXED_STRING(8),"
"partition_num=3);USE meta_client_test");
ASSERT_EQ(result.errorCode, nebula::ErrorCode::SUCCEEDED);

// auto result2 = session.execute("CREATE EDGE like(likeness int)");
// ASSERT_EQ(result2.errorCode, nebula::ErrorCode::SUCCEEDED);
// }
auto result2 = session.execute("CREATE EDGE like(likeness int)");
ASSERT_EQ(result2.errorCode, nebula::ErrorCode::SUCCEEDED);
}

static void runOnce(nebula::MetaClient &c) {
auto ret = c.getSpaceIdByNameFromCache("nba");
Expand Down Expand Up @@ -69,7 +70,7 @@ class MetaClientTest : public ClientTest {

TEST_F(MetaClientTest, Basic) {
nebula::MetaClient c({kServerHost ":45996"});
// prepare();
prepare();
runOnce(c);
}

Expand Down
12 changes: 0 additions & 12 deletions src/sclient/Init.cpp

This file was deleted.

5 changes: 4 additions & 1 deletion src/sclient/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ nebula_add_test(
StorageClientTest.cpp
OBJECTS
${NEBULA_SCLIENT_OBJS}
$<TARGET_OBJECTS:graph_thrift_obj>
$<TARGET_OBJECTS:nebula_common_obj>
$<TARGET_OBJECTS:nebula_graph_client_obj>
$<TARGET_OBJECTS:nebula_storage_client_obj>
LIBRARIES
gtest
${NEBULA_CLIENT_LIBRARIES}
${NEBULA_THIRD_PARTY_LIBRARIES}
)

0 comments on commit 846f11b

Please sign in to comment.