Home > Back-end >  Reply all error 12 gRPC server end, there is no error.
Reply all error 12 gRPC server end, there is no error.

Time:12-01

I'm developing a distributed database system, then mainly by the gRPC this library, and then my main is written according to gRPC paradigm, but appeared the problem, the error code is 12 said I didn't implement this function on the server side, they would like to ask you, the following is the code
Sundial_sync_server. H
 
# # ifndef SUNDIAL_GRPC_SYNC_SERVER_H
# define SUNDIAL_GRPC_SYNC_SERVER_H

# endif//SUNDIAL_GRPC_SYNC_SERVER_H

# include "sundial_grpc GRPC. Pb. H"
# include "sundial_grpc. Pb. H"
# include & lt; Iostream>
# include & lt; Memory>
# include & lt; String>
# include & lt; GRPCPP/GRPCPP. H>
Using GRPC: : Channel;
Using GRPC: : ServerContext;
Using GRPC: : Status;
Using sundial_rpc: : SundialRequest;
Using sundial_rpc: : SundialResponse;
Using sundial_rpc: : Sundial_GRPC_SYNC;
# # ifndef ABC
# define ABC
The class SundialServiceImp final: public Sundial_GRPC_SYNC: : Service
{
Public:
The Status contactRemote (: : GRPC: : ServerContext * context, const: : sundial_rpc: : SundialRequest * request, : : sundial_rpc: : SundialResponse * response) override.
Void the run ();

};
# endif

Sundial_sync_server. CPP
 # include "sundial_grpc. GRPC. Pb, h" 
# include "sundial_grpc. Pb. H"
# include & lt; Iostream>
# include & lt; Memory>
# include & lt; String>
# include & lt; GRPCPP/GRPCPP. H>
# include "TXN. H"
# include "global h"
H # include "manager."
# include "stats. H"
# include "helper. H"
# include "grpc_sync_server. H"
# include "txn_table. H"
# include & lt; GRPCPP/GRPCPP. H>
# include & lt; GRPCPP/health_check_service_interface. H>
# include & lt; GRPCPP/ext/proto_server_reflection_plugin. H>
Using GRPC: : ServerContext;
Using GRPC: : Status;
Using sundial_rpc: : SundialRequest;
Using sundial_rpc: : SundialResponse;
Using sundial_rpc: : Sundial_GRPC_SYNC;
Using GRPC: : Server;
Using GRPC: : ServerBuilder;
The Status SundialServiceImp: : contactRemote (: : GRPC: : ServerContext * context, const: : sundial_rpc: : SundialRequest * request, : : sundial_rpc: : SundialResponse * response) {
If (request - & gt; Request_type ()==SundialRequest: : SYS_REQ) {
Glob_manager - & gt; Receive_sync_request ();
The response - & gt; Set_response_type (SundialResponse: : SYS_RESP);
The return Status: : OK.
}
Uint64_t txn_id=request - & gt; Txn_id ();
TxnManager * txn_man=txn_table - & gt; Get_txn (txn_id);
//If no TxnManager exists for requesting the transaction, create one.
If (txn_man==NULL) {
//printf (" adding ld into txn_table txnID=% \ n ", txn_id);
Assert (request - & gt; Request_type ()==SundialRequest: : READ_REQ);
Txn_man=new TxnManager ();
Txn_man - & gt; Set_txn_id (txn_id);
Txn_table - & gt; Add_txn (txn_man);
}
//the transaction handles the RPC call
Txn_man - & gt; Process_remote_request (request, response);
//if the sub - the transaction is no longer required, remove the from txn_table
If (the response - & gt; The payload ()==SundialResponse: : RESP_ABORT
| | response - & gt; The payload ()==SundialResponse: : PREPARED_OK_RO
| | response - & gt; The payload ()==SundialResponse: : PREPARED_ABORT
| | response - & gt; The payload ()==SundialResponse: : ACK) {
Txn_table - & gt; Remove_txn (txn_man);
The delete txn_man;
}
The return Status: : OK.
}

Void SundialServiceImp: : run () {
STD: : istringstream in (ifconfig_string);
The string line;
Uint32_t num_nodes=0;
String port;
While (getline (in line)) {
If (line [0]=='#')
continue;
The else {
If (num_nodes==g_node_id) {
Port=line. Substr (0, the line. The length ());
break;
}
Num_nodes + +;
}
}
Port. Append (sync_port);
GRPC: : EnableDefaultHealthCheckService (true);
GRPC: : reflection: : InitProtoReflectionServerBuilderPlugin ();
ServerBuilder builder;
Builder. AddListeningPort (port, GRPC: : InsecureServerCredentials ());
Builder. RegisterService (this);
STD: : unique_ptr & lt; Server> Server (builder. BuildAndStart ());
STD: : cout & lt; <"Server listening on" & lt; Server - & gt; Wait ();
}

Sundial_sync_client. H
 # endif//SUNDIAL_GRPC_CLIENT_H 
# include "sundial_grpc GRPC. Pb. H"
# include "sundial_grpc. Pb. H"
# include & lt; Iostream>
# include & lt; Memory>
# include & lt; String>
# include & lt; GRPCPP/GRPCPP. H>
Using GRPC: : Channel;
Using GRPC: : ClientContext;
Using GRPC: : Status;
Using sundial_rpc: : SundialRequest;
Using sundial_rpc: : SundialResponse;
Using sundial_rpc: : Sundial_GRPC_SYNC;
//toDo: now assume we only have 2 nodes
# # ifndef SSC
# define SSC
The class Sundial_Sync_Client {
Public:
Sundial_Sync_Client (STD: : from & lt; Channel> * channel);
The Status contactRemote (uint64_t node_id SundialRequest& Request, SundialResponse * response);
Private:
STD: : unique_ptr & lt; Sundial_GRPC_SYNC: : Stub> Stub_;
};
# endif

Sundial_sync_client. CPP
 
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related