Documentation ¶
Index ¶
- type BlobIterator
- type ChecksumPosition
- type EncodedTract
- type PartitionAndID
- type RSChunkIterator
- type State
- type Txn
- func (t *Txn) BatchUpdateTimes(updates []UpdateTime)
- func (t *Txn) ChangeTract(id core.TractID, version int, hosts []core.TractserverID) core.Error
- func (t *Txn) Checksum(start ChecksumPosition, n int) (checksum uint64, next ChecksumPosition)
- func (t *Txn) Commit()
- func (t *Txn) DeleteBlob(id core.BlobID, when time.Time) core.Error
- func (t *Txn) Dump(writer io.Writer) (int64, error)
- func (t *Txn) FinishDeleteBlobs(ids []core.BlobID) core.Error
- func (t *Txn) GetBlob(id core.BlobID) *fb.BlobF
- func (t *Txn) GetBlobAll(id core.BlobID) *fb.BlobF
- func (t *Txn) GetCuratorID() core.CuratorID
- func (t *Txn) GetIndex() uint64
- func (t *Txn) GetIterator(start core.BlobID) (it *BlobIterator, has bool)
- func (t *Txn) GetKnownTSIDs() []core.TractserverID
- func (t *Txn) GetPartition(id core.PartitionID) *fb.PartitionF
- func (t *Txn) GetPartitions() (partitions []PartitionAndID)
- func (t *Txn) GetRSChunk(id core.RSChunkID) *fb.RSChunkF
- func (t *Txn) GetRSChunkIterator(start core.RSChunkID) (it *RSChunkIterator, has bool)
- func (t *Txn) GetReadOnlyMode() bool
- func (t *Txn) GetTracts(id core.BlobID, start, end int) ([]core.TractInfo, core.StorageClass, core.Error)
- func (t *Txn) LookupRSPiece(id core.TractID) (core.TractserverID, bool)
- func (t *Txn) PutBlob(id core.BlobID, blob *fb.Blob)
- func (t *Txn) PutPartition(id core.PartitionID, partition *fb.Partition)
- func (t *Txn) PutRSChunk(id core.RSChunkID, storage core.StorageClass, hosts []core.TractserverID, ...) core.Error
- func (t *Txn) SetBlobMetadata(id core.BlobID, md core.BlobInfo) core.Error
- func (t *Txn) SetCuratorID(id core.CuratorID)
- func (t *Txn) SetReadOnlyMode(mode bool)
- func (t *Txn) Stat(id core.BlobID) (info core.BlobInfo, err core.Error)
- func (t *Txn) UndeleteBlob(id core.BlobID) core.Error
- func (t *Txn) UpdateRSHosts(id core.RSChunkID, hosts []core.TractserverID) core.Error
- func (t *Txn) UpdateStorageClass(id core.BlobID, storage core.StorageClass) core.Error
- type UpdateTime
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 ¶
ChecksumPosition records the starting or endpoing point of a checksum iteration.
type EncodedTract ¶
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.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents replicated state of a curator.
func Open ¶
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 ¶
ReadOnlyTxn returns a Txn that supports read-only access to State. ReadOnlyTxn will get better concurrency than read-write transactions.
func (*State) WriteTxn ¶
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 ¶
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 ¶
DeleteBlob marks a blob as deleted instead of actually deleting it.
func (*Txn) FinishDeleteBlobs ¶
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 ¶
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 ¶
GetBlobAll is like GetBlob, but also returns blob that is marked as deleted.
func (*Txn) GetCuratorID ¶
GetCuratorID returns curator ID.
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 ¶
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 ¶
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 ¶
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) 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 ¶
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 ¶
SetCuratorID sets curator ID to 'id'.
func (*Txn) SetReadOnlyMode ¶
SetReadOnlyMode changes the read-only flag state. Note that this has nothing to do with whether the transaction is read-only.
func (*Txn) UndeleteBlob ¶
UndeleteBlob undeletes a blob that is marked as deleted.
func (*Txn) UpdateRSHosts ¶
UpdateRSHosts updates the host set for one RS chunk.
func (*Txn) UpdateStorageClass ¶
UpdateStorageClass changes the storage class of a blob. All the tracts in the blob must already support the new class.
type UpdateTime ¶
UpdateTime is an instruction to update one blob's mtime/atime.