@@ -3473,6 +3473,123 @@ class ShowQueriesHandler final : public HttpRequestHandler {
3473
3473
}
3474
3474
};
3475
3475
3476
+ class ShowLogsHandler final : public HttpRequestHandler {
3477
+ public:
3478
+ SharedPtr<OutgoingResponse> handle (const SharedPtr<IncomingRequest> &request) final {
3479
+ auto infinity = Infinity::RemoteConnect ();
3480
+ DeferFn defer_fn ([&]() { infinity->RemoteDisconnect (); });
3481
+
3482
+ nlohmann::json json_response;
3483
+ HTTPStatus http_status;
3484
+ QueryResult result = infinity->ShowLogs ();
3485
+
3486
+ if (result.IsOk ()) {
3487
+ SizeT block_rows = result.result_table_ ->DataBlockCount ();
3488
+ for (SizeT block_id = 0 ; block_id < block_rows; ++block_id) {
3489
+ DataBlock *data_block = result.result_table_ ->GetDataBlockById (block_id).get ();
3490
+ auto row_count = data_block->row_count ();
3491
+ auto column_cnt = result.result_table_ ->ColumnCount ();
3492
+ for (int row = 0 ; row < row_count; ++row) {
3493
+ nlohmann::json json_table;
3494
+ for (SizeT col = 0 ; col < column_cnt; ++col) {
3495
+ const String &column_name = result.result_table_ ->GetColumnNameById (col);
3496
+ Value value = data_block->GetValue (col, row);
3497
+ const String &column_value = value.ToString ();
3498
+ json_table[column_name] = column_value;
3499
+ }
3500
+ json_response[" logs" ].push_back (json_table);
3501
+ }
3502
+ }
3503
+ json_response[" error_code" ] = 0 ;
3504
+ http_status = HTTPStatus::CODE_200;
3505
+ } else {
3506
+ json_response[" error_code" ] = result.ErrorCode ();
3507
+ json_response[" error_message" ] = result.ErrorMsg ();
3508
+ http_status = HTTPStatus::CODE_500;
3509
+ }
3510
+
3511
+ return ResponseFactory::createResponse (http_status, json_response.dump ());
3512
+ }
3513
+ };
3514
+
3515
+ class ShowDeltaCheckpointHandler final : public HttpRequestHandler {
3516
+ public:
3517
+ SharedPtr<OutgoingResponse> handle (const SharedPtr<IncomingRequest> &request) final {
3518
+ auto infinity = Infinity::RemoteConnect ();
3519
+ DeferFn defer_fn ([&]() { infinity->RemoteDisconnect (); });
3520
+
3521
+ nlohmann::json json_response;
3522
+ HTTPStatus http_status;
3523
+ QueryResult result = infinity->ShowDeltaCheckpoint ();
3524
+
3525
+ if (result.IsOk ()) {
3526
+ SizeT block_rows = result.result_table_ ->DataBlockCount ();
3527
+ for (SizeT block_id = 0 ; block_id < block_rows; ++block_id) {
3528
+ DataBlock *data_block = result.result_table_ ->GetDataBlockById (block_id).get ();
3529
+ auto row_count = data_block->row_count ();
3530
+ auto column_cnt = result.result_table_ ->ColumnCount ();
3531
+ for (int row = 0 ; row < row_count; ++row) {
3532
+ nlohmann::json json_table;
3533
+ for (SizeT col = 0 ; col < column_cnt; ++col) {
3534
+ const String &column_name = result.result_table_ ->GetColumnNameById (col);
3535
+ Value value = data_block->GetValue (col, row);
3536
+ const String &column_value = value.ToString ();
3537
+ json_table[column_name] = column_value;
3538
+ }
3539
+ json_response[" delta_checkpoint" ].push_back (json_table);
3540
+ }
3541
+ }
3542
+ json_response[" error_code" ] = 0 ;
3543
+ http_status = HTTPStatus::CODE_200;
3544
+ } else {
3545
+ json_response[" error_code" ] = result.ErrorCode ();
3546
+ json_response[" error_message" ] = result.ErrorMsg ();
3547
+ http_status = HTTPStatus::CODE_500;
3548
+ }
3549
+
3550
+ return ResponseFactory::createResponse (http_status, json_response.dump ());
3551
+ }
3552
+ };
3553
+
3554
+ class ShowFullCheckpointHandler final : public HttpRequestHandler {
3555
+ public:
3556
+ SharedPtr<OutgoingResponse> handle (const SharedPtr<IncomingRequest> &request) final {
3557
+ auto infinity = Infinity::RemoteConnect ();
3558
+ DeferFn defer_fn ([&]() { infinity->RemoteDisconnect (); });
3559
+
3560
+ nlohmann::json json_response;
3561
+ HTTPStatus http_status;
3562
+ QueryResult result = infinity->ShowFullCheckpoint ();
3563
+
3564
+ if (result.IsOk ()) {
3565
+ SizeT block_rows = result.result_table_ ->DataBlockCount ();
3566
+ for (SizeT block_id = 0 ; block_id < block_rows; ++block_id) {
3567
+ DataBlock *data_block = result.result_table_ ->GetDataBlockById (block_id).get ();
3568
+ auto row_count = data_block->row_count ();
3569
+ auto column_cnt = result.result_table_ ->ColumnCount ();
3570
+ for (int row = 0 ; row < row_count; ++row) {
3571
+ nlohmann::json json_table;
3572
+ for (SizeT col = 0 ; col < column_cnt; ++col) {
3573
+ const String &column_name = result.result_table_ ->GetColumnNameById (col);
3574
+ Value value = data_block->GetValue (col, row);
3575
+ const String &column_value = value.ToString ();
3576
+ json_table[column_name] = column_value;
3577
+ }
3578
+ json_response[" global_checkpoint" ].push_back (json_table);
3579
+ }
3580
+ }
3581
+ json_response[" error_code" ] = 0 ;
3582
+ http_status = HTTPStatus::CODE_200;
3583
+ } else {
3584
+ json_response[" error_code" ] = result.ErrorCode ();
3585
+ json_response[" error_message" ] = result.ErrorMsg ();
3586
+ http_status = HTTPStatus::CODE_500;
3587
+ }
3588
+
3589
+ return ResponseFactory::createResponse (http_status, json_response.dump ());
3590
+ }
3591
+ };
3592
+
3476
3593
class AdminShowCurrentNodeHandler final : public HttpRequestHandler {
3477
3594
public:
3478
3595
SharedPtr<OutgoingResponse> handle (const SharedPtr<IncomingRequest> &request) final {
@@ -3806,6 +3923,9 @@ void HTTPServer::Start(const String &ip_address, u16 port) {
3806
3923
router->route (" GET" , " /instance/profiles" , MakeShared<ShowProfilesHandler>());
3807
3924
router->route (" GET" , " /instance/memindex" , MakeShared<ShowMemIndexHandler>());
3808
3925
router->route (" GET" , " /instance/queries" , MakeShared<ShowQueriesHandler>());
3926
+ router->route (" GET" , " /instance/logs" , MakeShared<ShowLogsHandler>());
3927
+ router->route (" GET" , " /instance/delta_checkpoint" , MakeShared<ShowDeltaCheckpointHandler>());
3928
+ router->route (" GET" , " /instance/global_checkpoint" , MakeShared<ShowFullCheckpointHandler>());
3809
3929
3810
3930
// variable
3811
3931
router->route (" GET" , " /variables/global" , MakeShared<ShowGlobalVariablesHandler>());
0 commit comments