recon

package
v0.0.0-...-6e15c72 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2013 License: GPL-3.0, AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package recon provides the SKS reconciliation protocol, prefix tree interface and an in-memory prefix-tree implementation.

Index

Constants

View Source
const (
	MsgTypeReconRqstPoly = MsgType(0)
	MsgTypeReconRqstFull = MsgType(1)
	MsgTypeElements      = MsgType(2)
	MsgTypeFullElements  = MsgType(3)
	MsgTypeSyncFail      = MsgType(4)
	MsgTypeDone          = MsgType(5)
	MsgTypeFlush         = MsgType(6)
	MsgTypeError         = MsgType(7)
	MsgTypeDbRqst        = MsgType(8)
	MsgTypeDbRepl        = MsgType(9)
	MsgTypeConfig        = MsgType(10)
)
View Source
const DefaultBitQuantum = 2
View Source
const DefaultJoinThreshold = DefaultSplitThreshold / 2
View Source
const DefaultMBar = 5
View Source
const DefaultNumSamples = DefaultMBar + 1
View Source
const DefaultSplitThreshold = DefaultThreshMult * DefaultMBar
View Source
const DefaultThreshMult = 10
View Source
const GOSSIP = "gossip:"
View Source
const SERVE = "serve:"

Variables

View Source
var ErrSamplePointElement = errors.New("Sample point added to elements")
View Source
var ErrUnexpectedLeafNode = errors.New("Unexpected leaf node")
View Source
var IncompatiblePeerError error = errors.New("Remote peer configuration is not compatible")
View Source
var NoPartnersError error = errors.New("No recon partners configured")
View Source
var PNodeNotFound error = errors.New("Prefix-tree node not found")
View Source
var ReconDone = errors.New("Reconciliation Done")
View Source
var ReconRqstPolyNotFound = errors.New("Peer should not receive a request for a non-existant node in ReconRqstPoly")
View Source
var RemoteConfigFailed string = "failed"
View Source
var RemoteConfigPassed string = "passed"
View Source
var RemoteRejectConfigError error = errors.New("Remote rejected configuration")
View Source
var SksZpNbytes int

Functions

func AddElementArray

func AddElementArray(t PrefixTree, z *Zp) (marray []*Zp, err error)

func DelElementArray

func DelElementArray(t PrefixTree, z *Zp) (marray []*Zp)

func NextChild

func NextChild(n PrefixNode, bs *Bitstring, depth int) int

func PadSksElement

func PadSksElement(zb []byte) []byte

func ReadBitstring

func ReadBitstring(r io.Reader) (*Bitstring, error)

func ReadInt

func ReadInt(r io.Reader) (n int, err error)

func ReadString

func ReadString(r io.Reader) (string, error)

func ReadZSet

func ReadZSet(r io.Reader) (*ZSet, error)

func ReadZZarray

func ReadZZarray(r io.Reader) ([]*Zp, error)

func ReadZp

func ReadZp(r io.Reader) (*Zp, error)

func WriteBitstring

func WriteBitstring(w io.Writer, bs *Bitstring) (err error)

func WriteInt

func WriteInt(w io.Writer, n int) (err error)

func WriteMsg

func WriteMsg(w io.Writer, msgs ...ReconMsg) (err error)

func WriteMsgDirect

func WriteMsgDirect(w io.Writer, msg ReconMsg) (err error)

func WriteString

func WriteString(w io.Writer, text string) (err error)

func WriteZSet

func WriteZSet(w io.Writer, zset *ZSet) error

func WriteZZarray

func WriteZZarray(w io.Writer, arr []*Zp) (err error)

func WriteZp

func WriteZp(w io.Writer, z *Zp) (err error)

Types

type Config

type Config struct {
	Version    string
	HttpPort   int
	BitQuantum int
	MBar       int
	Filters    string
	Custom     map[string]string
}

func (*Config) MsgType

func (msg *Config) MsgType() MsgType

func (*Config) String

func (msg *Config) String() string

type DbRepl

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

func (*DbRepl) MsgType

func (msg *DbRepl) MsgType() MsgType

func (*DbRepl) String

func (msg *DbRepl) String() string

type DbRqst

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

func (*DbRqst) MsgType

func (msg *DbRqst) MsgType() MsgType

func (*DbRqst) String

func (msg *DbRqst) String() string

type Done

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

func (*Done) MsgType

func (msg *Done) MsgType() MsgType

func (*Done) String

func (msg *Done) String() string

type Elements

