Documentation ¶
Overview ¶
Package server is the grpc server for processing distributed lock requests. It contains the grpc methods as well as the request queue (dependent on dmutex/bintree and dmutex/quorums)
Index ¶
- Variables
- type DistSyncServer
- func (r *DistSyncServer) DrainRepliesCh()
- func (r *DistSyncServer) GatherReplies(quorumNum int) error
- func (r *DistSyncServer) Inquire(ctx context.Context, inq *pb.Node) (*pb.InquireReply, error)
- func (r *DistSyncServer) Relinquish(ctx context.Context, relinquish *pb.Node) (*pb.Node, error)
- func (r *DistSyncServer) Reply(ctx context.Context, reply *pb.Node) (*pb.Node, error)
- func (r *DistSyncServer) Request(ctx context.Context, req *pb.LockReq) (*pb.Node, error)
- func (r *DistSyncServer) Validate(ctx context.Context, validate *pb.Node) (*pb.ValidateReply, error)
Constants ¶
This section is empty.
Variables ¶
var ( // Timeout for acquiring enough replies Timeout time.Duration // RPCPort is the port used by all nodes in the cluster for grpc messages RPCPort = "7070" // Peers is a mapping of nodes which are in the same quorum(s) as the local node. // Its used for tracking which peers have responded to a lock request Peers *peersMap )
Functions ¶
This section is empty.
Types ¶
type DistSyncServer ¶
type DistSyncServer struct {
// contains filtered or unexported fields
}
DistSyncServer manages grpc server and request queue
func NewDistSyncServer ¶
func NewDistSyncServer(addr string, numMembers int, timeout time.Duration, tlsCrtFile string, tlsKeyFile string) (*DistSyncServer, error)
NewDistSyncServer initializes the grpc server and mutex processing queue. It takes as arguments:
- the local node's IP address
- the number of members for creating message channels
- a timeout specifying grpc timeouts
- optional Certificate and Key files for encrypting connections between nodes
func (*DistSyncServer) DrainRepliesCh ¶
func (r *DistSyncServer) DrainRepliesCh()
DrainRepliesCh removes outstanding replies from the replies channel only to be used in error condition
func (*DistSyncServer) GatherReplies ¶
func (r *DistSyncServer) GatherReplies(quorumNum int) error
GatherReplies waits for and tracks replies from each peer node. Its called when the local node has sent lock requests its quorum(s) and returns either when all nodes have replied or the timeout has passed. It takes an int argument representing how many of the quorum need to have replied (in the common case this will be all local quorum).
func (*DistSyncServer) Inquire ¶
func (r *DistSyncServer) Inquire(ctx context.Context, inq *pb.Node) (*pb.InquireReply, error)
Inquire is a grpc method representing the Inquire message of the algorithm. It should either block on the request if the local node has acquired the lock or Yield if it has not yet acquired the lock
func (*DistSyncServer) Relinquish ¶
Relinquish is a grpc method representing the Relinquish message of the algorithm (releasing the lock)
func (*DistSyncServer) Reply ¶
Reply is a grpc method representing the Reply message of the algorithm (granting consent to enter the critical section)
func (*DistSyncServer) Request ¶
Request is a grpc method representing the Request message of the algorithm accepting lock requests from other nodes in the cluster
func (*DistSyncServer) Validate ¶
func (r *DistSyncServer) Validate(ctx context.Context, validate *pb.Node) (*pb.ValidateReply, error)
Validate is a grpc method verifying the health of the node holding the lock. Returns true if the local node is still holding the lock