Documentation ¶
Index ¶
- Constants
- Variables
- 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 NewPacketToTinyDeleteRecord(partitionID uint64, offset int64) (p *Packet)
- func NewStreamReadResponsePacket(requestID int64, partitionID uint64, extentID uint64) (p *Packet)
- func NewTinyDeleteRecordResponsePacket(requestID int64, partitionID uint64) (p *Packet)
- func (p *Packet) AfterTp() (ok bool)
- func (p *Packet) BeforeTp(clusterID string) (ok bool)
- func (p *Packet) IsErrPacket() bool
- func (p *Packet) IsMasterCommand() 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, 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 )
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 Packet ¶
type Packet struct { proto.Packet IsReleased int32 // TODO what is released? Object interface{} TpObject *exporter.TimePointCount NeedReply bool // contains filtered or unexported fields }
func (*Packet) IsErrPacket ¶
func (*Packet) IsMasterCommand ¶
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.