chord

package module
v0.0.0-...-4fe8f7e Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2022 License: MIT Imports: 13 Imported by: 0

README

chord

Chord DHT

Documentation

Index

Constants

View Source
const (
	Names string = "Names"
	Funs  string = "Functions"
)
View Source
const (
	PatternSize int = 100
)

Variables

This section is empty.

Functions

func FireTest

func FireTest(ip, port, ipSucc, portSucc string)

func JoinTest

func JoinTest(ip, port, ipSucc, portSucc string)

func KMP

func KMP(haystack string, needle string) []int

func NewRPCServer

func NewRPCServer(n *Node) *rpc.Server

func RunServer

func RunServer(s *rpc.Server, addr Address, stopC chan struct{})

func SearchNext

func SearchNext(haystack string, needle string) int

Search Last Position String

func SearchString

func SearchString(haystack string, needle string) int

Search First Position String

func SelfTest

func SelfTest(ip, port, ipSucc, portSucc string)

func SleepTest

func SleepTest(ip, port, ipSucc, portSucc string)

func StabilizeTest

func StabilizeTest(ip, port, ipSucc, portSucc string)

Types

type Address

type Address struct {
	IP   string
	Port string
}

type Agent

type Agent struct {
	Name string
}

type Comunication

type Comunication interface {
	GetSuccessorOf(Address) (NodeInfo, error)
	GetSuccessorOfKey(Address, []byte) (NodeInfo, error)
	GetPredecessorOf(Address) (NodeInfo, error)
	Notify(Address) error
	Ping(Address) bool
	AskForAKey(Address, []byte) (string, error)
}

Interface for comunication between Chord nodes All nodes have to implemet the interface

type Config

type Config struct {
	Hash     func() hash.Hash
	HashSize int
}

func DefaultConfig

func DefaultConfig() *Config

type DBChord

type DBChord interface {
	GetByName(string) ([]byte, error)
	//GetByFun(string) ([]string, error)
	Set(string, string, []byte) error
	Update(string, []byte) error
	Delete(string, string) error
}

type DataBasePl

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

Base de Datos para la plataforma

func NewDataBase

func NewDataBase(fileName string) *DataBasePl

func (*DataBasePl) Delete

func (db *DataBasePl) Delete(vKey []byte) error

func (*DataBasePl) GetAll

func (db *DataBasePl) GetAll() ([][]byte, error)

func (*DataBasePl) GetByName

func (db *DataBasePl) GetByName(key []byte) ([]byte, error)

func (*DataBasePl) Set

func (db *DataBasePl) Set(vKey []byte, vData []byte) error

func (*DataBasePl) Update

func (db *DataBasePl) Update(vKey []byte, vData []byte) error

type DataBasePlatform

type DataBasePlatform interface {
	GetByName([]byte) ([]byte, error)
	//GetByFun(string) ([][]byte, error)
	GetAll() ([][]byte, error)
	Set([]byte, []byte) error
	Update([]byte, []byte) error
	Delete([]byte) error
}

type DataKeyRequest

type DataKeyRequest struct {
	Key  []byte
	Data []byte
}

type DataResponse

type DataResponse struct {
	Data []byte
}

type EmptyRequest

type EmptyRequest struct{}

Request structs

type EmptyResponse

type EmptyResponse struct{}

Response structs

type KeyRequest

type KeyRequest struct{ Key []byte }

type Node

type Node struct {
	Info NodeInfo
	// contains filtered or unexported fields
}

func NewNode

func NewNode(info NodeInfo, cnf *Config, knowNode *NodeInfo, dbName string) *Node

func (*Node) AskForAKey

func (n *Node) AskForAKey(addr Address, key []byte) ([]byte, error)

Storage Methods

func (*Node) Delete

func (n *Node) Delete(name string, fun string) error

Falta arreglar error de no tener el Names o Fun

func (*Node) DeleteResource

func (n *Node) DeleteResource(request *KeyRequest, response *EmptyResponse) error

func (*Node) GetByName

func (n *Node) GetByName(agentName string) ([]byte, error)

func (*Node) GetPredecessorOf

func (n *Node) GetPredecessorOf(addr Address) (*NodeInfo, error)

Get the predecessor of nodeInfo

func (*Node) GetPredecessorOfRPC

func (n *Node) GetPredecessorOfRPC(request *EmptyRequest, response *NodeInfoResponse) error

Exported rpc method for getPredecessor

func (*Node) GetResource

func (n *Node) GetResource(request *KeyRequest, response *DataResponse) error

func (*Node) GetSuccessorOf

func (n *Node) GetSuccessorOf(addr Address) (*NodeInfo, error)

GetSuccessor -> Comunication interface implementation

func (*Node) GetSuccessorOfKey

func (n *Node) GetSuccessorOfKey(addr Address, key []byte) (*NodeInfo, error)

Ask node at address addr for the successor of key

func (*Node) GetSuccessorOfKeyRPC

func (n *Node) GetSuccessorOfKeyRPC(resquest *KeyRequest, response *NodeInfoResponse) error

Exported rpc method for GetSuccessorOfKey

func (*Node) GetSuccessorRPC

func (n *Node) GetSuccessorRPC(request *EmptyRequest, response *NodeInfoResponse) error

Exported rpc method for GetSuccessor

func (*Node) Join

func (n *Node) Join(knowNode *NodeInfo) error

Join node n to Chord Ring If knowNode is nil then n is the only node In the Ring

func (*Node) MakePingRPC

func (n *Node) MakePingRPC(request *EmptyRequest, response *EmptyResponse) error

func (*Node) Notify

func (n *Node) Notify(addr Address) error

Notify the successor of n that n exist

func (*Node) NotifyNode

func (n *Node) NotifyNode(request *NodeInfoRequest, response *EmptyResponse) error

Exported rpc method for notify

func (*Node) Ping

func (n *Node) Ping(addr Address) bool

Make ping to a node

func (*Node) SaveResource

func (n *Node) SaveResource(request *DataKeyRequest, response *EmptyResponse) error

func (*Node) SendDelete

func (n *Node) SendDelete(addr Address, key []byte) error

func (*Node) SendSet

func (n *Node) SendSet(addr Address, key, data []byte) error

func (*Node) Set

func (n *Node) Set(name string, fun string, data []byte) error

func (*Node) Stop

func (n *Node) Stop()

Stop

func (*Node) Update

func (n *Node) Update(name string, data []byte) error

Arreglar

type NodeInfo

type NodeInfo struct {
	NodeID   []byte
	EndPoint Address
}

type NodeInfoRequest

type NodeInfoRequest struct{ NInfo *NodeInfo }

type NodeInfoResponse

type NodeInfoResponse struct {
	NInfo *NodeInfo
	IsNil bool
}

type PingResquestError

type PingResquestError struct{}

Alive error

func (PingResquestError) Error

func (p PingResquestError) Error() string

type RowData

type RowData struct {
	Key  []byte
	Data []byte
}

Cada informacion es un par key-data

type StorageError

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

Errors

func (StorageError) Error

func (se StorageError) Error() string

Jump to

Keyboard shortcuts

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