type Elements struct {
	*ZSet
}

func (*Elements) MsgType

func (msg *Elements) MsgType() MsgType

func (*Elements) String

func (msg *Elements) String() string

type Error

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

func (*Error) MsgType

func (msg *Error) MsgType() MsgType

func (*Error) String

func (msg *Error) String() string

type Flush

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

func (*Flush) MsgType

func (msg *Flush) MsgType() MsgType

func (*Flush) String

func (msg *Flush) String() string

type FullElements

type FullElements struct {
	*ZSet
}

func (*FullElements) MsgType

func (msg *FullElements) MsgType() MsgType

func (*FullElements) String

func (msg *FullElements) String() string

type MemPrefixNode

type MemPrefixNode struct {
	// All nodes share the tree definition as a common context
	*MemPrefixTree
	// contains filtered or unexported fields
}

func (*MemPrefixNode) Children

func (n *MemPrefixNode) Children() (result []PrefixNode)

func (*MemPrefixNode) Elements

func (n *MemPrefixNode) Elements() []*Zp

func (*MemPrefixNode) IsLeaf

func (n *MemPrefixNode) IsLeaf() bool

func (*MemPrefixNode) Key

func (n *MemPrefixNode) Key() *Bitstring

func (*MemPrefixNode) Parent

func (n *MemPrefixNode) Parent() (PrefixNode, bool)

func (*MemPrefixNode) SValues

func (n *MemPrefixNode) SValues() []*Zp

func (*MemPrefixNode) Size

func (n *MemPrefixNode) Size() int

type MemPrefixTree

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

func (*MemPrefixTree) BitQuantum

func (t *MemPrefixTree) BitQuantum() int

func (*MemPrefixTree) Close

func (t *MemPrefixTree) Close() error

func (*MemPrefixTree) Create

func (t *MemPrefixTree) Create() error

func (*MemPrefixTree) Drop

func (t *MemPrefixTree) Drop() error

func (*MemPrefixTree) Init

func (t *MemPrefixTree) Init()

Init configures the tree with default settings if not already set, and initializes the internal state with sample data points, root node, etc.

func (*MemPrefixTree) Insert

func (t *MemPrefixTree) Insert(z *Zp) error

Insert a Z/Zp integer into the prefix tree

func (*MemPrefixTree) JoinThreshold

func (t *MemPrefixTree) JoinThreshold() int

func (*MemPrefixTree) Node

func (t *MemPrefixTree) Node(bs *Bitstring) (PrefixNode, error)

func (*MemPrefixTree) NumSamples

func (t *MemPrefixTree) NumSamples() int

func (*MemPrefixTree) Points

func (t *MemPrefixTree) Points() []*Zp

func (*MemPrefixTree) Remove

func (t *MemPrefixTree) Remove(z *Zp) error

Remove a Z/Zp integer from the prefix tree

func (*MemPrefixTree) Root

func (t *MemPrefixTree) Root() (PrefixNode, error)

func (*MemPrefixTree) SplitThreshold

func (t *MemPrefixTree) SplitThreshold() int

type MsgType

type MsgType uint8

func (MsgType) String

func (mt MsgType) String() string

type Peer

type Peer struct {
	*Settings
	PrefixTree
	RecoverChan RecoverChan
	// contains filtered or unexported fields
}

func NewMemPeer

func NewMemPeer() *Peer

func NewPeer

func NewPeer(settings *Settings, tree PrefixTree) *Peer

func (*Peer) Accept

func (p *Peer) Accept(conn net.Conn) error

func (*Peer) ExecCmd

func (p *Peer) ExecCmd(cmd reconCmd) (err error)

func (*Peer) Gossip

func (p *Peer) Gossip()

Gossip with remote servers, acting as a client.

func (*Peer) HandleCmds

func (p *Peer) HandleCmds()

HandleCmds executes recon cmds in a single goroutine. This forces sequential reads and writes to the prefix tree.

func (*Peer) InitiateRecon

func (p *Peer) InitiateRecon(conn net.Conn) error

func (*Peer) Insert

func (p *Peer) Insert(z *Zp) (err error)

func (*Peer) Pause

func (p *Peer) Pause()

func (*Peer) Remove

func (p *Peer) Remove(z *Zp) (err error)

func (*Peer) Resume

func (p *Peer) Resume()

func (*Peer) Serve

func (p *Peer) Serve()

func (*Peer) Start

func (p *Peer) Start()

func (*Peer) Stop

