partitioner

package
v0.0.0-...-46d7ffa Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const PT_KEY_NAME = "partitionTable"
View Source
const REPLICATION_FACTOR = 3

do not change this without extensive testing

Variables

This section is empty.

Functions

func AddNode

func AddNode(oldPartionTable *[]VNode, assignNumbVNodes int, newNodeId string, newNodeIp string, newNodePort string) (*[]VNode, error)

func GenerateNewPartitionTable

func GenerateNewPartitionTable(assignNumbVNodes int, nodeId string, nodeIp string, nodePort string) *[]VNode

func GenerateUUID

func GenerateUUID() string

func GetHash

func GetHash(s []byte) uint64

func GetHashForString

func GetHashForString(s string) uint64

func GetRandom

func GetRandom(max int) int

func OrderInReverse

func OrderInReverse(m *map[string]int) []string

func PrintDataSyncTasks

func PrintDataSyncTasks(tasks []DataSyncTask)

func PrintDistribution

func PrintDistribution(vnodes []VNode)

************** FUNCTIONS USED DURING DEV *************************************************

func PrintReplicastDistribution

func PrintReplicastDistribution(vnodes []VNode)

func PrintVnodes

func PrintVnodes(vnodes []VNode)

func RemoveNode

func RemoveNode(oldPartionTable *[]VNode, oldNodeId string) *[]VNode

func UpdateReplication

func UpdateReplication(nodesInClusterReplicationLoad *map[string]int, nodeId string, currentNodeReplication *[]string)

func VNodeToString

func VNodeToString(v VNode) string

Types

type DataSyncAction

type DataSyncAction uint8
const (
	SendData DataSyncAction = iota
	SendDataForReplication
	DeleteData
)

func (DataSyncAction) String

func (s DataSyncAction) String() string

type DataSyncTask

type DataSyncTask struct {
	ID                    string
	StartToken            uint64
	EndToken              uint64
	Status                DataSyncTaskStatus
	FromNodeId            string
	ToNodeId              string
	VNodeId               string
	Action                DataSyncAction
	Progress              uint64 //to save which data have been already sent
	ProgressCollection    string //to save at which collection the progress is
	PartionTableTimestamp uint64
	Error                 error
}

type DataSyncTaskStatus

type DataSyncTaskStatus uint8
const (
	NewTask DataSyncTaskStatus = iota
	Streaming
	SuspendedForError
	CompletedMessageNotSent
	Completed
)

func (DataSyncTaskStatus) String

func (s DataSyncTaskStatus) String() string

type HashLocation

type HashLocation struct {
	Master   string
	Replicas []string
}

type PartitionTable

type PartitionTable struct {
	VNodes    []VNode `json:"vNodes"`
	Timestamp int64   `json:"timstamp"`
}

func InitEmptyPartitionTable

func InitEmptyPartitionTable() *PartitionTable

func InitPartitionTable

func InitPartitionTable(nodes []VNode, timstamp int64) *PartitionTable

func LoadFromDb

func LoadFromDb(systemDb *storage.Collection) (*PartitionTable, error)

func (*PartitionTable) CalculateDataSyncTasks

func (pt *PartitionTable) CalculateDataSyncTasks(nodeId string, newPartitionTable *PartitionTable) []DataSyncTask

func (*PartitionTable) GetLocation

func (pt *PartitionTable) GetLocation(hash uint64) HashLocation

func (*PartitionTable) PrintToStdOut

func (pt *PartitionTable) PrintToStdOut()

func (*PartitionTable) SaveToDb

func (pt *PartitionTable) SaveToDb(systemDb *storage.Collection) error

type VNode

type VNode struct {
	StartToken       uint64   `json:"startToken"` //included in this vnode ring
	EndToken         uint64   `json:"endToken"`   //included in this vnode ring
	NodeId           string   `json:"nodeId"`
	NodeIp           string   `json:"nodeIp"`
	NodePort         string   `json:"nodePort"`
	ReplicatedTo     []string `json:"replicatedTo"`
	VNodeID          string   `json:"vNodeId"`
	PrevNodeID       string   `json:"prevVNodeId"` //the node that previously owned this vnode
	PrevReplicatedTo []string `json:"prevReplicatedTo"`
}

func InitVNode

func InitVNode(startToken uint64, endToken uint64, prevNodeID string, prevReplicatedTo []string, vNodeID string, nodeId string, nodeIp string, nodePort string, replicatedTo []string) *VNode

Directories

Path Synopsis
Package murmur3 implements Austin Appleby's non-cryptographic MurmurHash3.
Package murmur3 implements Austin Appleby's non-cryptographic MurmurHash3.

Jump to

Keyboard shortcuts

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