paxosio

package
v0.0.0-...-17369de Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// LogDBBinVersion is the current logdb binary compatibility version
	// implemented in go-paxos.
	LogDBBinVersion uint32 = 1
	// RPCBinVersion is the RPC binary compatibility version implemented in
	// go-paxos.
	RPCBinVersion uint32 = 1
)

Variables

View Source
var (
	// ErrNoSavedLog indicates no saved log.
	ErrNoSavedLog = errors.New("no saved log")
	// ErrNoBootstrapInfo indicates that there is no saved bootstrap info.
	ErrNoBootstrapInfo = errors.New("no bootstrap info")
)

Functions

This section is empty.

Types

type ChunkSinkFactory

type ChunkSinkFactory func() IChunkSink

ChunkSinkFactory is a factory function that returns a new IChunkSink instance. The returned IChunkSink will be used to accept future received snapshot chunks.

type IChunkSink

type IChunkSink interface {
	// Close closes the sink instance and releases all resources held by it.
	Close()

	// Tick moves forward the internal logic clock. It is suppose to be called
	// roughly every second.
	Tick()
}

IChunkSink is the interface of snapshot chunk sink. IChunkSink is used to accept received snapshot chunks.

type IConnection

type IConnection interface {
	// Close closes the IConnection instance.
	Close()
	// SendMessageBatch sends the specified message batch to the target. It is
	// recommended to deliver the message batch to the target in order to enjoy
	// best possible performance, but out of order delivery is allowed at the
	// cost of reduced performance.
	SendMessageBatch(batch paxospb.MessageBatch) error
}

IConnection is the interface used by the Raft RPC module for sending Raft messages. Each IConnection works for a specified target nodehost instance, it is possible for a target to have multiple concurrent IConnection instances.

type IContext

type IContext interface {
	Destroy()
	Reset()
	GetKey() IReusableKey
	GetValueBuffer(sz uint64) []byte
	GetUpdates() []paxospb.Update
	GetWriteBatch() interface{}
}

IContext is the per thread context used in the logdb module. IContext is expected to contain a list of reusable keys and byte slices that are owned per thread so they can be safely reused by the same thread when accessing ILogDB.

type ILogDB

type ILogDB interface {
	Name() string
	Close()
	GetLogDBThreadContext() IContext
	ListNodeInfo() ([]NodeInfo, error)

	// SaveBootstrapInfo saves the specified bootstrap info to the log DB.
	SaveBootstrapInfo(groupID uint64,
		nodeID uint64, bootstrap paxospb.Bootstrap) error
	// GetBootstrapInfo returns saved bootstrap info from log DB. It returns
	// ErrNoBootstrapInfo when there is no previously saved bootstrap info for
	// the specified node.
	GetBootstrapInfo(groupID uint64, nodeID uint64) (*paxospb.Bootstrap, error)
	SavePaxosState(updates []paxospb.Update, ctx IContext) error

	// IterateEntries returns the continuous Paxos log entries of the specified
	// Paxos node between the index value range of [low, high) up to a max size
	// limit of maxSize bytes. It returns the located log entries, their total
	// size in bytes and the occurred error.
	IterateEntries(groupID uint64, nodeID uint64, low uint64,
		high uint64) ([]paxospb.Entry, error)

	// ReadPaxosState returns the persistented paxos state found in Log DB.
	ReadPaxosState(groupID, nodeID, lastInstance uint64) (*PaxosState, error)
}

ILogDB is the interface implemented by the log DB for persistently store Paxos states, log entries and other Paxos metadata.

type IPaxosRPC

type IPaxosRPC interface {
	Name() string
	Start() error
	Stop()
	// GetConnection returns an IConnection instance responsible for
	// sending Raft messages to the specified target nodehost.
	GetConnection(ctx context.Context, target string) (IConnection, error)
}

IPaxosRPC ...

type IReusableKey

type IReusableKey interface {
	SetEntryBatchKey(groupID uint64, nodeID uint64, index uint64)
	// SetEntryKey sets the key to be an entry key for the specified paxos node
	// with the specified entry index.
	SetEntryKey(clustergroupIDID uint64, nodeID uint64, index uint64)
	// SetStateKey sets the key to be an persistent state key suitable
	// for the specified paxos group node.
	SetStateKey(groupID uint64, nodeID uint64)
	// SetMaxInstanceKey sets the key to be the max possible index key for the
	// specified paxos group node.
	SetMaxInstanceKey(groupID uint64, nodeID uint64)
	// Key returns the underlying byte slice of the key.
	Key() []byte
	// Release releases the key instance so it can be reused in the future.
	Release()
}

IReusableKey is the interface for keys that can be reused. A reusable key is usually obtained by calling the GetKey() function of the IContext instance.

type NodeInfo

type NodeInfo struct {
	GroupID uint64
	NodeID  uint64
}

NodeInfo ...

func GetNodeInfo

func GetNodeInfo(gid uint64, nid uint64) NodeInfo

GetNodeInfo ...

type PaxosState

type PaxosState struct {
	State *paxospb.State
	// FirstInstanceID is the index of the first entry to iterate
	FirstInstanceID uint64
	// EntryCount is the number of entries to iterate
	EntryCount uint64
}

PaxosState ...

type RequestHandler

type RequestHandler func(req paxospb.MessageBatch)

RequestHandler is the handler function type for handling received message batch. Received message batches should be passed to the request handler to have them processed by go-paxos.

type State

type State struct {
	InstanceID uint64
	Commit     uint64
}

State ...

Jump to

Keyboard shortcuts

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