|
@@ -57,11 +57,11 @@ void carmakerwork::threadwork()
|
|
|
|
|
|
|
|
|
|
gpr_timespec timespec;
|
|
gpr_timespec timespec;
|
|
- timespec.tv_sec = 10;//设置阻塞时间为2秒
|
|
|
|
|
|
+ timespec.tv_sec = 30;//设置阻塞时间为30秒
|
|
timespec.tv_nsec = 0;
|
|
timespec.tv_nsec = 0;
|
|
timespec.clock_type = GPR_TIMESPAN;
|
|
timespec.clock_type = GPR_TIMESPAN;
|
|
|
|
|
|
- int64_t interval = 100;
|
|
|
|
|
|
+ int64_t interval = 10;
|
|
|
|
|
|
int64_t lastreq = 0;
|
|
int64_t lastreq = 0;
|
|
|
|
|
|
@@ -78,11 +78,13 @@ void carmakerwork::threadwork()
|
|
|
|
|
|
if(nRes == 0)
|
|
if(nRes == 0)
|
|
{
|
|
{
|
|
|
|
+
|
|
int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
int64_t diff = static_cast<int64_t>(abs(nnow - lastreq)) ;
|
|
int64_t diff = static_cast<int64_t>(abs(nnow - lastreq)) ;
|
|
if(diff<interval)
|
|
if(diff<interval)
|
|
{
|
|
{
|
|
- std::this_thread::sleep_for(std::chrono::milliseconds(interval-diff));
|
|
|
|
|
|
+
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(interval-diff));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
iv::ipg::workReq request;
|
|
iv::ipg::workReq request;
|
|
@@ -117,9 +119,11 @@ void carmakerwork::threadwork()
|
|
|
|
|
|
lastreq = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
lastreq = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
|
|
|
|
|
|
|
|
+// std::cout<<" convertwork. "<<std::endl;
|
|
Status status = stub_->convertwork(&context, request, &reply);
|
|
Status status = stub_->convertwork(&context, request, &reply);
|
|
if (status.ok()) {
|
|
if (status.ok()) {
|
|
|
|
|
|
|
|
+ // std::cout<<"result."<<std::endl;
|
|
if(request.mnres() != 0)
|
|
if(request.mnres() != 0)
|
|
{
|
|
{
|
|
snprintf(strlog,256,"Complete workid:%lld nres:%d. uploaded to server.",request.workid(),request.mnres());
|
|
snprintf(strlog,256,"Complete workid:%lld nres:%d. uploaded to server.",request.workid(),request.mnres());
|
|
@@ -159,7 +163,7 @@ void carmakerwork::threadwork()
|
|
snprintf(strlog,256,"RPC Fail. status code: %d error msg:%s",status.error_code(),status.error_message().data());
|
|
snprintf(strlog,256,"RPC Fail. status code: %d error msg:%s",status.error_code(),status.error_message().data());
|
|
Log(strlog);
|
|
Log(strlog);
|
|
|
|
|
|
- if(status.error_code() == 4)
|
|
|
|
|
|
+ if((status.error_code() == 4) || (status.error_code() == 14))
|
|
{
|
|
{
|
|
std::cout<<" RPC Exceed Time. Create New Stub_"<<std::endl;
|
|
std::cout<<" RPC Exceed Time. Create New Stub_"<<std::endl;
|
|
channel = grpc::CreateCustomChannel(
|
|
channel = grpc::CreateCustomChannel(
|