Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
add heartbeat count
Browse files Browse the repository at this point in the history
  • Loading branch information
SonglinLyu committed Oct 18, 2023
1 parent 58312aa commit 6aefbda
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ public TuGraphDBManagement.HeartbeatResponse detectHeartbeat(TuGraphDBManagement
String reqMsg = request.getRequestMsg();
log.info(reqMsg);
String respMsg = "This is a heartbeat response message.";
int heartbeatCount = request.getHeartbeatCount();
TuGraphDBManagement.HeartbeatResponse.Builder respBuilder =
TuGraphDBManagement.HeartbeatResponse
.newBuilder();
respBuilder.setResponseMsg(respMsg);
respBuilder
.setResponseMsg(respMsg)
.setHeartbeatCount(heartbeatCount + 1);
return respBuilder.build();
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/proto/tugraph_db_management.proto
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ message JobManagementResponse {

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class TuGraphDBManagementApplicationTests {
@Autowired
private JobManagementServiceImpl jobManagementService;

@Autowired
private HeartbeatServiceImpl heartbeatService;

@Autowired
private JobService jobService;

Expand Down Expand Up @@ -167,4 +170,25 @@ void testJobManagementService() {
assertEquals(0, JobList.size());
}

@Test
@Transactional
@Order(1)
void testHeartbeatService() {
log.info("start testing heartbeat service.");

String reqMsg = "This is a heartbeat request message.";
int heartbeatCount = 0;

TuGraphDBManagement.HeartbeatRequest heartbeatRequest =
TuGraphDBManagement.HeartbeatRequest
.newBuilder()
.setRequestMsg(reqMsg)
.setHeartbeatCount(heartbeatCount)
.build();
TuGraphDBManagement.HeartbeatResponse heartbeatResponse =
heartbeatService.detectHeartbeat(heartbeatRequest);

assertEquals(heartbeatCount + 1, heartbeatResponse.getHeartbeatCount());
}

}

0 comments on commit 6aefbda

Please sign in to comment.