-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
250 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved | ||
* | ||
* This source code is licensed under Apache 2.0 License | ||
* (found in the LICENSE.Apache file in the root directory) | ||
*/ | ||
|
||
#include "base/Base.h" | ||
#include <thrift/lib/cpp2/server/ThriftServer.h> | ||
#include "meta/MetaServiceHandler.h" | ||
|
||
DEFINE_int32(port, 45500, "Meta daemon listening port"); | ||
|
||
|
||
int main(int argc, char *argv[]) { | ||
folly::init(&argc, &argv, true); | ||
|
||
using namespace nebula::meta; | ||
|
||
LOG(INFO) << "Starting the meta Daemon on port " << FLAGS_port; | ||
|
||
auto handler = std::make_shared<MetaServiceHandler>(); | ||
auto server = std::make_shared<apache::thrift::ThriftServer>(); | ||
CHECK(!!server) << "Failed to create the thrift server"; | ||
|
||
server->setInterface(handler); | ||
server->setPort(FLAGS_port); | ||
|
||
server->serve(); // Will wait until the server shuts down | ||
|
||
LOG(INFO) << "The storage Daemon on port " << FLAGS_port << " stopped"; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved | ||
* | ||
* This source code is licensed under Apache 2.0 License | ||
* (found in the LICENSE.Apache file in the root directory) | ||
*/ | ||
|
||
namespace cpp nebula.meta | ||
namespace java nebula.meta | ||
namespace go nebula.meta | ||
|
||
cpp_include "base/ThriftTypes.h" | ||
|
||
typedef i32 (cpp.type = "nebula::IPv4") IPv4 | ||
typedef i32 (cpp.type = "nebula::Port") Port | ||
|
||
enum ErrorCode { | ||
SUCCEEDED = 0, | ||
|
||
// RPC Failure | ||
E_DISCONNECTED = -1, | ||
E_FAIL_TO_CONNECT = -2, | ||
E_RPC_FAILURE = -3, | ||
|
||
E_LEADER_CHANAGED = -11, | ||
|
||
// Operation Failure | ||
E_NODE_HAS_EXISTED = -21, | ||
E_NODE_NOT_EXISTED = -22, | ||
} (cpp.enum_strict) | ||
|
||
struct HostAddr { | ||
1: IPv4 ip, | ||
2: Port port, | ||
} | ||
|
||
struct ExecResponse { | ||
1: ErrorCode ret, | ||
// Valid if ret equals E_LEADER_CHANAGED. | ||
2: HostAddr leader, | ||
} | ||
|
||
struct CreateNodeRequest { | ||
1: string path, | ||
2: string value, | ||
} | ||
|
||
struct SetNodeRequest { | ||
1: string path, | ||
2: string value, | ||
} | ||
|
||
struct GetNodeRequest { | ||
1: string path, | ||
} | ||
|
||
struct GetNodeResponse { | ||
1: ErrorCode ret, | ||
2: HostAddr leader, | ||
3: string value, | ||
4: i64 last_updated_time, | ||
} | ||
|
||
struct ListChildrenRequest { | ||
1: string path, | ||
} | ||
|
||
struct ListChildrenResponse { | ||
1: ErrorCode ret, | ||
2: HostAddr leader, | ||
3: list<string> children, | ||
} | ||
|
||
service MetaService { | ||
ExecResponse createNode(1: CreateNodeRequest req); | ||
ExecResponse setNode(1: SetNodeRequest req); | ||
GetNodeResponse getNode(1: GetNodeRequest req); | ||
ListChildrenResponse listChildren(1: ListChildrenRequest req); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved | ||
* | ||
* This source code is licensed under Apache 2.0 License | ||
* (found in the LICENSE.Apache file in the root directory) | ||
*/ | ||
#include "meta/MetaServiceHandler.h" | ||
|
||
namespace nebula { | ||
namespace meta { | ||
|
||
folly::Future<cpp2::ExecResponse> | ||
MetaServiceHandler::future_createNode(const cpp2::CreateNodeRequest& req) { | ||
UNUSED(req); | ||
folly::Promise<cpp2::ExecResponse> p; | ||
return p.getFuture(); | ||
} | ||
|
||
folly::Future<cpp2::ExecResponse> | ||
MetaServiceHandler::future_setNode(const cpp2::SetNodeRequest& req) { | ||
UNUSED(req); | ||
folly::Promise<cpp2::ExecResponse> p; | ||
return p.getFuture(); | ||
} | ||
|
||
folly::Future<cpp2::GetNodeResponse> | ||
MetaServiceHandler::future_getNode(const cpp2::GetNodeRequest& req) { | ||
UNUSED(req); | ||
folly::Promise<cpp2::GetNodeResponse> p; | ||
return p.getFuture(); | ||
} | ||
|
||
folly::Future<cpp2::ListChildrenResponse> | ||
MetaServiceHandler::future_listChildren(const cpp2::ListChildrenRequest& req) { | ||
UNUSED(req); | ||
folly::Promise<cpp2::ListChildrenResponse> p; | ||
return p.getFuture(); | ||
} | ||
|
||
} // namespace meta | ||
} // namespace nebula |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved | ||
* | ||
* This source code is licensed under Apache 2.0 License | ||
* (found in the LICENSE.Apache file in the root directory) | ||
*/ | ||
|
||
#ifndef META_METASERVICEHANDLER_H_ | ||
#define META_METASERVICEHANDLER_H_ | ||
|
||
#include "base/Base.h" | ||
#include "interface/gen-cpp2/MetaService.h" | ||
#include "kvstore/include/KVStore.h" | ||
|
||
namespace nebula { | ||
namespace meta { | ||
|
||
class MetaServiceHandler final : public cpp2::MetaServiceSvIf { | ||
public: | ||
folly::Future<cpp2::ExecResponse> | ||
future_createNode(const cpp2::CreateNodeRequest& req) override; | ||
|
||
folly::Future<cpp2::ExecResponse> | ||
future_setNode(const cpp2::SetNodeRequest& req) override; | ||
|
||
folly::Future<cpp2::GetNodeResponse> | ||
future_getNode(const cpp2::GetNodeRequest& req) override; | ||
|
||
folly::Future<cpp2::ListChildrenResponse> | ||
future_listChildren(const cpp2::ListChildrenRequest& req) override; | ||
|
||
private: | ||
kvstore::KVStore* kvstore_ = nullptr; | ||
}; | ||
|
||
} // namespace meta | ||
} // namespace nebula | ||
#endif // META_METASERVICEHANDLER_H_ |