paxoskv

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: 20 Imported by: 2

README

This is a sample that make rocksdb base on paxos to build a strong consistent distributed kv.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyNotExist means the key is not exist
	ErrKeyNotExist = errors.New("key not exists")
	//ErrKeyVersionConflict means the key version is conflict
	ErrKeyVersionConflict = errors.New("key version conflict")
)
View Source
var (
	ErrInvalidLengthPaxoskv = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowPaxoskv   = fmt.Errorf("proto: integer overflow")
)
View Source
var KVRequest_OperatorType_name = map[int32]string{
	0: "READ",
	1: "DELETE",
	2: "WRITE",
}
View Source
var KVRequest_OperatorType_value = map[string]int32{
	"READ":   0,
	"DELETE": 1,
	"WRITE":  2,
}
View Source
var KVResponse_Code_name = map[int32]string{
	0: "OK",
	1: "KEY_NOT_EXIST",
	2: "VERSION_CONFLICT",
}
View Source
var KVResponse_Code_value = map[string]int32{
	"OK":               0,
	"KEY_NOT_EXIST":    1,
	"VERSION_CONFLICT": 2,
}

Functions

func BytesDeepCopy

func BytesDeepCopy(b []byte) []byte

BytesDeepCopy ...

func NewDB

func NewDB(groupID uint64, nodeID uint64) statemachine.IStateMachine

NewDB creates a new DB instance.

func RegisterPhxKVServerServer

func RegisterPhxKVServerServer(s *grpc.Server, srv PhxKVServerServer)

Types

type DB

type DB struct {
	GroupID uint64
	NodeID  uint64
	KVMap   *kvMap
}

DB is the IStateMachine implementation used in the paxoskv example.

func (*DB) Close

func (d *DB) Close()

Close closes the DB instance.

func (*DB) GetHash

func (d *DB) GetHash() uint64

GetHash returns the state machine hash.

func (*DB) Lookup

func (d *DB) Lookup(key []byte) []byte

Lookup ...

func (*DB) Update

func (d *DB) Update(data []byte) uint64

Update updates the DB instance.

type KVData

type KVData struct {
	Value     []byte `protobuf:"bytes,1,opt,name=value" json:"value"`
	Version   uint64 `protobuf:"varint,2,opt,name=version" json:"version"`
	Isdeleted bool   `protobuf:"varint,3,opt,name=isdeleted" json:"isdeleted"`
}

func (*KVData) Descriptor

func (*KVData) Descriptor() ([]byte, []int)

func (*KVData) GetIsdeleted

func (m *KVData) GetIsdeleted() bool

func (*KVData) GetValue

func (m *KVData) GetValue() []byte

func (*KVData) GetVersion

func (m *KVData) GetVersion() uint64

func (*KVData) Marshal

func (m *KVData) Marshal() (dAtA []byte, err error)

func (*KVData) MarshalTo

func (m *KVData) MarshalTo(dAtA []byte) (int, error)

func (*KVData) ProtoMessage

func (*KVData) ProtoMessage()

func (*KVData) Reset

func (m *KVData) Reset()

func (*KVData) Size

func (m *KVData) Size() (n int)

func (*KVData) String

func (m *KVData) String() string

func (*KVData) Unmarshal

func (m *KVData) Unmarshal(dAtA []byte) error

func (*KVData) XXX_DiscardUnknown

func (m *KVData) XXX_DiscardUnknown()

func (*KVData) XXX_Marshal

func (m *KVData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*KVData) XXX_Merge

func (m *KVData) XXX_Merge(src proto.Message)

func (*KVData) XXX_Size

func (m *KVData) XXX_Size() int

func (*KVData) XXX_Unmarshal

func (m *KVData) XXX_Unmarshal(b []byte) error

type KVRequest

type KVRequest struct {
	Key      string                 `protobuf:"bytes,1,opt,name=key" json:"key"`
	Value    []byte                 `protobuf:"bytes,2,opt,name=value" json:"value"`
	Version  uint64                 `protobuf:"varint,3,opt,name=version" json:"version"`
	Operator KVRequest_OperatorType `protobuf:"varint,4,opt,name=operator,enum=paxoskv.KVRequest_OperatorType" json:"operator"`
	Sid      uint32                 `protobuf:"varint,5,opt,name=sid" json:"sid"`
}

func (*KVRequest) Descriptor

func (*KVRequest) Descriptor() ([]byte, []int)

func (*KVRequest) GetKey

func (m *KVRequest) GetKey() string

func (*KVRequest) GetOperator

func (m *KVRequest) GetOperator() KVRequest_OperatorType

func (*KVRequest) GetSid

func (m *KVRequest) GetSid() uint32

func (*KVRequest) GetValue

func (m *KVRequest) GetValue() []byte

func (*KVRequest) GetVersion

func (m *KVRequest) GetVersion() uint64

func (*KVRequest) Marshal

func (m *KVRequest) Marshal() (dAtA []byte, err error)

func (*KVRequest) MarshalTo

func (m *KVRequest) MarshalTo(dAtA []byte) (int, error)

func (*KVRequest) ProtoMessage

func (*KVRequest) ProtoMessage()

func (*KVRequest) Reset

func (m *KVRequest) Reset()

func (*KVRequest) Size

func (m *KVRequest) Size() (n int)

func (*KVRequest) String

func (m *KVRequest) String() string

