blockring

package module
v0.0.0-...-9df9967 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2017 License: MPL-2.0 Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

blockring

blockring is a building block for sharding, replicating and storing data. It has a peer-to-peer master-less design, which is highly-available and scalable with no single point of failure.

Data Categories

There are 2 main data categories. This determines how data is written to the ring.

  • Immutable
  • Mutable
Immutable

Immutable data does not go through the consensus process and is directly written. Data blocks are written in this manner.

Mutable (experimental)

Mutable data goes through the consensus process i.e. the log.

Roadmap
  • Node failure
  • Node leave
  • Replication
  • Compaction
  • Optimizations

References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockNetTransport

type BlockNetTransport struct {
	// contains filtered or unexported fields
}

func NewBlockNetTransport

func NewBlockNetTransport(bs store.BlockStore) *BlockNetTransport

func (*BlockNetTransport) GetBlockRPC

func (s *BlockNetTransport) GetBlockRPC(ctx context.Context, in *rpc.BlockRPCData) (*rpc.BlockRPCData, error)

func (*BlockNetTransport) Register

func (s *BlockNetTransport) Register(ch chan *rpc.RelocateRPCData)

Register registers a channel where incoming blocks are sent for processing.

func (*BlockNetTransport) ReleaseBlockRPC

func (s *BlockNetTransport) ReleaseBlockRPC(ctx context.Context, in *rpc.BlockRPCData) (*rpc.BlockRPCData, error)

func (*BlockNetTransport) SetBlockRPC

func (s *BlockNetTransport) SetBlockRPC(ctx context.Context, in *rpc.BlockRPCData) (*rpc.BlockRPCData, error)

func (*BlockNetTransport) TransferBlockRPC

func (s *BlockNetTransport) TransferBlockRPC(ctx context.Context, in *rpc.RelocateRPCData) (*rpc.RelocateRPCData, error)

type BlockNetTransportClient

type BlockNetTransportClient struct {
	// contains filtered or unexported fields
}

func NewBlockNetTransportClient

func NewBlockNetTransportClient(reapInterval, maxIdle int) *BlockNetTransportClient

func (*BlockNetTransportClient) GetBlock

func (s *BlockNetTransportClient) GetBlock(loc *structs.Location, id []byte) (*structs.Block, error)

func (*BlockNetTransportClient) ReleaseBlock

func (s *BlockNetTransportClient) ReleaseBlock(loc *structs.Location, id []byte) error

func (*BlockNetTransportClient) SetBlock

func (s *BlockNetTransportClient) SetBlock(loc *structs.Location, block *structs.Block) error

func (*BlockNetTransportClient) TransferBlock

func (s *BlockNetTransportClient) TransferBlock(id []byte, src, dst *structs.Location) error

TransferBlock submits a transfer request to the location for a Block by its id

type BlockRing

type BlockRing struct {
	// contains filtered or unexported fields
}

BlockRing is the core interface to perform operations around the ring.

func NewBlockRing

func NewBlockRing(locator Locator, maxSuccessors int, blkTrans BlockTransport, logTrans LogTransport, ch chan<- *rpc.RelocateRPCData) *BlockRing

NewBlockRing instantiates an instance of BlockRing. If the channel is not nil, proximity shifting is automatically enabled.

func (*BlockRing) CommitEntry

func (br *BlockRing) CommitEntry(tx *structs.LogEntryBlock, opts structs.RequestOptions) error

CommitEntry locates partipicating voters for the LogEntryBlock and asynchronously submits a commit request to each one participant, 1 per go-routine.

func (*BlockRing) EnableProximityShifting

func (br *BlockRing) EnableProximityShifting(enable bool)

EnableProximityShifting enables or disables proximity shifting. Proximity shifing can only enabled if the input block channel is not nil.

func (*BlockRing) GetBlock

func (br *BlockRing) GetBlock(id []byte, opts ...structs.RequestOptions) (*structs.Location, *structs.Block, error)

