-
Notifications
You must be signed in to change notification settings - Fork 436
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
issue=#1277:Add Timeoracle Implement #1278
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议增加一个功能, 当剩余时间戳个数小于50%的时候, 触发预分配
#include "proto/timeoracle_rpc.pb.h" | ||
#include "proto/rpc_client.h" | ||
|
||
DECLARE_int32(tera_rpc_timeout_period); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个flag名字起的有的模糊, 另外最好加上单位. 叫做tera_tso_rpc_timeout_ms?
namespace tera { | ||
namespace timeoracle { | ||
|
||
class TimeoracleClient : public RpcClient<TimeoracleServer::Stub> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没必要继承吧?
message GetTimestampResponse { | ||
optional StatusCode status = 1; | ||
optional uint64 start_timestamp = 2; | ||
optional uint64 number = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成count好一些?
|
||
#include "proto/timeoracle_client.h" | ||
|
||
using namespace tera; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
禁止using namespace
#include <time.h> | ||
#include <gflags/gflags.h> | ||
#include <glog/logging.h> | ||
#include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
系统库放在第三方库的前面
return start_timestamp; | ||
} | ||
|
||
uint64_t UpdateLimitTimestamp(uint64_t limit_timestamp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
增加一些INFO级别的日志方便debug
|
||
auto timeoracle = remote_timeoracle_->GetTimeoracle(); | ||
|
||
while (!timeoracle->GetLimitTimestamp()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetLimitTimestamp()不是返回整数吗? 这里是说需要等到limit_timestamp生效?
return false; | ||
} | ||
|
||
remote_timeoracle_->GetTimeoracle()->UpdateStartTimestamp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是应该在start()的时候调用?
timeoracle->UpdateLimitTimestamp(next_limit_timestamp); | ||
} | ||
|
||
ThisThread::Sleep(1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FLAGS_tera_timeoracle_max_lease_second 这个flag可以设置一个总得大小, 代表向zk保存的时间间隔.
|
||
inline uint64_t clock_realtime_ns() { | ||
struct timespec tp; | ||
::clock_gettime(CLOCK_REALTIME, &tp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
增加一个单测, 测试当时间跳变时的行为
#1277
TODO: