Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a db management client for later job management #305

Merged
merged 29 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "deps/tugraph-db-client-java"]
path = deps/tugraph-db-client-java
url = https://github.com/TuGraph-family/tugraph-db-client-java.git
[submodule "deps/tugraph-db-management"]
path = deps/tugraph-db-management
url = https://github.com/TuGraph-family/tugraph-db-management.git
1 change: 1 addition & 0 deletions deps/tugraph-db-management
Submodule tugraph-db-management added at 5a1fc2
7 changes: 5 additions & 2 deletions src/BuildLGraphServer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ endif ()
include(cmake/GenerateProtobuf.cmake)
GenerateProtobufCpp(${CMAKE_CURRENT_LIST_DIR}/protobuf
PROTO_SRCS PROTO_HEADERS
${CMAKE_CURRENT_LIST_DIR}/protobuf/ha.proto)
${CMAKE_CURRENT_LIST_DIR}/protobuf/ha.proto
${CMAKE_CURRENT_LIST_DIR}/protobuf/tugraph_db_management.proto)

include_directories(${DEPS_INCLUDE_DIR})

Expand All @@ -44,14 +45,16 @@ add_library(${TARGET_SERVER_LIB} STATIC
server/lgraph_server.cpp
server/state_machine.cpp
server/ha_state_machine.cpp
server/db_management_client.cpp
import/import_online.cpp
import/import_v2.cpp
import/import_v3.cpp
restful/server/rest_server.cpp
restful/server/stdafx.cpp
http/http_server.cpp
http/import_manager.cpp
http/import_task.cpp)
http/import_task.cpp
${PROTO_SRCS})

target_compile_options(${TARGET_SERVER_LIB} PUBLIC
-DGFLAGS_NS=${GFLAGS_NS}
Expand Down
137 changes: 137 additions & 0 deletions src/protobuf/tugraph_db_management.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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";
package com.antgroup.tugraph;

option cc_generic_services = true;
option java_outer_classname = "TuGraphDBManagement";

enum ResponseCode {
SUCCESS = 0;
FAILED = 1;
}

message Job {
required string db_id = 1;
required int32 job_id = 2;
required int64 start_time = 3;
required string period = 4;
required string procedure_name = 5;
required string procedure_type = 6;
required string status = 7;
required int64 runtime = 8;
required string user = 9;
required int64 create_time = 10;
}

message JobResult {
required int32 job_id = 1;
required string result = 2;
}

message CreateJobRequest {
required int64 start_time = 1;
required string period = 2;
required string procedure_name = 3;
required string procedure_type = 4;
required string user = 5;
required int64 create_time = 6;
}

message CreateJobResponse {
required int32 job_id = 1;
required ResponseCode response_code = 2;
}

message ReadJobRequest {
optional int32 job_id = 1;
}

message ReadJobResponse {
repeated Job job = 2;
required ResponseCode response_code = 1;
}

message ReadJobResultRequest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadJobResult 换个名字

required int32 job_id = 1;
}

message ReadJobResultResponse {
required JobResult job_result = 1;
required ResponseCode response_code = 2;
}

message UpdateJobRequest {
required int32 job_id = 1;
required string status = 2;
optional int64 runtime = 3;
optional string result = 4;
}

message UpdateJobResponse {
required ResponseCode response_code = 1;
}

message DeleteJobRequest {
required int32 job_id = 1;
}

message DeleteJobResponse {
required ResponseCode response_code = 1;
}

message JobManagementRequest {
required string db_host = 1;
required string db_port = 2;
oneof Req {
CreateJobRequest create_job_request = 3;
ReadJobRequest read_job_request = 4;
ReadJobResultRequest read_job_result_request = 5;
UpdateJobRequest update_job_request = 6;
DeleteJobRequest delete_job_request = 7;
};
};

message JobManagementResponse {
required ResponseCode response_code = 1;
oneof Resp {
CreateJobResponse create_job_response = 2;
ReadJobResponse read_job_response = 3;
ReadJobResultResponse read_job_result_response = 4;
UpdateJobResponse update_job_response = 5;
DeleteJobResponse delete_job_response = 6;
};
};

message HeartbeatRequest {
required string request_msg = 1;
required int32 heartbeat_count = 2;
};

message HeartbeatResponse {
required string response_msg = 1;
required int32 heartbeat_count = 2;
};

service JobManagementService {
rpc handleRequest(JobManagementRequest) returns (JobManagementResponse);
};

service HeartbeatService {
rpc detectHeartbeat(HeartbeatRequest) returns (HeartbeatResponse);
}
Loading