GetBlock lookups up the id hash then uses upto max successors to find the block.

func (*BlockRing) GetEntry

GetEntry gets a LogEntryBlock from the ring. It routes the id around the ring until an entry is found.

func (*BlockRing) GetLogBlock

func (br *BlockRing) GetLogBlock(key []byte, opts structs.RequestOptions) (*structs.Location, *structs.LogBlock, error)

GetLogBlock gets the LogBlock by routing the key until it is found.

func (*BlockRing) GetRootBlock

func (br *BlockRing) GetRootBlock(id []byte, opts ...structs.RequestOptions) (*structs.Location, *structs.RootBlock, error)

GetRootBlock gets a root block with the given id. It is a helper function that simply decodes a Block into a RootBlock

func (*BlockRing) NewEntry

NewEntry gets a new entry from the log.

func (*BlockRing) ProposeEntry

func (br *BlockRing) ProposeEntry(tx *structs.LogEntryBlock, opts structs.RequestOptions) error

ProposeEntry locates participating voters for the LogEntryBlock and submits a propose request to each participant, 1 per go-routine

func (*BlockRing) SetBlock

func (br *BlockRing) SetBlock(block *structs.Block, opts ...structs.RequestOptions) (*structs.Location, error)

SetBlock writes the block to the ring with the specified replicas

type BlockRingTransport

type BlockRingTransport struct {
	// contains filtered or unexported fields
}

BlockRingTransport allows to make block requests based on Location around the ring. It appropriately makes calls to the local or remote locations

func NewBlockRingTransport

func NewBlockRingTransport(hostname string, local store.BlockStore, remote BlockTransport) *BlockRingTransport

func (*BlockRingTransport) GetBlock

func (t *BlockRingTransport) GetBlock(loc *structs.Location, id []byte) (*structs.Block, error)

func (*BlockRingTransport) ReleaseBlock

func (t *BlockRingTransport) ReleaseBlock(loc *structs.Location, id []byte) error

func (*BlockRingTransport) SetBlock

func (t *BlockRingTransport) SetBlock(loc *structs.Location, block *structs.Block) error

func (*BlockRingTransport) TransferBlock

func (t *BlockRingTransport) TransferBlock(id []byte, src, dst *structs.Location) error

type BlockTransport

type BlockTransport interface {
	GetBlock(loc *structs.Location, id []byte) (*structs.Block, error)
	SetBlock(loc *structs.Location, block *structs.Block) error
	TransferBlock(id []byte, src, dst *structs.Location) error
	ReleaseBlock(loc *structs.Location, id []byte) error
}

BlockTransport implements the transport interface for the block store.

type ChordDelegate

type ChordDelegate struct {
	Store    *BlockRingTransport
	LogTrans *LogRingTransport

	// Incoming candidate blocks to be locally stored i.e. taken over. These are either stored or
	// forwarded based on location ID
	InBlocks chan *rpc.RelocateRPCData
	// contains filtered or unexported fields
}

ChordDelegate primarily handles the movement of data when nodes join and leave the ring.

func NewChordDelegate

func NewChordDelegate(peerStore store.PeerStore, conf *Config) *ChordDelegate

NewChordDelegate instantiates a new ChordDelegate with the supplied PeerStore and config.

func (*ChordDelegate) Leaving

func (s *ChordDelegate) Leaving(local, pred, succ *chord.Vnode)

Leaving is called when local node is leaving the ring

func (*ChordDelegate) NewPredecessor

func (s *ChordDelegate) NewPredecessor(local, remoteNew, remotePrev *chord.Vnode)

NewPredecessor is called when a new predecessor is found

func (*ChordDelegate) PredecessorLeaving

func (s *ChordDelegate) PredecessorLeaving(local, remote *chord.Vnode)

PredecessorLeaving is called when a predecessor leaves

func (*ChordDelegate) Register

func (s *ChordDelegate) Register(ring *ChordRing, blockRing *BlockRing)

