Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

pexeer
Copy link

@pexeer pexeer commented May 31, 2017

#1277

TODO:

  1. need add unittest
  2. need add performance test

@baidubot
Copy link
Collaborator

Reviewers: @00k @caijieming-baidu @taocp

Copy link
Member

@elithnever elithnever left a 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);
Copy link
Member

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> {
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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>
Copy link
Member

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) {
Copy link
Member

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()) {
Copy link
Member

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();
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

增加一个单测, 测试当时间跳变时的行为

@pexeer pexeer closed this Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants