forked from OpenAtomFoundation/pika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pika_binlog_sender_thread.h
78 lines (55 loc) · 1.62 KB
/
pika_binlog_sender_thread.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (c) 2015-present, Qihoo, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
#ifndef PIKA_BINLOG_SENDER_THREAD_H_
#define PIKA_BINLOG_SENDER_THREAD_H_
#include "pink_thread.h"
//#include "redis_cli.h"
#include "slice.h"
#include "status.h"
#include "env.h"
#include "slash_mutex.h"
namespace pink {
class RedisCli;
}
class PikaBinlogSenderThread : public pink::Thread {
public:
PikaBinlogSenderThread(std::string &ip, int port, slash::SequentialFile *queue, uint32_t filenum, uint64_t con_offset);
virtual ~PikaBinlogSenderThread();
/*
* Get and Set
*/
uint64_t last_record_offset () {
slash::RWLock l(&rwlock_, false);
return last_record_offset_;
}
uint32_t filenum() {
slash::RWLock l(&rwlock_, false);
return filenum_;
}
uint64_t con_offset() {
slash::RWLock l(&rwlock_, false);
return con_offset_;
}
int trim();
uint64_t get_next(bool &is_error);
private:
slash::Status Parse(std::string &scratch);
slash::Status Consume(std::string &scratch);
unsigned int ReadPhysicalRecord(slash::Slice *fragment);
uint64_t con_offset_;
uint32_t filenum_;
uint64_t initial_offset_;
uint64_t last_record_offset_;
uint64_t end_of_buffer_offset_;
slash::SequentialFile* queue_;
char* const backing_store_;
slash::Slice buffer_;
std::string ip_;
int port_;
pthread_rwlock_t rwlock_;
pink::RedisCli *cli_;
virtual void* ThreadMain();
};
#endif