chord

package
v0.0.0-...-3638f0a Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Mod *big.Int

	CutTime  time.Duration
	WaitTime time.Duration
)

Functions

func CalHash

func CalHash(str string) *big.Int

func GenerateClient

func GenerateClient(address string) (*rpc.Client, error)

func GetLocalIP

func GetLocalIP() string

func IfOnline

func IfOnline(address string) bool

func In

func In(target, low, high *big.Int) bool

func PlusTwoPower

func PlusTwoPower(raw *big.Int, exp int) *big.Int

PlusTwoPower (raw+2^exp)%Mod

func RemoteCall

func RemoteCall(addr string, serviceMethod string, args interface{}, reply interface{}) error

func WrappedAccept

func WrappedAccept(server *rpc.Server, lis net.Listener, ptr *Node)

Types

type DataManager

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

func (*DataManager) Init

func (ptr *DataManager) Init(targetNode *Node)

type Node

type Node struct {
	Id *big.Int
	// contains filtered or unexported fields
}

func (*Node) Create

func (ptr *Node) Create()

Create /* "Create" and "Join" are called after calling "Run". */

For a dhtNode, either "Create" or "Join" will be called, but not both.

func (*Node) DataSize

func (ptr *Node) DataSize() int

func (*Node) Delete

func (ptr *Node) Delete(key string) bool

func (*Node) ForceQuit

func (ptr *Node) ForceQuit()

ForceQuit /* Chord offers a way of "normal" quitting. */

For "force quit", the node quit the network without informing other nodes.
"ForceQuit" will be checked by TA manually.

func (*Node) Get

func (ptr *Node) Get(key string) (bool, string)

func (*Node) Init

func (ptr *Node) Init(port int)

func (*Node) Join

func (ptr *Node) Join(addr string) bool

func (*Node) Ping

func (ptr *Node) Ping(addr string) bool

Ping /* Check whether the node represented by the IP address is in the network. */

func (*Node) Put

func (ptr *Node) Put(key string, value string) bool

Put /* Put a key-value pair into the network (if KEY is already in the network, cover it), or

func (*Node) Quit

func (ptr *Node) Quit()

Quit /* Quit from the network it is currently in.*/

"Quit" will not be called before "Create" or "Join".
For a dhtNode, "Quit" may be called for many times.
For a quited node, call "Quit" again should have no effect.

func (*Node) Run

func (ptr *Node) Run()

Run /* "Run" is called after calling "NewNode". */

type Pair

type Pair struct {
	Key   string
	Value string
}

type RpcNode

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

func (*RpcNode) BackupAdd

func (ptr *RpcNode) BackupAdd(dataSet *map[string]string, _ *string) error

func (*RpcNode) BackupDelete

func (ptr *RpcNode) BackupDelete(key string, _ *string) error

func (*RpcNode) BackupRemove

func (ptr *RpcNode) BackupRemove(dataSet *map[string]string, _ *string) error

func (*RpcNode) BackupStore

func (ptr *RpcNode) BackupStore(dataPair Pair, _ *string) error

func (*RpcNode) DeleteData

func (ptr *RpcNode) DeleteData(key string, _ *string) error

func (*RpcNode) FindSuccessor

func (ptr *RpcNode) FindSuccessor(target *big.Int, result *string) error

func (*RpcNode) FixPredecessor

func (ptr *RpcNode) FixPredecessor(_ string, _ *string) error

func (*RpcNode) GenerateBackup

func (ptr *RpcNode) GenerateBackup(_ string, dataSet *map[string]string) error

func (*RpcNode) GetData

func (ptr *RpcNode) GetData(key string, value *string) error

func (*RpcNode) GetPredecessor

func (ptr *RpcNode) GetPredecessor(_ string, result *string) error

func (*RpcNode) GetSuccessorList

func (ptr *RpcNode) GetSuccessorList(_ string, result *[successorListSize]string) error

func (*RpcNode) InheritData

func (ptr *RpcNode) InheritData(preAddr string, dataSet *map[string]string) error

func (*RpcNode) Notify

func (ptr *RpcNode) Notify(addr string, _ *string) error

func (*RpcNode) Stabilize

func (ptr *RpcNode) Stabilize(_ string, _ *string) error

func (*RpcNode) StoreData

func (ptr *RpcNode) StoreData(dataPair Pair, _ *string) error

type WrapNode

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

func GenerateWrapNode

func GenerateWrapNode(addr string) WrapNode

func (*WrapNode) BackupAdd

func (ptr *WrapNode) BackupAdd(dataSet *map[string]string) error

func (*WrapNode) BackupDelete

func (ptr *WrapNode) BackupDelete(key string) error

func (*WrapNode) BackupRemove

func (ptr *WrapNode) BackupRemove(dataSet *map[string]string) error

func (*WrapNode) BackupStore

func (ptr *WrapNode) BackupStore(data Pair) error

func (*WrapNode) DeleteData

func (ptr *WrapNode) DeleteData(key string) error

func (*WrapNode) FindSuccessor

func (ptr *WrapNode) FindSuccessor(target *big.Int, result *string) error

func (*WrapNode) FixPredecessor

func (ptr *WrapNode) FixPredecessor() error

func (*WrapNode) GenerateBackup

func (ptr *WrapNode) GenerateBackup(dataSet *map[string]string) error

func (*WrapNode) GetData

func (ptr *WrapNode) GetData(key string, value *string) error

func (*WrapNode) GetPredecessor

func (ptr *WrapNode) GetPredecessor(result *string) error

func (*WrapNode) GetSuccessorList

func (ptr *WrapNode) GetSuccessorList(result *[successorListSize]string) error

func (*WrapNode) InheritData

func (ptr *WrapNode) InheritData(preAddr string, preStorage *map[string]string) error

func (*WrapNode) Notify

func (ptr *WrapNode) Notify(target string) error

func (*WrapNode) Stabilize

func (ptr *WrapNode) Stabilize() error

func (*WrapNode) StoreData

func (ptr *WrapNode) StoreData(key string, value string) error

Jump to

Keyboard shortcuts

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