lockservice

package
v0.0.0-...-69bd5ce Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clerk

type Clerk struct {
	// contains filtered or unexported fields
}

the lockservice Clerk lives in the client and maintains a little state.

func MakeClerk

func MakeClerk(primary string, backup string) *Clerk

func (*Clerk) Lock

func (ck *Clerk) Lock(lockname string) bool

ask the lock service for a lock. returns true if the lock service granted the lock, false otherwise.

you will have to modify this function.

func (*Clerk) Unlock

func (ck *Clerk) Unlock(lockname string) bool

type DeafConn

type DeafConn struct {
	// contains filtered or unexported fields
}

hack to allow test_test.go to have primary process an RPC but not send a reply. can't use the shutdown() trick b/c that causes client to immediately get an error and send to backup before primary does. please don't change anything to do with DeafConn.

func (DeafConn) Close

func (dc DeafConn) Close() error

func (DeafConn) Read

func (dc DeafConn) Read(p []byte) (n int, err error)

func (DeafConn) Write

func (dc DeafConn) Write(p []byte) (n int, err error)

type LockArgs

type LockArgs struct {
	// Go's net/rpc requires that these field
	// names start with upper case letters!
	Lockname string // lock name
}

Lock(lockname) returns OK=true if the lock is not held. If it is held, it returns OK=false immediately.

type LockReply

type LockReply struct {
	OK bool
}

type LockServer

type LockServer struct {
	// contains filtered or unexported fields
}

func StartServer

func StartServer(primary string, backup string, am_primary bool) *LockServer

func (*LockServer) Lock

func (ls *LockServer) Lock(args *LockArgs, reply *LockReply) error

server Lock RPC handler.

you will have to modify this function

func (*LockServer) Unlock

func (ls *LockServer) Unlock(args *UnlockArgs, reply *UnlockReply) error

server Unlock RPC handler.

type UnlockArgs

type UnlockArgs struct {
	Lockname string
}

Unlock(lockname) returns OK=true if the lock was held. It returns OK=false if the lock was not held.

type UnlockReply

type UnlockReply struct {
	OK bool
}

Jump to

Keyboard shortcuts

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