Documentation ¶
Index ¶
- Constants
- Variables
- type FollowerPacket
- type FollowerTransport
- type Packet
- func NewExtentRepairReadPacket(partitionID uint64, extentID uint64, offset, size int) (p *Packet)
- func NewPacket() (p *Packet)
- func NewPacketToGetAllWatermarks(partitionID uint64, extentType uint8) (p *Packet)
- func NewPacketToNotifyExtentRepair(partitionID uint64) (p *Packet)
- func NewPacketToReadTinyDeleteRecord(partitionID uint64, offset int64) (p *Packet)
- func NewReadTinyDeleteRecordResponsePacket(requestID int64, partitionID uint64) (p *Packet)
- func NewStreamReadResponsePacket(requestID int64, partitionID uint64, extentID uint64) (p *Packet)
- func NewTinyExtentRepairReadPacket(partitionID uint64, extentID uint64, offset, size int) (p *Packet)
- func NewTinyExtentStreamReadResponsePacket(requestID int64, partitionID uint64, extentID uint64) (p *Packet)
- func (p *Packet) AfterTp() (ok bool)
- func (p *Packet) BeforeTp(clusterID string) (ok bool)
- func (p *Packet) IsBatchDeleteExtents() bool
- func (p *Packet) IsBroadcastMinAppliedID() bool
- func (p *Packet) IsCreateExtentOperation() bool
- func (p *Packet) IsErrPacket() bool
- func (p *Packet) IsForwardPacket() bool
- func (p *Packet) IsLeaderPacket() (ok bool)
- func (p *Packet) IsMarkDeleteExtentOperation() bool
- func (p *Packet) IsMasterCommand() bool
- func (p *Packet) IsRandomWrite() bool
- func (p *Packet) IsReadOperation() bool
- func (p *Packet) IsSyncWrite() bool
- func (p *Packet) IsTinyExtentType() bool
- func (p *Packet) IsWriteOperation() bool
- func (p *Packet) PackErrorBody(action, msg string)
- func (p *Packet) ReadFromConnFromCli(c net.Conn, deadlineTime time.Duration) (err error)
- func (p *Packet) ReadFull(c net.Conn, opcode uint8, readSize int) (err error)
- type ReplProtocol
Constants ¶
const ( ActionSendToFollowers = "ActionSendToFollowers" ActionReceiveFromFollower = "ActionReceiveFromFollower" ActionWriteToClient = "ActionWriteToClient" ActionCheckReply = "ActionCheckReply" ActionPreparePkt = "ActionPreparePkt" )
const ( ReplRuning = 2 ReplExiting = 1 ReplHasExited = -3 FollowerTransportRuning = 2 FollowerTransportExiting = 1 FollowerTransportExited = -1 )
const (
ConnIsNullErr = "ConnIsNullErr"
)
const (
ReplProtocolError = 1
)
const (
RequestChanSize = 10240
)
Variables ¶
var ( ErrBadNodes = errors.New("BadNodesErr") ErrArgLenMismatch = errors.New("ArgLenMismatchErr") )
var (
ErrorUnknownOp = errors.New("unknown opcode")
)
Functions ¶
This section is empty.
Types ¶
type FollowerPacket ¶ added in v1.4.0
func NewFollowerPacket ¶ added in v1.4.0
func NewFollowerPacket() (fp *FollowerPacket)
func (*FollowerPacket) IsErrPacket ¶ added in v1.4.0
func (p *FollowerPacket) IsErrPacket() bool
func (*FollowerPacket) PackErrorBody ¶ added in v1.4.0
func (p *FollowerPacket) PackErrorBody(action, msg string)
type FollowerTransport ¶ added in v1.4.0
type FollowerTransport struct {
// contains filtered or unexported fields
}
func NewFollowersTransport ¶ added in v1.4.0
func NewFollowersTransport(addr string) (ft *FollowerTransport, err error)
func (*FollowerTransport) Destory ¶ added in v1.4.0
func (ft *FollowerTransport) Destory()
func (*FollowerTransport) Write ¶ added in v1.4.0
func (ft *FollowerTransport) Write(p *FollowerPacket)
type Packet ¶
type Packet struct { proto.Packet IsReleased int32 // TODO what is released? Object interface{} TpObject *exporter.TimePointCount NeedReply bool OrgBuffer []byte // contains filtered or unexported fields }
func NewPacketToReadTinyDeleteRecord ¶ added in v1.4.0
func NewReadTinyDeleteRecordResponsePacket ¶ added in v1.4.0
func NewTinyExtentRepairReadPacket ¶ added in v1.4.0
func NewTinyExtentStreamReadResponsePacket ¶ added in v1.4.0
func (*Packet) IsBatchDeleteExtents ¶
func (*Packet) IsBroadcastMinAppliedID ¶ added in v1.4.0
func (*Packet) IsCreateExtentOperation ¶ added in v1.4.0
func (*Packet) IsErrPacket ¶
func (*Packet) IsForwardPacket ¶ added in v1.4.0
func (*Packet) IsLeaderPacket ¶ added in v1.4.0
A leader packet is the packet send to the leader and does not require packet forwarding.
func (*Packet) IsMarkDeleteExtentOperation ¶ added in v1.4.0
func (*Packet) IsMasterCommand ¶
func (*Packet) IsRandomWrite ¶ added in v1.4.0
func (*Packet) IsReadOperation ¶ added in v1.4.0
func (*Packet) IsSyncWrite ¶ added in v1.4.0
func (*Packet) IsTinyExtentType ¶ added in v1.4.0
func (*Packet) IsWriteOperation ¶ added in v1.4.0
func (*Packet) PackErrorBody ¶
func (*Packet) ReadFromConnFromCli ¶
type ReplProtocol ¶
type ReplProtocol struct {
// contains filtered or unexported fields
}
ReplProtocol defines the struct of the replication protocol. 1. ServerConn reads a packet from the client socket, and analyzes the addresses of the followers. 2. After the preparation, the packet is send to toBeProcessedCh. If failure happens, send it to the response channel. 3. OperatorAndForwardPktGoRoutine fetches a packet from toBeProcessedCh, and determine if it needs to be forwarded to the followers. 4. receiveResponse fetches a reply from responseCh, executes postFunc, and writes a response to the client if necessary.
func NewReplProtocol ¶
func (*ReplProtocol) OperatorAndForwardPktGoRoutine ¶
func (rp *ReplProtocol) OperatorAndForwardPktGoRoutine()
OperatorAndForwardPktGoRoutine reads packets from the to-be-processed channel and writes responses to the client.
- Read a packet from toBeProcessCh, and determine if it needs to be forwarded or not. If the answer is no, then process the packet locally and put it into responseCh.
- If the packet needs to be forwarded, the first send it to the followers, and execute the operator function. Then notify receiveResponse to read the followers' responses.
- Read a reply from responseCh, and write to the client.
func (*ReplProtocol) ReceiveResponseFromFollowersGoRoutine ¶
func (rp *ReplProtocol) ReceiveResponseFromFollowersGoRoutine()
Receive response from all followers.
func (*ReplProtocol) ServerConn ¶
func (rp *ReplProtocol) ServerConn()
ServerConn keeps reading data from the socket to analyze the follower address, execute the prepare function, and throw the packets to the to-be-processed channel.