viewreplication

package
v0.0.0-...-fea0aa2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(rs *rpc.Server)

Types

type Client

type Client struct {
	Id string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(id string, port int) Client

func (*Client) Do

func (c *Client) Do(api string, req clientrpc.Request, res clientrpc.Response, async bool)

type ClientState

type ClientState struct {
	Id           string
	RequestId    int
	LastResponse *OpResponse
}

type CommitRequest

type CommitRequest struct {
	View      int
	CommitId  int
	ReplicaId int
	DestId    int
}

func (*CommitRequest) LogRequest

func (req *CommitRequest) LogRequest(recv bool)

type Configuration

type Configuration struct {
	Id       int
	Self     *Replica
	Replicas map[int]Replica

	QuorumSize int
	// contains filtered or unexported fields
}

func (*Configuration) GetClient

func (c *Configuration) GetClient(id string) Client

func (*Configuration) IsPrimary

func (c *Configuration) IsPrimary() bool

func (*Configuration) SetPrimary

func (c *Configuration) SetPrimary(id int, self bool)

type GetStateRequest

type GetStateRequest struct {
	View      int
	OpId      int
	ReplicaId int
	DestId    int
}

func (*GetStateRequest) LogRequest

func (req *GetStateRequest) LogRequest(recv bool)

type Impl

type Impl struct {
	Config          Configuration
	View            int
	OpId            int
	Ops             []log2.Operation
	CommitId        int
	ClusterStatus   Status
	ClientStates    map[string]*ClientState
	PrepareQueue    chan *clientrpc.WorkRequest
	CommitQueue     chan *clientrpc.WorkRequest
	ActivityTimer   *time.Timer
	ActivityTimeout time.Duration
}

func GetImpl

func GetImpl() *Impl

func (*Impl) AdvanceOpId

func (impl *Impl) AdvanceOpId() int

func (*Impl) AppendOp

func (impl *Impl) AppendOp(opId int, logMsg log2.LogMessage) log2.Operation

func (*Impl) BufferCommitRequest

func (impl *Impl) BufferCommitRequest(req *CommitRequest) *clientrpc.WorkRequest

func (*Impl) BufferPrepareRequest

func (impl *Impl) BufferPrepareRequest(req *PrepareRequest) *clientrpc.WorkRequest

func (*Impl) ClearOpsAfterOpId

func (impl *Impl) ClearOpsAfterOpId()

func (*Impl) Commit

func (impl *Impl) Commit(req *CommitRequest, res *clientrpc.EmptyResponse) error

func (*Impl) CreateClientState

func (impl *Impl) CreateClientState(clientId string) *ClientState

func (*Impl) DoPendingCommits

func (impl *Impl) DoPendingCommits(commitId int)

func (*Impl) GetBackups

func (impl *Impl) GetBackups() []Replica

func (*Impl) GetClientState

func (impl *Impl) GetClientState(clientId string) *ClientState

func (*Impl) GetClusterStatus

func (impl *Impl) GetClusterStatus() Status

func (*Impl) GetOtherReplicas

func (impl *Impl) GetOtherReplicas() []Replica

func (*Impl) GetPrimary

func (impl *Impl) GetPrimary() Replica

func (*Impl) GetQuorumSize

func (impl *Impl) GetQuorumSize() int

func (*Impl) GetState

func (impl *Impl) GetState(req *GetStateRequest) *NewStateResponse

func (*Impl) IsClusterStatusNormal

func (impl *Impl) IsClusterStatusNormal() bool

func (*Impl) IsPrimary

func (impl *Impl) IsPrimary() bool

func (*Impl) IsPrimaryReqRecvd

func (impl *Impl) IsPrimaryReqRecvd() bool

func (*Impl) Prepare

func (impl *Impl) Prepare(req *PrepareRequest, res *clientrpc.EmptyResponse) error

func (*Impl) ProcessCommitRequests

func (impl *Impl) ProcessCommitRequests()

func (*Impl) ProcessPrepareRequests

func (impl *Impl) ProcessPrepareRequests()

func (*Impl) Recovery

func (impl *Impl) Recovery(req *RecoveryRequest, res *RecoveryResponse) error

func (*Impl) SendRecoveryRequests

func (impl *Impl) SendRecoveryRequests(nonce []byte) chan *RecoveryResponse

func (*Impl) SetClusterStatusNormal

func (impl *Impl) SetClusterStatusNormal()

func (*Impl) SetClusterStatusViewChange

func (impl *Impl) SetClusterStatusViewChange()

func (*Impl) SetPrimaryReqRecvd

func (impl *Impl) SetPrimaryReqRecvd(status bool)

func (*Impl) UpdateClientState

func (impl *Impl) UpdateClientState(clientId string, requestId int, res *log2.OpResult) *OpResponse

func (*Impl) UpdatePrimaryNode

func (impl *Impl) UpdatePrimaryNode(id int)

func (*Impl) WaitForRecoveryQuorum

func (impl *Impl) WaitForRecoveryQuorum(nonce []byte, done chan *RecoveryResponse) *RecoveryResponse

func (*Impl) WaitForStateTransfer

func (impl *Impl) WaitForStateTransfer(view int)

type NewStateResponse

type NewStateResponse struct {
	View      int
	OpId      int
	CommitId  int
	Ops       []log2.Operation
	Primary   int
	ReplicaId int
	DestId    int
}

func (*NewStateResponse) LogResponse

func (res *NewStateResponse) LogResponse(recv bool)

type OpResponse

type OpResponse struct {
	View      int
	RequestId int
	Result    *log2.OpResult
}

func (*OpResponse) LogResponse

func (or *OpResponse) LogResponse(recv bool)

func (*OpResponse) String

func (or *OpResponse) String() string

type PrepareOkRequest

type PrepareOkRequest struct {
	View      int
	OpId      int
	ReplicaId int
	DestId    int
}

func (*PrepareOkRequest) LogRequest

func (req *PrepareOkRequest) LogRequest(recv bool)

type PrepareRequest

type PrepareRequest struct {
	ClientId  string
	RequestId int
	View      int
	Log       log2.LogMessage
	OpId      int
	CommitId  int
	ReplicaId int
	DestId    int
}

func (*PrepareRequest) LogRequest

func (req *PrepareRequest) LogRequest(recv bool)

type RecoveryRequest

type RecoveryRequest struct {
	Nonce     []byte
	ReplicaId int
	DestId    int
}

func (*RecoveryRequest) LogRequest

func (req *RecoveryRequest) LogRequest(recv bool)

type RecoveryResponse

type RecoveryResponse struct {
	View      int
	Ops       []log2.Operation
	Nonce     []byte
	OpId      int
	CommitId  int
	ReplicaId int
	DestId    int
}

func (*RecoveryResponse) LogResponse

func (res *RecoveryResponse) LogResponse(recv bool)

type Replica

type Replica struct {
	Id int

	Role Role
	// contains filtered or unexported fields
}

func NewReplica

func NewReplica(id int, port int, role Role) Replica

func (*Replica) Do

func (r *Replica) Do(api string, req clientrpc.Request, res clientrpc.Response, async bool) error

func (*Replica) GetPort

func (r *Replica) GetPort() int

func (Replica) IsConnected

func (r Replica) IsConnected() bool

func (*Replica) IsPrimary

func (r *Replica) IsPrimary() bool

func (*Replica) SetBackup

func (r *Replica) SetBackup()

func (*Replica) SetPrimary

func (r *Replica) SetPrimary()

type Role

type Role int
const (
	RolePrimary Role = iota
	RoleBackup
)

func (Role) String

func (r Role) String() string

type Status

type Status int
const (
	StatusNormal Status = iota
	StatusViewChange
	StatusRecover
)

func (Status) String

func (s Status) String() string

type ViewReplication

type ViewReplication interface {
	Prepare(req *PrepareRequest, res *clientrpc.EmptyResponse) error
	Commit(req *CommitRequest, res *clientrpc.EmptyResponse) error
	GetState(req *GetStateRequest, res *NewStateResponse) error
	Recovery(req *RecoveryRequest, res *RecoveryResponse) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL