common

package
v0.0.0-...-0f92b6b Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialAndCallNoFail

func DialAndCallNoFail(addr string, fn string, args interface{}) (int, error)

DialAndCallNoFail dial and then do the remote call TODO is there a way to make the reply generic?

func EmptyIntChan

func EmptyIntChan(c <-chan int)

EmptyIntChan drops everything in channel c

func MaxInt64

func MaxInt64(a int64, b int64) int64

MaxInt64 returns the maximum of a and b

func MinInt

func MinInt(a int, b int) int

MinInt returns the minimum of a and b

func RemoteCallNoFail

func RemoteCallNoFail(remote *rpc.Client, fn string, args interface{}, reply interface{}) error

RemoteCallNoFail does a remote.Call and logs failure

func RunRPC

func RunRPC(s interface{}, addr string)

RunRPC registers and runs the RPC server.

func SliceFromMap

func SliceFromMap(mymap map[string]IntClient) []string

SliceFromMap does what it says

func SliceToMap

func SliceToMap(ss []string) map[string]IntClient

SliceToMap is like the opposite of SliceFromMap

func TakeAllInt64Chan

func TakeAllInt64Chan(c <-chan int64) []int64

TakeAllInt64Chan returns a list with all the values in the buffered channel

Types

type IntClient

type IntClient struct {
	Client *rpc.Client
	ID     int64
}

IntClient stores an int64 ID and a Client pointer

type MsgType

type MsgType int

MsgType includes all messages types other than job list manipulation

const (
	ElectionMsg MsgType = iota
	CoordinateMsg
	MutexReq
	MutexResp
	GSUpMsg
	RMUpMsg
	GetCapacityMsg
)

func (MsgType) String

func (i MsgType) String() string

type MutexState

type MutexState int

MutexState are all the possible states for Ricart-Agrawala algorithm

const (
	StateReleased MutexState = iota
	StateWanted
	StateHeld
)

func (MutexState) String

func (i MutexState) String() string

type Node

type Node struct {
	ID   int
	Addr string
	Type NodeType
}

Node is a generic node

type NodeType

type NodeType int

NodeType can be either for GS, RM or DS (discosrv)

const (
	GSNode NodeType = iota
	RMNode
	DSNode
)

type SyncedSet

type SyncedSet struct {
	sync.RWMutex
	S map[string]IntClient
}

SyncedSet is a concurrent map

func (*SyncedSet) Delete

func (s *SyncedSet) Delete(k string) bool

Delete deletes entry at key k

func (*SyncedSet) Get

func (s *SyncedSet) Get(k string) (v IntClient, ok bool)

Get gets value at key k

func (*SyncedSet) GetAll

func (s *SyncedSet) GetAll() map[string]IntClient

GetAll does unwrapping

func (*SyncedSet) GetInt

func (s *SyncedSet) GetInt(k string) (int64, bool)

GetInt gets the int part of the value at key k

func (*SyncedSet) Set

func (s *SyncedSet) Set(k string, v IntClient)

Set sets the value IntClient on key k

func (*SyncedSet) SetInt

func (s *SyncedSet) SetInt(k string, v int64)

SetInt is Set but only sets the int64 part of IntClient

type SyncedVal

type SyncedVal struct {
	sync.RWMutex
	V interface{}
}

SyncedVal is an interface{} with RWMutex

func (*SyncedVal) Get

func (v *SyncedVal) Get() interface{}

Get gets the value

func (*SyncedVal) Geti64

func (v *SyncedVal) Geti64() int64

Geti64 is Get for int64

func (*SyncedVal) Set

func (v *SyncedVal) Set(x interface{})

Set sets the value

func (*SyncedVal) Tick

func (v *SyncedVal) Tick()

Tick increments int64 value

type Task

type Task func() (interface{}, error)

Task for running in CS or by a worker node

Jump to

Keyboard shortcuts

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