hop

package module
v0.0.0-...-8448112 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2016 License: BSD-3-Clause, BSD-2-Clause Imports: 4 Imported by: 0

README

Hop

Hop is a key/value store designed to meet the requirements of systems software and applications at exascale. Most key/value stores, and generally storage systems are designed as monolithic systems that provide certain range of functionality. Hop is designed as set of building blocks that can be assembled and extended based on the particular requirements for each application that uses it. This approach allows Hop to provide more flexible balance between scalability, consistency, reliability and performance than the existing storage systems. Hop allows per-key consistency and reliability configurations. Hop allows groups of users/ranks to create consistency domains that ensure consistency within the group while relaxing the requirements (and improving the performance) for consistency for clients outside of the group. Hop also uses a novel approach of using different key names to access the same data in different ways/formats. A paper describing the initial work on Hop was published at ISC 2015.

Release

This software has been approved for open source release and has been assigned LA-CC-16-9.

Copyright (c) 2015, Los Alamos National Security, LLC All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Documentation

Index

Constants

View Source
const (
	Any        = 0
	Lowest     = 1
	Highest    = Newest - 1
	Newest     = 0x7FFFFFFFFFFFFFFF
	Removed    = 0x8000000000000000
	PastNewest = 0xFFFFFFFFFFFFFFFF
)

Version values

View Source
const (
	// Atomically add the specified value to the current value.
	// The current value and the specified one need to be the same length.
	// Supports byte array lengths of 1, 2, 4, and 8, assumes little-endian
	// order, and converts them to the appropriate unsigned integer.
	Add = iota

	// Atomically subtracts the specified value from the current value.
	// Same requirements as AtomicAdd.
	Sub

	// If the specified value is nil, atomically set/clear one bit in the
	// current value that was zero before. Returns two byte arrays: the
	// new value of the entry, and the 'address' of the bit set/cleared as
	// a 32-bit integer, represented as 4-byte array.
	BitSet
	BitClear

	// Atomically append the specified value to the end of the current value
	Append

	// Atomically remove all matches of the specified value from the current
	// value. If there are no matches, the entry's value and version are
	// not modified
	Remove

	// Atomically replace all matches of the first specified value with the
	// second specified value. If there are no matches, the entry's value
	// and version are not modified
	Replace
)

Atomic Set operations

Variables

View Source
var Eexist = errors.New("key exists")
View Source
var Enoent = errors.New("key doesn't exist")
View Source
var Eperm = errors.New("permission denied")
View Source
var Eremoved = errors.New("key removed")

Functions

func Gblob

func Gblob(buf []byte) ([]byte, []byte)

func Gint16

func Gint16(buf []byte) (uint16, []byte)

func Gint32

func Gint32(buf []byte) (uint32, []byte)

func Gint64

func Gint64(buf []byte) (uint64, []byte)

func Gint8

func Gint8(buf []byte) (uint8, []byte)

func Gstr

func Gstr(buf []byte) (string, []byte)

func Pblob

func Pblob(val []byte, buf []byte) []byte

func Pint16

func Pint16(val uint16, buf []byte) []byte

func Pint32

func Pint32(val uint32, buf []byte) []byte

func Pint64

func Pint64(val uint64, buf []byte) []byte

func Pint8

func Pint8(val uint8, buf []byte) []byte

func Pstr

func Pstr(val string, buf []byte) []byte

Types

type AtomicHop

type AtomicHop interface {
	Atomic(key string, op uint16, values [][]byte) (ver uint64, vals [][]byte, err error)
}

type CreatorHop

type CreatorHop interface {
	Create(key, flags string, value []byte) (ver uint64, err error)
	Remove(key string) (err error)
}

Separate interfaces for each operation

type Entry

type Entry struct {
	sync.RWMutex
	sync.Cond
	Version uint64
	Value   []byte
	// contains filtered or unexported fields
}

func (*Entry) IncreaseVersion

func (e *Entry) IncreaseVersion()

should be called with e lock held

func (*Entry) Modified

func (e *Entry) Modified()

func (*Entry) SetEntry

func (e *Entry) SetEntry(version uint64, val []byte)

func (*Entry) SetLocked

func (e *Entry) SetLocked(val []byte)

called with e lock held

func (*Entry) SetValue

func (e *Entry) SetValue(val []byte)

type GetterHop

type GetterHop interface {
	Get(key string, version uint64) (ver uint64, val []byte, err error)
}

type Hop

type Hop interface {
	// Create add a new entry to the key-value store. The content of the
	// flags parameter is implementation dependent
	Create(key, flags string, value []byte) (ver uint64, err error)

	// Removes an entry from the key-value store.
	Remove(key string) (err error)

	// Retrieves the value for the specified key and version. If necessary,
	// the call waits until the entry's version becomes greater than the
	// specified. Version 0 (Any) returns immediately any value available.
	// Version 2^31-1 (Newest) tries to return the most up-to-date value.
	// Version 2^32-1 (PastNewest) waits until a new value is set and
	// returns it. Returns the version and the value.
	Get(key string, version uint64) (ver uint64, val []byte, err error)

	// Stores new value for the specified key. Returns the new version.
	Set(key string, value []byte) (ver uint64, err error)

	// Checks if the entry's current version and value match the specified
	// oldversion and oldvalue. If true, stores the new value and returns
	// the new version. If oldversion is Any, doesn't compare the versions.
	// If oldvalue is nil, doesn't compare the values.
	// TestSet(key, Any, nil, val) is equivalent to Set(key, val)
	TestSet(key string, oldversion uint64, oldvalue, value []byte) (ver uint64, val []byte, err error)

	// Atomically executes the specified operation on the entry's value.
	// Returns the new version and list of values. Number of specified
	// values, as well as the number of returned ones depends on the
	// operation type. If any values are returned, the first value in the
	// list should be the new value of the entry
	Atomic(key string, op uint16, values [][]byte) (ver uint64, vals [][]byte, err error)
}

