public interface ReplicableStore
| 限定符和类型 | 方法和说明 |
|---|---|
long |
appendEntryBuffer(ByteBuffer byteBuffer)
追加写入一段日志数据,给定的ByteBuffer必须满足如下条件:
1.
|
void |
clear(long position) |
void |
commit(long position)
LEADER 收到半数以上回复后,调用此方法提交位置。
|
long |
commitPosition()
当前日志提交的位置
|
void |
disable()
将服务状态置为false
|
void |
enable()
将服务状态置为true
|
int |
getEntryTerm(long position)
获取指定位置的日志的任期
|
long |
leftPosition()
当前日志最小位置
|
long |
position(long position,
int offsetCount)
计算日志相对于position的位置
|
ByteBuffer |
readEntryBuffer(long position,
int length)
读取一段日志数据,起始位置由position指定,最大长度不超过length。
|
long |
rightPosition()
当前日志最大位置
|
boolean |
serviceStatus()
节点服务状态
|
void |
setRightPosition(long position)
设置Store的最大位置。
|
int |
term()
当前任期
|
void |
term(int term)
修改任期,新任期必须必大于现任期;
|
boolean serviceStatus()
void enable()
void disable()
void setRightPosition(long position)
throws IOException
position:
1. 在最大最小位置之间 leftPosition() <= position < rightPosition():
截断 position之后的数据。
2. 否则清空存储所有数据,将最大最小位置都置为给定的positionposition - 给定新的最大位置IOException - 读写或删除文件异常时抛出long rightPosition()
long leftPosition()
void clear(long position)
throws IOException
IOExceptionlong commitPosition()
int term()
void term(int term)
ByteBuffer readEntryBuffer(long position, int length) throws IOException
position - 起始位置,必须是一条日志的开始位置。length - 返回数据的最大长度。ReadException - position 不是一条日志的开始位置,或者其他读日志异常。IOException - 发生IO错误long appendEntryBuffer(ByteBuffer byteBuffer) throws IOException, TimeoutException
byteBuffer - 待写入的ByteBuffer,将position至limit之间的数据写入存储。
写入完成后, position == limit。rightPosition()IOException - 发生IO错误TimeoutException - 等待写入超时,需要重试。long position(long position,
int offsetCount)
throws IOException
position - 当前位置,必须是日志的起始位置offsetCount - 偏移的日志条数,可以为负数IOExceptionvoid commit(long position)
int getEntryTerm(long position)
throws IOException
position - 日志起始位置ReadException - position 不是一条日志的开始位置,或者其他读日志异常。IOException - 发生IO错误Copyright © 2020 Joyqueue Community. All rights reserved.