Documentation ¶
Index ¶
- Constants
- Variables
- func InitMDS(name string, cfg Config, gmd GlobalMetadata, ringType RingType) error
- func MarshalBlocksetToProto(bs Blockset) ([]*models.BlockLayer, error)
- func MkdirsFor(dir string) error
- func RegisterBlockStore(name string, newFunc NewBlockStoreFunc)
- func RegisterMetadataInit(name string, newFunc InitMDSFunc)
- func RegisterMetadataService(name string, newFunc CreateMetadataServiceFunc)
- func RegisterMetadataWipe(name string, newFunc WipeMDSFunc)
- func RegisterSetRing(name string, newFunc SetRingFunc)
- func SetRing(name string, cfg Config, r Ring) error
- func WipeMDS(name string, cfg Config) error
- type BlockIterator
- type BlockLayer
- type BlockLayerKind
- type BlockLayerSpec
- type BlockRef
- func (b BlockRef) BlockType() BlockType
- func (b BlockRef) HasINode(i INodeRef, t BlockType) bool
- func (b BlockRef) IsZero() bool
- func (b *BlockRef) SetBlockType(t BlockType)
- func (b BlockRef) String() string
- func (b BlockRef) ToBytes() []byte
- func (b BlockRef) ToBytesBuf(buf []byte)
- func (b BlockRef) ToProto() *models.BlockRef
- type BlockStore
- type BlockType
- type Blockset
- type Config
- type CreateMetadataServiceFunc
- type DebugMetadataService
- type File
- func (f *File) Close() error
- func (f *File) Read(b []byte) (n int, err error)
- func (f *File) ReadAt(b []byte, off int64) (n int, ferr error)
- func (f *File) Replaces() uint64
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) Size() uint64
- func (f *File) SyncAllWrites() (INodeRef, error)
- func (f *File) SyncBlocks() error
- func (f *File) SyncINode(ctx context.Context) (INodeRef, error)
- func (f *File) Trim(offset, length int64) error
- func (f *File) Truncate(size int64) error
- func (f *File) Write(b []byte) (n int, err error)
- func (f *File) WriteAt(b []byte, off int64) (n int, err error)
- func (f *File) WriteOpen() bool
- type GlobalMetadata
- type INodeID
- type INodeIterator
- type INodeRef
- type INodeStore
- func (b *INodeStore) Close() error
- func (b *INodeStore) DeleteINode(ctx context.Context, i INodeRef) error
- func (b *INodeStore) Flush() error
- func (b *INodeStore) GetINode(ctx context.Context, i INodeRef) (*models.INode, error)
- func (b *INodeStore) INodeIterator() *INodeIterator
- func (b *INodeStore) WriteINode(ctx context.Context, i INodeRef, inode *models.INode) error
- type IndexID
- type InitMDSFunc
- type MetadataKind
- type MetadataService
- type ModifyableRing
- type NewBlockStoreFunc
- type PeerInfoList
- func (pi PeerInfoList) AndNot(b PeerList) PeerInfoList
- func (pi PeerInfoList) GetWeights() map[string]int
- func (pi PeerInfoList) HasUUID(uuid string) bool
- func (pi PeerInfoList) Intersect(b PeerInfoList) PeerInfoList
- func (pi PeerInfoList) PeerList() PeerList
- func (pi PeerInfoList) UUIDAt(uuid string) int
- func (pi PeerInfoList) Union(b PeerInfoList) PeerInfoList
- type PeerList
- type PeerPermutation
- type ReadLevel
- type Ring
- type RingAdder
- type RingRemover
- type RingType
- type Server
- func (s *Server) AddTimeoutCallback(f func(uuid string))
- func (s *Server) BeginHeartbeat(addr *url.URL) error
- func (s *Server) Close() error
- func (s *Server) CreateFile(volume *models.Volume, inode *models.INode, blocks Blockset) (*File, error)
- func (s *Server) Debug(w io.Writer) error
- func (s *Server) ExtendContext(ctx context.Context) context.Context
- func (s *Server) GetPeerMap() map[string]*models.PeerInfo
- func (s *Server) Lease() int64
- func (s *Server) UpdatePeerMap() map[string]*models.PeerInfo
- func (s *Server) UpdateRebalanceInfo(ri *models.RebalanceInfo)
- type SetRingFunc
- type Store
- type VolumeID
- type WipeMDSFunc
- type WriteLevel
Constants ¶
const ( CtxWriteLevel int = iota CtxReadLevel )
const BlockRefByteSize = 8 * 3
const INodeRefByteSize = 8 * 2
const VolumeIDByteSize = 5
const (
VolumeMax = 0x000000FFFFFFFFFF
)
Variables ¶
var ( // block. ErrBlockUnavailable = errors.New("torus: block cannot be retrieved") // INode. ErrINodeUnavailable = errors.New("torus: inode cannot be retrieved") // ErrBlockNotExist is returned when a function attempts to manipulate a // non-existant block. ErrBlockNotExist = errors.New("torus: block doesn't exist") // ErrClosed is returned when a function attempts to manipulate a Store // that is not currently open. ErrClosed = errors.New("torus: store is closed") // ErrInvalid is a locally invalid operation (such as Close()ing a nil file pointer) ErrInvalid = errors.New("torus: invalid operation") // ErrOutOfSpace is returned when the block storage is out of space. ErrOutOfSpace = errors.New("torus: out of space on block store") // ErrExists is returned if the entity already exists ErrExists = errors.New("torus: already exists") // ErrNotExist is returned if the entity doesn't already exist ErrNotExist = errors.New("torus: doesn't exist") // ErrAgain is returned if the operation was interrupted. The call was valid, and // may be tried again. ErrAgain = errors.New("torus: interrupted, try again") // ErrNoGlobalMetadata is returned if the metadata service hasn't been formatted. ErrNoGlobalMetadata = errors.New("torus: no global metadata available at mds") // ErrNonSequentialRing is returned if the ring's internal version number appears to jump. ErrNonSequentialRing = errors.New("torus: non-sequential ring") // ErrNoPeer is returned if the peer can't be found. ErrNoPeer = errors.New("torus: no such peer") // ErrCompareFailed is returned if the CAS operation failed to compare. ErrCompareFailed = errors.New("torus: compare failed") // ErrIsSymlink is returned if we're trying to modify a symlink incorrectly. ErrIsSymlink = errors.New("torus: is symlink") // ErrNotDir is returned if we're trying a directory operation on a non-directory path. ErrNotDir = errors.New("torus: not a directory") // ErrWrongVolumeType is returned if the operation cannot be performed on this type of volume. ErrWrongVolumeType = errors.New("torus: wrong volume type") // ErrNotSupported is returned if the interface doesn't implement the // requested subfuntionality. ErrNotSupported = errors.New("torus: not supported") // ErrLocked is returned if the resource is locked. ErrLocked = errors.New("torus: locked") )
var BlockLog = capnslog.NewPackageLogger("github.com/coreos/torus", "blocklog")
var Version string
Version is set by build scripts, do not touch.
Functions ¶
func InitMDS ¶ added in v0.1.0
func InitMDS(name string, cfg Config, gmd GlobalMetadata, ringType RingType) error
InitMDS calls the specific init function provided by a metadata package.
func MarshalBlocksetToProto ¶
func MarshalBlocksetToProto(bs Blockset) ([]*models.BlockLayer, error)
func RegisterBlockStore ¶
func RegisterBlockStore(name string, newFunc NewBlockStoreFunc)
func RegisterMetadataInit ¶ added in v0.1.0
func RegisterMetadataInit(name string, newFunc InitMDSFunc)
RegisterMetadataInit is the hook used for implementions of MetadataServices to register their ways of creating base metadata to the system.
func RegisterMetadataService ¶
func RegisterMetadataService(name string, newFunc CreateMetadataServiceFunc)
RegisterMetadataService is the hook used for implementions of MetadataServices to register themselves to the system. This is usually called in the init() of the package that implements the MetadataService. A similar pattern is used in database/sql of the standard library.
func RegisterMetadataWipe ¶ added in v0.1.0
func RegisterMetadataWipe(name string, newFunc WipeMDSFunc)
RegisterMetadataWipe is the hook used for implementions of MetadataServices to register their ways of deleting their metadata from the consistent store
func RegisterSetRing ¶
func RegisterSetRing(name string, newFunc SetRingFunc)
RegisterSetRing is the hook used for implementions of MetadataServices to register their ways of creating base metadata to the system.
Types ¶
type BlockIterator ¶
type BlockLayer ¶
type BlockLayer struct { Kind BlockLayerKind Options string }
type BlockLayerKind ¶
type BlockLayerKind int
type BlockLayerSpec ¶
type BlockLayerSpec []BlockLayer
type BlockRef ¶
BlockRef is the identifier for a unique block in the cluster.
func BlockFromProto ¶
func BlockRefFromBytes ¶
func (*BlockRef) SetBlockType ¶
func (BlockRef) ToBytesBuf ¶ added in v0.1.0
type BlockStore ¶
type BlockStore interface { Store HasBlock(ctx context.Context, b BlockRef) (bool, error) GetBlock(ctx context.Context, b BlockRef) ([]byte, error) WriteBlock(ctx context.Context, b BlockRef, data []byte) error WriteBuf(ctx context.Context, b BlockRef) ([]byte, error) DeleteBlock(ctx context.Context, b BlockRef) error NumBlocks() uint64 UsedBlocks() uint64 BlockIterator() BlockIterator BlockSize() uint64 }
BlockStore is the interface representing the standardized methods to interact with something storing blocks.
func CreateBlockStore ¶
func CreateBlockStore(kind string, name string, cfg Config, gmd GlobalMetadata) (BlockStore, error)
type Blockset ¶
type Blockset interface { Length() int Kind() uint32 GetBlock(ctx context.Context, i int) ([]byte, error) PutBlock(ctx context.Context, inode INodeRef, i int, b []byte) error GetLiveINodes() *roaring.Bitmap GetAllBlockRefs() []BlockRef Marshal() ([]byte, error) Unmarshal(data []byte) error GetSubBlockset() Blockset Truncate(lastIndex int, blocksize uint64) error Trim(from, to int) error String() string }
Blockset is the interface representing the standardized methods to interact with a set of blocks.
type CreateMetadataServiceFunc ¶
type CreateMetadataServiceFunc func(cfg Config) (MetadataService, error)
CreateMetadataServiceFunc is the signature of a constructor used to create a registered MetadataService.
type DebugMetadataService ¶
type File ¶
type File struct { ReadOnly bool // contains filtered or unexported fields }
func (*File) SyncAllWrites ¶
func (*File) SyncBlocks ¶ added in v0.1.0
type GlobalMetadata ¶
type GlobalMetadata struct { BlockSize uint64 DefaultBlockSpec BlockLayerSpec INodeReplication int }
type INodeIterator ¶
type INodeIterator struct {
// contains filtered or unexported fields
}
func (*INodeIterator) Close ¶
func (i *INodeIterator) Close() error
func (*INodeIterator) Err ¶
func (i *INodeIterator) Err() error
func (*INodeIterator) INodeRef ¶
func (i *INodeIterator) INodeRef() INodeRef
func (*INodeIterator) Next ¶
func (i *INodeIterator) Next() bool
type INodeRef ¶
type INodeRef struct { INode INodeID // contains filtered or unexported fields }
INodeRef is a reference to a unique INode in the cluster.
func INodeFromProto ¶
func INodeRefFromBytes ¶
func NewINodeRef ¶
type INodeStore ¶
type INodeStore struct {
// contains filtered or unexported fields
}
func NewINodeStore ¶
func NewINodeStore(bs BlockStore) *INodeStore
func (*INodeStore) Close ¶
func (b *INodeStore) Close() error
func (*INodeStore) DeleteINode ¶
func (b *INodeStore) DeleteINode(ctx context.Context, i INodeRef) error
func (*INodeStore) Flush ¶
func (b *INodeStore) Flush() error
func (*INodeStore) INodeIterator ¶
func (b *INodeStore) INodeIterator() *INodeIterator
func (*INodeStore) WriteINode ¶
type InitMDSFunc ¶ added in v0.1.0
type InitMDSFunc func(cfg Config, gmd GlobalMetadata, ringType RingType) error
InitMDSFunc is the signature of a function which preformats a metadata service.
type MetadataService ¶
type MetadataService interface { GetVolumes() ([]*models.Volume, VolumeID, error) GetVolume(volume string) (*models.Volume, error) NewVolumeID() (VolumeID, error) Kind() MetadataKind GlobalMetadata() (GlobalMetadata, error) // Returns a UUID based on the underlying datadir. Should be // unique for every created datadir. UUID() string GetRing() (Ring, error) SubscribeNewRings(chan Ring) UnsubscribeNewRings(chan Ring) SetRing(ring Ring) error WithContext(ctx context.Context) MetadataService GetLease() (int64, error) RegisterPeer(lease int64, pi *models.PeerInfo) error GetPeers() (PeerInfoList, error) Close() error CommitINodeIndex(VolumeID) (INodeID, error) GetINodeIndex(VolumeID) (INodeID, error) }
MetadataService is the interface representing the basic ways to manipulate consistently stored fileystem metadata.
func CreateMetadataService ¶
func CreateMetadataService(name string, cfg Config) (MetadataService, error)
CreateMetadataService calls the constructor of the specified MetadataService with the provided address.
type ModifyableRing ¶
type NewBlockStoreFunc ¶
type NewBlockStoreFunc func(string, Config, GlobalMetadata) (BlockStore, error)
type PeerInfoList ¶
func (PeerInfoList) AndNot ¶
func (pi PeerInfoList) AndNot(b PeerList) PeerInfoList
func (PeerInfoList) GetWeights ¶
func (pi PeerInfoList) GetWeights() map[string]int
func (PeerInfoList) HasUUID ¶
func (pi PeerInfoList) HasUUID(uuid string) bool
func (PeerInfoList) Intersect ¶
func (pi PeerInfoList) Intersect(b PeerInfoList) PeerInfoList
func (PeerInfoList) PeerList ¶
func (pi PeerInfoList) PeerList() PeerList
func (PeerInfoList) UUIDAt ¶
func (pi PeerInfoList) UUIDAt(uuid string) int
func (PeerInfoList) Union ¶
func (pi PeerInfoList) Union(b PeerInfoList) PeerInfoList
type PeerPermutation ¶
type RingAdder ¶
type RingAdder interface { ModifyableRing AddPeers(PeerInfoList) (Ring, error) }
type RingRemover ¶
type RingRemover interface { ModifyableRing RemovePeers(PeerList) (Ring, error) }
type Server ¶
type Server struct { Blocks BlockStore MDS MetadataService INodes *INodeStore Cfg Config ReplicationOpen bool // contains filtered or unexported fields }
Server is the type representing the generic distributed block store.
func NewMemoryServer ¶
func NewMemoryServer() *Server
func NewServerByImpl ¶
func NewServerByImpl(cfg Config, mds MetadataService, blocks BlockStore) (*Server, error)
func (*Server) AddTimeoutCallback ¶
func (*Server) BeginHeartbeat ¶
BeginHeartbeat spawns a goroutine for heartbeats. Non-blocking.
func (*Server) CreateFile ¶
func (*Server) UpdateRebalanceInfo ¶
func (s *Server) UpdateRebalanceInfo(ri *models.RebalanceInfo)
type SetRingFunc ¶
type Store ¶
Store is the interface that represents methods that should be common across all types of storage providers.
type WipeMDSFunc ¶ added in v0.1.0
type WriteLevel ¶
type WriteLevel int
const ( WriteAll WriteLevel = iota WriteOne WriteLocal )
func ParseWriteLevel ¶ added in v0.1.0
func ParseWriteLevel(s string) (wl WriteLevel, err error)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
nbd
Package nbd uses the Linux NBD layer to emulate a block device in user space
|
Package nbd uses the Linux NBD layer to emulate a block device in user space |
Package models is a generated protocol buffer package.
|
Package models is a generated protocol buffer package. |