Documentation ¶
Index ¶
- Constants
- func NewRaft(s *Server, bs *BlockStore, ls raft.LogStore, trans raft.Transport) (*raft.Raft, error)
- type BlockStore
- func (b *BlockStore) Apply(l *raft.Log) interface{}
- func (b *BlockStore) Close()
- func (b *BlockStore) ReadAt(p []byte, offset uint64) (int, error)
- func (b *BlockStore) Restore(r io.ReadCloser) error
- func (b *BlockStore) SizeOnDisk() (uint64, error)
- func (b *BlockStore) Snapshot() (raft.FSMSnapshot, error)
- type BlockStoreStats
- type LogStore
- func (rls *LogStore) DeleteRange(min, max uint64) error
- func (rls *LogStore) FirstIndex() (uint64, error)
- func (rls *LogStore) GetLog(index uint64, l *raft.Log) error
- func (rls *LogStore) LastIndex() (uint64, error)
- func (rls *LogStore) StoreLog(log *raft.Log) error
- func (rls *LogStore) StoreLogs(logs []*raft.Log) error
- type NBDServer
- type OutOfBounds
- type Peer
- type PeerStatus
- type RaftTransport
- func (r *RaftTransport) AppendEntries(id raft.ServerID, target raft.ServerAddress, args *raft.AppendEntriesRequest, ...) error
- func (r *RaftTransport) AppendEntriesPipeline(id raft.ServerID, target raft.ServerAddress) (raft.AppendPipeline, error)
- func (r *RaftTransport) Consumer() <-chan raft.RPC
- func (r *RaftTransport) DecodePeer(p []byte) raft.ServerAddress
- func (r *RaftTransport) EncodePeer(id raft.ServerID, addr raft.ServerAddress) []byte
- func (r *RaftTransport) HandleCommand(s quic.Stream, p *volumesAPI.RaftRPC) error
- func (r *RaftTransport) InstallSnapshot(id raft.ServerID, target raft.ServerAddress, args *raft.InstallSnapshotRequest, ...) error
- func (r *RaftTransport) LocalAddr() raft.ServerAddress
- func (r *RaftTransport) RequestVote(id raft.ServerID, target raft.ServerAddress, args *raft.RequestVoteRequest, ...) error
- func (r *RaftTransport) SetHeartbeatHandler(cb func(rpc raft.RPC))
- func (r *RaftTransport) TimeoutNow(id raft.ServerID, target raft.ServerAddress, args *raft.TimeoutNowRequest, ...) error
- type Server
- func (s *Server) AddPeer(peerID string, remoteAddr *net.UDPAddr) error
- func (s *Server) AddPeerWithRetry(peerID string, remoteAddr *net.UDPAddr, retryCount int) error
- func (s *Server) AddVolume(d *volumesAPI.Volume, placementPeers []string) error
- func (s *Server) BlockStoreStats() (*BlockStoreStats, error)
- func (s *Server) BlockVolumeStats(vol *Volume) (*BlockStoreStats, error)
- func (s *Server) BootPeers(peerInfo []string)
- func (s *Server) Export(volume string)
- func (s *Server) GetPeer(id string) *Peer
- func (s *Server) GetPeers(ids []string) []*Peer
- func (s *Server) Listen() error
- func (s *Server) LocalAddr() *net.UDPAddr
- func (s *Server) PeerID() string
- func (s *Server) PeerIDs() []string
- func (s *Server) SendMsg(stream quic.Stream, rpc proto.Message) error
- func (s *Server) SendReqViaChannel(p *Peer, channel string, m proto.Message) (proto.Message, error)
- func (s *Server) SetController(cont control.Controller)
- func (s *Server) SetPeerID(id string)
- func (s *Server) Shutdown()
- func (s *Server) Volume(id string) *Volume
- type StoreCommand
- type StoreCommandOp
- type Volume
Constants ¶
const ( //OpWrite write block OpWrite StoreCommandOp = iota //OpZeros replace block with zeros OpZeros //OpTrim _may_ be discarded OpTrim //OpFlush asked to persist all data OpFlush //BlockSize block size per raft log BlockSize = 16 * 1 << 10 //16KB //BlocksPerFile maximum number of blocks that should be in a file BlocksPerFile = 100 * 1 << 20 / BlockSize //100MB files //VolDescSizeMultiplier is the conversion factor for the volume description to bytes VolDescSizeMultiplier = 1 << 30 //volume definition size is in GB )
const ( NBDCMDRead = iota NBDCMDWrite NBDCMDDisc NBDCMDFlush NBDCMDTrim NBDCMDCache NBDCMDWriteZeroes NBDCMDBlockStatus )
NBD commands
const ( NBDCMDFlagFUA = uint16(1 << iota) NBDCMDFlagMayTrim NBDCMDFlagDF )
NBD command flags
const ( NBDFLAGHasFlags = uint16(1 << iota) NBDFLAGReadOnly NBDFLAGSendFlush NBDFLAGSendFUA NBDFLAGRotational NBDFLAGSendTrim NBDFLAGSendWriteZeroes NBDFLAGSendDF NBDFLAGMultiCon NBDFLAGSendResize NBDFLAGSendCache NBDFLAGFastZero )
NBD negotiation flags
const ( NBDMAGIC = 0x4e42444d41474943 NBDMAGICRequest = 0x25609513 NBDMAGICReply = 0x67446698 NBDMAGICCliserv = 0x00420281861253 NBDMAGICOpts = 0x49484156454F5054 NBDMAGICRep = 0x3e889045565a9 NBDMAGICStructuredReply = 0x668e33ef // NBD default port NBDDefaultPort = 10809 )
NBD magic numbers
const ( NBDOPTExportName = iota + 1 NBDOPTAbort NBDOPTList NBDOPTPeekExport NBDOPTStartTLS NBDOPTInfo NBDOPTGo NBDOPTStructuredReply // NBD option reply types NBDREPAck = uint32(1) NBDREPServer = uint32(2) NBDREPInfo = uint32(3) NBDREPFlagError = uint32(1 << 31) NBDREPErrUnsup = uint32(1 | NBDREPFlagError) NBDREPErrPolicy = uint32(2 | NBDREPFlagError) NBDREPErrInvalid = uint32(3 | NBDREPFlagError) NBDREPErrPlatform = uint32(4 | NBDREPFlagError) NBDREPErrTLSReqd = uint32(5 | NBDREPFlagError) NBDREPErrUnknown = uint32(6 | NBDREPFlagError) NBDREPErrShutdown = uint32(7 | NBDREPFlagError) NBDREPErrBlockSizeReqd = uint32(8 | NBDREPFlagError) // NBD reply flags NBDReplyFlagDone = 1 << 0 )
NBD options
const ( NBDREPLYTYPENone = iota NBDREPLYTYPEError NBDREPLYTYPEErrorOffset NBDREPLYTYPEOffsetData NBDREPLYTYPEOffsetHole )
NBD reply types
const ( NBDFLAGFixedNewstyle = 1 << iota NBDFLAGNoZeroes )
NBD hanshake flags
const ( NBDFLAGCFixedNewstyle = 1 << iota NBDFLAGCNoZeroes // NBD errors NBDEPERM = 1 NBDEIO = 5 NBDENOMEM = 12 NBDEINVAL = 22 NBDENOSPC = 28 NBDEOVERFLOW = 75 )
NBD client flags
const ( NBDINFOExport = iota NBDINFOName NBDINFODescription NBDINFOBlockSize )
NBD info types
const (
//DefaultListenPort main peer listening port
DefaultListenPort = 32546
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockStore ¶
type BlockStore struct { BaseDir string // contains filtered or unexported fields }
BlockStore block store backing e.g. local disks
func NewBlockStore ¶
func NewBlockStore(peerID string, d *volumesAPI.Volume, baseDir string, l *logrus.Logger) *BlockStore
NewBlockStore provides a new store for volumes
func (*BlockStore) Apply ¶
func (b *BlockStore) Apply(l *raft.Log) interface{}
Apply log is invoked once a log entry is committed and commits the change to the block store
func (*BlockStore) ReadAt ¶
func (b *BlockStore) ReadAt(p []byte, offset uint64) (int, error)
ReadAt allows for the block store to be read from block sets
func (*BlockStore) Restore ¶
func (b *BlockStore) Restore(r io.ReadCloser) error
Restore is used to restore the block store data from a snapshot
func (*BlockStore) SizeOnDisk ¶
func (b *BlockStore) SizeOnDisk() (uint64, error)
SizeOnDisk goes through each block and queries the underlying filesystem for it's current size
func (*BlockStore) Snapshot ¶
func (b *BlockStore) Snapshot() (raft.FSMSnapshot, error)
Snapshot is used to support log compaction
type BlockStoreStats ¶
BlockStoreStats provides OS status on the block store/volume
type LogStore ¶
type LogStore struct {
// contains filtered or unexported fields
}
LogStore provides a way for raft to store logs
func NewLogStore ¶
NewLogStore creates a new log store used in raft
func (*LogStore) DeleteRange ¶
DeleteRange deletes a range of log entries. The range is inclusive.
func (*LogStore) FirstIndex ¶
FirstIndex returns the first index written. 0 for no entries.
type NBDServer ¶
type NBDServer struct {
// contains filtered or unexported fields
}
NBDServer provides Linux NBD connectivity to a SBS cluster
func NewNBDServer ¶
func NewNBDServer(s *Server, port int, c control.Controller) *NBDServer
NewNBDServer provisions a new NBD listening server attached to the volume server
type OutOfBounds ¶
type OutOfBounds uint64
OutOfBounds when the given offset+data len is greater than allocated volume size
func (OutOfBounds) Error ¶
func (oob OutOfBounds) Error() string
type Peer ¶
type Peer struct { PeerID string RemoteAddr net.Addr Status PeerStatus Channels map[string]*streamChannel // contains filtered or unexported fields }
Peer remote volume peer
type PeerStatus ¶
type PeerStatus uint32
PeerStatus connection status of peer
const ( //PeerStatusConnected Peer is successfully connected PeerStatusConnected PeerStatus = iota //PeerStatusReconnecting peer is current being reconnected PeerStatusReconnecting )
type RaftTransport ¶
type RaftTransport struct {
// contains filtered or unexported fields
}
RaftTransport allows for raft rpcs via the main p2p comms loosely based around raft.NetworkTransport
func NewRaftTransport ¶
func NewRaftTransport(s *Server, volumeID string) *RaftTransport
NewRaftTransport creates a new transport compatible with raft
func (*RaftTransport) AppendEntries ¶
func (r *RaftTransport) AppendEntries(id raft.ServerID, target raft.ServerAddress, args *raft.AppendEntriesRequest, resp *raft.AppendEntriesResponse) error
AppendEntries sends the appropriate RPC to the target node.
func (*RaftTransport) AppendEntriesPipeline ¶
func (r *RaftTransport) AppendEntriesPipeline(id raft.ServerID, target raft.ServerAddress) (raft.AppendPipeline, error)
AppendEntriesPipeline returns an interface that can be used to pipeline AppendEntries requests.
func (*RaftTransport) Consumer ¶
func (r *RaftTransport) Consumer() <-chan raft.RPC
Consumer returns a channel that can be used to consume and respond to RPC requests.
func (*RaftTransport) DecodePeer ¶
func (r *RaftTransport) DecodePeer(p []byte) raft.ServerAddress
DecodePeer is used to deserialize a peer's address.
func (*RaftTransport) EncodePeer ¶
func (r *RaftTransport) EncodePeer(id raft.ServerID, addr raft.ServerAddress) []byte
EncodePeer is used to serialize a peer's address.
func (*RaftTransport) HandleCommand ¶
func (r *RaftTransport) HandleCommand(s quic.Stream, p *volumesAPI.RaftRPC) error
HandleCommand handles a remote Raft RPC command
func (*RaftTransport) InstallSnapshot ¶
func (r *RaftTransport) InstallSnapshot(id raft.ServerID, target raft.ServerAddress, args *raft.InstallSnapshotRequest, resp *raft.InstallSnapshotResponse, data io.Reader) error
InstallSnapshot is used to push a snapshot down to a follower. The data is read from the ReadCloser and streamed to the client.
func (*RaftTransport) LocalAddr ¶
func (r *RaftTransport) LocalAddr() raft.ServerAddress
LocalAddr is used to return our local address to distinguish from our peers.
func (*RaftTransport) RequestVote ¶
func (r *RaftTransport) RequestVote(id raft.ServerID, target raft.ServerAddress, args *raft.RequestVoteRequest, resp *raft.RequestVoteResponse) error
RequestVote sends the appropriate RPC to the target node.
func (*RaftTransport) SetHeartbeatHandler ¶
func (r *RaftTransport) SetHeartbeatHandler(cb func(rpc raft.RPC))
SetHeartbeatHandler is used to setup a heartbeat handler as a fast-pass. This is to avoid head-of-line blocking from disk IO.
func (*RaftTransport) TimeoutNow ¶
func (r *RaftTransport) TimeoutNow(id raft.ServerID, target raft.ServerAddress, args *raft.TimeoutNowRequest, resp *raft.TimeoutNowResponse) error
TimeoutNow is used to start a leadership transfer to the target node.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server Simple Block Storage server instance
func NewServerWithPort ¶
NewServerWithPort constructs a new SBS server on a specific listening port
func (*Server) AddPeerWithRetry ¶
AddPeerWithRetry tries to connect with a peer for given number of times
func (*Server) AddVolume ¶
func (s *Server) AddVolume(d *volumesAPI.Volume, placementPeers []string) error
AddVolume attaches a volume to the server
func (*Server) BlockStoreStats ¶
func (s *Server) BlockStoreStats() (*BlockStoreStats, error)
BlockStoreStats provides status for the block store overall
func (*Server) BlockVolumeStats ¶
func (s *Server) BlockVolumeStats(vol *Volume) (*BlockStoreStats, error)
BlockVolumeStats provides status for specific volumes
func (*Server) GetPeer ¶
GetPeer sends back a peer given it's ID. If the peer does not exist, it will try to discover it via the controller
func (*Server) SendReqViaChannel ¶
SendReqViaChannel sends via a channel/persistent stream if the channel doesn't exist, it will be created
func (*Server) SetController ¶
func (s *Server) SetController(cont control.Controller)
SetController provides the server with a controller for volume assignments
type StoreCommand ¶
type StoreCommand struct { Op StoreCommandOp `json:"op"` Offset uint64 `json:"offset"` Length uint32 `json:"length"` Data []byte `json:"data,omitempty"` }
StoreCommand block store mutation command
func (*StoreCommand) Decode ¶
func (bsc *StoreCommand) Decode(p []byte) error
Decode decodes the block command from transmission
func (*StoreCommand) Encode ¶
func (bsc *StoreCommand) Encode() ([]byte, error)
Encode encodes the block command to binary formats transmission
type Volume ¶
type Volume struct { PlacementPeers map[string]struct{} Blocks *BlockStore Raft *raft.Raft Transport *RaftTransport // contains filtered or unexported fields }
Volume instance
func (*Volume) RemovePeer ¶
RemovePeer adds a placment peer where the volume is expected to reside