func (*KVRequest) Unmarshal

func (m *KVRequest) Unmarshal(dAtA []byte) error

func (*KVRequest) XXX_DiscardUnknown

func (m *KVRequest) XXX_DiscardUnknown()

func (*KVRequest) XXX_Marshal

func (m *KVRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*KVRequest) XXX_Merge

func (m *KVRequest) XXX_Merge(src proto.Message)

func (*KVRequest) XXX_Size

func (m *KVRequest) XXX_Size() int

func (*KVRequest) XXX_Unmarshal

func (m *KVRequest) XXX_Unmarshal(b []byte) error

type KVRequest_OperatorType

type KVRequest_OperatorType int32
const (
	KVRequest_READ   KVRequest_OperatorType = 0
	KVRequest_DELETE KVRequest_OperatorType = 1
	KVRequest_WRITE  KVRequest_OperatorType = 2
)

func (KVRequest_OperatorType) Enum

func (KVRequest_OperatorType) EnumDescriptor

func (KVRequest_OperatorType) EnumDescriptor() ([]byte, []int)

func (KVRequest_OperatorType) String

func (x KVRequest_OperatorType) String() string

func (*KVRequest_OperatorType) UnmarshalJSON

func (x *KVRequest_OperatorType) UnmarshalJSON(data []byte) error

type KVResponse

type KVResponse struct {
	Data KVData          `protobuf:"bytes,1,opt,name=data" json:"data"`
	Code KVResponse_Code `protobuf:"varint,2,opt,name=code,enum=paxoskv.KVResponse_Code" json:"code"`
}

func (*KVResponse) Descriptor

func (*KVResponse) Descriptor() ([]byte, []int)

func (*KVResponse) GetCode

func (m *KVResponse) GetCode() KVResponse_Code

func (*KVResponse) GetData

func (m *KVResponse) GetData() KVData

func (*KVResponse) Marshal

func (m *KVResponse) Marshal() (dAtA []byte, err error)

func (*KVResponse) MarshalTo

func (m *KVResponse) MarshalTo(dAtA []byte) (int, error)

func (*KVResponse) ProtoMessage

func (*KVResponse) ProtoMessage()

func (*KVResponse) Reset

func (m *KVResponse) Reset()

func (*KVResponse) Size

func (m *KVResponse) Size() (n int)

func (*KVResponse) String

func (m *KVResponse) String() string

func (*KVResponse) Unmarshal

func (m *KVResponse) Unmarshal(dAtA []byte) error

func (*KVResponse) XXX_DiscardUnknown

func (m *KVResponse) XXX_DiscardUnknown()

func (*KVResponse) XXX_Marshal

func (m *KVResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*KVResponse) XXX_Merge

func (m *KVResponse) XXX_Merge(src proto.Message)

func (*KVResponse) XXX_Size

func (m *KVResponse) XXX_Size() int

func (*KVResponse) XXX_Unmarshal

func (m *KVResponse) XXX_Unmarshal(b []byte) error

type KVResponse_Code

type KVResponse_Code int32
const (
	KVResponse_OK               KVResponse_Code = 0
	KVResponse_KEY_NOT_EXIST    KVResponse_Code = 1
	KVResponse_VERSION_CONFLICT KVResponse_Code = 2
)

func (KVResponse_Code) Enum

func (x KVResponse_Code) Enum() *KVResponse_Code

func (KVResponse_Code) EnumDescriptor

func (KVResponse_Code) EnumDescriptor() ([]byte, []int)

func (KVResponse_Code) String

func (x KVResponse_Code) String() string

func (*KVResponse_Code) UnmarshalJSON

func (x *KVResponse_Code) UnmarshalJSON(data []byte) error

type PaxosKV

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

PaxosKV is the main struct used pb the kv

func NewPaxosKV

func NewPaxosKV(nh *paxos.NodeHost, grpcHost string) *PaxosKV

NewPaxosKV ...

func (*PaxosKV) Start

func (kv *PaxosKV) Start()

Start ...

func (*PaxosKV) Stop

func (kv *PaxosKV) Stop()

Stop ...

type PhxKVServerClient

type PhxKVServerClient interface {
	Put(ctx context.Context, in *KVRequest, opts ...grpc.CallOption) (*KVResponse, error)
	GetLocal(ctx context.Context, in *KVRequest, opts ...grpc.CallOption) (*KVResponse, error)
	Delete(ctx context.Context, in *KVRequest, opts ...grpc.CallOption) (*KVResponse, error)
}

PhxKVServerClient is the client API for PhxKVServer service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewPhxKVServerClient

func NewPhxKVServerClient(cc *grpc.ClientConn) PhxKVServerClient

type PhxKVServerServer

type PhxKVServerServer interface {
	Put(context.Context, *KVRequest) (*KVResponse, error)
	GetLocal(context.Context, *KVRequest) (*KVResponse, error)
	Delete(context.Context, *KVRequest) (*KVResponse, error)
}

PhxKVServerServer is the server API for PhxKVServer service.

type UnimplementedPhxKVServerServer

type UnimplementedPhxKVServerServer struct {
}

UnimplementedPhxKVServerServer can be embedded to have forward compatible implementations.

func (*UnimplementedPhxKVServerServer) Delete

func (*UnimplementedPhxKVServerServer) GetLocal

func (*UnimplementedPhxKVServerServer) Put

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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