func (p *Peer) Stop()

type PrefixNode

type PrefixNode interface {
	BitQuantum() int
	Parent() (PrefixNode, bool)
	Key() *Bitstring
	Elements() []*Zp
	Size() int
	Children() []PrefixNode
	SValues() []*Zp
	IsLeaf() bool
}

func Find

func Find(t PrefixTree, z *Zp) (PrefixNode, error)

type PrefixTree

type PrefixTree interface {
	Init()
	Create() error
	Drop() error
	Close() error
	SplitThreshold() int
	JoinThreshold() int
	BitQuantum() int
	NumSamples() int
	Points() []*Zp
	Root() (PrefixNode, error)
	Node(key *Bitstring) (PrefixNode, error)
	Insert(z *Zp) error
	Remove(z *Zp) error
}

type ReconMsg

type ReconMsg interface {
	MsgType() MsgType
	// contains filtered or unexported methods
}

func ReadMsg

func ReadMsg(r io.Reader) (msg ReconMsg, err error)

type ReconRqstFull

type ReconRqstFull struct {
	Prefix   *Bitstring
	Elements *ZSet
}

func (*ReconRqstFull) MsgType

func (msg *ReconRqstFull) MsgType() MsgType

func (*ReconRqstFull) String

func (msg *ReconRqstFull) String() string

type ReconRqstPoly

type ReconRqstPoly struct {
	Prefix  *Bitstring
	Size    int
	Samples []*Zp
}

func (*ReconRqstPoly) MsgType

func (msg *ReconRqstPoly) MsgType() MsgType

func (*ReconRqstPoly) String

func (msg *ReconRqstPoly) String() string

type Recover

type Recover struct {
	RemoteAddr     net.Addr
	RemoteConfig   *Config
	RemoteElements []*Zp
}

func (*Recover) HkpAddr

func (r *Recover) HkpAddr() (string, error)

func (*Recover) String

func (r *Recover) String() string

type RecoverChan

type RecoverChan chan *Recover

type Settings

type Settings struct {
	*toml.TomlTree
	// contains filtered or unexported fields
}

func DefaultSettings

func DefaultSettings() (settings *Settings)

func LoadSettings

func LoadSettings(path string) (*Settings, error)

func NewSettings

func NewSettings(tree *toml.TomlTree) (settings *Settings)

func (*Settings) BitQuantum

func (s *Settings) BitQuantum() int

func (*Settings) Config

func (s *Settings) Config() *Config

func (*Settings) ConnTimeout

func (s *Settings) ConnTimeout() int

func (*Settings) Filters

func (s *Settings) Filters() []string

func (*Settings) GetInt

func (s *Settings) GetInt(key string, defaultValue int) int

func (*Settings) GetString

func (s *Settings) GetString(key string, defaultValue string) string

func (*Settings) GetStrings

func (s *Settings) GetStrings(key string) (value []string)

func (*Settings) GossipIntervalSecs

func (s *Settings) GossipIntervalSecs() int

func (*Settings) HttpPort

func (s *Settings) HttpPort() int

func (*Settings) JoinThreshold

func (s *Settings) JoinThreshold() int

func (*Settings) LogName

func (s *Settings) LogName() string

func (*Settings) MBar

func (s *Settings) MBar() int

func (*Settings) MaxOutstandingReconRequests

func (s *Settings) MaxOutstandingReconRequests() int

func (*Settings) NumSamples

func (s *Settings) NumSamples() int

func (*Settings) PartnerAddrs

func (s *Settings) PartnerAddrs() (addrs []net.Addr, err error)

func (*Settings) Partners

func (s *Settings) Partners() []string

func (*Settings) ReadTimeout

func (s *Settings) ReadTimeout() int

func (*Settings) ReconPort

func (s *Settings) ReconPort() int

func (*Settings) SplitThreshold

func (s *Settings) SplitThreshold() int

func (*Settings) ThreshMult

func (s *Settings) ThreshMult() int

func (*Settings) UpdateDerived

func (s *Settings) UpdateDerived()

func (*Settings) Version

func (s *Settings) Version() string

type SyncFail

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

func (*SyncFail) MsgType

func (msg *SyncFail) MsgType() MsgType

func (*SyncFail) String

func (msg *SyncFail) String() string

Directories

Path Synopsis
Package leveldb provides a key-value storage implementation of the recon prefix tree interface.
Package leveldb provides a key-value storage implementation of the recon prefix tree interface.

Jump to

Keyboard shortcuts

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