models

package
v0.0.0-...-f3f2e11 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const M = 20 * 8

M - This is the max number of nodes in a finger table

Variables

This section is empty.

Functions

func GetClock

func GetClock() uint64

func IncrementClock

func IncrementClock(base uint64) uint64

func KeyToID

func KeyToID(key Identifier) uint64

KeyToID - helper to convert a key to a chord ring id

Types

type ContextKey

type ContextKey uint64

ContextKey - this is a type which is used as keys for the context

const (
	// DataPathContextKey - this is the context key for the data path
	DataPathContextKey ContextKey = iota
	// NumRequestWorkerContextKey - this is the context key for the data path
	NumRequestWorkerContextKey
	// SignatureContextKey - this is how the signature of the request is passed
	// to the handlers
	SignatureContextKey
	// ValidOwnerFunctionContextKey - function that performs validation of the ownership of a file
	ValidOwnerFunctionContextKey
	// RequestFileOwnerIDContextKey - The request "from" field
	RequestFileOwnerIDContextKey

	SelfPrivateKeyContextKey
	SelfIDContextKey
	SelfNodeContextKey
	UserPublicKeyContextKey
	ResourceNameContextKey
)

type Finger

type Finger struct {
	I         uint64
	Interval  Interval
	Successor Node
}

Finger - This is a finger entry

type FingerTable

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

FingerTable - This is the structure of a finger table

func NewFingerTable

func NewFingerTable() *FingerTable

NewFingerTable - Provision a new finger table

func (*FingerTable) GetIth

func (ft *FingerTable) GetIth(i uint64) (Finger, error)

GetIth - Get the i'th entry from the given finger table, and return that finger.

func (*FingerTable) SetIth

func (ft *FingerTable) SetIth(i uint64, interval Interval, successor, self Node) error

SetIth - Set the i'th entry in a given finger table

func (*FingerTable) ToString

func (ft *FingerTable) ToString() string

ToString - string representation of a finger table

type Identifier

type Identifier [20]byte

Identifier - This is a common Chord Identifier, also used for file names

type Interval

type Interval struct {
	Low  uint64 // excluded
	High uint64 // included
}

Interval - This is the interval in which a successor in the finger table is responsible

func NewInterval

func NewInterval(start, end Node) Interval

NewInterval - helper to create a new interval based on two nodes

func (Interval) ToString

func (i Interval) ToString() string

type Node

type Node struct {
	ID        Identifier
	Addr      string
	PublicKey *rsa.PublicKey
}

Node - This is a peer node representation

func (Node) Compare

func (n Node) Compare(nPrime Node) int

Compare - Given a Node, compare the parameter nPrime with this node to see which is greater/less/equal

func (Node) CompareID

func (n Node) CompareID(id Identifier) int

CompareID - Given a Node, compare it's ID to the id parameter

func (Node) ToString

func (n Node) ToString() string

ToString - Implementation of String

type SuccessorRequest

type SuccessorRequest struct {
	ID Identifier
}

SuccessorRequest - this is the chord successor request strurture, the ID is the key we are looking to find a successor for.

type TransactionEntity

type TransactionEntity struct {
	ResourceName string
	ResourceID   Identifier
	Entries      []TransactionEntry
}

TransactionEntity - a record of a transaction

type TransactionEntry

type TransactionEntry struct {
	Operation TransactionOperation
	ClientID  Identifier
	Timestamp uint64
}

type TransactionLog

type TransactionLog map[string]TransactionEntity

TransactionLog - a list of TransactionEntities

type TransactionOperation

type TransactionOperation int
const (
	UpdateOperation TransactionOperation = iota
	DeleteOperation
)

Jump to

Keyboard shortcuts

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