Register registers the chord ring to the delegate and starts processing incoming blocks

func (*ChordDelegate) Shutdown

func (s *ChordDelegate) Shutdown()

Shutdown is called when the node is shutting down

func (*ChordDelegate) SuccessorLeaving

func (s *ChordDelegate) SuccessorLeaving(local, remote *chord.Vnode)

SuccessorLeaving is called when a successor leaves

type ChordRing

type ChordRing struct {
	// contains filtered or unexported fields
}

ChordRing is a node part of the chord ring allowing to perform ring operations. This is used on peers participating in the ring.

func NewChordRing

func NewChordRing(conf *Config, peerStore store.PeerStore, gserver *grpc.Server) (*ChordRing, error)

NewChordRing instantiates new ChordRing struct joining or creating a ring based on the configuration.

func (*ChordRing) Hostname

func (cr *ChordRing) Hostname() string

Hostname returns the hostname of the node per the config.

func (*ChordRing) LocateReplicatedHash

func (cr *ChordRing) LocateReplicatedHash(hash []byte, n int) ([]*structs.Location, error)

LocateReplicatedHash returns vnodes where a key and n replicas are located.

func (*ChordRing) LocateReplicatedKey

func (cr *ChordRing) LocateReplicatedKey(key []byte, n int) ([]*structs.Location, error)

LocateReplicatedKey returns vnodes where a key and n replicas are located.

func (*ChordRing) LookupHash

func (cr *ChordRing) LookupHash(hash []byte, n int) (*chord.Vnode, []*chord.Vnode, error)

LookupHash returns the pred. vnode, n succesor vnodes

func (*ChordRing) LookupKey

func (cr *ChordRing) LookupKey(key []byte, n int) ([]byte, *chord.Vnode, []*chord.Vnode, error)

LookupKey returns the key hash, pred. vnode, n succesor vnodes

func (*ChordRing) NumSuccessors

func (cr *ChordRing) NumSuccessors() int

NumSuccessors returns the num of succesors per the config.

func (*ChordRing) Vnodes

func (cr *ChordRing) Vnodes(host string) ([]*chord.Vnode, error)

Vnodes returns all vnodes for a given host. If host is empty string, local vnodes are returned.

type Config

type Config struct {
	Chord           *chord.Config // Chord configuration
	BindAddr        string        // Bind address
	AdvAddr         string        // Advertise address used by peers
	Peers           []string      // Existing peers to join
	RetryJoin       bool          // keep trying peers on failure
	Timeouts        *NetTimeouts  // Network call timeouts
	BlockBufferSize int           // Input block buffer
	RequiredVotes   int           // Votes required for consensus
}

Config holds the overall config

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a sane config

func (*Config) SetPeers

func (cfg *Config) SetPeers(peers string)

SetPeers parses a comma separated list of peers into a slice and sets the config.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate validates the config

type Locator

type Locator interface {
	LookupHash(hash []byte, n int) (*chord.Vnode, []*chord.Vnode, error)
	LookupKey(key []byte, n int) ([]byte, *chord.Vnode, []*chord.Vnode, error)
	LocateReplicatedHash(hash []byte, n int) ([]*structs.Location, error)
	LocateReplicatedKey(key []byte, n int) ([]*structs.Location, error)
}

Locator implements a location and lookup service

type LogNetTransport

type LogNetTransport struct {
	// contains filtered or unexported fields
}

LogNetTransport is the network transport for the consensus log.

func NewLogNetTransport

func NewLogNetTransport(host string, txl *hexalog.HexaLog, bs hexalog.BlockStore) *LogNetTransport

NewLogNetTransport instantiates a new log network transport with the host, HexaLog and BlockStore

func (*LogNetTransport) CommitEntryRPC

func (t *LogNetTransport) CommitEntryRPC(ctx context.Context, req *rpc.BlockRPCData) (*rpc.BlockRPCData, error)

CommitEntryRPC serves a CommitEntry request

