state

package
v0.0.0-...-fd5963e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlobIterator

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

BlobIterator is used to iterate metadata of blobs in state.

func (*BlobIterator) Blob

func (i *BlobIterator) Blob() (core.BlobID, *fb.BlobF)

Blob returns metadata of the blob pointed by iterator. Only call this if 'Next' returns true.

func (*BlobIterator) Next

func (i *BlobIterator) Next() (has bool)

Next advances the iterator to next position. Returns true if it's not ended.

type ChecksumPosition

type ChecksumPosition struct {
	Blob []byte
	RS   []byte
}

ChecksumPosition records the starting or endpoing point of a checksum iteration.

type EncodedTract

type EncodedTract struct {
	ID         core.TractID
	Offset     int
	Length     int
	NewVersion int
}

EncodedTract describes one tract in an RSChunk

type PartitionAndID

type PartitionAndID struct {
	ID core.PartitionID
	P  fb.PartitionF
}

type RSChunkIterator

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

RSChunkIterator is used to iterate over RSChunks in state.

func (*RSChunkIterator) Next

func (i *RSChunkIterator) Next() (has bool)

Next advances the iterator to next position. Returns true if it's not ended.

func (*RSChunkIterator) RSChunk

func (i *RSChunkIterator) RSChunk() (core.RSChunkID, *fb.RSChunkF)

RSChunk returns the chunk pointed by iterator. Only call this if 'Next' returns true.

type State

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

State represents replicated state of a curator.

func Open

func Open(path string) *State

Open opens the state database on disk. If the path doesn't exist it will create a new one.

func (*State) Close

func (s *State) Close()

Close closes current State. Caller must guarantee that all transactions have been closed before calling "Close".

func (*State) ReadOnlyTxn

func (s *State) ReadOnlyTxn() *Txn

ReadOnlyTxn returns a Txn that supports read-only access to State. ReadOnlyTxn will get better concurrency than read-write transactions.

func (*State) WriteTxn

func (s *State) WriteTxn(index uint64) *Txn

WriteTxn returns a Txn that supports read-write accesses to State. All mutations to State from a Txn object will not be visible to other transactions until 'Commit' is called, though the uncommitted mutations can be seen by reads from the same Txn object. After you are done with the Txn you should call 'Commit' to make the mutations effective. It's OK to start multiple transactions from multiple threads, all write transactions will be serialized underneath.

type Txn

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

Txn is a transaction object that captures current snapshot of the state. Operations of Txn are done on the snapshot of the state and if there are mutations they will only be visible to other transactions after 'Commit' is called.

func (*Txn) BatchUpdateTimes

func (t *Txn) BatchUpdateTimes(updates []UpdateTime)

BatchUpdateTimes updates mtime/atime for a bunch of blobs at once. Errors are ignored.

func (*Txn) ChangeTract

func (t *Txn) ChangeTract(id core.TractID, version int, hosts []core.TractserverID) core.Error

ChangeTract changes the version and hosts list for a single tract. The hosts list may not change size, and the version must be exactly one greater than the previous version.

func (*Txn) Checksum

func (t *Txn) Checksum(start ChecksumPosition, n int) (checksum uint64, next ChecksumPosition)

Checksum computes a checksum of a portion of the state. Partitions and metadata are always included, and a subset of the blob and RS data (since that can be very large).

func (*Txn) Commit

func (t *Txn) Commit()

Commit commits all mutations in Txn to State, if there's any. Commit never fails.

func (*Txn) DeleteBlob

func (t *Txn) DeleteBlob(id core.BlobID, when time.Time) core.Error

DeleteBlob marks a blob as deleted instead of actually deleting it.

func (*Txn) Dump

func (t *Txn) Dump(writer io.Writer) (int64, error)

Dump dumps the state of the DB to a given writer.

func (*Txn) FinishDeleteBlobs

func (t *Txn) FinishDeleteBlobs(ids []core.BlobID) core.Error

FinishDeleteBlobs deletes the given blobs from the database. This is final and the blobs CANNOT be recovered after this. The caller must ensure that the given blobs have a deletion time or expiry time in the past.

func (*Txn) GetBlob

func (t *Txn) GetBlob(id core.BlobID) *fb.BlobF

GetBlob returns a blob given its blob ID. It will only return if the blob exists and is not marked as deleted.

func (*Txn) GetBlobAll

func (t *Txn) GetBlobAll(id core.BlobID) *fb.BlobF

GetBlobAll is like GetBlob, but also returns blob that is marked as deleted.

func (*Txn) GetCuratorID

func (t *Txn) GetCuratorID() core.CuratorID

