/* * Copyright 2021 4Paradigm * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ syntax = "proto2"; import "type.proto"; import "common.proto"; import "tablet.proto"; import "sql_procedure.proto"; package openmldb.nameserver; option cc_generic_services = true; option java_package = "com._4paradigm.openmldb.proto"; option java_outer_classname = "NS"; enum ServerMode { kNORMAL = 0; kLEADER = 1; kFOLLOWER = 2; } enum ClusterStatus { kClusterHealthy = 0; kClusterOffline = 1; kClusterRemove = 2; } message PartitionMeta { required string endpoint = 1; required bool is_leader = 2; optional bool is_alive = 3 [default = true]; optional uint64 offset = 4; optional uint64 record_cnt = 5; optional uint64 record_byte_size = 6; optional bool tablet_has_partition = 7 [default = true]; optional uint64 diskused = 8 [default = 0]; optional uint32 remote_tid = 9 [default = 4294967295]; // 4294967295 is UINT32 max value optional string alias = 10; } message TermPair { required uint64 term = 1; required uint64 offset = 2; } message TablePartition { required uint32 pid = 1; repeated PartitionMeta partition_meta = 2; repeated TermPair term_offset = 3; optional uint64 record_cnt = 4; optional uint64 record_byte_size = 5; optional uint64 diskused = 6 [default = 0]; repeated PartitionMeta remote_partition_meta = 7; } message UpdateTTLRequest { optional string name = 1; optional string db = 2 [default = ""]; optional string index_name = 3; optional openmldb.common.TTLSt ttl_desc = 4; } message UpdateTTLResponse { optional int32 code = 1; optional string msg = 2; } message OfflineTableInfo { required string path = 1; required string format = 2; optional bool deep_copy = 3 [default = true, deprecated = true]; map options = 4; repeated string symbolic_paths = 5; } message TableInfo { optional string name = 1; optional uint32 seg_cnt = 2 [default = 8]; repeated TablePartition table_partition = 3; optional uint32 tid = 4; optional uint32 partition_num = 5; optional uint32 replica_num = 6; // contain the leader optional openmldb.type.CompressType compress_type = 7 [default = kNoCompress]; optional uint32 key_entry_max_height = 8; repeated openmldb.common.ColumnDesc column_desc = 9; repeated openmldb.common.ColumnKey column_key = 10; repeated openmldb.common.ColumnDesc added_column_desc = 11; optional uint32 format_version = 12 [default = 1, deprecated = true]; optional string db = 13 [default = ""]; repeated string partition_key = 14; repeated common.VersionPair schema_versions = 15; optional OfflineTableInfo offline_table_info = 16; optional openmldb.common.StorageMode storage_mode = 17 [default = kMemory]; optional uint32 base_table_tid = 18 [default = 0]; } message CreateTableRequest { required TableInfo table_info = 1; optional ZoneInfo zone_info = 2; optional openmldb.api.TaskInfo task_info = 3; optional bool create_if_not_exist = 4 [default = false]; } message DropTableRequest { required string name = 1; optional ZoneInfo zone_info = 2; optional openmldb.api.TaskInfo task_info = 3; optional string db = 4 [default = ""]; } message TruncateTableRequest { optional string name = 1; optional string db = 2; } message TruncateTableResponse { optional int32 code = 1; optional string msg = 2; } message LoadTableRequest { optional string name = 1; optional string endpoint = 2; optional uint32 pid = 3; optional ZoneInfo zone_info = 4; optional openmldb.api.TaskInfo task_info = 5; optional string db = 6 [default = ""]; } message CreateTableInfoRequest { optional TableInfo table_info = 1; optional ZoneInfo zone_info = 2; } message ShowTableRequest { optional string name = 1; optional string db = 2 [default = ""]; optional bool show_all = 3 [default = false]; } message ShowTableResponse { repeated TableInfo table_info = 1; required int32 code = 2; optional string msg = 3; } message MakeSnapshotNSRequest { required string name = 1; required uint32 pid = 2; optional uint64 offset = 3; optional string db = 4 [default=""]; } message AddReplicaData { required string name = 1; required uint32 pid = 2; optional string endpoint = 3; optional uint32 remote_tid = 4; //for remote optional string alias = 5; //for remote optional TablePartition table_partition = 6; //for remote optional string db = 7 [default = ""]; } message AddReplicaNSRequest { required string name = 1; required uint32 pid = 2; required string endpoint = 3; repeated uint32 pid_group = 4; repeated string endpoint_group = 5; //for remote optional ZoneInfo zone_info = 6; //for remote optional openmldb.api.TaskInfo task_info = 7; //for remote optional string db = 8 [default = ""]; } message Pair { required string key = 1; required string value = 2; } message ConfSetRequest { required Pair conf = 1; } message ConfGetRequest {} message ConfGetResponse { required int32 code = 1; optional string msg = 2; repeated Pair conf = 3; } message ChangeLeaderRequest { required string name = 1; required uint32 pid = 2; optional string candidate_leader = 3; optional string db = 4 [default = ""]; } message OfflineEndpointRequest { required string endpoint = 1; optional uint32 concurrency = 2; } message RecoverEndpointRequest { required string endpoint = 1; optional bool need_restore = 2; optional uint32 concurrency = 3; } message GeneralResponse { required int32 code = 1; optional string msg = 2; } message CreateTableInfoResponse { optional TableInfo table_info = 1; required int32 code = 2; optional string msg = 3; } message ShowTabletRequest {} message AddTableFieldRequest { optional string name = 1; optional openmldb.common.ColumnDesc column_desc = 2; optional string db = 3 [default = ""]; } message TabletStatus { optional string endpoint = 1; optional string state = 2; optional uint64 age = 3; optional string real_endpoint = 4; } message ShowTabletResponse { repeated TabletStatus tablets = 1; optional int32 code = 2; optional string msg = 3; } message RecoverTableRequest { required string name = 1; required uint32 pid = 2; required string endpoint = 3; optional string db = 4 [default = ""]; } message DelReplicaNSRequest { required string name = 1; required uint32 pid = 2; required string endpoint = 3; repeated uint32 pid_group = 4; optional string db = 5 [default = ""]; } message MigrateRequest { required string src_endpoint = 1; required string name = 2; repeated uint32 pid = 3; required string des_endpoint = 4; optional string db = 5 [default = ""]; } message MigrateInfo { optional string src_endpoint = 1; optional string des_endpoint = 2; } message EndpointStatusData { optional string endpoint = 1; optional bool is_leader = 2; optional bool is_alive = 3; } message RecoverTableData { optional string endpoint = 1; optional uint64 offset_delta = 2; optional bool is_leader = 3; optional uint32 concurrency = 4; } message CreateTableData { optional string alias = 1; optional TableInfo table_info = 2; optional TableInfo remote_table_info = 3; } message ChangeLeaderData { optional string name = 1; optional uint32 tid = 2; optional uint32 pid = 3; optional uint64 term = 4; optional uint64 offset = 5; optional string leader = 6; repeated string follower = 7; optional string candidate_leader = 8; repeated openmldb.common.EndpointAndTid remote_follower = 9; optional string db = 10 [default = ""]; } message OPStatus { required uint64 op_id = 1; required string op_type = 2; required string status = 3; required uint64 start_time = 4; required uint64 end_time = 5; required string task_type = 6; optional string name = 7; optional uint32 pid = 8; optional int32 for_replica_cluster = 9 [default = 0]; optional string db = 10 [default = ""]; } message GetTablePartitionRequest { optional string name = 1; optional uint32 pid = 2; optional string db = 3 [default = ""]; } message GetTablePartitionResponse { optional int32 code = 1; optional string msg = 2; optional TablePartition table_partition = 3; } message SetTablePartitionRequest { optional string name = 1; optional TablePartition table_partition = 2; optional string db = 3 [default = ""]; } message UpdateTableAliveRequest { optional string name = 1; optional string endpoint = 2; optional uint32 pid = 3; optional bool is_alive = 4; optional string db = 5 [default = ""]; } message ShowOPStatusRequest { optional string name = 1; optional uint32 pid = 2; optional string db = 3; optional uint64 op_id = 4; } message DeleteOPRequest { optional string db = 1; optional uint64 op_id = 2; optional openmldb.api.TaskStatus status = 3; } message ConnectZKRequest {} message DisConnectZKRequest {} message ShowOPStatusResponse { optional int32 code = 1; optional string msg = 2; repeated OPStatus op_status = 3; } message CancelOPRequest { optional uint64 op_id = 1; } message ClusterAddress { optional string zk_endpoints = 1; optional string zk_path = 2; optional string alias = 3; optional string zk_auth_schema = 4; optional string zk_cert = 5; } message GeneralRequest {} message ClusterAddAge { optional ClusterAddress replica = 1; optional uint64 age = 2; optional string state = 3; } message ShowReplicaClusterResponse { repeated ClusterAddAge replicas = 1; optional int32 code = 2; optional string msg = 3; } message RemoveReplicaOfRequest { optional string alias = 1; } message ReplicaClusterByNsRequest { optional ZoneInfo zone_info = 1; } message ZoneInfo { optional string zone_name = 1; optional string replica_alias = 2; optional uint64 zone_term = 3; optional ServerMode mode = 4; } message AddReplicaClusterByNsResponse { repeated TabletStatus tablets = 1; repeated TableInfo table_info = 2; required int32 code = 3; optional string msg = 4; } message SwitchModeRequest { optional ServerMode sm = 1; } message SyncTableRequest { optional string name = 1; optional string cluster_alias = 2; optional uint32 pid = 3; optional string db = 4 [default = ""]; } message SetSdkEndpointRequest { optional string server_name = 1; optional string sdk_endpoint = 2; } message AddIndexMeta { optional string name = 1; optional uint32 pid = 2; optional openmldb.common.ColumnKey column_key = 3; optional uint32 idx = 4; optional string db = 5 [default = ""]; optional bool skip_data = 6 [default = false]; repeated openmldb.common.ColumnKey column_keys = 7; } message AddIndexRequest { optional string name = 1; optional openmldb.common.ColumnKey column_key = 2; optional string db = 3 [default = ""]; repeated openmldb.common.ColumnDesc cols = 4; repeated openmldb.common.ColumnKey column_keys = 5; optional bool skip_load_data = 6 [default = false]; } message DeleteIndexRequest { optional string table_name = 1; optional string idx_name = 2; optional string db_name = 3 [default = ""]; } message CreateDatabaseRequest { optional string db = 1; optional bool if_not_exists = 2 [default = false]; optional ZoneInfo zone_info = 3; } message UseDatabaseRequest { optional string db = 1; } message ShowDatabaseResponse { optional int32 code = 1; optional string msg = 2; repeated string db = 3; } message DropDatabaseRequest { optional string db = 1; optional ZoneInfo zone_info = 2; } message ShowSdkEndpointRequest {} message ShowSdkEndpointResponse { repeated TabletStatus tablets = 1; optional int32 code = 2; optional string msg = 3; } message ShowCatalogRequest {} message ShowCatalogResponse { repeated openmldb.common.CatalogInfo catalog = 1; optional int32 code = 2; optional string msg = 3; } message CreateFunctionRequest { optional openmldb.common.ExternalFun fun = 1; } message CreateFunctionResponse { optional int32 code = 1; optional string msg = 2; } message DropFunctionRequest { optional string name = 1; optional bool if_exists = 2; } message DropFunctionResponse { optional int32 code = 1; optional string msg = 2; } message ShowFunctionRequest { optional string name = 1; } message ShowFunctionResponse { optional int32 code = 1; optional string msg = 2; repeated openmldb.common.ExternalFun fun = 3; } message TableIndex { optional string db = 1; optional string name = 2; repeated openmldb.common.ColumnKey column_key = 3; } message PutUserRequest { required string host = 1; required string name = 2; required string password = 3; } message DeleteUserRequest { required string host = 1; required string name = 2; } enum PrivilegeLevel { NO_PRIVILEGE = 0; PRIVILEGE = 1; PRIVILEGE_WITH_GRANT_OPTION = 2; } message PutPrivilegeRequest { repeated string grantee = 1; repeated string privilege = 2; optional string target_type = 3; required string database = 4; required string target = 5; required bool is_all_privileges = 6; required PrivilegeLevel privilege_level = 7; } message DeploySQLRequest { optional openmldb.api.ProcedureInfo sp_info = 3; repeated TableIndex index = 4; } message DeploySQLResponse { optional int32 code = 1; optional string msg = 2; optional uint64 op_id = 3; } service NameServer { rpc CreateTable(CreateTableRequest) returns (GeneralResponse); rpc DropTable(DropTableRequest) returns (GeneralResponse); rpc TruncateTable(TruncateTableRequest) returns (TruncateTableResponse); rpc ShowTablet(ShowTabletRequest) returns (ShowTabletResponse); rpc ShowTable(ShowTableRequest) returns (ShowTableResponse); rpc MakeSnapshotNS(MakeSnapshotNSRequest) returns (GeneralResponse); rpc AddReplicaNS(AddReplicaNSRequest) returns (GeneralResponse); rpc DelReplicaNS(DelReplicaNSRequest) returns (GeneralResponse); rpc ShowOPStatus(ShowOPStatusRequest) returns (ShowOPStatusResponse); rpc CancelOP(CancelOPRequest) returns (GeneralResponse); rpc DeleteOP(DeleteOPRequest) returns (GeneralResponse); rpc ConfSet(ConfSetRequest) returns (GeneralResponse); rpc ConfGet(ConfGetRequest) returns (ConfGetResponse); rpc ChangeLeader(ChangeLeaderRequest) returns (GeneralResponse); rpc OfflineEndpoint(OfflineEndpointRequest) returns (GeneralResponse); rpc Migrate(MigrateRequest) returns (GeneralResponse); rpc RecoverTable(RecoverTableRequest) returns (GeneralResponse); rpc RecoverEndpoint(RecoverEndpointRequest) returns (GeneralResponse); rpc ConnectZK(ConnectZKRequest) returns (GeneralResponse); rpc DisConnectZK(DisConnectZKRequest) returns (GeneralResponse); rpc SetTablePartition(SetTablePartitionRequest) returns (GeneralResponse); rpc GetTablePartition(GetTablePartitionRequest) returns (GetTablePartitionResponse); rpc UpdateTTL(UpdateTTLRequest) returns (UpdateTTLResponse); rpc UpdateTableAliveStatus(UpdateTableAliveRequest) returns (GeneralResponse); rpc AddTableField(AddTableFieldRequest) returns (GeneralResponse); rpc AddReplicaCluster(ClusterAddress) returns (GeneralResponse); rpc ShowReplicaCluster(GeneralRequest) returns (ShowReplicaClusterResponse); rpc RemoveReplicaCluster(RemoveReplicaOfRequest) returns (GeneralResponse); rpc AddReplicaClusterByNs(ReplicaClusterByNsRequest) returns (AddReplicaClusterByNsResponse); rpc RemoveReplicaClusterByNs(ReplicaClusterByNsRequest) returns (GeneralResponse); rpc SwitchMode(SwitchModeRequest) returns (GeneralResponse); rpc GetTaskStatus(openmldb.api.TaskStatusRequest) returns (openmldb.api.TaskStatusResponse); rpc DeleteOPTask(openmldb.api.DeleteTaskRequest) returns (openmldb.api.GeneralResponse); rpc CreateTableInfo(CreateTableInfoRequest) returns (CreateTableInfoResponse); rpc CreateTableInfoSimply(CreateTableInfoRequest) returns (CreateTableInfoResponse); rpc LoadTable(LoadTableRequest) returns (GeneralResponse); rpc AddReplicaNSFromRemote(AddReplicaNSRequest) returns (GeneralResponse); rpc SyncTable(SyncTableRequest) returns (GeneralResponse); rpc AddIndex(AddIndexRequest) returns (GeneralResponse); rpc DeleteIndex(DeleteIndexRequest) returns (GeneralResponse); rpc CreateDatabase(CreateDatabaseRequest) returns (GeneralResponse); rpc UseDatabase(UseDatabaseRequest) returns (GeneralResponse); rpc ShowDatabase(GeneralRequest) returns (ShowDatabaseResponse); rpc DropDatabase(DropDatabaseRequest) returns (GeneralResponse); rpc SetSdkEndpoint(SetSdkEndpointRequest) returns (GeneralResponse); rpc ShowSdkEndpoint(ShowSdkEndpointRequest) returns (ShowSdkEndpointResponse); rpc ShowCatalog(ShowCatalogRequest) returns (ShowCatalogResponse); rpc UpdateOfflineTableInfo(TableInfo) returns (GeneralResponse); rpc CreateFunction(CreateFunctionRequest) returns (CreateFunctionResponse); rpc DropFunction(DropFunctionRequest) returns (DropFunctionResponse); rpc ShowFunction(ShowFunctionRequest) returns (ShowFunctionResponse); // sql procedure interfaces rpc CreateProcedure(openmldb.api.CreateProcedureRequest) returns (GeneralResponse); rpc DropProcedure(openmldb.api.DropProcedureRequest) returns (GeneralResponse); rpc ShowProcedure(openmldb.api.ShowProcedureRequest) returns (openmldb.api.ShowProcedureResponse); rpc DeploySQL(DeploySQLRequest) returns (DeploySQLResponse); // user related interfaces rpc PutUser(PutUserRequest) returns (GeneralResponse); rpc DeleteUser(DeleteUserRequest) returns (GeneralResponse); // authz related interfaces rpc PutPrivilege(PutPrivilegeRequest) returns (GeneralResponse); }