type KHop

type KHop struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewKHop

func NewKHop() *KHop

func (*KHop) AddEntry

func (h *KHop) AddEntry(key string, val []byte, ops interface{}) (e *Entry, err error)

If ops is a pointer to a struct that has field of type Entry, that entry is initialized and its value is put in the entries map.

func (*KHop) Atomic

func (h *KHop) Atomic(key string, op uint16, values [][]byte) (ver uint64, vals [][]byte, err error)

func (*KHop) Create

func (h *KHop) Create(key, flags string, value []byte) (ver uint64, err error)

func (*KHop) ExportEntries

func (h *KHop) ExportEntries(match func(key string) bool) (es []byte)

Exports entries that match to a byte array, that can be used by ImportKeys. The exported entries are removed from the datastore and if there are waiters on their values, they are informed. At the moment, we don't support "special" entries (i.e. entries that have ops != nil).

func (*KHop) FindEntry

func (h *KHop) FindEntry(key string) (ops interface{})

func (*KHop) Get

func (h *KHop) Get(key string, version uint64) (ver uint64, val []byte, err error)

func (*KHop) ImportKeys

func (h *KHop) ImportKeys(es []byte, replace bool) (rejected []string, err error)

imports the keys previously exported by ExportEntries. If replace is true overwrites existing keys. If it is false, returns the list of keys that weren't imported because of collisions. At the moment, we don't support "special" entries (i.e. entries that have ops != nil).

func (*KHop) InitKHop

func (h *KHop) InitKHop()

func (*KHop) NumEntries

func (h *KHop) NumEntries() (n int)

func (*KHop) Remove

func (h *KHop) Remove(key string) (err error)

func (*KHop) RemoveEntry

func (h *KHop) RemoveEntry(key string) (err error)

func (*KHop) Set

func (h *KHop) Set(key string, value []byte) (ver uint64, err error)

func (*KHop) TestSet

func (h *KHop) TestSet(key string, oldversion uint64, oldvalue, value []byte) (ver uint64, val []byte, err error)

func (*KHop) VisitEntries

func (h *KHop) VisitEntries(visit func(key string, e *Entry))

Calls the visit function for each entry. Use carefully, the h read lock is held while the function is called.

type Log

type Log struct {
	Data  interface{}
	Owner interface{}
	Type  int
}

type Logger

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

func NewLogger

func NewLogger(sz int) *Logger

func (*Logger) Filter

func (l *Logger) Filter(owner interface{}, itype int) []*Log

func (*Logger) Log

func (l *Logger) Log(data, owner interface{}, itype int)

func (*Logger) Resize

func (l *Logger) Resize(sz int)

type MHop

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

func NewMHop

func NewMHop(dflt interface{}) *MHop

func (*MHop) AddAfter

func (m *MHop) AddAfter(pattern string, exact bool, cutprefix bool, hop interface{}) error

func (*MHop) AddBefore

func (m *MHop) AddBefore(pattern string, exact bool, cutprefix bool, hop interface{}) error

func (*MHop) Atomic

func (m *MHop) Atomic(key string, op uint16, values [][]byte) (ver uint64, vals [][]byte, err error)

func (*MHop) Create

func (m *MHop) Create(key, flags string, value []byte) (ver uint64, err error)

func (*MHop) Get

func (m *MHop) Get(key string, version uint64) (ver uint64, val []byte, err error)

func (*MHop) Remove

func (m *MHop) Remove(key string) (err error)

func (*MHop) Set

func (m *MHop) Set(key string, value []byte) (ver uint64, err error)

func (*MHop) SetDefault

func (m *MHop) SetDefault(dflt interface{})

func (*MHop) String

func (m *MHop) String() string

func (*MHop) TestSet

func (m *MHop) TestSet(key string, oldversion uint64, oldvalue, value []byte) (ver uint64, val []byte, err error)

type SetterHop

type SetterHop interface {
	Set(key string, value []byte) (ver uint64, err error)
}

type TestSetterHop

type TestSetterHop interface {
	TestSet(key string, oldversion uint64, oldvalue, value []byte) (ver uint64, val []byte, err error)
}

Directories

Path Synopsis
bench command
chordsrv command
bench command
d2hopsrv command
dhopsrv command
kcd2hop command
kchopsrv command
ldd2hop command
ldhopsrv command
rmt
hopclnt
The clnt package provides definitions and functions used to implement a Hop client.
The clnt package provides definitions and functions used to implement a Hop client.
hopsrv
The srv package provides definitions and functions used to implement a remote Hop server.
The srv package provides definitions and functions used to implement a remote Hop server.
shopsrv command