cliftondbserver

package
v0.0.0-...-e532b39 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReadConsistency = Quorum
)
View Source
const PartionLockFileName = "partition.lock.file"
View Source
const TESTING = true

Variables

View Source
var ConsistencyLevelNotSupportedErr = errors.New("consistency level not supported")
View Source
var DefaultGetOption = GetOptions{
	DefaultReadConsistency,
}
View Source
var StoppedErr = errors.New("listener stopped")

Functions

func BytesAsId

func BytesAsId(buffer []byte) uint64

func IdAsBytes

func IdAsBytes(id uint64, buffer []byte)

func IsFileExists

func IsFileExists(filePath string) (bool, error)

func LoadConfig

func LoadConfig(config *Config) (err error)

func NewClusterNodeService

func NewClusterNodeService(raft *raft.RaftNode)

func NewGrpcKVService

func NewGrpcKVService(numConcurrentReq int) kv_client.KVStoreServer

func NewRaftPersistentStorage

func NewRaftPersistentStorage(w *wal.WAL, s *snap.Snapshotter) *raftPersistentStorage

Types

type ApiServer

type ApiServer struct {
	ListenPort uint32
}

type CliftonDbServer

type CliftonDbServer struct {
	Conf Config

	Partitions []PartitionId

	DbRootPath    string
	LockFilePath  string
	LogsPath      string
	MetadatPath   string
	PartitionPath string
	Logger        *zap.Logger
	// contains filtered or unexported fields
}

func NewCliftonDbServer

func NewCliftonDbServer(conf Config) (*CliftonDbServer, error)

func (*CliftonDbServer) AddNode

func (s *CliftonDbServer) AddNode(context.Context, *cluster_services.AddNodeReq) (*cluster_services.AddNodeRes, error)

func (*CliftonDbServer) Boostrap

func (s *CliftonDbServer) Boostrap() error

func (*CliftonDbServer) GetNodeList

func (s *CliftonDbServer) GetNodeList(context.Context, *interface{}) (*cluster_services.PeerListRes, error)

func (*CliftonDbServer) LookupPartitions

func (s *CliftonDbServer) LookupPartitions(key string) (kv *kvstore.CliftonDBKVStore, ok bool)

func (*CliftonDbServer) RemoveNode

func (s *CliftonDbServer) RemoveNode(context.Context, *cluster_services.RemoveNodeReq) (*cluster_services.RemoveNodeRes, error)

func (*CliftonDbServer) ServeClusterNodeApi

func (s *CliftonDbServer) ServeClusterNodeApi()

func (*CliftonDbServer) Shutdown

func (s *CliftonDbServer) Shutdown()

func (*CliftonDbServer) WriteLockFile

func (s *CliftonDbServer) WriteLockFile(data KvServerLockFileData) error

type ClusterConfig

type ClusterConfig struct {
	SelfId      uint
	JoinCluster bool
	Peers       []PeerEntry
	StoragePath string
}

func RaftClusterConfig

func RaftClusterConfig(id uint, peers []PeerEntry, path string) ClusterConfig

func RaftStandaloneConfig

func RaftStandaloneConfig(id uint, path string) ClusterConfig

type ClusterOptions

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

type Config

type Config struct {
	Server ApiServer `yaml:"grpc-grpcServer"`
	DbPath string    `yaml:"db-path"`
	Nodes  RaftNodes `yaml:"raft-nodes"`
}

type DirPathOption

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

type GetOptions

type GetOptions struct {
	ReadConsistencyLevel ReadConsistencyLevel
}

type GrpcClusterNodeService

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

func (GrpcClusterNodeService) AddNode

func (GrpcClusterNodeService) AddNode(context.Context, *cluster_node.AddNodeReq) (*cluster_node.AddNodeRes, error)

func (GrpcClusterNodeService) GetNodeList

func (GrpcClusterNodeService) GetNodeList(context.Context, *interface{}) (*cluster_node.PeerListRes, error)

func (GrpcClusterNodeService) RemoveNode

func (GrpcClusterNodeService) RemoveNode(context.Context, *cluster_node.RemoveNodeReq) (*cluster_node.RemoveNodeRes, error)

type GrpcKVService

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

func (*GrpcKVService) Delete

func (s *GrpcKVService) Delete(ctx context.Context, req *kv_client.DelReq) (*kv_client.DelRes, error)

func (GrpcKVService) Get

func (s GrpcKVService) Get(ctx context.Context, get *kv_client.GetReq) (*kv_client.Value, error)

func (GrpcKVService) Put

func (s GrpcKVService) Put(ctx context.Context, put *kv_client.PutReq) (*kv_client.PutRes, error)

func (*GrpcKVService) Register

func (s *GrpcKVService) Register(grpcServer *grpc.Server)

type JoinClusterOption

type JoinClusterOption struct{}

type KvServerLockFileData

type KvServerLockFileData struct {
	Partitions []PartitionId
}

type Options

type Options interface {
	// contains filtered or unexported methods
}

func JoinCluster

func JoinCluster() Options

func WithDirPath

func WithDirPath(dirPath string) Options

func WithPeers

func WithPeers(nodeId uint, entries ...PeerEntry) Options

type PartitionId

type PartitionId int

type Peer

type Peer struct {
	Id       uint32 `yaml:"id"`
	IpOrHost string `yaml:"host"`
	Port     uint32 `yaml:"port"`
}

type PeerEntry

type PeerEntry struct {
	Id          uint
	NetworkAddr string
}

type RaftNode