GetCuratorID returns curator ID.

func (*Txn) GetIndex

func (t *Txn) GetIndex() uint64

GetIndex returns the index of the latest transaction.

func (*Txn) GetIterator

func (t *Txn) GetIterator(start core.BlobID) (it *BlobIterator, has bool)

GetIterator returns an iterator that can iterate all blobs, and a boolean whether the iterator has any blobs left. The iteration will only see the current snapshot of the state, it's concurrent with any modifications. The iterator is positioned at the given blob to start (or the blob with the next higher ID.

func (*Txn) GetKnownTSIDs

func (t *Txn) GetKnownTSIDs() []core.TractserverID

GetKnownTSIDs returns all the known TSIDs in the database as a slice. Note that IDs that were added during this transaction may not be returned.

func (*Txn) GetPartition

func (t *Txn) GetPartition(id core.PartitionID) *fb.PartitionF

GetPartition returns info of a given partition.

func (*Txn) GetPartitions

func (t *Txn) GetPartitions() (partitions []PartitionAndID)

GetPartitions returns all partitions of this curator.

func (*Txn) GetRSChunk

func (t *Txn) GetRSChunk(id core.RSChunkID) *fb.RSChunkF

GetRSChunk returns an RS chunk given its ID.

func (*Txn) GetRSChunkIterator

func (t *Txn) GetRSChunkIterator(start core.RSChunkID) (it *RSChunkIterator, has bool)

GetRSChunkIterator returns an iterator that can iterate over all RS chunks.

func (*Txn) GetReadOnlyMode

func (t *Txn) GetReadOnlyMode() bool

GetReadOnlyMode returns true if the read-only flag is set in the state. Note that this has nothing to do with whether the transaction is read-only.

func (*Txn) GetTracts

func (t *Txn) GetTracts(id core.BlobID, start, end int) ([]core.TractInfo, core.StorageClass, core.Error)

GetTracts returns tracts of a blob from [start, end), if 'end' is past the last tract of the blob, only the tracts from 'start' to the last one will be returned.

func (*Txn) LookupRSPiece

func (t *Txn) LookupRSPiece(id core.TractID) (core.TractserverID, bool)

LookupRSPiece looks up an RS chunk ID (passed as a TractID) in the RS chunk bucket and returns the tractserver that it's supposed to be on, or false if the chunk piece ID is unknown.

func (*Txn) PutBlob

func (t *Txn) PutBlob(id core.BlobID, blob *fb.Blob)

PutBlob puts blob metadata into state.

func (*Txn) PutPartition

func (t *Txn) PutPartition(id core.PartitionID, partition *fb.Partition)

PutPartition puts a partition into state.

func (*Txn) PutRSChunk

func (t *Txn) PutRSChunk(id core.RSChunkID,
	storage core.StorageClass,
	hosts []core.TractserverID,
	data [][]EncodedTract) core.Error

PutRSChunk adds a new RSChunk and updates all the contained tracts to point to it.

func (*Txn) SetBlobMetadata

func (t *Txn) SetBlobMetadata(id core.BlobID, md core.BlobInfo) core.Error

SetBlobMetadata changes metadata for a blob. Only fields Hint, MTime, ATime, and Expires are used from md, others are ignored. Zero values for those fields mean "don't change this".

func (*Txn) SetCuratorID

func (t *Txn) SetCuratorID(id core.CuratorID)

SetCuratorID sets curator ID to 'id'.

func (*Txn) SetReadOnlyMode

func (t *Txn) SetReadOnlyMode(mode bool)

SetReadOnlyMode changes the read-only flag state. Note that this has nothing to do with whether the transaction is read-only.

func (*Txn) Stat

func (t *Txn) Stat(id core.BlobID) (info core.BlobInfo, err core.Error)

Stat returns stat of a blob.

func (*Txn) UndeleteBlob

func (t *Txn) UndeleteBlob(id core.BlobID) core.Error

UndeleteBlob undeletes a blob that is marked as deleted.

func (*Txn) UpdateRSHosts

func (t *Txn) UpdateRSHosts(id core.RSChunkID, hosts []core.TractserverID) core.Error

UpdateRSHosts updates the host set for one RS chunk.

func (*Txn) UpdateStorageClass

func (t *Txn) UpdateStorageClass(id core.BlobID, storage core.StorageClass) core.Error

UpdateStorageClass changes the storage class of a blob. All the tracts in the blob must already support the new class.

type UpdateTime

type UpdateTime struct {
	Blob         core.BlobID
	MTime, ATime int64 // zero means "don't change"
}

UpdateTime is an instruction to update one blob's mtime/atime.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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