Documentation ¶
Index ¶
- Constants
- Variables
- func IsRetriableBlbError(err error) bool
- func IsRetriableError(err Error) bool
- type AckExtendBlobReply
- type AckExtendBlobReq
- type BlobID
- type BlobInfo
- type BlobKey
- type CheckTractsReply
- type CheckTractsReq
- type CreateBlobReply
- type CreateBlobReq
- type CreateTractReq
- type CuratorHeartbeatReply
- type CuratorHeartbeatReq
- type CuratorID
- type CuratorTractserverHeartbeatReply
- type CuratorTractserverHeartbeatReq
- type DiskControlFlags
- type DiskStatus
- type Error
- type ExtendBlobReply
- type ExtendBlobReq
- type FixVersionReq
- type FsStatus
- type GCTractReq
- type GetDiskInfoReply
- type GetDiskInfoReq
- type GetTractsReply
- type GetTractsReq
- type GetTractserverInfoReply
- type GetTractserverInfoReq
- type ListBlobsReply
- type ListBlobsReq
- type ListPartitionsReply
- type ListPartitionsReq
- type LookupCuratorReply
- type LookupCuratorReq
- type LookupPartitionReply
- type LookupPartitionReq
- type MasterCreateBlobReq
- type MasterTractserverHeartbeatReply
- type MasterTractserverHeartbeatReq
- type NewPartitionReply
- type NewPartitionReq
- type PackTractSpec
- type PackTractsReq
- type PartitionID
- type PartitionType
- type Priority
- type PullTractReq
- type RSChunkID
- type RSEncodeReq
- type ReadReply
- type ReadReq
- type RegisterCuratorReply
- type RegisterCuratorReq
- type RegisterTractserverReply
- type RegisterTractserverReq
- type ReportBadTSReq
- type SetControlFlagsReq
- type SetMetadataReq
- type SetVersionReply
- type SetVersionReq
- type StatBlobReply
- type StatTractReply
- type StatTractReq
- type StorageClass
- type StorageHint
- type TSAddr
- type TractID
- type TractInfo
- type TractKey
- type TractPointer
- type TractState
- type TractserverID
- type TractserverInfo
- type TractserverLoad
- type WriteReq
Constants ¶
const ( // TractLength is the fixed tract length of 8 MB. TractLength = 8 * 1024 * 1024 // MaxReplicationFactor is the maximum allowed replication of a blob. MaxReplicationFactor int = 10 // TombstoneVersion is the flag to indicate a tract should be removed. // When Curator is preparing a TractStateReply, it checks the version // numbers for tracts being asked for. If this tract doesn't exist any // more, TombstoneVersion is set as the version number. When // Tractserver receives the reply and compare the versions, it will // garbage collect the tract if the replied version is // TombstoneVersion. TombstoneVersion int = -1 // ProposalTimeout is the period before a Raft application's proposal // times out. ProposalTimeout = 4 * time.Second // RSChunkVersion is a constant fake "version" for tracts that are actually // RS chunks. RS chunks are write-once, so we don't need to use versions to // enforce consistency. RSChunkVersion = -317866832 )
Global constants that several components need to agree on are defined here. If a constant is only needed for single component, probably it should not be placed here.
const ( // NoError means no error. NoError = Error(iota) // ErrHaveNewerVersion is returned when the Curator asks us to increment our version // number but our version is higher. ErrHaveNewerVersion // ErrBadVersion is returned if the provided version number is bad. ErrBadVersion // ErrVersionMismatch is returned if there is a tract version mismatch. ErrVersionMismatch // ErrNoSuchTract is returned when an operation requires a tract to exist but it does not. ErrNoSuchTract // ErrDiskRemoved is returned for all disk calls after Stop has been called on the disk. ErrDiskRemoved // ErrStampChanged is returned for a conditional SetVersion if the stamp changed. ErrStampChanged // ErrShortRead is returned if we get less data than we wanted, in a context // where that is unexpected/disallowed. ErrShortRead // ErrNoVersion is returned when there isn't a version set on a tract. ErrNoVersion // ErrGeneralDisk is returned from the BadDisk mock disk. ErrGeneralDisk // ErrWrongTractserver is returned if the curator thinks it's sending a request to one tractserver but another one received it. ErrWrongTractserver // ErrAlreadyExists is returned when users want to create a duplicate file. ErrAlreadyExists // ErrFileNotFound is returned when users want to access a unexisting file. ErrFileNotFound // ErrCorruptData is returned if a block is corrupted when read, or if a write unavoidably // causes a corruption. ErrCorruptData // ErrNoSpace is returned when a disk fills up while writing a block. ErrNoSpace // ErrEOF is returned when reach the end of a file. ErrEOF // ErrInitManager is returned if a disk.Manager cannot be initialized. ErrInitManager // ErrRemoveFile is returned if os.Remove fails. ErrRemoveFile // ErrIO is returned if there is an OS-level IO error. // The file is probably corrupt in this case. ErrIO // ErrNoAttribute is returned if the specified attribute was not found. ErrNoAttribute // ErrInvalidArgument is returned if an argument is bad or confusing (eg negative size) ErrInvalidArgument // ErrBlobFull is returned if the blob has hit its tract limit. ErrBlobFull // ErrGenBlobID is returned if we fail to generate a BlobID. ErrGenBlobID // ErrHostExist is returned if we already have a host in our state but an RPC implies otherwise. ErrHostExist // ErrHostNotExist is returned if we don't have a host in our state but an RPC implies otherwise. ErrHostNotExist // ErrAllocHost is returned if we fail to allocate a host. ErrAllocHost // ErrExtendConflict is returned if the client tries to acknowledge the // extension of a blob with existing tracts. Probably it means that // another client is concurrently extending the blob and succeeds before // this one finishes. The failed client can retry upon this error. ErrExtendConflict // ErrBadCuratorID means an invalid curator ID was provided. ErrBadCuratorID // ErrBadHosts means that invalid or insufficient hostnames were provided. ErrBadHosts // ErrCantFindCuratorAddr means can't locate curator address of a given curator group. ErrCantFindCuratorAddr // ErrExceedNewPartitionQuota means the daily quota for new partitions has reached. ErrExceedNewPartitionQuota // ErrNetworkConn is returned if we fail to connection to a host. ErrNetworkConn // ErrInvalidState is returned if we find data in our state that doesn't // make sense or is inconsistent. ErrInvalidState // ErrTooBusy means the server is too busy to do whatever it was asked to do. ErrTooBusy // ErrTooBig is returned if the client is asking for too much data allocation. ErrTooBig // ErrNoSuchBlob is returned if the blob doesn't exist. ErrNoSuchBlob // ErrRPC is returned when the RPC layer errors during sending/receiving. ErrRPC // ErrStaleLeader is returned when the received message is sent from a stale leader of a repl group ErrStaleLeader // ErrRaftTimeout means a proposal timed out, most likely because the // quorum is not available due to node/network failures. The user should // retry but with caution -- there is chance that the operation succeeds // after the timeout signal is received. If the operation is not // idempotent, the user needs to verify before retrying. ErrRaftTimeout // ErrRaftNodeNotLeader means a node is not a leader. ErrRaftNodeNotLeader // ErrRaftNotLeaderAnymore means a leader has stepped down. ErrRaftNotLeaderAnymore // ErrRaftTooManyPendingReqs means too many pending requests. ErrRaftTooManyPendingReqs // ErrLeaderContinuityBroken is returned if a Raft leader has not been leader for a continuous duration. ErrLeaderContinuityBroken // ErrUnknown is an error that we're not really sure about. ErrUnknown // ErrNotYetImplemented is returned if the method or feature isn't implemented yet. ErrNotYetImplemented // ErrCanceled is returned when a request is canceled. ErrCanceled // ErrCancelFailed is returned when there was no request to cancel. ErrCancelFailed // ErrReadOnlyStorageClass means that the client is trying to write to a // storage class that doesn't support writing (i.e. erasure-coded). The // client can request that the blob be transitioned to a replicated storage // class and try again. ErrReadOnlyStorageClass // ErrConflictingState means an update to raft state failed because it // conflicted with other changes. ErrConflictingState // ErrReadOnlyMode is returned when a raft-based service is temporarily in // read-only mode (likely during a rolling upgrade). ErrReadOnlyMode // ErrDrainDisk is a fake error that should be treated the same as // ErrCorruptData or ErrIO. ErrDrainDisk )
const AckExtendBlobMethod = "CuratorSrvHandler.AckExtendBlob"
AckExtendBlobMethod is the method name for client to curator to acknowledge extending blob.
const CancelReqMethod = "TSSrvHandler.Cancel"
CancelReqMethod is the method name for canceling a client request.
The request type is the string passed in a previous request's ReqID field. The reply type is a core.Error.
const CheckTractsMethod = "TSCtlHandler.CheckTracts"
CheckTractsMethod is the method name for curator to check that the tractserver is hosting the data the curator expects it to.
const CreateBlobMethod = "CuratorSrvHandler.CreateBlob"
CreateBlobMethod is sent from the client to the curator to create a blob.
const CreateTractMethod = "TSSrvHandler.CreateTract"
CreateTractMethod is the method name for curator to tractserver create tract. Reply is Error.
const CtlReadMethod = "TSCtlHandler.CtlRead"
CtlReadMethod is the method name for tractserver to tractserver read.
const CtlStatTractMethod = "TSCtlHandler.CtlStatTract"
CtlStatTractMethod is the method name for curator to tractserver stat tract.
const CtlWriteMethod = "TSCtlHandler.CtlWrite"
CtlWriteMethod is the method name for tractserver to tractserver write/create.
const CuratorHeartbeatMethod = "MasterCtlHandler.CuratorHeartbeat"
CuratorHeartbeatMethod is the method name for curator to master heartbeat.
const CuratorTractserverHeartbeatMethod = "CuratorCtlHandler.CuratorTractserverHeartbeat"
CuratorTractserverHeartbeatMethod is the method name for tractserver to curator heartbeat.
const DeleteBlobMethod = "CuratorSrvHandler.DeleteBlob"
DeleteBlobMethod is the method name for client to curator delete blob. Request is BlobID, reply is Error.
const ExtendBlobMethod = "CuratorSrvHandler.ExtendBlob"
ExtendBlobMethod is the method name for client to curator to extend blob.
const FixVersionMethod = "CuratorSrvHandler.FixVersion"
FixVersionMethod is the method called by a client when an IO on the tractserver fails due to incorrect version information.
const GCTractMethod = "TSCtlHandler.GCTract"
GCTractMethod is the method name for garbage collecting a tract.
const GetDiskInfoMethod = "TSSrvHandler.GetDiskInfo"
GetDiskInfoMethod is the method name for GetDiskInfo. Request is GetDiskInfoReq, reply is GetDiskInfoReply.
const GetTSIDMethod = "TSCtlHandler.GetTSID"
GetTSIDMethod is the method name for the GetTSID method. Request is struct{}, reply is core.TractserverID.
const GetTractsMethod = "CuratorSrvHandler.GetTracts"
GetTractsMethod is the method name for client to curator get tracts.
const GetTractserverInfoMethod = "MasterSrvHandler.GetTractserverInfo"
GetTractserverInfoMethod is the method name to get an overall tractserver summary.
const ListBlobsMethod = "CuratorSrvHandler.ListBlobs"
ListBlobsMethod is the method name for clients to ask the curator for existing blobs.
const ListPartitionsMethod = "MasterSrvHandler.ListPartitions"
ListPartitionsMethod is the method name for client to master list partitions.
const LookupCuratorMethod = "MasterSrvHandler.LookupCurator"
LookupCuratorMethod is the method name for client to master blob lookup.
const LookupPartitionMethod = "MasterSrvHandler.LookupPartition"
LookupPartitionMethod is the method name for client to master blob lookup.
const MasterCreateBlobMethod = "MasterSrvHandler.MasterCreateBlob"
MasterCreateBlobMethod is the method name for client to master new blob. Reply is LookupCuratorReply.
const MasterTractserverHeartbeatMethod = "MasterCtlHandler.MasterTractserverHeartbeat"
MasterTractserverHeartbeatMethod is the method name for tractserver to master heartbeat.
const MaxBlobKey = math.MaxUint32
MaxBlobKey is the maximum value of a BlobKey.
const MaxBlobSize = math.MaxUint16 + 1
MaxBlobSize is the maximum number of tracts can be created in a blob. This is determined by TractKey length (currently 2 bytes).
const MaxPartitionID = (1 << 30) - 1
MaxPartitionID is the maximum id of a regular partition (or the max of the id part of a RS partition).
const MaxRSChunkKey uint64 = (1 << 48) - 1
MaxRSChunkKey is the maximum value of the key part of an RSChunkID.
const NewPartitionMethod = "MasterCtlHandler.NewPartition"
NewPartitionMethod is the method name for curator to master new partition.
const PackTractsMethod = "TSCtlHandler.PackTracts"
PackTractsMethod is the method name for the PackTracts RPC. Request is PackTractsReq, reply is Error.
const PullTractMethod = "TSCtlHandler.PullTract"
PullTractMethod is the method name for curator to tractserver to pull tract. Reply is Error.
const RSEncodeMethod = "TSCtlHandler.RSEncode"
RSEncodeMethod is the method name for RSEncode. Request is RSEncodeReq, reply is Error.
const ReadMethod = "TSSrvHandler.Read"
ReadMethod is the method name for client to tractserver read.
const RegisterCuratorMethod = "MasterCtlHandler.RegisterCurator"
RegisterCuratorMethod is the method name for curator to master registration.
const RegisterTractserverMethod = "MasterCtlHandler.RegisterTractserver"
RegisterTractserverMethod is the method name for tractserver to master registration.
const ReportBadTSMethod = "CuratorSrvHandler.ReportBadTS"
ReportBadTSMethod lets clients report tractserver errors to the curator.
const SetControlFlagsMethod = "TSSrvHandler.SetControlFlags"
SetControlFlagsMethod is the method name for SetControlFlags. Request is SetControlFlags, reply is core.Error.
const SetMetadataMethod = "CuratorSrvHandler.SetMetadata"
SetMetadataMethod is the method name for client to curator request to change blob metadata. Request is SetMetadataReq, reply is Error.
const SetVersionMethod = "TSCtlHandler.SetVersion"
SetVersionMethod is the method name for curator to tractserver set tract version.
const SizeofTractID = int(unsafe.Sizeof(TractID{}))
SizeofTractID is the size of a TractID value in bytes. Declared here so other packages don't have to import unsafe.
const StatBlobMethod = "CuratorSrvHandler.StatBlob"
StatBlobMethod is the method name for client to curator stat blob. Request is BlobID.
const StatTractMethod = "TSSrvHandler.StatTract"
StatTractMethod is the method name for client to tractserver stat tract.
const UndeleteBlobMethod = "CuratorSrvHandler.UndeleteBlob"
UndeleteBlobMethod is the method name for client to curator request to undelete a blob. Request is BlobID, reply is Error.
const WriteMethod = "TSSrvHandler.Write"
WriteMethod is the method name for client to tractserver write. Reply is Error.
Variables ¶
var EnumNamesPriority = map[Priority]string{ PriorityTSDEFAULT: "TSDEFAULT", PriorityLOW: "LOW", PriorityMEDIUM: "MEDIUM", PriorityHIGH: "HIGH", }
var EnumNamesStorageClass = map[StorageClass]string{ StorageClassREPLICATED: "REPLICATED", StorageClassRS_6_3: "RS_6_3", StorageClassRS_8_3: "RS_8_3", StorageClassRS_10_3: "RS_10_3", StorageClassRS_12_5: "RS_12_5", }
var EnumNamesStorageHint = map[StorageHint]string{ StorageHintDEFAULT: "DEFAULT", StorageHintHOT: "HOT", StorageHintWARM: "WARM", StorageHintCOLD: "COLD", }
var ErrInvalidID = errors.New("invalid id format")
ErrInvalidID is the error returned when a string representation of an ID is invalid.
Functions ¶
func IsRetriableBlbError ¶
IsRetriableBlbError checks if this is 1) core.Error 2) retriable
func IsRetriableError ¶
IsRetriableError checks if we should retry on a given returned error. We consider errors that might be transient to be retriable errors.
Types ¶
type AckExtendBlobReply ¶
type AckExtendBlobReply struct { // Number of tracts after extending the blob. NumTracts int Err Error }
AckExtendBlobReply is the reply message for AckExtendBlobReq.
type AckExtendBlobReq ¶
type AckExtendBlobReq struct { // The ID of the blob the client wants to extend. Blob BlobID // Successfully created tracts. Tracts []TractInfo }
AckExtendBlobReq is the request message for extending a blob. Reply is Error.
type BlobID ¶
type BlobID uint64
BlobID refers to a Blob stored in Blb. A BlobID consists of a PartitionID prefix and a BlobKey suffix. Clients of Blb communicate in BlobIDs.
const ZeroBlobID BlobID = 0
ZeroBlobID is an invalid blob id for most purposes, but is used for metadata tracts in the tractserver.
func BlobIDFromParts ¶
func BlobIDFromParts(pid PartitionID, bk BlobKey) BlobID
BlobIDFromParts makes a BlobID from a PartitionID and a BlobKey.
func ParseBlobID ¶
ParseBlobID parses a BlobID from the provided string. The string must be in the format produced by BlobID.String(). If it is not, ErrInvalidID will be returned.
func (BlobID) Partition ¶
func (b BlobID) Partition() PartitionID
Partition returns the partition ID.
type BlobInfo ¶
type BlobInfo struct { // What is the replication factor of this blob? (REPLICATED storage class only) Repl int // How many tracts make up the blob? NumTracts int // When was the blob last written/read? MTime, ATime time.Time // How is this blob stored? Class StorageClass // How did the client hint that this should be stored? Hint StorageHint // Time after which this blob can be automatically deleted by the system. Expires time.Time }
BlobInfo is information about a blob, analogous to os.FileInfo.
type BlobKey ¶
type BlobKey uint32
BlobKey identifies a blob in a partition. It is the suffix part of a BlobID. Valid BlobKeys start from 1.
type CheckTractsReply ¶
type CheckTractsReply struct { // NoError if everything went OK, otherwise an error representing what // went wrong. Err Error }
CheckTractsReply is the reply to a CheckTractsReq
type CheckTractsReq ¶
type CheckTractsReq struct { // The tractserver that the curator expects it's talking to. TSID TractserverID // What tracts must the tractserver host? Tracts []TractState }
CheckTractsReq is sent from a Curator to a Tractserver verify that it's hosting the tracts that the curator thinks it's hosting.
type CreateBlobReply ¶
type CreateBlobReply struct { // Was there an error? If so, it's here. Err Error // The ID of the blob. ID BlobID }
CreateBlobReply is a reply to a CreateBlobReq sent from the curator to the client.
type CreateBlobReq ¶
type CreateBlobReq struct { // The required replication factor for the blob we're creating. Repl int // The initial storage hint for the blob. Hint StorageHint // Expiry time. Expires time.Time }
CreateBlobReq is sent from the client to a curator to create a blob.
type CreateTractReq ¶
type CreateTractReq struct { TSID TractserverID ID TractID B []byte Off int64 Pri Priority // contains filtered or unexported fields }
CreateTractReq is sent from a client to a tractserver to ask the tractserver to create a tract with id 'ID' and writes the bytes to it.
func (*CreateTractReq) Get ¶
func (c *CreateTractReq) Get() ([]byte, bool)
The following implement the rpc.BulkData interface:
func (*CreateTractReq) Set ¶
func (c *CreateTractReq) Set(b []byte, e bool)
type CuratorHeartbeatReply ¶
type CuratorHeartbeatReply struct { // What partitions does the curator own? Partitions []PartitionID // lib.NoError is everything went OK, otherwise an error representing // what went wrong. Err Error }
CuratorHeartbeatReply is the reply to a curator heartbeat. This message piggybacks partition assignment info so far.
type CuratorHeartbeatReq ¶
type CuratorHeartbeatReq struct { // What is the ID of this group? CuratorID CuratorID // Where can we reach the curator? Addr string }
CuratorHeartbeatReq is sent from the primary curator to the master.
type CuratorID ¶
type CuratorID uint32
CuratorID is a master assigned ID to a Curator. Valid CuratorIDs start from 1.
type CuratorTractserverHeartbeatReply ¶
type CuratorTractserverHeartbeatReply struct { // What partitions does the curator have? Partitions []PartitionID // NoError if everything went OK, otherwise an error representing what // went wrong. Err Error }
CuratorTractserverHeartbeatReply is the reply to a CuratorTractserverHeartbeatReq.
type CuratorTractserverHeartbeatReq ¶
type CuratorTractserverHeartbeatReq struct { // The master assigned ID for the tractserver. TSID TractserverID // Where can we reach the tractserver? Addr string // What tracts are corrupt on this tractserver? These tracts may not be owned by the // curator receiving this message, in which case the curator can ignore the entries it // doesn't own. Corrupt []TractID // A subset of tracts owned by this tractserver that we think the curator // manages. Has []TractID // Load state of this tractserver. Load TractserverLoad }
CuratorTractserverHeartbeatReq is sent from a Tractserver to a Curator.
type DiskControlFlags ¶
type DiskControlFlags struct { // Stop allocating new tracts to this disk, but don't change anything else. StopAllocating bool // Slowly report this many tracts per second as "corrupt" (non-zero value // implies StopAllocating). Drain int // Slowly try to move this many tracts per second to other disks (non-zero // value implies StopAllocating). DrainLocal int }
DiskControlFlags are flags that an administrator can manually set on a disk to control tractserver behavior.
type DiskStatus ¶
type DiskStatus struct { // Root path Root string // Is the disk full? Full bool // Has the disk seen any filesystem corruption? Healthy bool // What's the current queue length? QueueLen int // What's the average wait time of an op? AvgWaitMs int // Manual control flags. Flags DiskControlFlags }
DiskStatus is lightweight information about how a disk is doing.
type Error ¶
type Error int
Error is our own defined error type for sending errors over an RPC layer.
func FromRaftError ¶
FromRaftError translets Raft errors defined in raft pacakge to `core.Error` types to be sent over the wire.
func (Error) Error ¶
Error returns a golang error object with an error message corresponding to this core.Error.
type ExtendBlobReply ¶
type ExtendBlobReply struct { Err Error // Information for newly allocated tracts. NewTracts []TractInfo }
ExtendBlobReply is the reply message to an ExtendBlobReq.
type ExtendBlobReq ¶
type ExtendBlobReq struct { // The ID of the blob the client wants to extend. Blob BlobID // If the number of tracts in the blob is less than this, more tracts will be added. NumTracts int }
ExtendBlobReq is the request message for extending a blob.
type FixVersionReq ¶
type FixVersionReq struct { // Info is the tract ID, version pair the client was having trouble with. Info TractInfo // Bad is the address of the tractserver who rejected our version. Bad string }
FixVersionReq is a client request to verify that the version(s) of the provided tract are correct.
type FsStatus ¶
type FsStatus struct { Status DiskStatus // Basic health information observed during operation. Ops map[string]string // If not nil, per-op information. // On-disk information. NumTracts int // Number of tracts. NumDeletedTracts int // How many tracts have been deleted but not GC-ed? NumUnknownFiles int // How many files exist but don't look like tracts or former tracts? AvailSpace uint64 // Available space in bytes on the filesystem. TotalSpace uint64 // Total space in bytes on the filesystem. }
FsStatus is heavyweight status information for a disk. It includes information about the underlying file system and per-operation statistics.
type GCTractReq ¶
type GCTractReq struct { // The tractserver that the curator expects it's talking to. TSID TractserverID // Outdated tracts that the tractserver can GC. Old []TractState // Tracts that belong to a deleted blob. Gone []TractID }
GCTractReq is a request to a tractserver to garbage collect some tracts.
type GetDiskInfoReply ¶
type GetDiskInfoReply struct { // Disks has one value for each disk in the tractserver. Disks []FsStatus Err Error }
GetDiskInfoReply is the reply for GetDiskInfo.
type GetTractsReply ¶
type GetTractsReply struct { // The tracts that the user asked for. // If there are no tracts in the range the user asked for, this is nil. // If there are no tracts in the blob, this is nil. // // Otherwise, Tracts[0] is the GetTractsReq.Start-th tract in the blob, // and Tracts contains as many entries as possible, up to (End-Start). Tracts []TractInfo // Was there any error encountered? If so, the rest of the fields should be ignored. Err Error }
GetTractsReply is the reply to a GetTractsReq.
type GetTractsReq ¶
type GetTractsReq struct { // What blob does the client want information for? Blob BlobID // Get tracts [Start, End) for the blob. Start, End int // Is the client intending to open this blob for reading or writing (or both)? ForRead, ForWrite bool }
GetTractsReq is sent by a client who wants to read or write existing tracts in a blob.
type GetTractserverInfoReply ¶
type GetTractserverInfoReply struct { Info []TractserverInfo Err Error }
GetTractserverInfoReply is a summary of the disks in the cluster.
type GetTractserverInfoReq ¶
type GetTractserverInfoReq struct { }
GetTractserverInfoReq requests a tractserver summary from the master.
type ListBlobsReply ¶
ListBlobsReply is the result of a ListBlobs call.
type ListBlobsReq ¶
type ListBlobsReq struct { Partition PartitionID Start BlobKey }
ListBlobsReq is the client request for a list of blob keys.
type ListPartitionsReply ¶
type ListPartitionsReply struct { Partitions []PartitionID Err Error }
ListPartitionsReply is the response to a ListPartitions request. It contains all known partition ids.
type ListPartitionsReq ¶
type ListPartitionsReq struct { }
ListPartitionsReq is the request for the master to list partitions.
type LookupCuratorReply ¶
type LookupCuratorReply struct { // Replicas[0] is the primary curator, and the rest are secondaries. Replicas []string // NoError if everything went OK, otherwise an error representing // what went wrong. Err Error }
LookupCuratorReply is sent in response to a LookupCuratorReq.
type LookupCuratorReq ¶
type LookupCuratorReq struct { // Find the curator that owns this blobid. Blob BlobID }
LookupCuratorReq is sent by a client who wants to access a blob.
type LookupPartitionReply ¶
type LookupPartitionReply struct { // Replicas[0] is the primary curator, and the rest are secondaries. Replicas []string // NoError if everything went OK, otherwise an error representing // what went wrong. Err Error }
LookupPartitionReply is sent in response to a LookupPartitionReq.
type LookupPartitionReq ¶
type LookupPartitionReq struct { // Find the curator that owns this partition. Partition PartitionID }
LookupPartitionReq is sent by a client who wants to access a blob.
type MasterCreateBlobReq ¶
type MasterCreateBlobReq struct { }
MasterCreateBlobReq is sent from the client to the master to create a blob.
type MasterTractserverHeartbeatReply ¶
type MasterTractserverHeartbeatReply struct { // Each entry in Curators is the current primary of a Curator replica set. Curators []string // NoError if everything went OK, otherwise an error representing what // went wrong. Err Error }
MasterTractserverHeartbeatReply is the reply to a MasterTractserverHeartbeatReq.
type MasterTractserverHeartbeatReq ¶
type MasterTractserverHeartbeatReq struct { // What is the ID of this tractserver? TractserverID TractserverID // Where can we reach the tractserver? Addr string // Per-disk status Disks []FsStatus }
MasterTractserverHeartbeatReq is sent from a Tractserver to Master.
type NewPartitionReply ¶
type NewPartitionReply struct { // The new partition that the curator now owns. PartitionID PartitionID // NoError if everything went OK, otherwise an error representing // what went wrong. Err Error }
NewPartitionReply allocates a new partition ID to the curator.
type NewPartitionReq ¶
type NewPartitionReq struct { // What is the ID of the requesting curator? CuratorID CuratorID }
NewPartitionReq is sent by a curator to request ownership of an additional PartitionID.
type PackTractSpec ¶
type PackTractSpec struct { ID TractID // tract id From []TSAddr // host(s) that it can be read from Version int // expected version Offset int // destination offset in packed tract Length int // expected length }
PackTractSpec describes one tract to pack.
type PackTractsReq ¶
type PackTractsReq struct { TSID TractserverID // The tractserver that the curator expects it's talking to. Length int // Total length of packed chunk. TS will pad with zeros. Tracts []*PackTractSpec // Tracts to pack. Must be ordered by Offset and must not overlap. ChunkID RSChunkID // What chunk id to write to. }
PackTractsReq is a request to the TS to pack mulitple regular data tracts into a data chunk and store it locally, in preparation for erasure coding. The length will probably be greater than the standard tract length.
type PartitionID ¶
type PartitionID uint32
PartitionID identifies a partition that the master assigned to a curator. BlobIDs and TractIDs generated in this partition are all prefixed by it. Valid PartitionIDs start from 1.
func (PartitionID) FirstBlobID ¶
func (p PartitionID) FirstBlobID() BlobID
FirstBlobID returns the first BlobID in the partition. Note we reserve the first value as guard and thus the plus one below.
func (PartitionID) IsValidRS ¶
func (p PartitionID) IsValidRS() bool
IsValidRS returns true if p is a valid PartitionID for a RS partition.
func (PartitionID) IsValidRegular ¶
func (p PartitionID) IsValidRegular() bool
IsValidRegular returns true if 'p' is a valid PartitionID of a regular partition.
func (PartitionID) LastBlobID ¶
func (p PartitionID) LastBlobID() BlobID
LastBlobID returns the last BlobID in the partition.
func (PartitionID) Type ¶
func (p PartitionID) Type() PartitionType
Type returns the type of the paritition (upper two bits).
func (PartitionID) WithoutType ¶
func (p PartitionID) WithoutType() PartitionID
WithoutType returns the ID part of the full partition ID, that is, collapsing RS partitions to their corresponding regular partition.
type PartitionType ¶
type PartitionType uint32
PartitionType is a type for partition IDs. PartitionIDs come in two varieties (so far), regular partitions and RS partitions. RS partitions are used for allocating IDs for RS-encoded chunks. They're differentiated by their uppermost two bits.
const ( // RegularPartition is the type for partitions holding regular blobs and tracts. RegularPartition PartitionType = iota // RSPartition is the type for partitions holding RS chunks (data and parity). RSPartition )
type PullTractReq ¶
type PullTractReq struct { // The tractserver that the curator expects it's talking to. TSID TractserverID // What hosts should we try to pull the tract from? Multiple hosts are // provided in case error is encountered and retry is performed from // different sources. From []string // What is the ID of the tract? ID TractID // And what is the version? Version int }
PullTractReq is a request from a curator to a tractserver to pull the tract (ID, Version) from 'From'.
type RSChunkID ¶
type RSChunkID struct { Partition PartitionID ID uint64 // only lower 48 bits used }
RSChunkID is the id of a Reed-Solomon-encoded bunch of tracts. It is the same size as a tract id so that tractservers can handle it identically. Partition in an RSChunkID must be a RS partition, with upper two bits 10.
type RSEncodeReq ¶
type RSEncodeReq struct { TSID TractserverID // The tractserver that the curator expects it's talking to. ChunkID RSChunkID // The starting chunk id for this RS chunk. Length int // Total length of each piece of the chunk. Srcs []TSAddr // Where to read the N data pieces from. Dests []TSAddr // Where to write the M parity pieces to. IndexMap []int // Data indexes for reconstruction (see below). }
RSEncodeReq is a request to perform erasure coding or reconstruction on a chunk. For Reed-Solomon with N data and M parity pieces, there should be exactly N Srcs and M Dests. This tractserver will read the N pieces from other tractservers (or itself), perform the calculation, and then write out the coded parity or reconstructed data pieces to other tractservers (or itself). All pieces must be the same length. Since holding (N+M)*L bytes in memory might be prohibitive, the IO and calculation may be carried out in smaller pieces.
type ReadReq ¶
type ReadReq struct { ID TractID Version int Len int Off int64 Pri Priority // ID for cancellation. ReqID string }
ReadReq is the request for reading data from an existing file.
type RegisterCuratorReply ¶
type RegisterCuratorReply struct { // An ID identifying this curator that must be persisted and used in all further // communications. CuratorID CuratorID // lib.NoError if everything went OK, otherwise an error representing // what went wrong. Err Error }
RegisterCuratorReply is sent by the master to a curator in response to a RegisterCuratorReq.
type RegisterCuratorReq ¶
type RegisterCuratorReq struct { // Where can we reach the curator? Addr string }
RegisterCuratorReq is sent by a new curator to the master to register it as available to serve metadata.
type RegisterTractserverReply ¶
type RegisterTractserverReply struct { // An ID identifying this tractserver that must be persisted and used in all further // communications. TSID TractserverID // lib.NoError if everything went OK, otherwise an error representing // what went wrong. Err Error }
RegisterTractserverReply is sent by the master to a tractserver in response to a RegisterTractserverReq.
type RegisterTractserverReq ¶
type RegisterTractserverReq struct { // Where we can reach this tractserver. Addr string }
RegisterTractserverReq is sent by a new tractserver to the master to register it as available to serve data.
type ReportBadTSReq ¶
type ReportBadTSReq struct { // What tract or RS chunk is problematic? ID TractID // What host is the client blocked on? Bad string // What operation were they trying to do? ("read" or "write") Operation string // What error did they get? GotError Error // If operation is a read, was the client able to complete the read from // another tractserver, or reconstruct erasure-coded data? (If so, the // curator may choose to treat this as lower priority.) CouldRecover bool }
ReportBadTSReq lets clients report tractserver errors to the curator.
type SetControlFlagsReq ¶
type SetControlFlagsReq struct { Root string Flags DiskControlFlags }
SetControlFlagsReq requests to change control flags on one disk on the tractserver.
type SetMetadataReq ¶
type SetMetadataReq struct { Blob BlobID // Only changing Hint, MTime, ATime, Expires is supported. Other fields are ignored. Metadata BlobInfo }
SetMetadataReq asks the curator to change some blob metadata.
type SetVersionReply ¶
type SetVersionReply struct { // Was there an error handling this request? Err Error // What version does the tractserver have now? NewVersion int }
SetVersionReply is a reply to a SetVersionReq.
type SetVersionReq ¶
type SetVersionReq struct { // The tractserver that the curator expects it's talking to. TSID TractserverID // The ID of the tract we're setting the version on. ID TractID // What version does the curator want the tractserver to increase to? // This will be one more than the current durable version. NewVersion int // If this is nonzero, the SetVersion is made conditional on the // modification stamp of the tract being equal to this value. ConditionalStamp uint64 }
SetVersionReq is sent by the Curator to set the version of a tract.
type StatBlobReply ¶
type StatBlobReply struct { // Was there any error encountered in processing this request? // If so, the rest of the fields in this message should be ignored. Err Error Info BlobInfo }
StatBlobReply is sent in response to a request to Stat a blob.
type StatTractReply ¶
type StatTractReply struct { Err Error Size int64 // ModStamp is a value that can be used to detect writes to a tract. If two // stat calls return the same modstamp, the tract was definitely not written // to in between those calls. If two calls return different mod stamps, the // tract may have been written to. ModStamp uint64 }
StatTractReply is a reply to a StatTractReq.
type StatTractReq ¶
StatTractReq is a request to stat an existing tract.
type StorageClass ¶
type StorageClass int32
const ( StorageClassREPLICATED StorageClass = 0 StorageClassRS_6_3 StorageClass = 1 StorageClassRS_8_3 StorageClass = 2 StorageClassRS_10_3 StorageClass = 3 StorageClassRS_12_5 StorageClass = 4 )
func (StorageClass) String ¶
func (c StorageClass) String() string
type StorageHint ¶
type StorageHint int32
const ( StorageHintDEFAULT StorageHint = 0 StorageHintHOT StorageHint = 1 StorageHintWARM StorageHint = 2 StorageHintCOLD StorageHint = 3 )
func ParseStorageHint ¶
func ParseStorageHint(s string) (StorageHint, bool)
ParseStorageHint returns the StorageHint that matches the given string (case-sensitive).
func (StorageHint) String ¶
func (h StorageHint) String() string
type TSAddr ¶
type TSAddr struct { ID TractserverID // If 0, don't write out this parity chunk. Host string }
TSAddr is a pair of TSID and hostname that refers to a tractserver.
type TractID ¶
type TractID struct { // What blob does this tract belong to? Blob BlobID // What Index in the blob is this tract? Index TractKey }
TractID refers to a tract stored on a Tractserver. A TractID consists of a BlobId prefix and a TractKey suffix. BlobIDs are mapped to TractIDs internally. This is not visible to the Blb client.
func ParseTractID ¶
ParseTractID parses a TractID from the provided string. The string must be in the format produced by TractID.String(). If it is not, ErrInvalidID will be returned.
func TractIDFromParts ¶
TractIDFromParts makes a TractID from a BlobID and a TractKey.
type TractInfo ¶
type TractInfo struct { // The unique ID for the tract. Tract TractID // Latest version known to Curator. // Used to detect stale versions from failed tractservers. Version int // List of tractservers serving this tract. Maybe be stale. Hosts []string // The corresponding tractserver IDs. TSIDs []TractserverID // Pointer to the tract encoded in an RS chunk. RS TractPointer }
TractInfo describes one tract and where to find it.
type TractKey ¶
type TractKey uint16
TractKey identifies a tract in a blob. It is the suffix part of a TractID. Valid TractKeys start from 0, so that we can align them with slice indices.
type TractPointer ¶
type TractPointer struct { Chunk RSChunkID Host string TSID TractserverID Offset uint32 Length uint32 // Metadata for client-side reconstruction. These are parallel lists // containing the location of the other pieces of data that this tract was // coded with. Hosts that are known to be down may have "" / 0. If Class is // 0 (REPLICATED), OtherHosts/TSIDs are not valid (should be empty). Class StorageClass BaseChunk RSChunkID OtherHosts []string OtherTSIDs []TractserverID }
TractPointer is a reference to a tract embedded in an RS chunk.
func (*TractPointer) Present ¶
func (tp *TractPointer) Present() bool
Present returns true if this TractPointer is not the zero value.
type TractState ¶
TractState is a pair of TractID and version number.
type TractserverID ¶
type TractserverID uint32
TractserverID is a master assigned ID to a Tractserver. Valid TractserverIDs start from 1.
func (TractserverID) IsValid ¶
func (t TractserverID) IsValid() bool
IsValid returns if 't' is a valid TractserverID.
func (TractserverID) String ¶
func (t TractserverID) String() string
type TractserverInfo ¶
type TractserverInfo struct { ID TractserverID Addr string Disks []FsStatus LastHeartbeat time.Time }
TractserverInfo is info about one tractserver.
type TractserverLoad ¶
type TractserverLoad struct { // How many tracts is this TS currently storing? NumTracts int // In bytes. AvailSpace uint64 TotalSpace uint64 }
TractserverLoad describes load state of a tractserver.