func (*LogNetTransport) GetEntryRPC

func (t *LogNetTransport) GetEntryRPC(ctx context.Context, req *rpc.BlockRPCData) (*rpc.BlockRPCData, error)

GetEntryRPC serves a GetEntry request.

func (*LogNetTransport) GetLogBlockRPC

func (t *LogNetTransport) GetLogBlockRPC(ctx context.Context, req *rpc.BlockRPCData) (*rpc.BlockRPCData, error)

GetLogBlockRPC serves a GetLogBlock request.

func (*LogNetTransport) NewEntryRPC

func (t *LogNetTransport) NewEntryRPC(ctx context.Context, req *rpc.BlockRPCData) (*rpc.BlockRPCData, error)

NewEntryRPC services a NewEntry request

func (*LogNetTransport) ProposeEntryRPC

func (t *LogNetTransport) ProposeEntryRPC(ctx context.Context, req *rpc.BlockRPCData) (*rpc.BlockRPCData, error)

ProposeEntryRPC serves a ProposeEntry request

func (*LogNetTransport) Register

func (t *LogNetTransport) Register(ch chan *rpc.RelocateRPCData)

Register registers a channel where incoming blocks are sent for processing.

func (*LogNetTransport) ReleaseLogBlockRPC

func (t *LogNetTransport) ReleaseLogBlockRPC(ctx context.Context, req *rpc.BlockRPCData) (*rpc.BlockRPCData, error)

func (*LogNetTransport) TransferLogBlockRPC

func (t *LogNetTransport) TransferLogBlockRPC(ctx context.Context, req *rpc.RelocateRPCData) (*rpc.RelocateRPCData, error)

TransferLogBlockRPC submits a LogBlock transfer request to the local input block channel.

type LogNetTransportClient

type LogNetTransportClient struct {
	// contains filtered or unexported fields
}

func NewLogNetTransportClient

func NewLogNetTransportClient(reapInterval, maxIdle int) *LogNetTransportClient

func (*LogNetTransportClient) CommitEntry

CommitEntry makes a CommitEntry request to the Location

func (*LogNetTransportClient) GetEntry

GetEntry makes a GetEntry rpc call to the location with the id.

func (*LogNetTransportClient) GetLogBlock

GetLogBlock gets a LogBlock from the provided location.

func (*LogNetTransportClient) NewEntry

NewEntry makes a new a entry request to Location for key

func (*LogNetTransportClient) ProposeEntry

ProposeEntry makes an ProposeEntry rpc call to a location.

func (*LogNetTransportClient) TransferLogBlock

func (c *LogNetTransportClient) TransferLogBlock(key []byte, src, dst *structs.Location) error

TransferLogBlock submits a transfer request to the location for a LogBlock by the key

type LogRingTransport

type LogRingTransport struct {
	// contains filtered or unexported fields
}

LogRingTransport is a transport to make log requests around the ring based on location.

func NewLogRingTransport

func NewLogRingTransport(host string, txl *hexalog.HexaLog, bs hexalog.BlockStore, remote LogTransport) *LogRingTransport

NewLogRingTransport instantiates a new LogRingTransport to make location based calls around the ring

func (*LogRingTransport) CommitEntry

CommitEntry commits the LogEntryBlock to the specified Location

func (*LogRingTransport) GetEntry

GetEntry gets a log entry from a location returning the entry and the location it was retreived from.

func (*LogRingTransport) GetLogBlock

GetLogBlock retrieves a LogBlock from a local or remote Location

func (*LogRingTransport) NewEntry

NewEntry creates a new LogEntryBlock from the provided Location

func (*LogRingTransport) ProposeEntry

ProposeEntry proposes a LogEntryBlock to a local or remote Location

func (*LogRingTransport) TransferLogBlock

func (lt *LogRingTransport) TransferLogBlock(key []byte, src, dst *structs.Location) error

