Documentation
¶
Index ¶
- Constants
- Variables
- func IsPlacementEmpty(p Placement) bool
- func MetaKeyByVersion(key string, ver int) string
- type ClusterManager
- type DefaultPlacer
- func (l *DefaultPlacer) Dispatch(ins *lambdastore.Instance, cmd types.Command) (err error)
- func (l *DefaultPlacer) Get(key string, chunk int) (*Meta, bool)
- func (l *DefaultPlacer) GetByVersion(key string, ver int, chunk int) (*Meta, bool)
- func (l *DefaultPlacer) InsertAndPlace(key string, newMeta *Meta, cmd types.Command) (*Meta, MetaPostProcess, error)
- func (l *DefaultPlacer) MetaStats() types.MetaStoreStats
- func (l *DefaultPlacer) NewMeta(reqId string, key string, size int64, dChunks, pChunks, chunkId int, ...) *Meta
- func (l *DefaultPlacer) Place(meta *Meta, chunkId int, cmd types.Command) (*lambdastore.Instance, MetaPostProcess, error)
- type InstanceManager
- type LRUPlacer
- func (p *LRUPlacer) AddObject(meta *Meta)
- func (p *LRUPlacer) Dispatch(ins *lambdastore.Instance, cmd types.Command) error
- func (p *LRUPlacer) FindPlacement(meta *Meta, chunkId int) (*lambdastore.Instance, MetaPostProcess, error)
- func (p *LRUPlacer) Get(key string, chunk int) (*Meta, bool)
- func (p *LRUPlacer) GetByVersion(key string, ver int, chunk int) (*Meta, bool)
- func (p *LRUPlacer) Insert(key string, newMeta *Meta) (*Meta, MetaPostProcess, error)
- func (p *LRUPlacer) InsertAndPlace(key string, newMeta *Meta, cmd types.Command) (*Meta, MetaPostProcess, error)
- func (p *LRUPlacer) MetaStats() types.MetaStoreStats
- func (p *LRUPlacer) NewMeta(reqId string, key string, size int64, dChunks, pChunks, chunk int, ...) *Meta
- func (p *LRUPlacer) NextAvailableObject(meta *Meta, candidate *Meta) (*Meta, bool)
- func (p *LRUPlacer) Place(meta *Meta, chunkId int, cmd types.Command) (*lambdastore.Instance, MetaPostProcess, error)
- func (p *LRUPlacer) TouchObject(meta *Meta)
- type LRUPlacerMeta
- type Meta
- func (m *Meta) ChunkKey(chunkId int) string
- func (m *Meta) ConfirmCreated()
- func (m *Meta) Delete()
- func (m *Meta) GetPlace(chunkId int) uint64
- func (m *Meta) HasHistory() bool
- func (m *Meta) Invalidate()
- func (m *Meta) IsCreated() bool
- func (m *Meta) IsDeleted() bool
- func (m *Meta) IsValid() bool
- func (m *Meta) Key() string
- func (m *Meta) KeyByVersion(ver int) string
- func (m *Meta) NumChunks() int
- func (m *Meta) PreviousVersion() int
- func (m *Meta) ReviseBy(newMeta *Meta) *Meta
- func (m *Meta) ReviseFrom(lastVer *Meta) *Meta
- func (m *Meta) SetTimout(timeout time.Duration)
- func (m *Meta) Validate() bool
- func (m *Meta) Version() int
- func (m *Meta) VersioningKey() string
- func (m *Meta) Wait()
- type MetaDoPostProcess
- type MetaPostProcess
- type MetaStore
- type Placement
- type Placer
- type PlacerEvent
- type PlacerEvents
- type PlacerHandler
- type Slice
- type SliceInitializer
Constants ¶
const ( // MetaFlagValid flags that the meta is valid. // If the meta is invalid because of a former creation, some chunks may be created. // A new PUT should skip current version and advance to the next version. MetaFlagValid = int32(0x01) // MetaFlagCreated flags that the object is successfully created MetaFlagCreated = int32(0x02) // MetaFlagDeleted flags that the object is deleted MetaFlagDeleted = int32(0x04) )
const ( // Report there's not enough space in storage // Parameter: *lambdastore.Instance EventInsufficientStorage = 300 )
const (
INIT_LRU_CAPACITY = 10000
)
const (
PlacerEventBeforePlacing = "before_placing"
)
Variables ¶
var (
ErrConcurrentCreation = errors.New("concurrent creation")
)
var (
ErrPlacementConflict = errors.New("conflict on placing")
)
var (
InvalidPlacement = ^uint64(0)
)
var (
RegDelimiter = regexp.MustCompile(`@`)
)
Functions ¶
func IsPlacementEmpty ¶
func MetaKeyByVersion ¶
MetaKeyByVersion is the static version of Meta.KeyByVersion. Key will be santicized first.
Types ¶
type ClusterManager ¶
type ClusterManager interface { // GetActiveInstances Request available instances with minimum number required. GetActiveInstances(int) lambdastore.InstanceEnumerator // GetSlice Get slice implementation if support GetSlice(int) Slice // Trigger Trigger event with code and parameter Trigger(int, ...interface{}) }
type DefaultPlacer ¶
type DefaultPlacer struct { *PlacerEvents // contains filtered or unexported fields }
func NewDefaultPlacer ¶
func NewDefaultPlacer(store *MetaStore, cluster InstanceManager) *DefaultPlacer
func (*DefaultPlacer) Dispatch ¶
func (l *DefaultPlacer) Dispatch(ins *lambdastore.Instance, cmd types.Command) (err error)
func (*DefaultPlacer) GetByVersion ¶
func (*DefaultPlacer) InsertAndPlace ¶
func (l *DefaultPlacer) InsertAndPlace(key string, newMeta *Meta, cmd types.Command) (*Meta, MetaPostProcess, error)
func (*DefaultPlacer) MetaStats ¶
func (l *DefaultPlacer) MetaStats() types.MetaStoreStats
func (*DefaultPlacer) Place ¶
func (l *DefaultPlacer) Place(meta *Meta, chunkId int, cmd types.Command) (*lambdastore.Instance, MetaPostProcess, error)
type InstanceManager ¶
type InstanceManager interface { lambdastore.InstanceManager ClusterManager }
type LRUPlacer ¶
type LRUPlacer struct { *PlacerEvents // contains filtered or unexported fields }
Placer implements a Clock LRU for object eviction. Because objects (or metas) are constantly added to the system in partial (chunks), a object (newer) can be appended to the list normally, while a later chunk of the object requires an eviction of another object (older). In this case, we evict the older in whole based on Clock LRU algorithm, and set the original position of the newer to nil, which a compact operation is needed later. We use a secondary array for online compact.
func NewLRUPlacer ¶
func NewLRUPlacer(store *MetaStore, cluster InstanceManager) *LRUPlacer
func (*LRUPlacer) FindPlacement ¶
func (p *LRUPlacer) FindPlacement(meta *Meta, chunkId int) (*lambdastore.Instance, MetaPostProcess, error)
NewMeta will remap idx according to following logic:
- If an LRU relocation is present, remap according to "chunk" in relocation array.
- Base on the size of slice, remap to a instance in the group.
- If target instance is full, request an LRU relocation and restart from 0.
- If no Balancer relocation is available, request one.
- Remap to smaller "Size" of instance between target instance and remapped instance according to "chunk" in relocation array.
func (*LRUPlacer) GetByVersion ¶
func (*LRUPlacer) InsertAndPlace ¶
func (*LRUPlacer) MetaStats ¶
func (p *LRUPlacer) MetaStats() types.MetaStoreStats
func (*LRUPlacer) NextAvailableObject ¶
func (*LRUPlacer) Place ¶
func (p *LRUPlacer) Place(meta *Meta, chunkId int, cmd types.Command) (*lambdastore.Instance, MetaPostProcess, error)
func (*LRUPlacer) TouchObject ¶
type LRUPlacerMeta ¶
type LRUPlacerMeta struct {
// contains filtered or unexported fields
}
type Meta ¶
type Meta struct { Size int64 DChunks int PChunks int Placement ChunkSize int64 // contains filtered or unexported fields }
func (*Meta) ConfirmCreated ¶
func (m *Meta) ConfirmCreated()
func (*Meta) HasHistory ¶
func (*Meta) Invalidate ¶
func (m *Meta) Invalidate()
func (*Meta) KeyByVersion ¶
func (*Meta) PreviousVersion ¶
func (*Meta) ReviseBy ¶
Revise prepares the new meta created from calling NewMeta with new version infomation
func (*Meta) ReviseFrom ¶
ReviseFrom updates the meta with new version information according to the specified meta of latest version.
func (*Meta) VersioningKey ¶
type MetaPostProcess ¶
type MetaPostProcess func(MetaDoPostProcess)
type MetaStore ¶
type MetaStore struct {
// contains filtered or unexported fields
}
func NewWithCapacity ¶
func (*MetaStore) GetByVersion ¶
func (*MetaStore) GetOrInsert ¶
GetOrInsert get the meta if exists, otherwise insert a new one. The second return value is true if a existed meta is loaded.
type Placer ¶
type Placer interface { // Parameters: key, size, dChunks, pChunks, chunkId, chunkSize, lambdaId, sliceSize NewMeta(string, string, int64, int, int, int, int64, uint64, int) *Meta InsertAndPlace(key string, prepared *Meta, req types.Command) (meta *Meta, postProcess MetaPostProcess, err error) Place(meta *Meta, chunkId int, req types.Command) (ins *lambdastore.Instance, postProcess MetaPostProcess, err error) Get(string, int) (*Meta, bool) GetByVersion(string, int, int) (*Meta, bool) Dispatch(*lambdastore.Instance, types.Command) error MetaStats() types.MetaStoreStats RegisterHandler(event PlacerEvent, handler PlacerHandler) }
type PlacerEvent ¶
type PlacerEvent string
type PlacerEvents ¶
type PlacerEvents struct {
// contains filtered or unexported fields
}
func (*PlacerEvents) RegisterHandler ¶
func (e *PlacerEvents) RegisterHandler(event PlacerEvent, handler PlacerHandler)