server

package
v0.0.0-...-3e94386 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2018 License: MIT Imports: 14 Imported by: 1

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

Constants

This section is empty.

Variables

View Source
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

func (r *DistSyncServer) Relinquish(ctx context.Context, relinquish *pb.Node) (*pb.Node, error)

Relinquish is a grpc method representing the Relinquish message of the algorithm (releasing the lock)

func (*DistSyncServer) Reply

func (r *DistSyncServer) Reply(ctx context.Context, reply *pb.Node) (*pb.Node, error)

Reply is a grpc method representing the Reply message of the algorithm (granting consent to enter the critical section)

func (*DistSyncServer) Request

func (r *DistSyncServer) Request(ctx context.Context, req *pb.LockReq) (*pb.Node, error)

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

Jump to

Keyboard shortcuts

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