TransferLogBlock makes a transfer request to the destination. It returns an error if a local transfer is initiated otherwise the remote transport error is returned.

type LogTransport

type LogTransport interface {
	GetEntry(loc *structs.Location, key []byte, opts structs.RequestOptions) (*structs.LogEntryBlock, *structs.Location, error)
	NewEntry(loc *structs.Location, key []byte, opts structs.RequestOptions) (*structs.LogEntryBlock, *structs.Location, error)
	ProposeEntry(loc *structs.Location, tx *structs.LogEntryBlock, opts structs.RequestOptions) error
	CommitEntry(loc *structs.Location, tx *structs.LogEntryBlock, opts structs.RequestOptions) error
	GetLogBlock(loc *structs.Location, key []byte, opts structs.RequestOptions) (*structs.LogBlock, *structs.Location, error)
	TransferLogBlock(key []byte, src, dst *structs.Location) error
}

LogTransport implements a transport for the distributed log

type LookupService

type LookupService struct {
	// contains filtered or unexported fields
}

func NewLookupSerivce

func NewLookupSerivce(ring *ChordRing, peerStore store.PeerStore) *LookupService

func (*LookupService) LocateReplicatedHashRPC

func (ls *LookupService) LocateReplicatedHashRPC(ctx context.Context, req *rpc.LocateRequest) (*rpc.LocateResponse, error)

func (*LookupService) LocateReplicatedKeyRPC

func (ls *LookupService) LocateReplicatedKeyRPC(ctx context.Context, req *rpc.LocateRequest) (*rpc.LocateResponse, error)

func (*LookupService) LookupHashRPC

func (ls *LookupService) LookupHashRPC(ctx context.Context, req *rpc.LocateRequest) (*rpc.LocateResponse, error)

func (*LookupService) LookupKeyRPC

func (ls *LookupService) LookupKeyRPC(ctx context.Context, req *rpc.LocateRequest) (*rpc.LocateResponse, error)

func (*LookupService) NegotiateRPC

func (ls *LookupService) NegotiateRPC(ctx context.Context, req *rpc.NegotiateRequest) (*rpc.NegotiateResponse, error)

type LookupServiceClient

type LookupServiceClient struct {
	// contains filtered or unexported fields
}

func NewLookupServiceClient

func NewLookupServiceClient(reapInterval, maxIdle int) *LookupServiceClient

func (*LookupServiceClient) LocateReplicatedHash

func (ls *LookupServiceClient) LocateReplicatedHash(host string, hash []byte, r int) ([]*structs.Location, error)

func (*LookupServiceClient) LocateReplicatedKey

func (ls *LookupServiceClient) LocateReplicatedKey(host string, key []byte, r int) ([]*structs.Location, error)

LocateReplicatedKey makes a LocateReplicatedKey RPC request to the host

func (*LookupServiceClient) LookupHash

func (ls *LookupServiceClient) LookupHash(host string, hash []byte, n int) (*chord.Vnode, []*chord.Vnode, error)

LookupHash performs a hash lookup on the host

func (*LookupServiceClient) LookupKey

func (ls *LookupServiceClient) LookupKey(host string, key []byte, n int) ([]byte, *chord.Vnode, []*chord.Vnode, error)

LookupKey performs a key lookup on the host

func (*LookupServiceClient) Negotiate

func (ls *LookupServiceClient) Negotiate(host string) (*rpc.NegotiateResponse, error)

Negotiate negotiates various parameters from the network when a new Client is instantiated

type NetTimeouts

type NetTimeouts struct {
	Dial time.Duration
	RPC  time.Duration
	Idle time.Duration
}

NetTimeouts holds timeouts for rpc's

func DefaultNetTimeouts

func DefaultNetTimeouts() *NetTimeouts

DefaultNetTimeouts initializes sane timeouts

Directories

Path Synopsis
Package rpc is a generated protocol buffer package.
Package rpc is a generated protocol buffer package.
Package structs is a generated protocol buffer package.
Package structs is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址