model

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2014 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package model implements repository abstraction and file pulling mechanisms

Index

Constants

View Source
const (
	RepoIdle repoState = iota
	RepoScanning
	RepoSyncing
	RepoCleaning
)
View Source
const (
	IndexPerBlockSize = 40 // Each BlockInfo is approximately this big

)

How many files to send in each Index/IndexUpdate message.

Variables

View Source
var (
	ErrNoSuchFile = errors.New("no such file")
	ErrInvalid    = errors.New("file is invalid")
)

Functions

This section is empty.

Types

type ConnectionInfo

type ConnectionInfo struct {
	protocol.Statistics
	Address       string
	ClientVersion string
}

type Model

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

func NewModel

func NewModel(indexDir string, cfg *config.Configuration, nodeName, clientName, clientVersion string, db *leveldb.DB) *Model

NewModel creates and starts a new model. The model starts in read-only mode, where it sends index information to connected peers and responds to requests for file data without altering the local repository in any way.

func (*Model) AddConnection

func (m *Model) AddConnection(rawConn io.Closer, protoConn protocol.Connection)

AddConnection adds a new peer connection to the model. An initial index will be sent to the connected peer, thereafter index updates whenever the local repository changes.

func (*Model) AddRepo added in v0.8.6

func (m *Model) AddRepo(cfg config.RepositoryConfiguration)

func (*Model) CleanRepos added in v0.8.6

func (m *Model) CleanRepos()

func (*Model) Close

func (m *Model) Close(node protocol.NodeID, err error)

Close removes the peer from the model and closes the underlying connection if possible. Implements the protocol.Model interface.

func (*Model) ClusterConfig added in v0.8.6

func (m *Model) ClusterConfig(nodeID protocol.NodeID, config protocol.ClusterConfigMessage)

func (*Model) Completion added in v0.9.0

func (m *Model) Completion(node protocol.NodeID, repo string) float64

Returns the completion status, in percent, for the given node and repo.

func (*Model) ConnectedTo

func (m *Model) ConnectedTo(nodeID protocol.NodeID) bool

ConnectedTo returns true if we are connected to the named node.

func (*Model) ConnectionStats

func (m *Model) ConnectionStats() map[string]ConnectionInfo

ConnectionStats returns a map with connection statistics for each connected node.

func (*Model) CurrentGlobalFile added in v0.8.6

func (m *Model) CurrentGlobalFile(repo string, file string) protocol.FileInfo

func (*Model) CurrentRepoFile added in v0.8.6

func (m *Model) CurrentRepoFile(repo string, file string) protocol.FileInfo

func (*Model) GlobalSize

func (m *Model) GlobalSize(repo string) (files, deleted int, bytes int64)

GlobalSize returns the number of files, deleted files and total bytes for all files in the global model.

func (*Model) Index

func (m *Model) Index(nodeID protocol.NodeID, repo string, fs []protocol.FileInfo)

Index is called when a new node is connected and we receive their full index. Implements the protocol.Model interface.

func (*Model) IndexUpdate

func (m *Model) IndexUpdate(nodeID protocol.NodeID, repo string, fs []protocol.FileInfo)

IndexUpdate is called for incremental updates to connected nodes' indexes. Implements the protocol.Model interface.

func (*Model) LocalSize

func (m *Model) LocalSize(repo string) (files, deleted int, bytes int64)

LocalSize returns the number of files, deleted files and total bytes for all files in the local repository.

func (*Model) LocalVersion added in v0.9.0

func (m *Model) LocalVersion(repo string) uint64

Version returns the change version for the given repository. This is guaranteed to increment if the contents of the local or global repository has changed.

func (*Model) NeedFilesRepo added in v0.8.6

func (m *Model) NeedFilesRepo(repo string) []protocol.FileInfo

NeedFiles returns the list of currently needed files

func (*Model) NeedSize added in v0.8.6

func (m *Model) NeedSize(repo string) (files int, bytes int64)

NeedSize returns the number and total size of currently needed files.

func (*Model) NodeStatistics added in v0.9.9

func (m *Model) NodeStatistics() map[string]stats.NodeStatistics

Returns statistics about each node

func (*Model) Override added in v0.8.16

func (m *Model) Override(repo string)

func (*Model) ReplaceLocal

func (m *Model) ReplaceLocal(repo string, fs []protocol.FileInfo)

ReplaceLocal replaces the local repository index with the given list of files.

func (*Model) Request

func (m *Model) Request(nodeID protocol.NodeID, repo, name string, offset int64, size int) ([]byte, error)

Request returns the specified data segment by reading it from local disk. Implements the protocol.Model interface.

func (*Model) ScanRepo added in v0.8.6

func (m *Model) ScanRepo(repo string) error

func (*Model) ScanRepoSub added in v0.9.3

func (m *Model) ScanRepoSub(repo, sub string) error

func (*Model) ScanRepos added in v0.8.6

func (m *Model) ScanRepos()

func (*Model) StartRepoRO added in v0.8.6

func (m *Model) StartRepoRO(repo string)

StartRO starts read only processing on the current model. When in read only mode the model will announce files to the cluster but not pull in any external changes.

func (*Model) StartRepoRW added in v0.8.6

func (m *Model) StartRepoRW(repo string, threads int)

StartRW starts read/write processing on the current model. When in read/write mode the model will attempt to keep in sync with the cluster by pulling needed files from peer nodes.

func (*Model) State added in v0.8.6

func (m *Model) State(repo string) (string, time.Time)

Jump to

Keyboard shortcuts

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