Documentation
¶
Index ¶
- type Assembler
- type BlockDevice
- type Blox
- type Header
- type LocalNetTranport
- func (trans *LocalNetTranport) BlockExists(host string, id []byte) (bool, error)
- func (trans *LocalNetTranport) GetBlock(host string, id []byte) (block.Block, error)
- func (trans *LocalNetTranport) Register(local BlockDevice)
- func (trans *LocalNetTranport) RemoveBlock(host string, id []byte) error
- func (trans *LocalNetTranport) SetBlock(host string, blk block.Block) ([]byte, error)
- func (trans *LocalNetTranport) Shutdown() error
- func (trans *LocalNetTranport) Start(ln *net.TCPListener) error
- type NetBlock
- type NetClient
- func (trans *NetClient) BlockExists(host string, id []byte) (bool, error)
- func (trans *NetClient) GetBlock(host string, id []byte) (block.Block, error)
- func (trans *NetClient) RemoveBlock(host string, id []byte) error
- func (trans *NetClient) SetBlock(host string, blk block.Block) ([]byte, error)
- func (trans *NetClient) Shutdown()
- type NetClientOptions
- type NetDevice
- func (dev *NetDevice) BlockExists(id []byte) (bool, error)
- func (dev *NetDevice) Close() error
- func (dev *NetDevice) GetBlock(id []byte) (block.Block, error)
- func (dev *NetDevice) Hasher() func() hash.Hash
- func (dev *NetDevice) RemoveBlock(id []byte) error
- func (dev *NetDevice) SetBlock(blk block.Block) ([]byte, error)
- type NetTransport
- type StreamSharder
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assembler ¶
type Assembler struct {
// contains filtered or unexported fields
}
Assembler assembles all blocks in a root block
func NewAssembler ¶
func NewAssembler(dev BlockDevice, numRoutines int) *Assembler
NewAssembler inits a new assembler backed by the BlockDevice. It launches numRoutines assemblers to retreive and process blocks.
func (*Assembler) Assemble ¶
Assemble begins to retreive all blocks in the root and write then to the writer. Sequence order is maintained
type BlockDevice ¶
type BlockDevice interface {
Hasher() func() hash.Hash
SetBlock(block.Block) ([]byte, error)
GetBlock(id []byte) (block.Block, error)
RemoveBlock(id []byte) error
BlockExists(id []byte) (bool, error)
Stats() *device.Stats
}
BlockDevice implements a local block storage interface. It abstracts the index, tree and data block operations.
type Blox ¶
type Blox struct {
// contains filtered or unexported fields
}
Blox is used to read and write data streams to a block device
func NewBlox ¶
func NewBlox(dev BlockDevice) *Blox
NewBlox inits a new Blox instance with a block device.
func (*Blox) WriteIndex ¶
func (blox *Blox) WriteIndex(rd io.ReadCloser, parallel int) (idx *block.IndexBlock, err error)
WriteIndex reads from the reader and writes to blox storage
type LocalNetTranport ¶
type LocalNetTranport struct {
// contains filtered or unexported fields
}
LocalNetTranport is an interface to interact with blocks locally and remotely. It selects between making a remote vs a local call based on the given host
func NewLocalNetTranport ¶
func NewLocalNetTranport(host string, remote Transport) *LocalNetTranport
NewLocalNetTranport creates a new instance using the provided store and transport. It registers the store with the transport. The transport is started once the local BlockDevice has been registered.
func (*LocalNetTranport) BlockExists ¶
func (trans *LocalNetTranport) BlockExists(host string, id []byte) (bool, error)
BlockExists calls BlockExists on a local or remote host
func (*LocalNetTranport) Register ¶
func (trans *LocalNetTranport) Register(local BlockDevice)
Register registers the store locally as well as with the network transport
func (*LocalNetTranport) RemoveBlock ¶
func (trans *LocalNetTranport) RemoveBlock(host string, id []byte) error
RemoveBlock calls RemoveBlock on a local or remote host
func (*LocalNetTranport) Shutdown ¶
func (trans *LocalNetTranport) Shutdown() error
Shutdown shuts the remote network transport down
func (*LocalNetTranport) Start ¶
func (trans *LocalNetTranport) Start(ln *net.TCPListener) error
Start starts the the remote transport
type NetBlock ¶
type NetBlock struct {
*block.StreamedBlock
// contains filtered or unexported fields
}
NetBlock is network block backed by the network connection. It primarily is used to return the connection back to the pool
type NetClient ¶
type NetClient struct {
// contains filtered or unexported fields
}
NetClient is a network client to perform block operations remotely
func NewNetClient ¶
func NewNetClient(opt NetClientOptions) *NetClient
NewNetClient inits a new client transport with the given connection pool, connection reap interval and hash size of ids
func (*NetClient) BlockExists ¶
BlockExists returns true if the block exists on a remote host
func (*NetClient) RemoveBlock ¶
RemoveBlock makes a RemoveBlock call to the remote host.
type NetClientOptions ¶
type NetClientOptions struct {
Timeout time.Duration
MaxIdle time.Duration
ReapInterval time.Duration
Hasher func() hash.Hash
}
NetClientOptions are options available when using the network client
func DefaultNetClientOptions ¶
func DefaultNetClientOptions(hasher func() hash.Hash) NetClientOptions
DefaultNetClientOptions returns a set of sane defaults. It takes the hash size as input
type NetDevice ¶
type NetDevice struct {
// contains filtered or unexported fields
}
NetDevice is a network BlockDevice. It allows to make direct block operations on a single remote device.
func NewNetDevice ¶
func NewNetDevice(remote string, opts NetClientOptions) *NetDevice
NewNetDevice inits a new network device connected to the provided single remote. The provided options are used to establish the connection
func (*NetDevice) BlockExists ¶
BlockExists returns if the block exists on the remote host
func (*NetDevice) RemoveBlock ¶
RemoveBlock submits a request to remove a block on the device
type NetTransport ¶
type NetTransport struct {
// Client transport
*NetClient
// contains filtered or unexported fields
}
NetTransport is the network transport for block operations
func NewNetTransport ¶
func NewNetTransport(opts NetClientOptions) *NetTransport
NewNetTransport initializes a new network transport for the store
func (*NetTransport) Register ¶
func (trans *NetTransport) Register(dev BlockDevice)
Register registers a BlockDevice with the transport. This must be called before a call to Start is made
func (*NetTransport) Shutdown ¶
func (trans *NetTransport) Shutdown() error
Shutdown issues a shutdown of the transport. It stops taking new incoming connections
func (*NetTransport) Start ¶
func (trans *NetTransport) Start(ln *net.TCPListener) error
Start checks for a block device registration and starts a server to service incoming requests. Register must be called before starting the transport. Register and Start are not thread safe
type StreamSharder ¶
type StreamSharder struct {
// contains filtered or unexported fields
}
StreamSharder takes a stream and shards it by the given block size. It produces an index block of the stream
func NewStreamSharder ¶
func NewStreamSharder(dev BlockDevice, numRoutines int) *StreamSharder
NewStreamSharder creates a new sharder using the block device as storage. It launches numRoutines to write blocks in parallel
func (*StreamSharder) IndexBlock ¶
func (sh *StreamSharder) IndexBlock() *block.IndexBlock
IndexBlock returns the index block os the shard stream
func (*StreamSharder) Runtime ¶
func (sh *StreamSharder) Runtime() time.Duration
Runtime returns the time take to shard the input stream
func (*StreamSharder) SetBlockSize ¶
func (sh *StreamSharder) SetBlockSize(blockSize uint64)
SetBlockSize sets the block size for the sharder. This should be called before Shard is called in order to take affect
func (*StreamSharder) Shard ¶
func (sh *StreamSharder) Shard(rd io.ReadCloser) error
Shard starts sharding a given stream. It returns an IndexBlock or an error
type Transport ¶
type Transport interface {
GetBlock(host string, id []byte) (block.Block, error)
SetBlock(host string, blk block.Block) ([]byte, error)
BlockExists(host string, id []byte) (bool, error)
RemoveBlock(host string, id []byte) error
Register(store BlockDevice)
Start(ln *net.TCPListener) error
Shutdown() error
}
Transport is the transport interface to access blocks. This is used to abstract and combine local and remote