pipeline

package
v0.6.20 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2019 License: Apache-2.0, BSD-3-Clause, MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MD5ToBlockID = make(map[string]int)

MD5ToBlockID simple lookup table mapping an MD5 string to a blockID

View Source
var MD5ToBlockIDLock sync.RWMutex

MD5ToBlockIDLock a lock for the map

Functions

func NewBytesBufferChan

func NewBytesBufferChan(bufferSize uint64) chan []byte

NewBytesBufferChan creates a channel with 'n' slices of []bytes. 'n' is the bufferQCapacity. If the bufferQCapacity times bufferSize is greater than 1 GB 'n' is limited to a value that meets the constraint.

Types

type Part

type Part struct {
	Offset                  uint64
	BlockSize               uint32
	BytesToRead             uint32
	Data                    []byte // The data for the block.  Can be nil if not yet read from the source
	BlockID                 string
	DuplicateOfBlockOrdinal int // -1 if not a duplicate of another, already read, block.
	Ordinal                 int // sequentially assigned at creation time to enable chunk ordering (0,1,2)

	SourceURI      string
	TargetAlias    string
	NumberOfBlocks int
	BufferQ        chan []byte
	// contains filtered or unexported fields
}

Part description of and data for a block of the source

func ConstructPartsQueue

func ConstructPartsQueue(size uint64, blockSize uint64, sourceURI string, targetAlias string, bufferQ chan []byte) (parts []Part, numOfBlocks int)

ConstructPartsQueue constructs a slice of parts calculated arithmetically from blockSize and size.

func NewPart

func NewPart(offset uint64, bytesCount uint32, ordinal int, sourceURI string, targetAlias string) *Part

NewPart represents a block of data to be read from the source and written to the target

func (*Part) GetBuffer

func (p *Part) GetBuffer()

GetBuffer sets the part's buffer (p.Data) to slice of bytes of size BytesToRead. The slice is read from channel of pre-allocated buffers. If the channel is empty a new slice is allocated.

func (*Part) IsMD5Computed

func (p *Part) IsMD5Computed() bool

IsMD5Computed true if the MD5 value was computed

func (*Part) LookupMD5DupeOrdinal

func (p *Part) LookupMD5DupeOrdinal() (ordinal int)

LookupMD5DupeOrdinal finds the ordinal of a block which has the same data as this one. If none, then -1.

func (*Part) MD5

func (p *Part) MD5() string

MD5 returns computed MD5 for this block or empty string if no data yet.

func (*Part) MD5Bytes added in v0.6.12

func (p *Part) MD5Bytes() []byte

MD5Bytes TODO

func (*Part) NewBuffer

func (p *Part) NewBuffer() *bytes.Buffer

NewBuffer creates a new buffer from the underlying data

func (*Part) ReturnBuffer

func (p *Part) ReturnBuffer()

ReturnBuffer adds part's buffer to channel so it can be reused.

func (*Part) ToString

func (p *Part) ToString() string

ToString prints friendly format.

type PartsPartition

type PartsPartition struct {
	Offset          int64
	NumOfParts      int
	TotalNumOfParts int64
	TotalSize       int64
	PartitionSize   int64
	Parts           []Part
}

PartsPartition represents a set of parts that can be read sequentially starting at the partition's Offset

func ConstructPartsPartition

func ConstructPartsPartition(numOfPartitions int, size int64, blockSize int64, sourceURI string, targetAlias string, bufferQ chan []byte) []PartsPartition

ConstructPartsPartition creates a slice of PartsPartition with a len of numberOfPartitions.

type SourceInfo

type SourceInfo struct {
	SourceName  string
	Size        uint64
	TargetAlias string
}

SourceInfo basic information about a source item.

type SourcePipeline

type SourcePipeline interface {
	ConstructBlockInfoQueue(blockSize uint64) (partitionQ chan PartsPartition, partsQ chan Part, numOfBlocks int, Size uint64)
	ExecuteReader(partitionQ chan PartsPartition, partsQ chan Part, readPartsQ chan Part, id int, wg *sync.WaitGroup)
	GetSourcesInfo() []SourceInfo
}

SourcePipeline operations that abstract the creation of the empty and read parts channels.

type StorageAccountCredentials

type StorageAccountCredentials struct {
	AccountName string // short name of the storage account.  e.g., mystore
	AccountKey  string // Base64-encoded storage account key
}

StorageAccountCredentials a central location for account info.

type TargetCommittedListInfo

type TargetCommittedListInfo struct {
	List interface{}
}

TargetCommittedListInfo contains a list parts that have been written to a target.

type TargetPipeline

type TargetPipeline interface {
	PreProcessSourceInfo(source *SourceInfo, blockSize uint64) (err error)
	CommitList(listInfo *TargetCommittedListInfo, numberOfBlocks int, targetName string) (msg string, err error)
	WritePart(part *Part) (duration time.Duration, startTime time.Time, numOfRetries int, err error)
	ProcessWrittenPart(result *WorkerResult, listInfo *TargetCommittedListInfo) (requeue bool, err error)
}

TargetPipeline operations that abstract how parts a written and processed to a given target

type WorkerResult

type WorkerResult struct {
	BlockSize               int
	Result                  string
	WorkerID                int
	ItemID                  string
	DuplicateOfBlockOrdinal int
	Ordinal                 int
	Offset                  uint64
	SourceURI               string
	NumberOfBlocks          int
	TargetName              string
	Stats                   *WorkerResultStats
}

WorkerResult represents the result of a single block upload

type WorkerResultStats

type WorkerResultStats struct {
	Duration         time.Duration
	StartTime        time.Time
	Retries          int
	CumWriteDuration time.Duration
	NumOfWrites      int64
}

WorkerResultStats stats at the worker level.

Jump to

Keyboard shortcuts

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