chord

package
v0.0.0-...-a24eca1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	M = 160

	SuccListLen = 10

	UpdateInterval = 50 * time.Millisecond

	RemoteTryTime     = 3
	RemoteTryInterval = 25 * time.Millisecond
)

Variables

View Source
var Log = logrus.New()
View Source
var Mod = big.NewInt(0).Exp(big.NewInt(2), big.NewInt(M), nil)

Functions

func Diag

func Diag(addr string) (*rpc.Client, error)

func Hash

func Hash(str string) big.Int

func IsIn

func IsIn(ll *big.Int, rr *big.Int, val *big.Int, lClosed bool, rClosed bool) bool

func LogInit

func LogInit()

func Ping

func Ping(addr string) error

Types

type AddrType

type AddrType struct {
	Ip string
	Id big.Int
}

type BoolStrPair

type BoolStrPair struct {
	First  bool
	Second string
}

type LockMap

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

func (*LockMap) Copy

func (this *LockMap) Copy() map[string]string

func (*LockMap) Delete

func (this *LockMap) Delete(key string) (founded bool)

func (*LockMap) Init

func (this *LockMap) Init()

func (LockMap) Load

func (this LockMap) Load(key string) (founded bool, ret string)

func (*LockMap) Store

func (this *LockMap) Store(key string, val string)

type NodeType

type NodeType struct {
	Addr    AddrType
	Running bool
	// contains filtered or unexported fields
}

func NewNode

func NewNode(ip string) *NodeType

func (*NodeType) Create

func (this *NodeType) Create()

Create the Network in NodeType: pre and suc <- self

func (*NodeType) Delete

func (this *NodeType) Delete(key string) bool

Delete Key

func (*NodeType) Display

func (this *NodeType) Display()

Display for debug

func (*NodeType) FixFingers

func (this *NodeType) FixFingers(fixPos *int)

FixFingers fixPos is the index to fix, every time fixPos++ to fix the next pos

func (*NodeType) ForceQuit

func (this *NodeType) ForceQuit()

ForceQuit can't rpc anyone

func (*NodeType) Get

func (this *NodeType) Get(key string) (founded bool, value string)

Get V

func (*NodeType) Join

func (this *NodeType) Join(ip string) bool

Join Guide: ip

func (*NodeType) Put

func (this *NodeType) Put(key string, value string) bool

Put K-V Pair

func (*NodeType) Quit

func (this *NodeType) Quit()

Quit tell pre and suc, move its data to succ

func (*NodeType) Updating

func (this *NodeType) Updating()

Updating 3 stages, When a Node is Running, it will Updating its data

type ReceiverType

type ReceiverType struct {
	Node     *NodeType
	Server   *rpc.Server
	Listener net.Listener
}

func NewReceiver

func NewReceiver(ip string) *ReceiverType

func (*ReceiverType) BackupDirectlyDelete

func (this *ReceiverType) BackupDirectlyDelete(args string, reply *bool) error

func (*ReceiverType) BackupDirectlyPut

func (this *ReceiverType) BackupDirectlyPut(args StrPair, reply *bool) error

func (*ReceiverType) Delete

func (this *ReceiverType) Delete(args string, reply *bool) error

func (*ReceiverType) DirectlyDelete

func (this *ReceiverType) DirectlyDelete(args string, reply *bool) error

func (*ReceiverType) DirectlyPut

func (this *ReceiverType) DirectlyPut(args StrPair, reply *bool) error

func (ReceiverType) FindSuccessor

func (this ReceiverType) FindSuccessor(args *big.Int, reply *AddrType) error

func (*ReceiverType) Get

func (this *ReceiverType) Get(args string, reply *BoolStrPair) error

func (*ReceiverType) GetData

func (this *ReceiverType) GetData(_ int, reply *map[string]string) error

func (ReceiverType) GetPredecessor

func (this ReceiverType) GetPredecessor(_ int, reply *AddrType) error

func (ReceiverType) GetSuccList

func (this ReceiverType) GetSuccList(_ int, reply *SuccListType) error

func (*ReceiverType) MergeIntoBackup

func (this *ReceiverType) MergeIntoBackup(args map[string]string, _ *int) error

func (*ReceiverType) MergeIntoData

func (this *ReceiverType) MergeIntoData(args map[string]string, _ *int) error

func (*ReceiverType) MoveFromData

func (this *ReceiverType) MoveFromData(args []string, _ *int) error

func (*ReceiverType) Notify

func (this *ReceiverType) Notify(args *AddrType, _ *int) error

func (*ReceiverType) PredecessorUpdate

func (this *ReceiverType) PredecessorUpdate(args *AddrType, _ *int) error

func (*ReceiverType) Put

func (this *ReceiverType) Put(args StrPair, reply *bool) error

func (*ReceiverType) SuccListUpdate

func (this *ReceiverType) SuccListUpdate(args *AddrType, _ *int) error

func (*ReceiverType) UpdateBackup

func (this *ReceiverType) UpdateBackup(args map[string]string, reply *int) error

type StrPair

type StrPair struct {
	First  string
	Second string
}

type SuccListType

type SuccListType [SuccListLen]AddrType

Jump to

Keyboard shortcuts

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