From e4409391973e3b08f855588188ebd2de240378fe Mon Sep 17 00:00:00 2001 From: Shylock Hg <33566796+Shylock-Hg@users.noreply.github.com> Date: Wed, 8 Dec 2021 10:22:33 +0800 Subject: [PATCH] Feature/verify client version (#67) * Add client version checking. --- .github/workflows/pull_request.yml | 6 +- gen-interface.sh | 21 +- include/common/graph/GraphCpp2Ops.h | 4 + include/common/graph/Response.h | 10 + .../graph/VerifyClientVersionReqOps-inl.h | 138 ++ .../graph/VerifyClientVersionRespOps-inl.h | 178 +++ include/nebula/client/Connection.h | 2 + src/client/Connection.cpp | 18 + src/interface/common.thrift | 464 ++++++ src/interface/gen-cpp2/GraphService.cpp | 12 +- src/interface/gen-cpp2/GraphService.h | 20 +- src/interface/gen-cpp2/GraphService.tcc | 12 +- .../gen-cpp2/GraphServiceAsyncClient.cpp | 48 +- .../gen-cpp2/GraphServiceAsyncClient.h | 44 +- src/interface/gen-cpp2/graph_types.h | 2 + src/interface/graph.thrift | 125 ++ src/interface/meta.thrift | 1281 +++++++++++++++++ src/interface/storage.thrift | 911 ++++++++++++ 18 files changed, 3220 insertions(+), 76 deletions(-) create mode 100644 include/common/graph/VerifyClientVersionReqOps-inl.h create mode 100644 include/common/graph/VerifyClientVersionRespOps-inl.h create mode 100644 src/interface/common.thrift create mode 100644 src/interface/graph.thrift create mode 100644 src/interface/meta.thrift create mode 100644 src/interface/storage.thrift diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index fb4adce9..2a12dfe2 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -33,7 +33,7 @@ jobs: build: name: build needs: lint - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -139,10 +139,10 @@ jobs: ASAN_OPTIONS: fast_unwind_on_malloc=1 run: | pushd build - ctest -j $(($(nproc)/2+1)) --timeout 400 --output-on-failure + ctest -j $(nproc) --timeout 10000 --output-on-failure make install popd - timeout-minutes: 4 + timeout-minutes: 10 - name: Build example run: | case ${{ matrix.os }} in diff --git a/gen-interface.sh b/gen-interface.sh index 85eb9d30..9235f90c 100755 --- a/gen-interface.sh +++ b/gen-interface.sh @@ -7,13 +7,18 @@ set -e NEBULA_THIRDPARYTY_HOME=/opt/vesoft/third-party/2.0 +NEBULA_INTERFACE_HOME=src/interface +SYNC_REMOTE_INTERFACE=0 # Parsing options from arguments -while getopts "t:" opt; do +while getopts "t:u" opt; do case $opt in t) NEBULA_THIRDPARYTY_HOME=${OPTARG} ;; + u) + SYNC_REMOTE_INTERFACE=1 + ;; \?) echo "Invalid option: -${OPTARG}" >&2 exit 1 @@ -25,9 +30,11 @@ while getopts "t:" opt; do esac done -for mod in common meta storage graph; do - wget https://raw.githubusercontent.com/vesoft-inc/nebula/master/src/interface/$mod.thrift -done +if [ $SYNC_REMOTE_INTERFACE -eq 1 ]; then + for mod in common meta storage graph; do + wget -P $NEBULA_INTERFACE_HOME https://raw.githubusercontent.com/vesoft-inc/nebula/master/src/interface/$mod.thrift + done +fi # Strip nebula source # for mod in common graph; do @@ -35,8 +42,8 @@ done # sed -i 's/cpp.type = "[^"]\+"//g' $mod.thrift # done +pushd $NEBULA_INTERFACE_HOME for mod in common meta storage graph; do - $NEBULA_THIRDPARYTY_HOME/bin/thrift1 --strict --allow-neg-enum-vals --gen "mstch_cpp2:include_prefix=${include_prefix},stack_arguments" -o ./src/interface/ $mod.thrift + $NEBULA_THIRDPARYTY_HOME/bin/thrift1 --strict --allow-neg-enum-vals --gen "mstch_cpp2:include_prefix=${include_prefix},stack_arguments" -o . $mod.thrift done - -rm common.thrift graph.thrift meta.thrift storage.thrift +popd diff --git a/include/common/graph/GraphCpp2Ops.h b/include/common/graph/GraphCpp2Ops.h index 2f57eea8..b6458c39 100644 --- a/include/common/graph/GraphCpp2Ops.h +++ b/include/common/graph/GraphCpp2Ops.h @@ -15,6 +15,8 @@ struct PlanDescription; struct PlanNodeBranchInfo; struct PlanNodeDescription; struct ProfilingStats; +struct VerifyClientVersionReq; +struct VerifyClientVersionResp; } // namespace nebula namespace apache::thrift { @@ -26,5 +28,7 @@ SPECIALIZE_CPP2OPS(nebula::PlanDescription); SPECIALIZE_CPP2OPS(nebula::PlanNodeBranchInfo); SPECIALIZE_CPP2OPS(nebula::PlanNodeDescription); SPECIALIZE_CPP2OPS(nebula::ProfilingStats); +SPECIALIZE_CPP2OPS(nebula::VerifyClientVersionReq); +SPECIALIZE_CPP2OPS(nebula::VerifyClientVersionResp); } // namespace apache::thrift diff --git a/include/common/graph/Response.h b/include/common/graph/Response.h index fdb9eaa5..a2b43f32 100644 --- a/include/common/graph/Response.h +++ b/include/common/graph/Response.h @@ -400,4 +400,14 @@ struct ExecutionResponse { std::unique_ptr comment{nullptr}; }; +struct VerifyClientVersionResp { + ErrorCode errorCode{ErrorCode::SUCCEEDED}; + std::unique_ptr errorMsg{nullptr}; +}; + +struct VerifyClientVersionReq { + // TODO initialize when build + std::string version{"2.6.0"}; +}; + } // namespace nebula diff --git a/include/common/graph/VerifyClientVersionReqOps-inl.h b/include/common/graph/VerifyClientVersionReqOps-inl.h new file mode 100644 index 00000000..3d306215 --- /dev/null +++ b/include/common/graph/VerifyClientVersionReqOps-inl.h @@ -0,0 +1,138 @@ +/* Copyright (c) 2021 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License. + */ + +#pragma once + +#include +#include +#include + +#include + +#include "common/graph/GraphCpp2Ops.h" +#include "common/graph/Response.h" +#include "common/utils/utils.h" + +namespace apache { +namespace thrift { + +/************************************** + * + * Ops for class VerifyClientVersionReq + * + *************************************/ +namespace detail { + +template <> +struct TccStructTraits { + static void translateFieldName(MAYBE_UNUSED folly::StringPiece _fname, + MAYBE_UNUSED int16_t& fid, + MAYBE_UNUSED apache::thrift::protocol::TType& _ftype) { + if (false) { + } else if (_fname == "version") { + fid = 1; + _ftype = apache::thrift::protocol::T_STRING; + } + } +}; + +} // namespace detail + +inline constexpr apache::thrift::protocol::TType +Cpp2Ops<::nebula::VerifyClientVersionReq>::thriftType() { + return apache::thrift::protocol::T_STRUCT; +} + +template +uint32_t Cpp2Ops<::nebula::VerifyClientVersionReq>::write( + Protocol* proto, ::nebula::VerifyClientVersionReq const* obj) { + uint32_t xfer = 0; + xfer += proto->writeStructBegin("nebula::VerifyClientVersionReq"); + xfer += proto->writeFieldBegin("version", apache::thrift::protocol::T_STRING, 1); + xfer += proto->writeBinary(obj->version); + xfer += proto->writeFieldEnd(); + xfer += proto->writeFieldStop(); + xfer += proto->writeStructEnd(); + return xfer; +} + +template +void Cpp2Ops<::nebula::VerifyClientVersionReq>::read(Protocol* proto, + ::nebula::VerifyClientVersionReq* obj) { + apache::thrift::detail::ProtocolReaderStructReadState _readState; + + _readState.readStructBegin(proto); + + using apache::thrift::TProtocolException; + + bool isset_version = false; + + if (UNLIKELY(!_readState.advanceToNextField(proto, 0, 1, apache::thrift::protocol::T_STRING))) { + goto _loop; + } +_readField_version : { + proto->readBinary(obj->version); + isset_version = true; +} + +_end: + _readState.readStructEnd(proto); + + if (!isset_version) { + TProtocolException::throwMissingRequiredField("version", "nebula::VerifyClientVersionReq"); + } + return; + +_loop: + if (_readState.fieldType == apache::thrift::protocol::T_STOP) { + goto _end; + } + if (proto->kUsesFieldNames()) { + apache::thrift::detail::TccStructTraits::translateFieldName( + _readState.fieldName(), _readState.fieldId, _readState.fieldType); + } + + switch (_readState.fieldId) { + case 1: { + if (LIKELY(_readState.fieldType == apache::thrift::protocol::T_STRING)) { + goto _readField_version; + } else { + goto _skip; + } + } + default: { +_skip: + proto->skip(_readState.fieldType); + _readState.readFieldEnd(proto); + _readState.readFieldBeginNoInline(proto); + goto _loop; + } + } +} + +template +uint32_t Cpp2Ops<::nebula::VerifyClientVersionReq>::serializedSize( + Protocol const* proto, ::nebula::VerifyClientVersionReq const* obj) { + uint32_t xfer = 0; + xfer += proto->serializedStructSize("nebula::VerifyClientVersionReq"); + xfer += proto->serializedFieldSize("version", apache::thrift::protocol::T_STRING, 1); + xfer += proto->serializedSizeBinary(obj->version); + xfer += proto->serializedSizeStop(); + return xfer; +} + +template +uint32_t Cpp2Ops<::nebula::VerifyClientVersionReq>::serializedSizeZC( + Protocol const* proto, ::nebula::VerifyClientVersionReq const* obj) { + uint32_t xfer = 0; + xfer += proto->serializedStructSize("nebula::VerifyClientVersionReq"); + xfer += proto->serializedFieldSize("version", apache::thrift::protocol::T_STRING, 1); + xfer += proto->serializedSizeZCBinary(obj->version); + xfer += proto->serializedSizeStop(); + return xfer; +} + +} // namespace thrift +} // namespace apache diff --git a/include/common/graph/VerifyClientVersionRespOps-inl.h b/include/common/graph/VerifyClientVersionRespOps-inl.h new file mode 100644 index 00000000..72a25213 --- /dev/null +++ b/include/common/graph/VerifyClientVersionRespOps-inl.h @@ -0,0 +1,178 @@ +/* Copyright (c) 2021 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License. + */ + +#pragma once + +#include +#include +#include + +#include + +#include "common/graph/GraphCpp2Ops.h" +#include "common/graph/Response.h" +#include "common/utils/utils.h" + +namespace apache { +namespace thrift { + +/************************************** + * + * Ops for class VerifyClientVersionResp + * + *************************************/ +namespace detail { + +template <> +struct TccStructTraits { + static void translateFieldName(MAYBE_UNUSED folly::StringPiece _fname, + MAYBE_UNUSED int16_t& fid, + MAYBE_UNUSED apache::thrift::protocol::TType& _ftype) { + if (false) { + } else if (_fname == "error_code") { + fid = 1; + _ftype = apache::thrift::protocol::T_I32; + } else if (_fname == "error_msg") { + fid = 2; + _ftype = apache::thrift::protocol::T_STRING; + } + } +}; + +} // namespace detail + +inline constexpr apache::thrift::protocol::TType +Cpp2Ops<::nebula::VerifyClientVersionResp>::thriftType() { + return apache::thrift::protocol::T_STRUCT; +} + +template +uint32_t Cpp2Ops<::nebula::VerifyClientVersionResp>::write( + Protocol* proto, ::nebula::VerifyClientVersionResp const* obj) { + uint32_t xfer = 0; + xfer += proto->writeStructBegin("nebula::VerifyClientVersionResp"); + xfer += proto->writeFieldBegin("error_code", apache::thrift::protocol::T_I32, 1); + xfer += + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::enumeration, + ::nebula::ErrorCode>::write(*proto, + obj->errorCode); + xfer += proto->writeFieldEnd(); + if (obj->errorMsg != nullptr) { + xfer += proto->writeFieldBegin("error_msg", apache::thrift::protocol::T_STRING, 2); + xfer += proto->writeBinary(*obj->errorMsg); + xfer += proto->writeFieldEnd(); + } + xfer += proto->writeFieldStop(); + xfer += proto->writeStructEnd(); + return xfer; +} + +template +void Cpp2Ops<::nebula::VerifyClientVersionResp>::read(Protocol* proto, + ::nebula::VerifyClientVersionResp* obj) { + apache::thrift::detail::ProtocolReaderStructReadState _readState; + + _readState.readStructBegin(proto); + + using apache::thrift::TProtocolException; + + bool isset_error_code = false; + + if (UNLIKELY(!_readState.advanceToNextField(proto, 0, 1, apache::thrift::protocol::T_I32))) { + goto _loop; + } +_readField_error_code : { + ::apache::thrift::detail::pm::protocol_methods<::apache::thrift::type_class::enumeration, + ::nebula::ErrorCode>::read(*proto, obj->errorCode); + isset_error_code = true; +} + + if (UNLIKELY(!_readState.advanceToNextField(proto, 1, 2, apache::thrift::protocol::T_STRING))) { + goto _loop; + } +_readField_error_msg : { + obj->errorMsg = std::make_unique(); + proto->readBinary(*obj->errorMsg); + // this->__isset.error_msg = true; +} + +_end: + _readState.readStructEnd(proto); + + if (!isset_error_code) { + TProtocolException::throwMissingRequiredField("error_code", "nebula::VerifyClientVersionResp"); + } + return; + +_loop: + if (_readState.fieldType == apache::thrift::protocol::T_STOP) { + goto _end; + } + if (proto->kUsesFieldNames()) { + apache::thrift::detail::TccStructTraits::translateFieldName( + _readState.fieldName(), _readState.fieldId, _readState.fieldType); + } + + switch (_readState.fieldId) { + case 1: { + if (LIKELY(_readState.fieldType == apache::thrift::protocol::T_I32)) { + goto _readField_error_code; + } else { + goto _skip; + } + } + case 2: { + if (LIKELY(_readState.fieldType == apache::thrift::protocol::T_STRING)) { + goto _readField_error_msg; + } else { + goto _skip; + } + } + default: { +_skip: + proto->skip(_readState.fieldType); + _readState.readFieldEnd(proto); + _readState.readFieldBeginNoInline(proto); + goto _loop; + } + } +} + +template +uint32_t Cpp2Ops<::nebula::VerifyClientVersionResp>::serializedSize( + Protocol const* proto, ::nebula::VerifyClientVersionResp const* obj) { + uint32_t xfer = 0; + xfer += proto->serializedStructSize("nebula::VerifyClientVersionResp"); + xfer += proto->serializedFieldSize("error_code", apache::thrift::protocol::T_I32, 1); + xfer += ::apache::thrift::detail::pm::protocol_methods< + ::apache::thrift::type_class::enumeration, + ::nebula::ErrorCode>::serializedSize(*proto, obj->errorCode); + if (obj->errorMsg != nullptr) { + xfer += proto->serializedFieldSize("error_msg", apache::thrift::protocol::T_STRING, 2); + xfer += proto->serializedSizeBinary(*obj->errorMsg); + } + xfer += proto->serializedSizeStop(); + return xfer; +} + +template +uint32_t Cpp2Ops<::nebula::VerifyClientVersionResp>::serializedSizeZC( + Protocol const* proto, ::nebula::VerifyClientVersionResp const* obj) { + uint32_t xfer = 0; + xfer += proto->serializedStructSize("nebula::VerifyClientVersionResp"); + xfer += proto->serializedFieldSize("error_code", apache::thrift::protocol::T_I32, 1); + xfer += ::apache::thrift::detail::pm::protocol_methods< + ::apache::thrift::type_class::enumeration, + ::nebula::ErrorCode>::serializedSize(*proto, obj->errorCode); + if (obj->errorMsg != nullptr) { + xfer += proto->serializedFieldSize("error_msg", apache::thrift::protocol::T_STRING, 2); + xfer += proto->serializedSizeZCBinary(*obj->errorMsg); + } + xfer += proto->serializedSizeStop(); + return xfer; +} + +} // namespace thrift +} // namespace apache diff --git a/include/nebula/client/Connection.h b/include/nebula/client/Connection.h index 44394918..b315febe 100644 --- a/include/nebula/client/Connection.h +++ b/include/nebula/client/Connection.h @@ -62,6 +62,8 @@ class Connection { void asyncExecuteJson(int64_t sessionId, const std::string &stmt, ExecuteJsonCallback cb); + VerifyClientVersionResp verifyClientVersion(const VerifyClientVersionReq &req); + bool isOpen(); void close(); diff --git a/src/client/Connection.cpp b/src/client/Connection.cpp index f1c0e224..98c8c516 100644 --- a/src/client/Connection.cpp +++ b/src/client/Connection.cpp @@ -104,6 +104,11 @@ bool Connection::open(const std::string &address, auto channel = apache::thrift::HeaderClientChannel::newChannel(socket); channel->setTimeout(timeout); client_ = new graph::cpp2::GraphServiceAsyncClient(std::move(channel)); + auto resp = verifyClientVersion(VerifyClientVersionReq{}); + if (resp.errorCode != ErrorCode::SUCCEEDED) { + DLOG(ERROR) << "Failed to verify client version: " << *resp.errorMsg; + return false; + } return true; } @@ -209,4 +214,17 @@ void Connection::signout(int64_t sessionId) { } } +VerifyClientVersionResp Connection::verifyClientVersion(const VerifyClientVersionReq &req) { + if (client_ == nullptr) { + return VerifyClientVersionResp{ErrorCode::E_DISCONNECTED, + std::make_unique("Not open connection.")}; + } + try { + return client_->future_verifyClientVersion(req).get(); + } catch (const std::exception &ex) { + return VerifyClientVersionResp{ErrorCode::E_RPC_FAILURE, + std::make_unique(ex.what())}; + } +} + } // namespace nebula diff --git a/src/interface/common.thrift b/src/interface/common.thrift new file mode 100644 index 00000000..463fceb2 --- /dev/null +++ b/src/interface/common.thrift @@ -0,0 +1,464 @@ +/* vim: ft=proto + * Copyright (c) 2018 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License. + */ + + +namespace cpp nebula +namespace java com.vesoft.nebula +namespace go nebula +namespace js nebula +namespace csharp nebula +namespace py nebula2.common + +cpp_include "common/thrift/ThriftTypes.h" +cpp_include "common/datatypes/DateOps-inl.h" +cpp_include "common/datatypes/VertexOps-inl.h" +cpp_include "common/datatypes/EdgeOps-inl.h" +cpp_include "common/datatypes/PathOps-inl.h" +cpp_include "common/datatypes/ValueOps-inl.h" +cpp_include "common/datatypes/MapOps-inl.h" +cpp_include "common/datatypes/ListOps-inl.h" +cpp_include "common/datatypes/SetOps-inl.h" +cpp_include "common/datatypes/DataSetOps-inl.h" +cpp_include "common/datatypes/KeyValueOps-inl.h" +cpp_include "common/datatypes/HostAddrOps-inl.h" +cpp_include "common/datatypes/GeographyOps-inl.h" + +/* + * + * Note: In order to support multiple languages, all strings + * have to be defined as **binary** in the thrift file + * + */ + +const binary (cpp.type = "char const *") version = "2.6.0" + +typedef i32 (cpp.type = "nebula::GraphSpaceID") GraphSpaceID +typedef i32 (cpp.type = "nebula::PartitionID") PartitionID +typedef i32 (cpp.type = "nebula::TagID") TagID +typedef i32 (cpp.type = "nebula::EdgeType") EdgeType +typedef i64 (cpp.type = "nebula::EdgeRanking") EdgeRanking +typedef i64 (cpp.type = "nebula::LogID") LogID +typedef i64 (cpp.type = "nebula::TermID") TermID + +typedef i64 (cpp.type = "nebula::Timestamp") Timestamp + +typedef i32 (cpp.type = "nebula::IndexID") IndexID + +typedef i32 (cpp.type = "nebula::Port") Port + +typedef i64 (cpp.type = "nebula::SessionID") SessionID + +typedef i64 (cpp.type = "nebula::ExecutionPlanID") ExecutionPlanID + +union SchemaID { + 1: TagID tag_id, + 2: EdgeType edge_type, +} + +// !! Struct Date has a shadow data type defined in the Date.h +// So any change here needs to be reflected to the shadow type there +struct Date { + 1: i16 year; // Calendar year, such as 2019 + 2: byte month; // Calendar month: 1 - 12 + 3: byte day; // Calendar day: 1 -31 +} (cpp.type = "nebula::Date") + +// !! Struct Time has a shadow data type defined in the Date.h +// So any change here needs to be reflected to the shadow type there +struct Time { + 1: byte hour; // Hour: 0 - 23 + 2: byte minute; // Minute: 0 - 59 + 3: byte sec; // Second: 0 - 59 + 4: i32 microsec; // Micro-second: 0 - 999,999 +} (cpp.type = "nebula::Time") + +// !! Struct DateTime has a shadow data type defined in the Date.h +// So any change here needs to be reflected to the shadow type there +struct DateTime { + 1: i16 year; + 2: byte month; + 3: byte day; + 4: byte hour; // Hour: 0 - 23 + 5: byte minute; // Minute: 0 - 59 + 6: byte sec; // Second: 0 - 59 + 7: i32 microsec; // Micro-second: 0 - 999,999 +} (cpp.type = "nebula::DateTime") + +enum NullType { + __NULL__ = 0, + NaN = 1, + BAD_DATA = 2, + BAD_TYPE = 3, + ERR_OVERFLOW = 4, + UNKNOWN_PROP = 5, + DIV_BY_ZERO = 6, + OUT_OF_RANGE = 7, +} (cpp.enum_strict, cpp.type = "nebula::NullType") + + +// The type to hold any supported values during the query +union Value { + 1: NullType nVal; + 2: bool bVal; + 3: i64 iVal; + 4: double fVal; + 5: binary sVal; + 6: Date dVal; + 7: Time tVal; + 8: DateTime dtVal; + 9: Vertex (cpp.type = "nebula::Vertex") vVal (cpp.ref_type = "unique"); + 10: Edge (cpp.type = "nebula::Edge") eVal (cpp.ref_type = "unique"); + 11: Path (cpp.type = "nebula::Path") pVal (cpp.ref_type = "unique"); + 12: NList (cpp.type = "nebula::List") lVal (cpp.ref_type = "unique"); + 13: NMap (cpp.type = "nebula::Map") mVal (cpp.ref_type = "unique"); + 14: NSet (cpp.type = "nebula::Set") uVal (cpp.ref_type = "unique"); + 15: DataSet (cpp.type = "nebula::DataSet") gVal (cpp.ref_type = "unique"); + 16: Geography (cpp.type = "nebula::Geography") ggVal (cpp.ref_type = "unique"); +} (cpp.type = "nebula::Value") + + +// Ordered list +struct NList { + 1: list values; +} (cpp.type = "nebula::List") + + +// Unordered key/values pairs +struct NMap { + 1: map (cpp.template = "std::unordered_map") kvs; +} (cpp.type = "nebula::Map") + + +// Unordered and unique values +struct NSet { + 1: set (cpp.template = "std::unordered_set") values; +} (cpp.type = "nebula::Set") + + +struct Row { + 1: list values; +} (cpp.type = "nebula::Row") + + +struct DataSet { + 1: list column_names; // Column names + 2: list rows; +} (cpp.type = "nebula::DataSet") + +struct Coordinate { + 1: double x; + 2: double y; +} (cpp.type = "nebula::Coordinate") + +struct Point { + 1: Coordinate coord; +} (cpp.type = "nebula::Point") + +struct LineString { + 1: list coordList; +} (cpp.type = "nebula::LineString") + +struct Polygon { + 1: list> coordListList; +} (cpp.type = "nebula::Polygon") + +union Geography { + 1: Point ptVal (cpp.ref_type = "unique"); + 2: LineString lsVal (cpp.ref_type = "unique"); + 3: Polygon pgVal (cpp.ref_type = "unique"); +} (cpp.type = "nebula::Geography") + + +struct Tag { + 1: binary name, + // List of + 2: map (cpp.template = "std::unordered_map") props, +} (cpp.type = "nebula::Tag") + + +struct Vertex { + 1: Value vid, + 2: list tags, +} (cpp.type = "nebula::Vertex") + + +struct Edge { + 1: Value src, + 2: Value dst, + 3: EdgeType type, + 4: binary name, + 5: EdgeRanking ranking, + // List of + 6: map (cpp.template = "std::unordered_map") props, +} (cpp.type = "nebula::Edge") + + +struct Step { + 1: Vertex dst, + 2: EdgeType type, + 3: binary name, + 4: EdgeRanking ranking, + 5: map (cpp.template = "std::unordered_map") props, +} (cpp.type = "nebula::Step") + + +// Special type to support path during the query +struct Path { + 1: Vertex src, + 2: list steps; +} (cpp.type = "nebula::Path") + + +struct HostAddr { + // Host could be a valid IPv4 or IPv6 address, or a valid domain name + 1: string host, + 2: Port port, +} (cpp.type = "nebula::HostAddr") + + +struct KeyValue { + 1: binary key, + 2: binary value, +} (cpp.type = "nebula::KeyValue") + +struct LogInfo { + 1: LogID log_id; + 2: TermID term_id; +} + +struct DirInfo { + // Installation directory for nebula + 1: binary root, + // nebula's data directory + 2: list data, +} + +struct NodeInfo { + 1: HostAddr host, + 2: DirInfo dir, +} + +struct PartitionBackupInfo { + 1: map (cpp.template = "std::unordered_map") info, +} + +struct CheckpointInfo { + 1: PartitionBackupInfo partition_info, + // storage checkpoint directory name + 2: binary path, +} + + +// These are all data types supported in the graph properties +enum PropertyType { + UNKNOWN = 0, + + // Simple types + BOOL = 1, + INT64 = 2, // This is the same as INT in v1 + VID = 3, // Deprecated, only supported by v1 + FLOAT = 4, + DOUBLE = 5, + STRING = 6, + // String with fixed length. If the string content is shorteri + // than the given length, '\0' will be padded to the end + FIXED_STRING = 7, // New in v2 + INT8 = 8, // New in v2 + INT16 = 9, // New in v2 + INT32 = 10, // New in v2 + + // Date time + TIMESTAMP = 21, + DATE = 24, + DATETIME = 25, + TIME = 26, + + // Geo spatial + GEOGRAPHY = 31, +} (cpp.enum_strict) + +/* + * ErrorCode for graphd, metad, storaged,raftd + * -1xxx for graphd + * -2xxx for metad + * -3xxx for storaged + */ +enum ErrorCode { + // for common code + SUCCEEDED = 0, + + E_DISCONNECTED = -1, // RPC Failure + E_FAIL_TO_CONNECT = -2, + E_RPC_FAILURE = -3, + E_LEADER_CHANGED = -4, + + + // only unify metad and storaged error code + E_SPACE_NOT_FOUND = -5, + E_TAG_NOT_FOUND = -6, + E_EDGE_NOT_FOUND = -7, + E_INDEX_NOT_FOUND = -8, + E_EDGE_PROP_NOT_FOUND = -9, + E_TAG_PROP_NOT_FOUND = -10, + E_ROLE_NOT_FOUND = -11, + E_CONFIG_NOT_FOUND = -12, + E_GROUP_NOT_FOUND = -13, + E_ZONE_NOT_FOUND = -14, + E_LISTENER_NOT_FOUND = -15, + E_PART_NOT_FOUND = -16, + E_KEY_NOT_FOUND = -17, + E_USER_NOT_FOUND = -18, + E_STATS_NOT_FOUND = -19, + + // backup failed + E_BACKUP_FAILED = -24, + E_BACKUP_EMPTY_TABLE = -25, + E_BACKUP_TABLE_FAILED = -26, + E_PARTIAL_RESULT = -27, + E_REBUILD_INDEX_FAILED = -28, + E_INVALID_PASSWORD = -29, + E_FAILED_GET_ABS_PATH = -30, + + + // 1xxx for graphd + E_BAD_USERNAME_PASSWORD = -1001, // Authentication error + E_SESSION_INVALID = -1002, // Execution errors + E_SESSION_TIMEOUT = -1003, + E_SYNTAX_ERROR = -1004, + E_EXECUTION_ERROR = -1005, + E_STATEMENT_EMPTY = -1006, // Nothing is executed When command is comment + + E_BAD_PERMISSION = -1008, + E_SEMANTIC_ERROR = -1009, // semantic error + E_TOO_MANY_CONNECTIONS = -1010, // Exceeding the maximum number of connections + E_PARTIAL_SUCCEEDED = -1011, + + + // 2xxx for metad + E_NO_HOSTS = -2001, // Operation Failure + E_EXISTED = -2002, + E_INVALID_HOST = -2003, + E_UNSUPPORTED = -2004, + E_NOT_DROP = -2005, + E_BALANCER_RUNNING = -2006, + E_CONFIG_IMMUTABLE = -2007, + E_CONFLICT = -2008, + E_INVALID_PARM = -2009, + E_WRONGCLUSTER = -2010, + + E_STORE_FAILURE = -2021, + E_STORE_SEGMENT_ILLEGAL = -2022, + E_BAD_BALANCE_PLAN = -2023, + E_BALANCED = -2024, + E_NO_RUNNING_BALANCE_PLAN = -2025, + E_NO_VALID_HOST = -2026, + E_CORRUPTTED_BALANCE_PLAN = -2027, + E_NO_INVALID_BALANCE_PLAN = -2028, + + + // Authentication Failure + E_IMPROPER_ROLE = -2030, + E_INVALID_PARTITION_NUM = -2031, + E_INVALID_REPLICA_FACTOR = -2032, + E_INVALID_CHARSET = -2033, + E_INVALID_COLLATE = -2034, + E_CHARSET_COLLATE_NOT_MATCH = -2035, + + // Admin Failure + E_SNAPSHOT_FAILURE = -2040, + E_BLOCK_WRITE_FAILURE = -2041, + E_REBUILD_INDEX_FAILURE = -2042, + E_INDEX_WITH_TTL = -2043, + E_ADD_JOB_FAILURE = -2044, + E_STOP_JOB_FAILURE = -2045, + E_SAVE_JOB_FAILURE = -2046, + E_BALANCER_FAILURE = -2047, + E_JOB_NOT_FINISHED = -2048, + E_TASK_REPORT_OUT_DATE = -2049, + E_JOB_NOT_IN_SPACE = -2050, + E_INVALID_JOB = -2065, + + // Backup Failure + E_BACKUP_BUILDING_INDEX = -2066, + E_BACKUP_SPACE_NOT_FOUND = -2067, + + // RESTORE Failure + E_RESTORE_FAILURE = -2068, + + E_SESSION_NOT_FOUND = -2069, + + // ListClusterInfo Failure + E_LIST_CLUSTER_FAILURE = -2070, + E_LIST_CLUSTER_GET_ABS_PATH_FAILURE = -2071, + E_GET_META_DIR_FAILURE = -2072, + + E_QUERY_NOT_FOUND = -2073, + + // 3xxx for storaged + E_CONSENSUS_ERROR = -3001, + E_KEY_HAS_EXISTS = -3002, + E_DATA_TYPE_MISMATCH = -3003, + E_INVALID_FIELD_VALUE = -3004, + E_INVALID_OPERATION = -3005, + E_NOT_NULLABLE = -3006, // Not allowed to be null + // The field neither can be NULL, nor has a default value + E_FIELD_UNSET = -3007, + // Value exceeds the range of type + E_OUT_OF_RANGE = -3008, + // Atomic operation failed + E_ATOMIC_OP_FAILED = -3009, + E_DATA_CONFLICT_ERROR = -3010, // data conflict, for index write without toss. + + E_WRITE_STALLED = -3011, + + // meta failures + E_IMPROPER_DATA_TYPE = -3021, + E_INVALID_SPACEVIDLEN = -3022, + + // Invalid request + E_INVALID_FILTER = -3031, + E_INVALID_UPDATER = -3032, + E_INVALID_STORE = -3033, + E_INVALID_PEER = -3034, + E_RETRY_EXHAUSTED = -3035, + E_TRANSFER_LEADER_FAILED = -3036, + E_INVALID_STAT_TYPE = -3037, + E_INVALID_VID = -3038, + E_NO_TRANSFORMED = -3039, + + // meta client failed + E_LOAD_META_FAILED = -3040, + + // checkpoint failed + E_FAILED_TO_CHECKPOINT = -3041, + E_CHECKPOINT_BLOCKED = -3042, + + // Filter out + E_FILTER_OUT = -3043, + E_INVALID_DATA = -3044, + + E_MUTATE_EDGE_CONFLICT = -3045, + E_MUTATE_TAG_CONFLICT = -3046, + + // transaction + E_OUTDATED_LOCK = -3047, + + // task manager failed + E_INVALID_TASK_PARA = -3051, + E_USER_CANCEL = -3052, + E_TASK_EXECUTION_FAILED = -3053, + + E_PLAN_IS_KILLED = -3060, + // toss + E_NO_TERM = -3070, + E_OUTDATED_TERM = -3071, + E_OUTDATED_EDGE = -3072, + E_WRITE_WRITE_CONFLICT = -3073, + + E_CLIENT_SERVER_INCOMPATIBLE = -3061, + + E_UNKNOWN = -8000, +} (cpp.enum_strict) diff --git a/src/interface/gen-cpp2/GraphService.cpp b/src/interface/gen-cpp2/GraphService.cpp index bd293ea3..8acad477 100644 --- a/src/interface/gen-cpp2/GraphService.cpp +++ b/src/interface/gen-cpp2/GraphService.cpp @@ -101,22 +101,22 @@ void GraphServiceSvIf::async_tm_executeJson(std::unique_ptr GraphServiceSvIf::semifuture_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { - return apache::thrift::detail::si::semifuture_returning([&]( ::nebula::graph::cpp2::VerifyClientVersionResp& _return) { verifyClientVersion(_return, p_req); }); +folly::SemiFuture GraphServiceSvIf::semifuture_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req) { + return apache::thrift::detail::si::semifuture_returning([&](nebula::VerifyClientVersionResp& _return) { verifyClientVersion(_return, p_req); }); } -folly::Future< ::nebula::graph::cpp2::VerifyClientVersionResp> GraphServiceSvIf::future_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +folly::Future GraphServiceSvIf::future_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req) { using Source = apache::thrift::concurrency::ThreadManager::Source; auto scope = getRequestContext()->getRequestExecutionScope(); auto ka = getThreadManager()->getKeepAlive(std::move(scope), Source::INTERNAL); return apache::thrift::detail::si::future(semifuture_verifyClientVersion(p_req), std::move(ka)); } -void GraphServiceSvIf::async_tm_verifyClientVersion(std::unique_ptr> callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +void GraphServiceSvIf::async_tm_verifyClientVersion(std::unique_ptr> callback, const nebula::VerifyClientVersionReq& p_req) { apache::thrift::detail::si::async_tm(this, std::move(callback), [&] { return future_verifyClientVersion(p_req); }); @@ -132,7 +132,7 @@ void GraphServiceSvNull::execute(nebula::ExecutionResponse& /*_return*/, int64_t void GraphServiceSvNull::executeJson(::std::string& /*_return*/, int64_t /*sessionId*/, const ::std::string& /*stmt*/) {} -void GraphServiceSvNull::verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& /*_return*/, const ::nebula::graph::cpp2::VerifyClientVersionReq& /*req*/) {} +void GraphServiceSvNull::verifyClientVersion(nebula::VerifyClientVersionResp& /*_return*/, const nebula::VerifyClientVersionReq& /*req*/) {} diff --git a/src/interface/gen-cpp2/GraphService.h b/src/interface/gen-cpp2/GraphService.h index 205872ca..56521bcd 100644 --- a/src/interface/gen-cpp2/GraphService.h +++ b/src/interface/gen-cpp2/GraphService.h @@ -18,6 +18,8 @@ #include "common/graph/PlanDescriptionOps-inl.h" #include "common/graph/ExecutionResponseOps-inl.h" #include "common/graph/AuthResponseOps-inl.h" +#include "common/graph/VerifyClientVersionRespOps-inl.h" +#include "common/graph/VerifyClientVersionReqOps-inl.h" namespace folly { class IOBuf; @@ -47,9 +49,9 @@ class GraphServiceSvAsyncIf { virtual void async_tm_executeJson(std::unique_ptr> callback, int64_t p_sessionId, const ::std::string& p_stmt) = 0; virtual folly::Future<::std::string> future_executeJson(int64_t p_sessionId, const ::std::string& p_stmt) = 0; virtual folly::SemiFuture<::std::string> semifuture_executeJson(int64_t p_sessionId, const ::std::string& p_stmt) = 0; - virtual void async_tm_verifyClientVersion(std::unique_ptr> callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) = 0; - virtual folly::Future< ::nebula::graph::cpp2::VerifyClientVersionResp> future_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) = 0; - virtual folly::SemiFuture< ::nebula::graph::cpp2::VerifyClientVersionResp> semifuture_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) = 0; + virtual void async_tm_verifyClientVersion(std::unique_ptr> callback, const nebula::VerifyClientVersionReq& p_req) = 0; + virtual folly::Future future_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req) = 0; + virtual folly::SemiFuture semifuture_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req) = 0; }; class GraphServiceAsyncProcessor; @@ -76,10 +78,10 @@ class GraphServiceSvIf : public GraphServiceSvAsyncIf, public apache::thrift::Se folly::Future<::std::string> future_executeJson(int64_t p_sessionId, const ::std::string& p_stmt) override; folly::SemiFuture<::std::string> semifuture_executeJson(int64_t p_sessionId, const ::std::string& p_stmt) override; void async_tm_executeJson(std::unique_ptr> callback, int64_t p_sessionId, const ::std::string& p_stmt) override; - virtual void verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& /*_return*/, const ::nebula::graph::cpp2::VerifyClientVersionReq& /*req*/); - folly::Future< ::nebula::graph::cpp2::VerifyClientVersionResp> future_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) override; - folly::SemiFuture< ::nebula::graph::cpp2::VerifyClientVersionResp> semifuture_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) override; - void async_tm_verifyClientVersion(std::unique_ptr> callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) override; + virtual void verifyClientVersion(nebula::VerifyClientVersionResp& /*_return*/, const nebula::VerifyClientVersionReq& /*req*/); + folly::Future future_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req) override; + folly::SemiFuture semifuture_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req) override; + void async_tm_verifyClientVersion(std::unique_ptr> callback, const nebula::VerifyClientVersionReq& p_req) override; }; class GraphServiceSvNull : public GraphServiceSvIf { @@ -88,7 +90,7 @@ class GraphServiceSvNull : public GraphServiceSvIf { void signout(int64_t /*sessionId*/) override; void execute(nebula::ExecutionResponse& /*_return*/, int64_t /*sessionId*/, const ::std::string& /*stmt*/) override; void executeJson(::std::string& /*_return*/, int64_t /*sessionId*/, const ::std::string& /*stmt*/) override; - void verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& /*_return*/, const ::nebula::graph::cpp2::VerifyClientVersionReq& /*req*/) override; + void verifyClientVersion(nebula::VerifyClientVersionResp& /*_return*/, const nebula::VerifyClientVersionReq& /*req*/) override; }; class GraphServiceAsyncProcessor : public ::apache::thrift::GeneratedAsyncProcessor { @@ -144,7 +146,7 @@ class GraphServiceAsyncProcessor : public ::apache::thrift::GeneratedAsyncProces template void process_verifyClientVersion(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx,folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm); template - static folly::IOBufQueue return_verifyClientVersion(int32_t protoSeqId, apache::thrift::ContextStack* ctx, ::nebula::graph::cpp2::VerifyClientVersionResp const& _return); + static folly::IOBufQueue return_verifyClientVersion(int32_t protoSeqId, apache::thrift::ContextStack* ctx, nebula::VerifyClientVersionResp const& _return); template static void throw_wrapped_verifyClientVersion(apache::thrift::ResponseChannelRequest::UniquePtr req,int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx); public: diff --git a/src/interface/gen-cpp2/GraphService.tcc b/src/interface/gen-cpp2/GraphService.tcc index 499ec1d4..6de9c416 100644 --- a/src/interface/gen-cpp2/GraphService.tcc +++ b/src/interface/gen-cpp2/GraphService.tcc @@ -18,8 +18,8 @@ typedef apache::thrift::ThriftPresult> GraphService_execute_presult; typedef apache::thrift::ThriftPresult, apache::thrift::FieldData<2, ::apache::thrift::type_class::binary, ::std::string*>> GraphService_executeJson_pargs; typedef apache::thrift::ThriftPresult> GraphService_executeJson_presult; -typedef apache::thrift::ThriftPresult> GraphService_verifyClientVersion_pargs; -typedef apache::thrift::ThriftPresult> GraphService_verifyClientVersion_presult; +typedef apache::thrift::ThriftPresult> GraphService_verifyClientVersion_pargs; +typedef apache::thrift::ThriftPresult> GraphService_verifyClientVersion_presult; template void GraphServiceAsyncProcessor::setUpAndProcess_authenticate(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, iface_)) { @@ -244,7 +244,7 @@ void GraphServiceAsyncProcessor::process_verifyClientVersion(apache::thrift::Res // so async calls don't accidentally use it iface_->setRequestContext(nullptr); GraphService_verifyClientVersion_pargs args; - ::nebula::graph::cpp2::VerifyClientVersionReq uarg_req; + nebula::VerifyClientVersionReq uarg_req; args.get<0>().value = &uarg_req; std::unique_ptr ctxStack(this->getContextStack(this->getServiceName(), "GraphService.verifyClientVersion", ctx)); try { @@ -256,7 +256,7 @@ void GraphServiceAsyncProcessor::process_verifyClientVersion(apache::thrift::Res return; } req->setStartedProcessing(); - auto callback = std::make_unique>(std::move(req), std::move(ctxStack), return_verifyClientVersion, throw_wrapped_verifyClientVersion, ctx->getProtoSeqId(), eb, tm, ctx); + auto callback = std::make_unique>(std::move(req), std::move(ctxStack), return_verifyClientVersion, throw_wrapped_verifyClientVersion, ctx->getProtoSeqId(), eb, tm, ctx); if (!callback->isRequestActive()) { return; } @@ -264,10 +264,10 @@ void GraphServiceAsyncProcessor::process_verifyClientVersion(apache::thrift::Res } template -folly::IOBufQueue GraphServiceAsyncProcessor::return_verifyClientVersion(int32_t protoSeqId, apache::thrift::ContextStack* ctx, ::nebula::graph::cpp2::VerifyClientVersionResp const& _return) { +folly::IOBufQueue GraphServiceAsyncProcessor::return_verifyClientVersion(int32_t protoSeqId, apache::thrift::ContextStack* ctx, nebula::VerifyClientVersionResp const& _return) { ProtocolOut_ prot; GraphService_verifyClientVersion_presult result; - result.get<0>().value = const_cast< ::nebula::graph::cpp2::VerifyClientVersionResp*>(&_return); + result.get<0>().value = const_cast(&_return); result.setIsSet(0, true); return serializeResponse("verifyClientVersion", &prot, protoSeqId, ctx, result); } diff --git a/src/interface/gen-cpp2/GraphServiceAsyncClient.cpp b/src/interface/gen-cpp2/GraphServiceAsyncClient.cpp index 7cb3a553..ecb2e17a 100644 --- a/src/interface/gen-cpp2/GraphServiceAsyncClient.cpp +++ b/src/interface/gen-cpp2/GraphServiceAsyncClient.cpp @@ -17,8 +17,8 @@ typedef apache::thrift::ThriftPresult> GraphService_execute_presult; typedef apache::thrift::ThriftPresult, apache::thrift::FieldData<2, ::apache::thrift::type_class::binary, ::std::string*>> GraphService_executeJson_pargs; typedef apache::thrift::ThriftPresult> GraphService_executeJson_presult; -typedef apache::thrift::ThriftPresult> GraphService_verifyClientVersion_pargs; -typedef apache::thrift::ThriftPresult> GraphService_verifyClientVersion_presult; +typedef apache::thrift::ThriftPresult> GraphService_verifyClientVersion_pargs; +typedef apache::thrift::ThriftPresult> GraphService_verifyClientVersion_presult; template void GraphServiceAsyncClient::authenticateT(Protocol_* prot, apache::thrift::RpcOptions rpcOptions, std::shared_ptr ctx, apache::thrift::RequestClientCallback::Ptr callback, const ::std::string& p_username, const ::std::string& p_password) { @@ -76,11 +76,11 @@ void GraphServiceAsyncClient::executeJsonT(Protocol_* prot, apache::thrift::RpcO } template -void GraphServiceAsyncClient::verifyClientVersionT(Protocol_* prot, apache::thrift::RpcOptions rpcOptions, std::shared_ptr ctx, apache::thrift::RequestClientCallback::Ptr callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +void GraphServiceAsyncClient::verifyClientVersionT(Protocol_* prot, apache::thrift::RpcOptions rpcOptions, std::shared_ptr ctx, apache::thrift::RequestClientCallback::Ptr callback, const nebula::VerifyClientVersionReq& p_req) { std::shared_ptr header(ctx, &ctx->header); GraphService_verifyClientVersion_pargs args; - args.get<0>().value = const_cast< ::nebula::graph::cpp2::VerifyClientVersionReq*>(&p_req); + args.get<0>().value = const_cast(&p_req); auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static constexpr const folly::StringPiece methodName = "verifyClientVersion"; @@ -689,12 +689,12 @@ folly::exception_wrapper GraphServiceAsyncClient::recv_instance_wrapped_executeJ return recv_wrapped_executeJson(_return, state); } -void GraphServiceAsyncClient::verifyClientVersion(std::unique_ptr callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +void GraphServiceAsyncClient::verifyClientVersion(std::unique_ptr callback, const nebula::VerifyClientVersionReq& p_req) { ::apache::thrift::RpcOptions rpcOptions; verifyClientVersion(rpcOptions, std::move(callback), p_req); } -void GraphServiceAsyncClient::verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +void GraphServiceAsyncClient::verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const nebula::VerifyClientVersionReq& p_req) { auto ctx = verifyClientVersionCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = @@ -704,7 +704,7 @@ void GraphServiceAsyncClient::verifyClientVersion(apache::thrift::RpcOptions& rp verifyClientVersionImpl(rpcOptions, std::move(ctx), std::move(wrappedCallback), p_req); } -void GraphServiceAsyncClient::verifyClientVersionImpl(const apache::thrift::RpcOptions& rpcOptions, std::shared_ptr ctx, apache::thrift::RequestClientCallback::Ptr callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +void GraphServiceAsyncClient::verifyClientVersionImpl(const apache::thrift::RpcOptions& rpcOptions, std::shared_ptr ctx, apache::thrift::RequestClientCallback::Ptr callback, const nebula::VerifyClientVersionReq& p_req) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { @@ -734,12 +734,12 @@ std::shared_ptr<::apache::thrift::detail::ac::ClientRequestContext> GraphService "GraphService.verifyClientVersion"); } -void GraphServiceAsyncClient::sync_verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& _return, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +void GraphServiceAsyncClient::sync_verifyClientVersion(nebula::VerifyClientVersionResp& _return, const nebula::VerifyClientVersionReq& p_req) { ::apache::thrift::RpcOptions rpcOptions; sync_verifyClientVersion(rpcOptions, _return, p_req); } -void GraphServiceAsyncClient::sync_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, ::nebula::graph::cpp2::VerifyClientVersionResp& _return, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +void GraphServiceAsyncClient::sync_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, nebula::VerifyClientVersionResp& _return, const nebula::VerifyClientVersionReq& p_req) { apache::thrift::ClientReceiveState returnState; apache::thrift::ClientSyncCallback callback(&returnState); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); @@ -765,53 +765,53 @@ void GraphServiceAsyncClient::sync_verifyClientVersion(apache::thrift::RpcOption } -folly::Future< ::nebula::graph::cpp2::VerifyClientVersionResp> GraphServiceAsyncClient::future_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +folly::Future GraphServiceAsyncClient::future_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req) { ::apache::thrift::RpcOptions rpcOptions; return future_verifyClientVersion(rpcOptions, p_req); } -folly::SemiFuture< ::nebula::graph::cpp2::VerifyClientVersionResp> GraphServiceAsyncClient::semifuture_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +folly::SemiFuture GraphServiceAsyncClient::semifuture_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req) { ::apache::thrift::RpcOptions rpcOptions; return semifuture_verifyClientVersion(rpcOptions, p_req); } -folly::Future< ::nebula::graph::cpp2::VerifyClientVersionResp> GraphServiceAsyncClient::future_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { - folly::Promise< ::nebula::graph::cpp2::VerifyClientVersionResp> promise; +folly::Future GraphServiceAsyncClient::future_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const nebula::VerifyClientVersionReq& p_req) { + folly::Promise promise; auto future = promise.getFuture(); - auto callback = std::make_unique>(std::move(promise), recv_wrapped_verifyClientVersion, channel_); + auto callback = std::make_unique>(std::move(promise), recv_wrapped_verifyClientVersion, channel_); verifyClientVersion(rpcOptions, std::move(callback), p_req); return future; } -folly::SemiFuture< ::nebula::graph::cpp2::VerifyClientVersionResp> GraphServiceAsyncClient::semifuture_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +folly::SemiFuture GraphServiceAsyncClient::semifuture_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const nebula::VerifyClientVersionReq& p_req) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_verifyClientVersion, channel_); auto callback = std::move(callbackAndFuture.first); verifyClientVersion(rpcOptions, std::move(callback), p_req); return std::move(callbackAndFuture.second); } -folly::Future>> GraphServiceAsyncClient::header_future_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { - folly::Promise>> promise; +folly::Future>> GraphServiceAsyncClient::header_future_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const nebula::VerifyClientVersionReq& p_req) { + folly::Promise>> promise; auto future = promise.getFuture(); - auto callback = std::make_unique>(std::move(promise), recv_wrapped_verifyClientVersion, channel_); + auto callback = std::make_unique>(std::move(promise), recv_wrapped_verifyClientVersion, channel_); verifyClientVersion(rpcOptions, std::move(callback), p_req); return future; } -folly::SemiFuture>> GraphServiceAsyncClient::header_semifuture_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +folly::SemiFuture>> GraphServiceAsyncClient::header_semifuture_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const nebula::VerifyClientVersionReq& p_req) { auto callbackAndFuture = makeHeaderSemiFutureCallback(recv_wrapped_verifyClientVersion, channel_); auto callback = std::move(callbackAndFuture.first); verifyClientVersion(rpcOptions, std::move(callback), p_req); return std::move(callbackAndFuture.second); } -void GraphServiceAsyncClient::verifyClientVersion(folly::Function callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { +void GraphServiceAsyncClient::verifyClientVersion(folly::Function callback, const nebula::VerifyClientVersionReq& p_req) { verifyClientVersion(std::make_unique(std::move(callback)), p_req); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES -folly::exception_wrapper GraphServiceAsyncClient::recv_wrapped_verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state) { +folly::exception_wrapper GraphServiceAsyncClient::recv_wrapped_verifyClientVersion(nebula::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state) { if (state.isException()) { return std::move(state.exception()); } @@ -841,18 +841,18 @@ folly::exception_wrapper GraphServiceAsyncClient::recv_wrapped_verifyClientVersi return folly::make_exception_wrapper("Could not find Protocol"); } -void GraphServiceAsyncClient::recv_verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state) { +void GraphServiceAsyncClient::recv_verifyClientVersion(nebula::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state) { auto ew = recv_wrapped_verifyClientVersion(_return, state); if (ew) { ew.throw_exception(); } } -void GraphServiceAsyncClient::recv_instance_verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state) { +void GraphServiceAsyncClient::recv_instance_verifyClientVersion(nebula::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state) { return recv_verifyClientVersion(_return, state); } -folly::exception_wrapper GraphServiceAsyncClient::recv_instance_wrapped_verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state) { +folly::exception_wrapper GraphServiceAsyncClient::recv_instance_wrapped_verifyClientVersion(nebula::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state) { return recv_wrapped_verifyClientVersion(_return, state); } diff --git a/src/interface/gen-cpp2/GraphServiceAsyncClient.h b/src/interface/gen-cpp2/GraphServiceAsyncClient.h index 229123c8..ed451104 100644 --- a/src/interface/gen-cpp2/GraphServiceAsyncClient.h +++ b/src/interface/gen-cpp2/GraphServiceAsyncClient.h @@ -17,6 +17,8 @@ #include "common/graph/PlanDescriptionOps-inl.h" #include "common/graph/ExecutionResponseOps-inl.h" #include "common/graph/AuthResponseOps-inl.h" +#include "common/graph/VerifyClientVersionRespOps-inl.h" +#include "common/graph/VerifyClientVersionReqOps-inl.h" namespace apache { namespace thrift { class Cpp2RequestContext; @@ -343,34 +345,34 @@ class GraphServiceAsyncClient : public apache::thrift::GeneratedAsyncClient { void executeJsonT(Protocol_* prot, apache::thrift::RpcOptions rpcOptions, std::shared_ptr ctx, apache::thrift::RequestClientCallback::Ptr callback, int64_t p_sessionId, const ::std::string& p_stmt); std::shared_ptr<::apache::thrift::detail::ac::ClientRequestContext> executeJsonCtx(apache::thrift::RpcOptions* rpcOptions); public: - virtual void verifyClientVersion(std::unique_ptr callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); - virtual void verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); + virtual void verifyClientVersion(std::unique_ptr callback, const nebula::VerifyClientVersionReq& p_req); + virtual void verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const nebula::VerifyClientVersionReq& p_req); protected: - void verifyClientVersionImpl(const apache::thrift::RpcOptions& rpcOptions, std::shared_ptr ctx, apache::thrift::RequestClientCallback::Ptr callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); + void verifyClientVersionImpl(const apache::thrift::RpcOptions& rpcOptions, std::shared_ptr ctx, apache::thrift::RequestClientCallback::Ptr callback, const nebula::VerifyClientVersionReq& p_req); public: - virtual void sync_verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& _return, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); - virtual void sync_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, ::nebula::graph::cpp2::VerifyClientVersionResp& _return, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); + virtual void sync_verifyClientVersion(nebula::VerifyClientVersionResp& _return, const nebula::VerifyClientVersionReq& p_req); + virtual void sync_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, nebula::VerifyClientVersionResp& _return, const nebula::VerifyClientVersionReq& p_req); - virtual folly::Future< ::nebula::graph::cpp2::VerifyClientVersionResp> future_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); - virtual folly::SemiFuture< ::nebula::graph::cpp2::VerifyClientVersionResp> semifuture_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); - virtual folly::Future< ::nebula::graph::cpp2::VerifyClientVersionResp> future_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); - virtual folly::SemiFuture< ::nebula::graph::cpp2::VerifyClientVersionResp> semifuture_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); - virtual folly::Future>> header_future_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); - virtual folly::SemiFuture>> header_semifuture_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); + virtual folly::Future future_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req); + virtual folly::SemiFuture semifuture_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req); + virtual folly::Future future_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const nebula::VerifyClientVersionReq& p_req); + virtual folly::SemiFuture semifuture_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const nebula::VerifyClientVersionReq& p_req); + virtual folly::Future>> header_future_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const nebula::VerifyClientVersionReq& p_req); + virtual folly::SemiFuture>> header_semifuture_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const nebula::VerifyClientVersionReq& p_req); #if FOLLY_HAS_COROUTINES template - folly::coro::Task< ::nebula::graph::cpp2::VerifyClientVersionResp> co_verifyClientVersion(const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { + folly::coro::Task co_verifyClientVersion(const nebula::VerifyClientVersionReq& p_req) { return co_verifyClientVersion(nullptr, p_req); } template - folly::coro::Task< ::nebula::graph::cpp2::VerifyClientVersionResp> co_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { + folly::coro::Task co_verifyClientVersion(apache::thrift::RpcOptions& rpcOptions, const nebula::VerifyClientVersionReq& p_req) { return co_verifyClientVersion(&rpcOptions, p_req); } private: template - folly::coro::Task< ::nebula::graph::cpp2::VerifyClientVersionResp> co_verifyClientVersion(apache::thrift::RpcOptions* rpcOptions, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req) { + folly::coro::Task co_verifyClientVersion(apache::thrift::RpcOptions* rpcOptions, const nebula::VerifyClientVersionReq& p_req) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); @@ -403,7 +405,7 @@ class GraphServiceAsyncClient : public apache::thrift::GeneratedAsyncClient { rpcOptions->setReadHeaders(returnState.header()->releaseHeaders()); } }; - ::nebula::graph::cpp2::VerifyClientVersionResp _return; + nebula::VerifyClientVersionResp _return; if (auto ew = recv_wrapped_verifyClientVersion(_return, returnState)) { co_yield folly::coro::co_error(std::move(ew)); } @@ -412,17 +414,17 @@ class GraphServiceAsyncClient : public apache::thrift::GeneratedAsyncClient { public: #endif // FOLLY_HAS_COROUTINES - virtual void verifyClientVersion(folly::Function callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); + virtual void verifyClientVersion(folly::Function callback, const nebula::VerifyClientVersionReq& p_req); - static folly::exception_wrapper recv_wrapped_verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state); - static void recv_verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state); + static folly::exception_wrapper recv_wrapped_verifyClientVersion(nebula::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state); + static void recv_verifyClientVersion(nebula::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state); // Mock friendly virtual instance method - virtual void recv_instance_verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state); - virtual folly::exception_wrapper recv_instance_wrapped_verifyClientVersion( ::nebula::graph::cpp2::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state); + virtual void recv_instance_verifyClientVersion(nebula::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state); + virtual folly::exception_wrapper recv_instance_wrapped_verifyClientVersion(nebula::VerifyClientVersionResp& _return, ::apache::thrift::ClientReceiveState& state); private: template - void verifyClientVersionT(Protocol_* prot, apache::thrift::RpcOptions rpcOptions, std::shared_ptr ctx, apache::thrift::RequestClientCallback::Ptr callback, const ::nebula::graph::cpp2::VerifyClientVersionReq& p_req); + void verifyClientVersionT(Protocol_* prot, apache::thrift::RpcOptions rpcOptions, std::shared_ptr ctx, apache::thrift::RequestClientCallback::Ptr callback, const nebula::VerifyClientVersionReq& p_req); std::shared_ptr<::apache::thrift::detail::ac::ClientRequestContext> verifyClientVersionCtx(apache::thrift::RpcOptions* rpcOptions); public: }; diff --git a/src/interface/gen-cpp2/graph_types.h b/src/interface/gen-cpp2/graph_types.h index c4e03675..1a73b25b 100644 --- a/src/interface/gen-cpp2/graph_types.h +++ b/src/interface/gen-cpp2/graph_types.h @@ -17,6 +17,8 @@ #include "common/graph/PlanDescriptionOps-inl.h" #include "common/graph/ExecutionResponseOps-inl.h" #include "common/graph/AuthResponseOps-inl.h" +#include "common/graph/VerifyClientVersionRespOps-inl.h" +#include "common/graph/VerifyClientVersionReqOps-inl.h" namespace apache { namespace thrift { diff --git a/src/interface/graph.thrift b/src/interface/graph.thrift new file mode 100644 index 00000000..f2a9d8b0 --- /dev/null +++ b/src/interface/graph.thrift @@ -0,0 +1,125 @@ +/* vim: ft=proto + * Copyright (c) 2018 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License. + */ + +namespace cpp nebula.graph +namespace java com.vesoft.nebula.graph +namespace go nebula.graph +namespace js nebula.graph +namespace csharp nebula.graph +namespace py nebula2.graph + +include "common.thrift" + +cpp_include "common/graph/PairOps-inl.h" +cpp_include "common/graph/ProfilingStatsOps-inl.h" +cpp_include "common/graph/PlanNodeBranchInfoOps-inl.h" +cpp_include "common/graph/PlanNodeDescriptionOps-inl.h" +cpp_include "common/graph/PlanDescriptionOps-inl.h" +cpp_include "common/graph/ExecutionResponseOps-inl.h" +cpp_include "common/graph/AuthResponseOps-inl.h" +cpp_include "common/graph/VerifyClientVersionRespOps-inl.h" +cpp_include "common/graph/VerifyClientVersionReqOps-inl.h" + +/* + * + * Note: In order to support multiple languages, all string + * have to be defined as **binary** in the thrift file + * + */ + +struct ProfilingStats { + // How many rows being processed in an executor. + 1: required i64 rows; + // Duration spent in an executor. + 2: required i64 exec_duration_in_us; + // Total duration spent in an executor, contains schedule time + 3: required i64 total_duration_in_us; + // Other profiling stats data map + 4: optional map + (cpp.template = "std::unordered_map") other_stats; +} (cpp.type = "nebula::ProfilingStats") + +// The info used for select/loop. +struct PlanNodeBranchInfo { + // True if loop body or then branch of select + 1: required bool is_do_branch; + // select/loop node id + 2: required i64 condition_node_id; +} (cpp.type = "nebula::PlanNodeBranchInfo") + +struct Pair { + 1: required binary key; + 2: required binary value; +} (cpp.type = "nebula::Pair") + +struct PlanNodeDescription { + 1: required binary name; + 2: required i64 id; + 3: required binary output_var; + // other description of an executor + 4: optional list description; + // If an executor would be executed multi times, + // the profiling statistics should be multi-versioned. + 5: optional list profiles; + 6: optional PlanNodeBranchInfo branch_info; + 7: optional list dependencies; +} (cpp.type = "nebula::PlanNodeDescription") + +struct PlanDescription { + 1: required list plan_node_descs; + // map from node id to index of list + 2: required map + (cpp.template = "std::unordered_map") node_index_map; + // the print format of exec plan, lowercase string like `dot' + 3: required binary format; + // the time optimizer spent + 4: required i32 optimize_time_in_us; +} (cpp.type = "nebula::PlanDescription") + + +struct ExecutionResponse { + 1: required common.ErrorCode error_code; + 2: required i32 latency_in_us; // Execution time on server + 3: optional common.DataSet data; + 4: optional binary space_name; + 5: optional binary error_msg; + 6: optional PlanDescription plan_desc; + 7: optional binary comment; // Supplementary instruction +} (cpp.type = "nebula::ExecutionResponse") + + +struct AuthResponse { + 1: required common.ErrorCode error_code; + 2: optional binary error_msg; + 3: optional i64 session_id; + 4: optional i32 time_zone_offset_seconds; + 5: optional binary time_zone_name; +} (cpp.type = "nebula::AuthResponse") + + +struct VerifyClientVersionResp { + 1: required common.ErrorCode error_code; + 2: optional binary error_msg; +} (cpp.type = "nebula::VerifyClientVersionResp") + + +struct VerifyClientVersionReq { + 1: required binary version = common.version; +} (cpp.type = "nebula::VerifyClientVersionReq") + + +service GraphService { + AuthResponse authenticate(1: binary username, 2: binary password) + + oneway void signout(1: i64 sessionId) + + ExecutionResponse execute(1: i64 sessionId, 2: binary stmt) + + // Same as execute(), but response will be a json string + binary executeJson(1: i64 sessionId, 2: binary stmt) + + VerifyClientVersionResp verifyClientVersion(1: VerifyClientVersionReq req) +} diff --git a/src/interface/meta.thrift b/src/interface/meta.thrift new file mode 100644 index 00000000..9418a9d7 --- /dev/null +++ b/src/interface/meta.thrift @@ -0,0 +1,1281 @@ +/* Copyright (c) 2018 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License. + */ + +namespace cpp nebula.meta +namespace java com.vesoft.nebula.meta +namespace go nebula.meta +namespace js nebula.meta +namespace csharp nebula.meta +namespace py nebula2.meta + +include "common.thrift" + +/* + * + * Note: In order to support multiple languages, all strings + * have to be defined as **binary** in the thrift file + * + */ + +typedef i64 (cpp.type = "nebula::SchemaVer") SchemaVer + +typedef i64 (cpp.type = "nebula::ClusterID") ClusterID + +enum AlterSchemaOp { + ADD = 0x01, + CHANGE = 0x02, + DROP = 0x03, + UNKNOWN = 0x04, +} (cpp.enum_strict) + +/* + * GOD is A global senior administrator.like root of Linux systems. + * ADMIN is an administrator for a given Graph Space. + * USER is a normal user for a given Graph Space. A User can access (read and write) + * the data in the Graph Space. + * GUEST is a read-only role for a given Graph Space. A Guest cannot modify the data + * in the Graph Space. + * + * Refer to header file src/graph/PermissionManager.h for details. + */ + +enum RoleType { + GOD = 0x01, + ADMIN = 0x02, + DBA = 0x03, + USER = 0x04, + GUEST = 0x05, +} (cpp.enum_strict) + + +union ID { + 1: common.GraphSpaceID space_id, + 2: common.TagID tag_id, + 3: common.EdgeType edge_type, + 4: common.IndexID index_id, + 5: ClusterID cluster_id, +} + + +// Geo shape type +enum GeoShape { + ANY = 0, + POINT = 1, + LINESTRING = 2, + POLYGON = 3, +} (cpp.enum_strict) + + +struct ColumnTypeDef { + 1: required common.PropertyType type, + // type_length is valid for fixed_string type + 2: optional i16 type_length = 0, + // geo_shape is valid for geography type + 3: optional GeoShape geo_shape, +} + +struct ColumnDef { + 1: required binary name, + 2: required ColumnTypeDef type, + 3: optional binary default_value, + 4: optional bool nullable = false, + 5: optional binary comment, +} + +struct SchemaProp { + 1: optional i64 ttl_duration, + 2: optional binary ttl_col, + 3: optional binary comment, +} + +struct Schema { + 1: list columns, + 2: SchemaProp schema_prop, +} + +struct IdName { + 1: ID id, + 2: binary name, +} + +enum IsolationLevel { + DEFAULT = 0x00, // allow add half edge(either in or out edge succeeded) + TOSS = 0x01, // add in and out edge atomic +} (cpp.enum_strict) + +struct SpaceDesc { + 1: binary space_name, + 2: i32 partition_num = 0, + 3: i32 replica_factor = 0, + 4: binary charset_name, + 5: binary collate_name, + 6: ColumnTypeDef vid_type = {"type": common.PropertyType.FIXED_STRING, "type_length": 8}, + 7: optional binary group_name, + 8: optional IsolationLevel isolation_level, + 9: optional binary comment, +} + +struct SpaceItem { + 1: common.GraphSpaceID space_id, + 2: SpaceDesc properties, +} + +struct TagItem { + 1: common.TagID tag_id, + 2: binary tag_name, + 3: SchemaVer version, + 4: Schema schema, +} + +struct AlterSchemaItem { + 1: AlterSchemaOp op, + 2: Schema schema, +} + +struct EdgeItem { + 1: common.EdgeType edge_type, + 2: binary edge_name, + 3: SchemaVer version, + 4: Schema schema, +} + +struct IndexItem { + 1: common.IndexID index_id, + 2: binary index_name, + 3: common.SchemaID schema_id + 4: binary schema_name, + 5: list fields, + 6: optional binary comment, +} + +enum HostStatus { + ONLINE = 0x00, + OFFLINE = 0x01, + UNKNOWN = 0x02, +} (cpp.enum_strict) + +enum SnapshotStatus { + VALID = 0x00, + INVALID = 0x01, +} (cpp.enum_strict) + +struct HostItem { + 1: common.HostAddr hostAddr, + 2: HostStatus status, + 3: map> + (cpp.template = "std::unordered_map") leader_parts, + 4: map> + (cpp.template = "std::unordered_map") all_parts, + 5: HostRole role, + 6: binary git_info_sha, + 7: optional binary zone_name, + // version of binary + 8: optional binary version, +} + +struct UserItem { + 1: binary account, + // Disable user if lock status is true. + 2: bool is_lock, + // The number of queries an account can issue per hour + 3: i32 max_queries_per_hour, + // The number of updates an account can issue per hour + 4: i32 max_updates_per_hour, + // The number of times an account can connect to the server per hour + 5: i32 max_connections_per_hour, + // The number of simultaneous connections to the server by an account + 6: i32 max_user_connections, +} + +struct RoleItem { + 1: binary user_id, + 2: common.GraphSpaceID space_id, + 3: RoleType role_type, +} + +struct ExecResp { + 1: common.ErrorCode code, + // For custom kv operations, it is useless. + 2: ID id, + // Valid if ret equals E_LEADER_CHANGED. + 3: common.HostAddr leader, +} + +// Job related data structures +enum AdminJobOp { + ADD = 0x01, + SHOW_All = 0x02, + SHOW = 0x03, + STOP = 0x04, + RECOVER = 0x05, +} (cpp.enum_strict) + +struct AdminJobReq { + 1: AdminJobOp op, + 2: AdminCmd cmd, + 3: list paras, +} + +enum AdminCmd { + COMPACT = 0, + FLUSH = 1, + REBUILD_TAG_INDEX = 2, + REBUILD_EDGE_INDEX = 3, + REBUILD_FULLTEXT_INDEX = 4, + STATS = 5, + DATA_BALANCE = 6, + DOWNLOAD = 7, + INGEST = 8, + UNKNOWN = 99, +} (cpp.enum_strict) + +enum JobStatus { + QUEUE = 0x01, + RUNNING = 0x02, + FINISHED = 0x03, + FAILED = 0x04, + STOPPED = 0x05, + INVALID = 0xFF, +} (cpp.enum_strict) + +struct JobDesc { + 1: i32 id, + 2: AdminCmd cmd, + 3: list paras, + 4: JobStatus status, + 5: i64 start_time, + 6: i64 stop_time, +} + +struct TaskDesc { + 1: i32 task_id, + 2: common.HostAddr host, + 3: JobStatus status, + 4: i64 start_time, + 5: i64 stop_time, + 6: i32 job_id, +} + +struct AdminJobResult { + // used in a new added job, e.g. "flush" "compact" + // other job type which also need jobId in their result + // will use other filed. e.g. JobDesc::id + 1: optional i32 job_id, + + // used in "show jobs" and "show job " + 2: optional list job_desc, + + // used in "show job " + 3: optional list task_desc, + + // used in "recover job" + 4: optional i32 recovered_job_num, +} + +struct AdminJobResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: AdminJobResult result, +} + +struct Correlativity { + 1: common.PartitionID part_id, + 2: double proportion, +} + +struct StatsItem { + // The number of vertices of tagName + 1: map + (cpp.template = "std::unordered_map") tag_vertices, + // The number of out edges of edgeName + 2: map + (cpp.template = "std::unordered_map") edges, + // The number of vertices of current space + 3: i64 space_vertices, + // The number of edges of current space + 4: i64 space_edges, + // Used to describe the proportion of positive edges + // between the current partition and other partitions. + 5: map> + (cpp.template = "std::unordered_map") positive_part_correlativity, + // Used to describe the proportion of negative edges + // between the current partition and other partitions. + 6: map> + (cpp.template = "std::unordered_map") negative_part_correlativity, + 7: JobStatus status, +} + +// Graph space related operations. +struct CreateSpaceReq { + 1: SpaceDesc properties, + 2: bool if_not_exists, +} + +struct CreateSpaceAsReq { + 1: binary old_space_name, + 2: binary new_space_name, +} + +struct DropSpaceReq { + 1: binary space_name + 2: bool if_exists, +} + +struct ListSpacesReq { +} + +struct ListSpacesResp { + 1: common.ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: list spaces, +} + +struct GetSpaceReq { + 1: binary space_name, +} + +struct GetSpaceResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: SpaceItem item, +} + +// Tags related operations +struct CreateTagReq { + 1: common.GraphSpaceID space_id, + 2: binary tag_name, + 3: Schema schema, + 4: bool if_not_exists, +} + +struct AlterTagReq { + 1: common.GraphSpaceID space_id, + 2: binary tag_name, + 3: list tag_items, + 4: SchemaProp schema_prop, +} + +struct DropTagReq { + 1: common.GraphSpaceID space_id, + 2: binary tag_name, + 3: bool if_exists, +} + +struct ListTagsReq { + 1: common.GraphSpaceID space_id, +} + +struct ListTagsResp { + 1: common.ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: list tags, +} + +struct GetTagReq { + 1: common.GraphSpaceID space_id, + 2: binary tag_name, + 3: SchemaVer version, +} + +struct GetTagResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: Schema schema, +} + +// Edge related operations. +struct CreateEdgeReq { + 1: common.GraphSpaceID space_id, + 2: binary edge_name, + 3: Schema schema, + 4: bool if_not_exists, +} + +struct AlterEdgeReq { + 1: common.GraphSpaceID space_id, + 2: binary edge_name, + 3: list edge_items, + 4: SchemaProp schema_prop, +} + +struct GetEdgeReq { + 1: common.GraphSpaceID space_id, + 2: binary edge_name, + 3: SchemaVer version, +} + +struct GetEdgeResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: Schema schema, +} + +struct DropEdgeReq { + 1: common.GraphSpaceID space_id, + 2: binary edge_name, + 3: bool if_exists, +} + +struct ListEdgesReq { + 1: common.GraphSpaceID space_id, +} + +struct ListEdgesResp { + 1: common.ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: list edges, +} + +enum ListHostType { + // nebula 1.0 show hosts, show leader, partition info + ALLOC = 0x00, + GRAPH = 0x01, + META = 0x02, + STORAGE = 0x03, +} (cpp.enum_strict) + +struct ListHostsReq { + 1: ListHostType type +} + +struct ListHostsResp { + 1: common.ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: list hosts, +} + +struct PartItem { + 1: required common.PartitionID part_id, + 2: optional common.HostAddr leader, + 3: required list peers, + 4: required list losts, +} + +struct ListPartsReq { + 1: common.GraphSpaceID space_id, + 2: list part_ids; +} + +struct ListPartsResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list parts, +} + +struct GetPartsAllocReq { + 1: common.GraphSpaceID space_id, +} + +struct GetPartsAllocResp { + 1: common.ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: map>(cpp.template = "std::unordered_map") parts, + 4: optional map(cpp.template = "std::unordered_map") terms, +} + +struct MultiPutReq { + // segment is used to avoid conflict with system data. + // it should be comprised of numbers and letters. + 1: binary segment, + 2: list pairs, +} + +struct GetReq { + 1: binary segment, + 2: binary key, +} + +struct GetResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: binary value, +} + +struct MultiGetReq { + 1: binary segment, + 2: list keys, +} + +struct MultiGetResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list values, +} + +struct RemoveReq { + 1: binary segment, + 2: binary key, +} + +struct RemoveRangeReq { + 1: binary segment, + 2: binary start, + 3: binary end, +} + +struct ScanReq { + 1: binary segment, + 2: binary start, + 3: binary end, +} + +struct ScanResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list values, +} + +struct HBResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: ClusterID cluster_id, + 4: i64 last_update_time_in_ms, + 5: i32 meta_version, +} + +enum HostRole { + GRAPH = 0x00, + META = 0x01, + STORAGE = 0x02, + LISTENER = 0x03, + UNKNOWN = 0x04 +} (cpp.enum_strict) + +struct LeaderInfo { + 1: common.PartitionID part_id, + 2: i64 term +} + +struct HBReq { + 1: HostRole role, + 2: common.HostAddr host, + 3: ClusterID cluster_id, + 4: optional map> + (cpp.template = "std::unordered_map") leader_partIds; + 5: binary git_info_sha, + // version of binary + 6: optional binary version, +} + +struct IndexFieldDef { + 1: required binary name, + // type_length is required if the field type is STRING. + 2: optional i16 type_length, +} + +struct CreateTagIndexReq { + 1: common.GraphSpaceID space_id, + 2: binary index_name, + 3: binary tag_name, + 4: list fields, + 5: bool if_not_exists, + 6: optional binary comment, +} + +struct DropTagIndexReq { + 1: common.GraphSpaceID space_id, + 2: binary index_name, + 3: bool if_exists, +} + +struct GetTagIndexReq { + 1: common.GraphSpaceID space_id, + 2: binary index_name, +} + +struct GetTagIndexResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: IndexItem item, +} + +struct ListTagIndexesReq { + 1: common.GraphSpaceID space_id, +} + +struct ListTagIndexesResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list items, +} + +struct CreateEdgeIndexReq { + 1: common.GraphSpaceID space_id, + 2: binary index_name, + 3: binary edge_name, + 4: list fields, + 5: bool if_not_exists, + 6: optional binary comment, +} + +struct DropEdgeIndexReq { + 1: common.GraphSpaceID space_id, + 2: binary index_name, + 3: bool if_exists, +} + +struct GetEdgeIndexReq { + 1: common.GraphSpaceID space_id, + 2: binary index_name, +} + +struct GetEdgeIndexResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: IndexItem item, +} + +struct ListEdgeIndexesReq { + 1: common.GraphSpaceID space_id, +} + +struct ListEdgeIndexesResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list items, +} + +struct RebuildIndexReq { + 1: common.GraphSpaceID space_id, + 2: binary index_name, +} + +struct CreateUserReq { + 1: binary account, + 2: binary encoded_pwd, + 3: bool if_not_exists, +} + +struct DropUserReq { + 1: binary account, + 2: bool if_exists, +} + +struct AlterUserReq { + 1: binary account, + 2: binary encoded_pwd, +} + +struct GrantRoleReq { + 1: RoleItem role_item, +} + +struct RevokeRoleReq { + 1: RoleItem role_item, +} + +struct ListUsersReq { +} + +struct ListUsersResp { + 1: common.ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + // map + 3: map (cpp.template = "std::unordered_map") users, +} + +struct ListRolesReq { + 1: common.GraphSpaceID space_id, +} + +struct ListRolesResp { + 1: common.ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: list roles, +} + +struct GetUserRolesReq { + 1: binary account, +} + +struct ChangePasswordReq { + 1: binary account, + 2: binary new_encoded_pwd, + 3: binary old_encoded_pwd, +} + +struct BalanceReq { + 1: optional common.GraphSpaceID space_id, + // Specify the balance id to check the status of the related balance plan + 2: optional i64 id, + 3: optional list host_del, + 4: optional bool stop, + 5: optional bool reset, +} + +enum TaskResult { + SUCCEEDED = 0x00, + FAILED = 0x01, + IN_PROGRESS = 0x02, + INVALID = 0x03, +} (cpp.enum_strict) + + +struct BalanceTask { + 1: binary id, + 2: TaskResult result, +} + +struct BalanceResp { + 1: common.ErrorCode code, + 2: i64 id, + // Valid if code equals E_LEADER_CHANGED. + 3: common.HostAddr leader, + 4: list tasks, +} + +struct LeaderBalanceReq { +} + +enum ConfigModule { + UNKNOWN = 0x00, + ALL = 0x01, + GRAPH = 0x02, + META = 0x03, + STORAGE = 0x04, +} (cpp.enum_strict) + +enum ConfigMode { + IMMUTABLE = 0x00, + REBOOT = 0x01, + MUTABLE = 0x02, + IGNORED = 0x03, +} (cpp.enum_strict) + +struct ConfigItem { + 1: ConfigModule module, + 2: binary name, + 3: ConfigMode mode, + 4: common.Value value, +} + +struct RegConfigReq { + 1: list items, +} + +struct GetConfigReq { + 1: ConfigItem item, +} + +struct GetConfigResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list items, +} + +struct SetConfigReq { + 1: ConfigItem item, +} + +struct ListConfigsReq { + 1: binary space, + 2: ConfigModule module, +} + +struct ListConfigsResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list items, +} + +struct CreateSnapshotReq { +} + +struct DropSnapshotReq { + 1: binary name, +} + +struct ListSnapshotsReq { +} + +struct Snapshot { + 1: binary name, + 2: SnapshotStatus status, + 3: binary hosts, +} + +struct ListSnapshotsResp { + 1: common.ErrorCode code, + // Valid if code equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: list snapshots, +} + +struct ListIndexStatusReq { + 1: common.GraphSpaceID space_id, +} + +struct IndexStatus { + 1: binary name, + 2: binary status, +} + +struct ListIndexStatusResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list statuses, +} + +// Zone related interface +struct AddZoneReq { + 1: binary zone_name, + 2: list nodes, +} + +struct DropZoneReq { + 1: binary zone_name, +} + +struct AddHostIntoZoneReq { + 1: common.HostAddr node, + 2: binary zone_name, +} + +struct DropHostFromZoneReq { + 1: common.HostAddr node, + 2: binary zone_name, +} + +struct GetZoneReq { + 1: binary zone_name, +} + +struct GetZoneResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list hosts, +} + +struct ListZonesReq { +} + +struct Zone { + 1: binary zone_name, + 2: list nodes, +} + +struct ListZonesResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list zones, +} + +struct AddGroupReq { + 1: binary group_name, + 2: list zone_names, +} + +struct DropGroupReq { + 1: binary group_name, +} + +struct AddZoneIntoGroupReq { + 1: binary zone_name, + 2: binary group_name, +} + +struct DropZoneFromGroupReq { + 1: binary zone_name, + 2: binary group_name, +} + +struct GetGroupReq { + 1: binary group_name, +} + +struct GetGroupResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list zone_names, +} + +struct ListGroupsReq { +} + +struct Group { + 1: binary group_name, + 2: list zone_names, +} + +struct ListGroupsResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list groups, +} + +enum ListenerType { + UNKNOWN = 0x00, + ELASTICSEARCH = 0x01, +} (cpp.enum_strict) + +struct AddListenerReq { + 1: common.GraphSpaceID space_id, + 2: ListenerType type, + 3: list hosts, +} + +struct RemoveListenerReq { + 1: common.GraphSpaceID space_id, + 2: ListenerType type, +} + +struct ListListenerReq { + 1: common.GraphSpaceID space_id, +} + +struct ListenerInfo { + 1: ListenerType type, + 2: common.HostAddr host, + 3: common.PartitionID part_id, + 4: HostStatus status, +} + +struct ListListenerResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list listeners, +} + +struct GetStatsReq { + 1: common.GraphSpaceID space_id, +} + +struct GetStatsResp { + 1: common.ErrorCode code, + // Valid if ret equals E_LEADER_CHANGED. + 2: common.HostAddr leader, + 3: StatsItem stats, +} + +struct BackupInfo { + 1: common.HostAddr host, + 2: list info, +} + +struct SpaceBackupInfo { + 1: SpaceDesc space, + 2: list info, +} + +struct BackupMeta { + // space_name => SpaceBackupInfo + 1: map (cpp.template = "std::unordered_map") backup_info, + // sst file + 2: list meta_files, + // backup + 3: binary backup_name, + 4: bool full, + 5: bool include_system_space, + 6: i64 create_time, +} + +struct CreateBackupReq { + // null means all spaces + 1: optional list spaces, +} + +struct CreateBackupResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: BackupMeta meta, +} + +struct HostPair { + 1: common.HostAddr from_host, + 2: common.HostAddr to_host, +} + +struct RestoreMetaReq { + 1: list files, + 2: list hosts, +} + +enum FTServiceType { + ELASTICSEARCH = 0x01, +} (cpp.enum_strict) + +struct FTClient { + 1: required common.HostAddr host, + 2: optional binary user, + 3: optional binary pwd, +} + +struct SignInFTServiceReq { + 1: FTServiceType type, + 2: list clients, +} + +struct SignOutFTServiceReq { +} + +struct ListFTClientsReq { +} + +struct ListFTClientsResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list clients, +} + +struct FTIndex { + 1: common.GraphSpaceID space_id, + 2: common.SchemaID depend_schema, + 3: list fields, +} + +struct CreateFTIndexReq { + 1: binary fulltext_index_name, + 2: FTIndex index, +} + +struct DropFTIndexReq { + 1: common.GraphSpaceID space_id, + 2: binary fulltext_index_name, +} + +struct ListFTIndexesReq { +} + +struct ListFTIndexesResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: map (cpp.template = "std::unordered_map") indexes, +} + +enum QueryStatus { + RUNNING = 0x01, + KILLING = 0x02, +} (cpp.enum_strict) + +struct QueryDesc { + 1: common.Timestamp start_time; + 2: QueryStatus status; + 3: i64 duration; + 4: binary query; + // The session might transfer between query engines, but the query do not, we must + // record which query engine the query belongs to + 5: common.HostAddr graph_addr, +} + +struct Session { + 1: common.SessionID session_id, + 2: common.Timestamp create_time, + 3: common.Timestamp update_time, + 4: binary user_name, + 5: binary space_name, + 6: common.HostAddr graph_addr, + 7: i32 timezone, + 8: binary client_ip, + 9: map(cpp.template = "std::unordered_map") configs, + 10: map(cpp.template = "std::unordered_map") queries; +} + +struct CreateSessionReq { + 1: binary user, + 2: common.HostAddr graph_addr, + 3: binary client_ip, +} + +struct CreateSessionResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: Session session, +} + +struct UpdateSessionsReq { + 1: list sessions, +} + +struct UpdateSessionsResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: map (cpp.template = "std::unordered_map")> + (cpp.template = "std::unordered_map") killed_queries, +} + +struct ListSessionsReq { +} + +struct ListSessionsResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list sessions, +} + +struct GetSessionReq { + 1: common.SessionID session_id, +} + +struct GetSessionResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: Session session, +} + +struct RemoveSessionReq { + 1: common.SessionID session_id, +} + +struct KillQueryReq { + 1: map (cpp.template = "std::unordered_set")> + (cpp.template = "std::unordered_map") kill_queries, +} + +struct ReportTaskReq { + 1: common.ErrorCode code, + 2: i32 job_id, + 3: i32 task_id, + 4: optional StatsItem stats +} + +struct ListClusterInfoResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: list meta_servers, + 4: list storage_servers, +} + +struct ListClusterInfoReq { +} + +struct GetMetaDirInfoResp { + 1: common.ErrorCode code, + 2: common.DirInfo dir, +} + +struct GetMetaDirInfoReq { +} + +struct VerifyClientVersionResp { + 1: common.ErrorCode code, + 2: common.HostAddr leader, + 3: optional binary error_msg; +} + + +struct VerifyClientVersionReq { + 1: required binary version = common.version; +} + +service MetaService { + ExecResp createSpace(1: CreateSpaceReq req); + ExecResp dropSpace(1: DropSpaceReq req); + GetSpaceResp getSpace(1: GetSpaceReq req); + ListSpacesResp listSpaces(1: ListSpacesReq req); + + ExecResp createSpaceAs(1: CreateSpaceAsReq req); + + ExecResp createTag(1: CreateTagReq req); + ExecResp alterTag(1: AlterTagReq req); + ExecResp dropTag(1: DropTagReq req); + GetTagResp getTag(1: GetTagReq req); + ListTagsResp listTags(1: ListTagsReq req); + + ExecResp createEdge(1: CreateEdgeReq req); + ExecResp alterEdge(1: AlterEdgeReq req); + ExecResp dropEdge(1: DropEdgeReq req); + GetEdgeResp getEdge(1: GetEdgeReq req); + ListEdgesResp listEdges(1: ListEdgesReq req); + + ListHostsResp listHosts(1: ListHostsReq req); + + GetPartsAllocResp getPartsAlloc(1: GetPartsAllocReq req); + ListPartsResp listParts(1: ListPartsReq req); + + ExecResp multiPut(1: MultiPutReq req); + GetResp get(1: GetReq req); + MultiGetResp multiGet(1: MultiGetReq req); + ExecResp remove(1: RemoveReq req); + ExecResp removeRange(1: RemoveRangeReq req); + ScanResp scan(1: ScanReq req); + + ExecResp createTagIndex(1: CreateTagIndexReq req); + ExecResp dropTagIndex(1: DropTagIndexReq req ); + GetTagIndexResp getTagIndex(1: GetTagIndexReq req); + ListTagIndexesResp listTagIndexes(1:ListTagIndexesReq req); + ExecResp rebuildTagIndex(1: RebuildIndexReq req); + ListIndexStatusResp listTagIndexStatus(1: ListIndexStatusReq req); + ExecResp createEdgeIndex(1: CreateEdgeIndexReq req); + ExecResp dropEdgeIndex(1: DropEdgeIndexReq req ); + GetEdgeIndexResp getEdgeIndex(1: GetEdgeIndexReq req); + ListEdgeIndexesResp listEdgeIndexes(1: ListEdgeIndexesReq req); + ExecResp rebuildEdgeIndex(1: RebuildIndexReq req); + ListIndexStatusResp listEdgeIndexStatus(1: ListIndexStatusReq req); + + ExecResp createUser(1: CreateUserReq req); + ExecResp dropUser(1: DropUserReq req); + ExecResp alterUser(1: AlterUserReq req); + ExecResp grantRole(1: GrantRoleReq req); + ExecResp revokeRole(1: RevokeRoleReq req); + ListUsersResp listUsers(1: ListUsersReq req); + ListRolesResp listRoles(1: ListRolesReq req); + ListRolesResp getUserRoles(1: GetUserRolesReq req); + ExecResp changePassword(1: ChangePasswordReq req); + + HBResp heartBeat(1: HBReq req); + BalanceResp balance(1: BalanceReq req); + ExecResp leaderBalance(1: LeaderBalanceReq req); + + ExecResp regConfig(1: RegConfigReq req); + GetConfigResp getConfig(1: GetConfigReq req); + ExecResp setConfig(1: SetConfigReq req); + ListConfigsResp listConfigs(1: ListConfigsReq req); + + ExecResp createSnapshot(1: CreateSnapshotReq req); + ExecResp dropSnapshot(1: DropSnapshotReq req); + ListSnapshotsResp listSnapshots(1: ListSnapshotsReq req); + + AdminJobResp runAdminJob(1: AdminJobReq req); + + ExecResp addZone(1: AddZoneReq req); + ExecResp dropZone(1: DropZoneReq req); + ExecResp addHostIntoZone(1: AddHostIntoZoneReq req); + ExecResp dropHostFromZone(1: DropHostFromZoneReq req); + GetZoneResp getZone(1: GetZoneReq req); + ListZonesResp listZones(1: ListZonesReq req); + + ExecResp addGroup(1: AddGroupReq req); + ExecResp dropGroup(1: DropGroupReq req); + ExecResp addZoneIntoGroup(1: AddZoneIntoGroupReq req); + ExecResp dropZoneFromGroup(1: DropZoneFromGroupReq req); + GetGroupResp getGroup(1: GetGroupReq req); + ListGroupsResp listGroups(1: ListGroupsReq req); + + CreateBackupResp createBackup(1: CreateBackupReq req); + ExecResp restoreMeta(1: RestoreMetaReq req); + ExecResp addListener(1: AddListenerReq req); + ExecResp removeListener(1: RemoveListenerReq req); + ListListenerResp listListener(1: ListListenerReq req); + + GetStatsResp getStats(1: GetStatsReq req); + ExecResp signInFTService(1: SignInFTServiceReq req); + ExecResp signOutFTService(1: SignOutFTServiceReq req); + ListFTClientsResp listFTClients(1: ListFTClientsReq req); + + ExecResp createFTIndex(1: CreateFTIndexReq req); + ExecResp dropFTIndex(1: DropFTIndexReq req); + ListFTIndexesResp listFTIndexes(1: ListFTIndexesReq req); + + CreateSessionResp createSession(1: CreateSessionReq req); + UpdateSessionsResp updateSessions(1: UpdateSessionsReq req); + ListSessionsResp listSessions(1: ListSessionsReq req); + GetSessionResp getSession(1: GetSessionReq req); + ExecResp removeSession(1: RemoveSessionReq req); + ExecResp killQuery(1: KillQueryReq req); + + ExecResp reportTaskFinish(1: ReportTaskReq req); + + ListClusterInfoResp listCluster(1: ListClusterInfoReq req); + GetMetaDirInfoResp getMetaDirInfo(1: GetMetaDirInfoReq req); + + VerifyClientVersionResp verifyClientVersion(1: VerifyClientVersionReq req) +} diff --git a/src/interface/storage.thrift b/src/interface/storage.thrift new file mode 100644 index 00000000..be82a0ca --- /dev/null +++ b/src/interface/storage.thrift @@ -0,0 +1,911 @@ +/* vim: ft=proto + * Copyright (c) 2018 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License. + */ + +namespace cpp nebula.storage +namespace java com.vesoft.nebula.storage +namespace go nebula.storage +namespace csharp nebula.storage +namespace js nebula.storage +namespace py nebula2.storage + +include "common.thrift" +include "meta.thrift" + +/* + * + * Note: In order to support multiple languages, all strings + * have to be defined as **binary** in the thrift file + * + */ + +struct RequestCommon { + 1: optional common.SessionID session_id, + 2: optional common.ExecutionPlanID plan_id, + 3: optional bool profile_detail, +} + +struct PartitionResult { + 1: required common.ErrorCode code, + 2: required common.PartitionID part_id, + // Only valid when code is E_LEADER_CHANAGED. + 3: optional common.HostAddr leader, +} + + +struct ResponseCommon { + // Only contains the partition that returns error + 1: required list failed_parts, + // Query latency from storage service + 2: required i32 latency_in_us, + 3: optional map latency_detail_us, +} + + +/* + * + * Common types used by all services + * + */ +// Enumeration of the statistic methods +enum StatType { + SUM = 1, + COUNT = 2, + AVG = 3, + MAX = 4, + MIN = 5, +} (cpp.enum_strict) + + +// Define a statistic calculator for each source vertex +struct StatProp { + // Alias of the stats property + 1: binary alias, + // An eperssion. In most of cases, it is a reference to a specific property + 2: binary prop, + // Stats method + 3: StatType stat, +} + + +// Define an expression +struct Expr { + // Alias of the expression + 1: binary alias, + // An eperssion. It could be any valid expression, + 2: binary expr, +} + + +// Define an edge property +struct EdgeProp { + // A valid edge type + 1: common.EdgeType type, + // The list of property names. If it is empty, then all properties in value will be returned. + // Support kSrc, kType, kRank and kDst as well. + 2: list props, +} + + +// Define a vertex property +struct VertexProp { + // A valid tag id + 1: common.TagID tag, + // The list of property names. If it is empty, then all properties in value will be returned. + // Support kVid and kTag as well. + 2: list props, +} + + +enum OrderDirection { + ASCENDING = 1, + DESCENDING = 2, +} + + +struct OrderBy { + // An expression which result will be used to sort + 1: binary prop, + 2: OrderDirection direction, +} + + +enum EdgeDirection { + BOTH = 1, + IN_EDGE = 2, + OUT_EDGE = 3, +} + + +/////////////////////////////////////////////////////////// +// +// Requests, responses for the GraphStorageService +// +/////////////////////////////////////////////////////////// + +struct TraverseSpec { + // When edge_type > 0, going along the out-edge, otherwise, along the in-edge + // If the edge type list is empty, all edges will be scaned + 1: list edge_types, + // When above edge_types is not empty, edge_direction should be ignored + // When edge_types is empty, edge_direction decided which edge types will be + // followed. The default value is BOTH, which means both in-edges and out-edges + // will be traversed. If the edge_direction is IN_EDGE, then only the in-edges + // will be traversed. OUT_EDGE indicates only the out-edges will be traversed + 2: EdgeDirection edge_direction = EdgeDirection.BOTH, + // Whether to do the dedup based on the entire row. The dedup will be done on the + // neighbors of each vertex + 3: bool dedup = false, + + 4: optional list stat_props, + // A list of source vertex properties to be returned. If the list is not given, + // no prop will be returned. If an empty prop list is given, all properties + // will be returned. + 5: optional list vertex_props, + // A list of edge properties to be returned. If the list is not given, + // no prop will be returned. If an empty prop list is given, all edge properties + // will be returned. + 6: optional list edge_props, + // A list of expressions which are evaluated on each edge + 7: optional list expressions, + // A list of expressions used to sort the result + 8: optional list order_by, + // Combined with "limit", the random flag makes the result of each query different + 9: optional bool random, + // Return the top/bottom N rows for each given vertex + 10: optional i64 limit, + // If provided, only the rows satified the given expression will be returned + 11: optional binary filter, +} + + +/* + * Start of GetNeighbors section + */ +struct GetNeighborsRequest { + 1: common.GraphSpaceID space_id, + // Column names for input data. The first column name must be "_vid" + 2: list column_names, + // partId => rows + 3: map> + (cpp.template = "std::unordered_map") parts, + 4: TraverseSpec traverse_spec, + 5: optional RequestCommon common, +} + + +struct GetNeighborsResponse { + 1: required ResponseCommon result, + // The result will be returned in a dataset, which is in the following form + // + // Each row represents one source vertex and its neighbors + // + // Here is the layout of the dataset + // =========================================================================================== + // | _vid | stats_column | tag_column | ... | edge_column | ... | expr_column | + // |=========================================================================================| + // | string | list | list | ... | list> | ... | list> | + // |-----------------------------------------------------------------------------------------| + // | ..... | + // =========================================================================================== + // + // The first column in the dataset stores the source vertex id. The column name + // is "_vid". The value should be type of string + // + // The second column contains the statistic result for the vertex if stat_props + // in the request is not empty. The column name is in the following format + // + // "_stats:::..." + // + // Basically the column name contains the statistic alias names, separated by + // the ":". The value in this column is a list of Values, which are corresponding + // to the properties specified in the column name. + // + // Starting from the third column, source vertex properties will be returned if the + // GetNeighborsRequest::vertex_props is not empty. Each column contains properties + // from one tag. The column name will be in the following format in the same order + // which specified in VertexProp + // + // "_tag::::..." + // + // The value of each tag column is a list of Values, which follows the order of the + // property names specified in the above column name. If a vertex does not have + // the specific tag, the value will be empty value + // + // Columns after the tag columns are edge columns. One column per edge type. The + // column name is in the following format in the same order which specified in EdgeProp + // + // "_edge::::..." + // + // The value of each edge column is list>, which represents multiple + // edges. For each edge, the list of Values will follow the order of the property + // names specified in the column name. If a vertex does not have any edge for a + // specific edge type, the value for that column will be empty value + // + // The last column is the expression column, if the GetNeighborsRequest::expressions + // is not empty. The column name is in the format of this + // + // "_expr:::..." + // + 2: optional common.DataSet vertices, +} +/* + * End of GetNeighbors section + */ + + +// +// Response for data modification requests +// +struct ExecResponse { + 1: required ResponseCommon result, +} + + +/* + * Start of GetProp section + */ +struct GetPropRequest { + 1: common.GraphSpaceID space_id, + 2: map> + (cpp.template = "std::unordered_map") parts, + // Based on whether to get the vertex properties or to get the edge properties, + // exactly one of the vertex_props or edge_props must be set. If an empty list is given + // then all properties of the vertex or the edge will be returned in tagId/edgeType ascending order + 3: optional list vertex_props, + 4: optional list edge_props, + // A list of expressions with alias + 5: optional list expressions, + // Whether to do the dedup based on the entire result row + 6: bool dedup = false, + // List of expressions used by the order-by clause + 7: optional list order_by, + 8: optional i64 limit, + // If a filter is provided, only vertices that are satisfied the filter + // will be returned + 9: optional binary filter, + 10: optional RequestCommon common, + +} + + +struct GetPropResponse { + 1: ResponseCommon result, + // The result will be returned in a dataset, which is in the following form + // + // Each row represents properties for one vertex or one edge + // + // Here is the layout of the dataset + // ==================================== + // | alias1 | alias2 | alias3 | ... | + // |==================================| + // | Value | Value | Value | ... | + // |----------------------------------| + // | ..... | + // ==================================== + // + // Each column represents one peoperty. the column name is in the form of "tag_name.prop_alias" + // or "edge_type_name.prop_alias" in the same order which specified in VertexProp or EdgeProp + // + // If the request is to get tag prop, the first column will **always** be the vid, + // and the first column name is "_vid". + // + // If the vertex or the edge does NOT have the given property, the value will be an empty value + 2: optional common.DataSet props, +} +/* + * End of GetProp section + */ + + +/* + * Start of AddVertices section + */ +struct NewTag { + 1: common.TagID tag_id, + 2: list props, +} + + +struct NewVertex { + 1: common.Value id, + 2: list tags, +} + + +struct EdgeKey { + 1: common.Value src, + // When edge_type > 0, it's an out-edge, otherwise, it's an in-edge + // When query edge props, the field could be unset. + 2: common.EdgeType edge_type, + 3: common.EdgeRanking ranking, + 4: common.Value dst, +} + + +struct NewEdge { + 1: EdgeKey key, + 2: list props, +} + + +struct AddVerticesRequest { + 1: common.GraphSpaceID space_id, + // partId => vertices + 2: map> + (cpp.template = "std::unordered_map") parts, + // A map from TagID -> list of prop_names + // The order of the property names should match the data order specified + // in the NewVertex.NewTag.props + 3: map> + (cpp.template = "std::unordered_map") prop_names, + // if ture, when (vertexID,tagID) already exists, do nothing + 4: bool if_not_exists, + 5: optional RequestCommon common, +} + +struct AddEdgesRequest { + 1: common.GraphSpaceID space_id, + // partId => edges + 2: map>( + cpp.template = "std::unordered_map") parts, + // A list of property names. The order of the property names should match + // the data order specified in the NewEdge.props + 3: list prop_names, + // if ture, when edge already exists, do nothing + 4: bool if_not_exists, + 5: optional RequestCommon common, +} + +/* + * End of AddVertices section + */ + + +/* + * Start of DeleteVertex section + */ +struct DeleteVerticesRequest { + 1: common.GraphSpaceID space_id, + // partId => vertexId + 2: map> + (cpp.template = "std::unordered_map") parts, + 3: optional RequestCommon common, +} + + +struct DeleteEdgesRequest { + 1: common.GraphSpaceID space_id, + // partId => edgeKeys + 2: map> + (cpp.template = "std::unordered_map") parts, + 3: optional RequestCommon common, +} +/* + * End of DeleteVertex section + */ + +struct DelTags { + 1: common.Value id, + 2: list tags, +} + +struct DeleteTagsRequest { + 1: common.GraphSpaceID space_id, + // partId => vertexId + 2: map> + (cpp.template = "std::unordered_map") parts, + 3: optional RequestCommon common, +} +// Response for update requests +struct UpdateResponse { + 1: required ResponseCommon result, + // The result will be returned in a dataset, which is in the following form + // + // The name of the first column is "_inserted". It has a boolean value. It's + // TRUE if insertion happens + // Starting from the second column, it's the all returned properties, one column + // per peoperty. If there is no given property, the value will be a NULL + 2: optional common.DataSet props, +} + + +struct UpdatedProp { + 1: required binary name, // property name + 2: required binary value, // new value (encoded expression) +} + +/* + * Start of UpdateVertex section + */ +struct UpdateVertexRequest { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + 3: common.Value vertex_id, + 4: required common.TagID tag_id + 5: list updated_props, + 6: optional bool insertable = false, + // A list of kSrcProperty expressions, support kVid and kTag + 7: optional list return_props, + // If provided, the update happens only when the condition evaluates true + 8: optional binary condition, + 9: optional RequestCommon common, +} +/* + * End of UpdateVertex section + */ + + +/* + * Start of UpdateEdge section + */ +struct UpdateEdgeRequest { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + 3: EdgeKey edge_key, + 4: list updated_props, + 5: optional bool insertable = false, + // A list of kEdgeProperty expressions, support kSrc, kType, kRank and kDst + 6: optional list return_props, + // If provided, the update happens only when the condition evaluates true + 7: optional binary condition, + 8: optional RequestCommon common, +} +/* + * End of UpdateEdge section + */ + + +/* + * Start of GetUUID section + */ +struct GetUUIDReq { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + 3: binary name, + 4: optional RequestCommon common, +} + + +struct GetUUIDResp { + 1: required ResponseCommon result, + 2: common.Value id, +} +/* + * End of GetUUID section + */ + + +/* + * Start of Index section + */ +struct LookupIndexResp { + 1: required ResponseCommon result, + // The result will be returned in a dataset, which is in the following form + // + // When looking up the vertex index, each row represents one vertex and its + // properties; when looking up the edge index, each row represents one edge + // and its properties. + // + // Each column represents one peoperty. the column name is in the form of "tag_name.prop_alias" + // or "edge_type_name.prop_alias" in the same order which specified in return_columns of request + 2: optional common.DataSet data, +} + +enum ScanType { + PREFIX = 1, + RANGE = 2, +} (cpp.enum_strict) + +struct IndexColumnHint { + 1: binary column_name, + // If scan_type == PREFIX, using begin_value to handler prefix. + // Else using begin_value and end_value to handler ranger. + 2: ScanType scan_type, + 3: common.Value begin_value, + 4: common.Value end_value, + // When `columnhint` means ` >= begin_value`, `include_begin` is true + // and include_end is similar + 5: bool include_begin = true, + 6: bool include_end = false, +} + +struct IndexQueryContext { + 1: common.IndexID index_id, + // filter is an encoded expression of where clause. + // Used for secondary filtering from a result set + 2: binary filter, + // There are two types of scan: 1, range scan; 2, match scan (prefix); + // When the field size of index_id IndexItem is not zero, the columns_hints are not allowed + // to be empty, At least one index column must be hit. + // When the field size of index_id IndexItem is zero, the columns_hints must be empty. + 3: list column_hints, +} + + +struct IndexSpec { + // In order to union multiple indices, multiple index hints are allowed + 1: required list contexts, + 2: common.SchemaID schema_id, +} + + +struct LookupIndexRequest { + 1: required common.GraphSpaceID space_id, + 2: required list parts, + 3: IndexSpec indices, + // The list of property names. Should not be empty. + // Support kVid and kTag for vertex, kSrc, kType, kRank and kDst for edge. + 4: optional list return_columns, + 5: optional RequestCommon common, + // max row count of each partition in this response + 6: optional i64 limit, +} + + +// This request will make the storage lookup the index first, then traverse +// to the neighbor nodes from the index results. So it is the combination +// of lookupIndex() and getNeighbors() +struct LookupAndTraverseRequest { + 1: required common.GraphSpaceID space_id, + 2: required list parts, + 3: IndexSpec indices, + 4: TraverseSpec traverse_spec, + 5: optional RequestCommon common, +} + +/* + * End of Index section + */ + +struct ScanVertexRequest { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + // start key of this block + 3: optional binary cursor, + 4: VertexProp return_columns, + // max row count of tag in this response + 5: i64 limit, + // only return data in time range [start_time, end_time) + 6: optional i64 start_time, + 7: optional i64 end_time, + 8: optional binary filter, + // when storage enable multi versions and only_latest_version is true, only return latest version. + // when storage disable multi versions, just use the default value. + 9: bool only_latest_version = false, + // if set to false, forbid follower read + 10: bool enable_read_from_follower = true, + 11: optional RequestCommon common, +} + +struct ScanVertexResponse { + 1: required ResponseCommon result, + // The data will return as a dataset. The format is as follows: + // Each column represents one property. the column name is in the form of "tag_name.prop_alias" + // in the same order which specified in VertexProp in request. + 2: common.DataSet vertex_data, + 3: bool has_next, + // next start key of scan, only valid when has_next is true + 4: optional binary next_cursor, +} + +struct ScanEdgeRequest { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + // start key of this block + 3: optional binary cursor, + 4: EdgeProp return_columns, + // max row count of edge in this response + 5: i64 limit, + // only return data in time range [start_time, end_time) + 6: optional i64 start_time, + 7: optional i64 end_time, + 8: optional binary filter, + // when storage enable multi versions and only_latest_version is true, only return latest version. + // when storage disable multi versions, just use the default value. + 9: bool only_latest_version = false, + // if set to false, forbid follower read + 10: bool enable_read_from_follower = true, + 11: optional RequestCommon common, +} + +struct ScanEdgeResponse { + 1: required ResponseCommon result, + // The data will return as a dataset. The format is as follows: + // Each column represents one property. the column name is in the form of "edge_name.prop_alias" + // in the same order which specified in EdgeProp in requesss. + 2: common.DataSet edge_data, + 3: bool has_next, + // next start key of scan, only valid when has_next is true + 4: optional binary next_cursor, +} + +struct TaskPara { + 1: common.GraphSpaceID space_id, + 2: optional list parts, + 3: optional list task_specfic_paras +} + +struct AddAdminTaskRequest { + // rebuild index / flush / compact / statis + 1: meta.AdminCmd cmd + 2: i32 job_id + 3: i32 task_id + 4: TaskPara para + 5: optional i32 concurrency +} + +struct StopAdminTaskRequest { + 1: i32 job_id + 2: i32 task_id +} + +service GraphStorageService { + GetNeighborsResponse getNeighbors(1: GetNeighborsRequest req) + + // Get vertex or edge properties + GetPropResponse getProps(1: GetPropRequest req); + + ExecResponse addVertices(1: AddVerticesRequest req); + ExecResponse addEdges(1: AddEdgesRequest req); + + ExecResponse deleteEdges(1: DeleteEdgesRequest req); + ExecResponse deleteVertices(1: DeleteVerticesRequest req); + ExecResponse deleteTags(1: DeleteTagsRequest req); + + UpdateResponse updateVertex(1: UpdateVertexRequest req); + UpdateResponse updateEdge(1: UpdateEdgeRequest req); + + ScanVertexResponse scanVertex(1: ScanVertexRequest req) + ScanEdgeResponse scanEdge(1: ScanEdgeRequest req) + + GetUUIDResp getUUID(1: GetUUIDReq req); + + // Interfaces for edge and vertex index scan + LookupIndexResp lookupIndex(1: LookupIndexRequest req); + + GetNeighborsResponse lookupAndTraverse(1: LookupAndTraverseRequest req); + + UpdateResponse chainUpdateEdge(1: UpdateEdgeRequest req); + ExecResponse chainAddEdges(1: AddEdgesRequest req); +} + + +////////////////////////////////////////////////////////// +// +// Requests, responses for the StorageAdminService +// +////////////////////////////////////////////////////////// +// Common response for admin methods +struct AdminExecResp { + 1: required ResponseCommon result, + 2: optional meta.StatsItem stats, +} + + +struct TransLeaderReq { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + 3: common.HostAddr new_leader, +} + + +struct AddPartReq { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + 3: bool as_learner, + 4: list peers, +} + + +struct AddLearnerReq { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + 3: common.HostAddr learner, +} + + +struct RemovePartReq { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, +} + + +struct MemberChangeReq { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + 3: common.HostAddr peer, + // true means add a peer, false means remove a peer. + 4: bool add, +} + + +struct CatchUpDataReq { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + 3: common.HostAddr target, +} + +struct GetLeaderReq { +} + +struct CreateCPRequest { + 1: common.GraphSpaceID space_id, + 2: binary name, +} + + +struct DropCPRequest { + 1: common.GraphSpaceID space_id, + 2: binary name, +} + + +enum EngineSignType { + BLOCK_ON = 1, + BLOCK_OFF = 2, +} + + +struct BlockingSignRequest { + 1: common.GraphSpaceID space_id, + 2: required EngineSignType sign, +} + + +struct GetLeaderPartsResp { + 1: required ResponseCommon result, + 2: map> ( + cpp.template = "std::unordered_map") leader_parts; +} + + +struct CheckPeersReq { + 1: common.GraphSpaceID space_id, + 2: common.PartitionID part_id, + 3: list peers, +} + + +struct RebuildIndexRequest { + 1: common.GraphSpaceID space_id, + 2: list parts, + 3: common.IndexID index_id, +} + +struct CreateCPResp { + 1: required ResponseCommon result, + 2: list info, +} + +struct ListClusterInfoResp { + 1: required ResponseCommon result, + 2: common.DirInfo dir, +} + +struct ListClusterInfoReq { +} + +service StorageAdminService { + // Interfaces for admin operations + AdminExecResp transLeader(1: TransLeaderReq req); + AdminExecResp addPart(1: AddPartReq req); + AdminExecResp addLearner(1: AddLearnerReq req); + AdminExecResp removePart(1: RemovePartReq req); + AdminExecResp memberChange(1: MemberChangeReq req); + AdminExecResp waitingForCatchUpData(1: CatchUpDataReq req); + + // Interfaces for nebula cluster checkpoint + CreateCPResp createCheckpoint(1: CreateCPRequest req); + AdminExecResp dropCheckpoint(1: DropCPRequest req); + AdminExecResp blockingWrites(1: BlockingSignRequest req); + + // Interfaces for rebuild index + AdminExecResp rebuildTagIndex(1: RebuildIndexRequest req); + AdminExecResp rebuildEdgeIndex(1: RebuildIndexRequest req); + + // Return all leader partitions on this host + GetLeaderPartsResp getLeaderParts(1: GetLeaderReq req); + // Return all peers + AdminExecResp checkPeers(1: CheckPeersReq req); + + AdminExecResp addAdminTask(1: AddAdminTaskRequest req); + AdminExecResp stopAdminTask(1: StopAdminTaskRequest req); + + ListClusterInfoResp listClusterInfo(1: ListClusterInfoReq req); +} + + +////////////////////////////////////////////////////////// +// +// Requests, responses for the GeneralStorageService +// +////////////////////////////////////////////////////////// +struct KVGetRequest { + 1: common.GraphSpaceID space_id, + 2: map>( + cpp.template = "std::unordered_map") parts, + // When return_partly is true and some of the keys not found, will return the keys + // which exist + 3: bool return_partly +} + + +struct KVGetResponse { + 1: required ResponseCommon result, + 2: map(cpp.template = "std::unordered_map") key_values, +} + + +struct KVPutRequest { + 1: common.GraphSpaceID space_id, + // part -> key/value + 2: map>( + cpp.template = "std::unordered_map") parts, +} + + +struct KVRemoveRequest { + 1: common.GraphSpaceID space_id, + // part -> key + 2: map>( + cpp.template = "std::unordered_map") parts, +} + + +service GeneralStorageService { + // Interfaces for key-value storage + KVGetResponse get(1: KVGetRequest req); + ExecResponse put(1: KVPutRequest req); + ExecResponse remove(1: KVRemoveRequest req); +} + +////////////////////////////////////////////////////////// +// +// Requests, responses for the InternalStorageService +// +////////////////////////////////////////////////////////// + +// transaction request +struct InternalTxnRequest { + 1: i64 txn_id, + 2: map term_of_parts, + 3: optional AddEdgesRequest add_edge_req, + 4: optional UpdateEdgeRequest upd_edge_req, + 5: optional map>( + cpp.template = "std::unordered_map") edge_ver, +} + + +struct ChainAddEdgesRequest { + 1: common.GraphSpaceID space_id, + // partId => edges + 2: map>( + cpp.template = "std::unordered_map") parts, + // A list of property names. The order of the property names should match + // the data order specified in the NewEdge.props + 3: list prop_names, + // if ture, when edge already exists, do nothing + 4: bool if_not_exists, + // 5: map term_of_parts, + 5: i64 term + 6: optional i64 edge_version + // 6: optional map>( + // cpp.template = "std::unordered_map") edge_ver, +} + + +struct ChainUpdateEdgeRequest { + 1: UpdateEdgeRequest update_edge_request, + 2: i64 term, + 3: optional i64 edge_version + 4: common.GraphSpaceID space_id, + 5: required list parts, +} + +service InternalStorageService { + ExecResponse chainAddEdges(1: ChainAddEdgesRequest req); + UpdateResponse chainUpdateEdge(1: ChainUpdateEdgeRequest req); +}