store

package
v0.0.0-...-9b63123 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetaBlobSize = 2 + 8 + 4 + 64
	Padding      = 8
)
View Source
const (
	DefaultStoreVer  = 1
	DefaultStoreSize = 100 * 1024 * 1024 * 1024 // 100GB
)
View Source
const (
	NEEDLE_FLAG_DELETE = 1 << iota
)
View Source
const (
	STORE_FLAG_READ_ONLY = 1 << iota
)

Variables

View Source
var (
	STORE_MAGIC = []byte{'\xc4', '\xc4'}
)

Functions

func Uint32ToBytes

func Uint32ToBytes(i uint32) []byte

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

Types

type Index

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

func NewIndex

func NewIndex() *Index

func (*Index) Delete

func (i *Index) Delete(ID uint64)

func (*Index) Dump

func (i *Index) Dump(filename string) error

func (*Index) Get

func (i *Index) Get(ID uint64) (*Payload, bool)

func (*Index) Open

func (i *Index) Open(filepath string) error

func (*Index) Put

func (i *Index) Put(ID uint64, offset int64, sz uint32)

type MetaBlob

type MetaBlob struct {
	Version uint16
	MaxSize uint64
	Flags   uint32
	StoreID [64]byte
}

fixed size meta

func (*MetaBlob) Bytes

func (m *MetaBlob) Bytes() []byte

func (*MetaBlob) FromBytes

func (m *MetaBlob) FromBytes(buf []byte) error

func (MetaBlob) ID

func (m MetaBlob) ID() string

func (*MetaBlob) SetFlag

func (m *MetaBlob) SetFlag(flag int)

func (*MetaBlob) SetID

func (m *MetaBlob) SetID(ID string)

type Needle

type Needle struct {
	ID       uint64
	Flags    uint32
	Data     []byte
	CheckSum uint32 // crc32
}

func NewNeedle

func NewNeedle(ID uint64, data []byte) *Needle

func (*Needle) Bytes

func (n *Needle) Bytes() []byte

func (*Needle) FromPayload

func (n *Needle) FromPayload(b []byte) error

payload: | id (8bytes) | data size (4 bytes) | data | checksum (4bytes)

type Payload

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

type Server

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

func (*Server) Init

func (s *Server) Init(storeID string, createIfExists bool, initPeers []string) error

func (*Server) Serve

func (s *Server) Serve(addr string) error

type StorageNodeInfo

type StorageNodeInfo struct {
	meta.NodeInfo

	IsReadOnly bool `json:"readonly"`
}

type Store

type Store struct {
	MetaBlob
	// contains filtered or unexported fields
}

func NewStoreWithIDAndConfig

func NewStoreWithIDAndConfig(ID string, cfg *StoreConfig) *Store

func (*Store) Close

func (s *Store) Close()

func (*Store) DeleteNeedle

func (s *Store) DeleteNeedle(n *Needle)

func (*Store) IsReadOnly

func (s *Store) IsReadOnly() bool

func (*Store) Join

func (s *Store) Join(nodeName string, nodeGossipAddr string, nodeGossipPort int, peerAddrs []string) error

func (*Store) Open

func (s *Store) Open(createIfNotExists bool) error

func (*Store) ReadID

func (s *Store) ReadID(ID uint64) (*Needle, error)

func (*Store) ReadNeedleAt

func (s *Store) ReadNeedleAt(offset int64) (*Needle, error)

func (*Store) ReadNeedleWithOffsetAndSize

func (s *Store) ReadNeedleWithOffsetAndSize(offset int64, size uint32) (*Needle, error)

func (*Store) SetReadOnly

func (s *Store) SetReadOnly() error

func (*Store) SetStoreID

func (s *Store) SetStoreID(ID string)

func (*Store) WriteNeedle

func (s *Store) WriteNeedle(n *Needle, needSync bool) (int64, uint32, error)

type StoreConfig

type StoreConfig struct {
	Version uint16
	MaxSize uint64
}

func NewDefaultStoreConfig

func NewDefaultStoreConfig() *StoreConfig

type StoreNodeDelegate

type StoreNodeDelegate struct {
	Info *StorageNodeInfo
}

func (*StoreNodeDelegate) GetBroadcasts

func (d *StoreNodeDelegate) GetBroadcasts(overhead, limit int) [][]byte

func (*StoreNodeDelegate) LocalState

func (d *StoreNodeDelegate) LocalState(join bool) []byte

func (*StoreNodeDelegate) MergeRemoteState

func (d *StoreNodeDelegate) MergeRemoteState(buf []byte, join bool)

func (*StoreNodeDelegate) NodeMeta

func (d *StoreNodeDelegate) NodeMeta(limit int) []byte

func (*StoreNodeDelegate) NotifyMsg

func (d *StoreNodeDelegate) NotifyMsg([]byte)

Jump to

Keyboard shortcuts

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