type RaftNode struct {
	Id types.ID

	Peers     []PeerEntry
	ClusterId types.ID

	WalDir  string
	SnapDir string

	LastIndex uint64

	Node raft.Node

	RaftURL string
	// contains filtered or unexported fields
}

func NewRaftNode

func NewRaftNode(conf ClusterConfig, proposeC <-chan string, confChangeC <-chan raftpb.ConfChange,
	options ...Options) (*RaftNode, error)

func (*RaftNode) CommitC

func (r *RaftNode) CommitC() chan *string

func (*RaftNode) ErrorC

func (r *RaftNode) ErrorC() chan error

func (*RaftNode) IsIDRemoved

func (rc *RaftNode) IsIDRemoved(id uint64) bool

func (*RaftNode) Loop

func (r *RaftNode) Loop(ticker *time.Ticker) error

func (*RaftNode) Process

func (rc *RaftNode) Process(ctx context.Context, m raftpb.Message) error

func (*RaftNode) ProcessEntries

func (r *RaftNode) ProcessEntries(entry []raftpb.Entry) bool

func (*RaftNode) Propose

func (r *RaftNode) Propose(ctx context.Context, entryData []byte) error

func (*RaftNode) ProposeConfChange

func (r *RaftNode) ProposeConfChange(ctx context.Context, change raftpb.ConfChange) error

func (*RaftNode) PublishEntries

func (r *RaftNode) PublishEntries(entries []raftpb.Entry) bool

func (*RaftNode) PublishSnapshot

func (r *RaftNode) PublishSnapshot(snapshot raftpb.Snapshot) error

func (*RaftNode) ReportSnapshot

func (rc *RaftNode) ReportSnapshot(id uint64, status raft.SnapshotStatus)

func (*RaftNode) ReportUnreachable

func (rc *RaftNode) ReportUnreachable(id uint64)

func (*RaftNode) Restart

func (r *RaftNode) Restart()

func (*RaftNode) Start

func (r *RaftNode) Start()

func (*RaftNode) StartRaftServer

func (r *RaftNode) StartRaftServer() error

func (*RaftNode) Stop

func (r *RaftNode) Stop()

func (*RaftNode) TriggerSnapshot

func (r *RaftNode) TriggerSnapshot()

type RaftNodes

type RaftNodes struct {
	SelfId   uint32 `yaml:"self-id"`
	Port     uint32 `yaml:"port"`
	PeerList []Peer `yaml:"peers"`
}

type RaftPersistentStorage

type RaftPersistentStorage interface {
	Save(state raftpb.HardState, entries []raftpb.Entry) error
	SaveSnap(sp raftpb.Snapshot) error
	Close() error
}

type ReadConsistencyLevel

type ReadConsistencyLevel int
const (
	Serializable ReadConsistencyLevel = iota
	Quorum
	Linearizable
)

type ReplicatedKvStore

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

func (*ReplicatedKvStore) Apply

func (s *ReplicatedKvStore) Apply(entryData []byte)

func (*ReplicatedKvStore) Get

func (st *ReplicatedKvStore) Get(ctx context.Context, key string, options GetOptions) ([]byte, error)

func (*ReplicatedKvStore) KvGrpcServer

func (kv *ReplicatedKvStore) KvGrpcServer() kv_client.KVStoreServer

func (*ReplicatedKvStore) NewReplicatedKvStore

func (p *ReplicatedKvStore) NewReplicatedKvStore(conf ClusterConfig) (*ReplicatedKvStore, error)

func (*ReplicatedKvStore) ProposeC

func (st *ReplicatedKvStore) ProposeC() chan<- string

func (*ReplicatedKvStore) ProposeDelete

func (st *ReplicatedKvStore) ProposeDelete(ctx context.Context, key []byte) (
	*internal_request.InternalResponse, error)

func (*ReplicatedKvStore) ProposePut

func (kv *ReplicatedKvStore) ProposePut(ctx context.Context, key []byte, value []byte) (
	*internal_request.InternalResponse, error)

func (*ReplicatedKvStore) RaftHandler

func (kv *ReplicatedKvStore) RaftHandler() http.Handler

func (*ReplicatedKvStore) ServeKvStoreApi

func (s *ReplicatedKvStore) ServeKvStoreApi()

func (*ReplicatedKvStore) Stop

func (s *ReplicatedKvStore) Stop()

type RequestBuilder

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

func NewRequestBuilder

func NewRequestBuilder(gen RequestIdGenerator) *RequestBuilder

func (*RequestBuilder) NewDeleteRequest

func (b *RequestBuilder) NewDeleteRequest(key []byte) *internal_request.InternalRequest

func (*RequestBuilder) NewGetRequest

func (b *RequestBuilder) NewGetRequest(key []byte) *internal_request.InternalRequest

func (*RequestBuilder) NewPutRequest

func (b *RequestBuilder) NewPutRequest(key []byte, value []byte) *internal_request.InternalRequest

type RequestIdGenerator

type RequestIdGenerator interface {
	NextId() uint64
}

func NewRequestIdGenerator

func NewRequestIdGenerator(initial uint64) RequestIdGenerator

type StoppableListener

type StoppableListener struct {
	*net.TCPListener
	// contains filtered or unexported fields
}

func NewStoppableListener

func NewStoppableListener(l net.Listener) (*StoppableListener, error)

func (*StoppableListener) Accept

func (l *StoppableListener) Accept() (net.Conn, error)

func (*StoppableListener) Stop

func (l *StoppableListener) Stop()

Jump to

Keyboard shortcuts

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