Documentation ¶
Overview ¶
Package datastore provides versioning and persisting supported data types using one of the supported storage engines.
Index ¶
- Constants
- Variables
- func AddToNodeLog(uuid dvid.UUID, msgs []string) error
- func AddToRepoLog(uuid dvid.UUID, msgs []string) error
- func BlockOnUpdating(uuid dvid.UUID, name dvid.InstanceName) error
- func CloseReopenTest(datamap ...DataStorageMap)
- func CloseTest()
- func Commit(uuid dvid.UUID, note string, log []string) error
- func CompiledChart() string
- func CompiledTypes() map[dvid.TypeString]TypeService
- func CompiledURLs() string
- func CopyInstance(uuid dvid.UUID, source, target dvid.InstanceName, c dvid.Config) error
- func DeleteConflicts(uuid dvid.UUID, data DataService, oldParents, newParents []dvid.UUID) error
- func DeleteDataByName(uuid dvid.UUID, name dvid.InstanceName, passcode string) error
- func DeleteDataByVersion(v dvid.VersionID, name dvid.InstanceName, passcode string) error
- func DeleteRepo(uuid dvid.UUID, passcode string) error
- func FlattenMetadata(uuid dvid.UUID, configFName string) error
- func GetAncestry(v dvid.VersionID) ([]dvid.VersionID, error)
- func GetBlobStore(d dvid.Data) (store storage.BlobStore, err error)
- func GetBranchVersions(uuid dvid.UUID, name string) ([]dvid.UUID, error)
- func GetBranchVersionsJSON(uuid dvid.UUID, name string) (string, error)
- func GetChildrenByVersion(v dvid.VersionID) ([]dvid.VersionID, error)
- func GetGraphDB(d dvid.Data) (db storage.GraphDB, err error)
- func GetKeyValueBatcher(d dvid.Data) (db storage.KeyValueBatcher, err error)
- func GetKeyValueDB(d dvid.Data) (db storage.KeyValueDB, err error)
- func GetNodeLog(uuid dvid.UUID) ([]string, error)
- func GetNodeNote(uuid dvid.UUID) (string, error)
- func GetOrderedKeyValueDB(d dvid.Data) (db storage.OrderedKeyValueDB, err error)
- func GetParentsByVersion(v dvid.VersionID) ([]dvid.VersionID, error)
- func GetRepoAlias(uuid dvid.UUID) (string, error)
- func GetRepoDescription(uuid dvid.UUID) (string, error)
- func GetRepoJSON(uuid dvid.UUID) (string, error)
- func GetRepoLog(uuid dvid.UUID) ([]string, error)
- func GetRepoRoot(uuid dvid.UUID) (dvid.UUID, error)
- func GetRepoRootVersion(v dvid.VersionID) (dvid.VersionID, error)
- func GetStorageDetails() (map[string]StorageStats, error)
- func GetStorageSummary() (string, error)
- func HideBranch(uuid dvid.UUID, branchName string) error
- func Initialize(initMetadata bool, iconfig Config) error
- func LimitVersions(uui dvid.UUID, configFName string) error
- func LockedUUID(uuid dvid.UUID) (bool, error)
- func LockedVersion(v dvid.VersionID) (bool, error)
- func LogRepoOpToKafka(uuid dvid.UUID, b []byte) error
- func MakeMaster(newMasterNode dvid.UUID, oldMasterBranchName string) error
- func MarshalJSON() ([]byte, error)
- func MatchingUUID(uuidStr string) (dvid.UUID, dvid.VersionID, error)
- func Merge(parents []dvid.UUID, note string, mt MergeType) (dvid.UUID, error)
- func MigrateBatch(uuid dvid.UUID, configFName string) (err error)
- func MigrateInstance(uuid dvid.UUID, source dvid.InstanceName, srcStore, dstStore dvid.Store, ...) error
- func ModifyDataConfigByName(uuid dvid.UUID, name dvid.InstanceName, c dvid.Config) error
- func NewRepo(alias, description string, assign *dvid.UUID, passcode string) (dvid.UUID, error)
- func NewTestRepo() (dvid.UUID, dvid.VersionID)
- func NewUUID(assign *dvid.UUID) (dvid.UUID, dvid.VersionID, error)
- func NewVersion(parent dvid.UUID, note string, branchname string, assign *dvid.UUID) (dvid.UUID, error)
- func NotifySubscribers(e SyncEvent, m SyncMessage) error
- func OpenTest(datamap ...DataStorageMap)
- func PushData(d dvid.Data, p *PushSession) error
- func PushRepo(uuid dvid.UUID, target string, config dvid.Config) error
- func Register(t TypeService)
- func ReloadMetadata() error
- func RenameData(uuid dvid.UUID, oldname, newname dvid.InstanceName, passcode string) error
- func SaveDataByUUID(uuid dvid.UUID, data DataService) error
- func SaveDataByVersion(v dvid.VersionID, data DataService) error
- func SetNodeNote(uuid dvid.UUID, note string) error
- func SetRepoAlias(uuid dvid.UUID, alias string) error
- func SetRepoDescription(uuid dvid.UUID, desc string) error
- func SetSyncByJSON(d dvid.Data, uuid dvid.UUID, replace bool, in io.ReadCloser) error
- func SetSyncData(data dvid.Data, syncs dvid.UUIDSet, replace bool) error
- func SetTagsByJSON(d dvid.Data, uuid dvid.UUID, replace bool, in io.ReadCloser) error
- func Shutdown()
- func TransferData(uuid dvid.UUID, srcStore, dstStore dvid.Store, configFName string) error
- func Types() (map[dvid.URLString]TypeService, error)
- func UUIDFromVersion(v dvid.VersionID) (dvid.UUID, error)
- func VersionFromUUID(uuid dvid.UUID) (dvid.VersionID, error)
- type BlobService
- type CommitSyncer
- type Config
- type Data
- func (d *Data) Checksum() dvid.Checksum
- func (d *Data) Compression() dvid.Compression
- func (d *Data) DAGRootUUID() (dvid.UUID, error)
- func (d *Data) DataName() dvid.InstanceName
- func (d *Data) DataUUID() dvid.UUID
- func (d *Data) DescribeTKeyClass(tkc storage.TKeyClass) string
- func (d *Data) Equals(d2 *Data) bool
- func (d *Data) GetBlob(ref string) (data []byte, err error)
- func (d *Data) GetReadLog() storage.ReadLog
- func (d *Data) GetType() TypeService
- func (d *Data) GetWriteLog() storage.WriteLog
- func (d *Data) GobDecode(b []byte) error
- func (d *Data) GobEncode() ([]byte, error)
- func (d *Data) InstanceID() dvid.InstanceID
- func (d *Data) IsDeleted() bool
- func (d *Data) IsMutationRequest(action, endpoint string) bool
- func (d *Data) KVStore() (dvid.Store, error)
- func (d *Data) MarshalJSON() ([]byte, error)
- func (d *Data) MarshalJSONTags() ([]byte, error)
- func (d *Data) ModifyConfig(config dvid.Config) error
- func (d *Data) MutAdd(mutID uint64) (newOp bool)
- func (d *Data) MutDelete(mutID uint64)
- func (d *Data) MutDone(mutID uint64)
- func (d *Data) MutWait(mutID uint64)
- func (d *Data) NewMutationID() uint64
- func (d *Data) PersistMetadata() error
- func (d *Data) ProduceKafkaMsg(b []byte) error
- func (d *Data) PushData(p *PushSession) error
- func (d *Data) PutBlob(b []byte) (ref string, err error)
- func (d *Data) RootUUID() dvid.UUID
- func (d *Data) RootVersionID() (dvid.VersionID, error)
- func (d *Data) SetDataUUID(uuid dvid.UUID)
- func (d *Data) SetDeleted(deleted bool)
- func (d *Data) SetInstanceID(id dvid.InstanceID)
- func (d *Data) SetKVStore(kvStore dvid.Store)
- func (d *Data) SetLogStore(logStore dvid.Store)
- func (d *Data) SetName(name dvid.InstanceName)
- func (d *Data) SetRootUUID(uuid dvid.UUID)
- func (d *Data) SetSync(syncs dvid.UUIDSet)
- func (d *Data) SetTags(tags map[string]string)
- func (d *Data) SyncPending() bool
- func (d *Data) SyncedData() dvid.UUIDSet
- func (d *Data) SyncedNames() []dvid.InstanceName
- func (d *Data) Tags() map[string]string
- func (d *Data) TypeName() dvid.TypeString
- func (d *Data) TypeURL() dvid.URLString
- func (d *Data) TypeVersion() string
- func (d *Data) Versioned() bool
- type DataAvail
- type DataInitializer
- type DataService
- func GetDataByDataUUID(dataUUID dvid.UUID) (DataService, error)
- func GetDataByUUIDName(uuid dvid.UUID, name dvid.InstanceName) (DataService, error)
- func GetDataByVersionName(v dvid.VersionID, name dvid.InstanceName) (DataService, error)
- func NewData(uuid dvid.UUID, t TypeService, name dvid.InstanceName, c dvid.Config) (DataService, error)
- type DataStorageMap
- type DataTxInit
- type Initializer
- type InstanceMutator
- type InstanceStats
- type KVMessage
- type KeyStats
- type MergeType
- type MutationDumper
- type MutationMutexer
- type PropertyCopier
- type PushSession
- type Request
- type Response
- type Shutdowner
- type StorageStats
- type SyncEvent
- type SyncMessage
- type SyncSub
- type SyncSubs
- type Syncer
- type Type
- type TypeMigrator
- type TypeService
- type TypeUpgrader
- type Updater
- type VersionInitializer
- type VersionRemapper
- type VersionedCtx
- func (vctx *VersionedCtx) GetBestKeyVersion(keys []storage.Key) (storage.Key, error)
- func (vctx *VersionedCtx) GetGraphDB() (storage.GraphDB, error)
- func (vctx *VersionedCtx) GetKeyValueDB() (storage.KeyValueDB, error)
- func (vctx *VersionedCtx) GetOrderedKeyValueDB() (storage.OrderedKeyValueDB, error)
- func (vctx *VersionedCtx) Head() bool
- func (vctx *VersionedCtx) MasterVersion(version dvid.VersionID) bool
- func (vctx *VersionedCtx) NumVersions() int32
- func (vctx *VersionedCtx) RepoRoot() (dvid.UUID, error)
- func (vctx *VersionedCtx) String() string
- func (vctx *VersionedCtx) VersionUUID() dvid.UUID
- func (vctx *VersionedCtx) Versioned() bool
- func (vctx *VersionedCtx) VersionedKeyValue(values []*storage.KeyValue) (*storage.KeyValue, error)
Constants ¶
const ( StartDataMsg = "datastore.startData" PutKVMsg = "datastore.putKV" )
const DataShutdownTime = 20
DataShutdownTime is the maximum number of seconds a data instance can delay when terminating goroutines during Shutdown.
const InitialMutationID = 1000000000 // billion
InitialMutationID is the initial mutation ID for all new repositories. It was chosen to be a large number to distinguish between mutations with repo-wide persistent IDs and the legacy data instance-specific mutation IDs that would reset on server restart.
const PropertyTKeyClass = 1
PropertyTKeyClass is the TKeyClass reserved for data instance properties, and should be reserved in each data type implementation.
const RepoFormatVersion = 1
RepoFormatVersion is the current repo metadata format version
const (
ServerLockKey storage.TKeyClass // name of key for locking metadata globally
)
Key space handling for metadata
const StrideMutationID = 100
StrideMutationID is a way to minimize cost of persisting mutation IDs for a repo. We persist the current mutation ID plus the stride, so that we don't have to update the persisted mutation ID frequently. The downside is that there may be jumps in mutation IDs on restarts, since the persisted ID is loaded on next restart.
const (
Version = "0.10.0"
)
Variables ¶
var ( ErrManagerNotInitialized = errors.New("datastore repo manager not initialized") ErrBadMergeType = errors.New("bad merge type") ErrInvalidUUID = errors.New("UUID is not present in datastore") ErrInvalidVersion = errors.New("server-specific version id is invalid") ErrInvalidRepoID = errors.New("server-specific repo id is invalid") ErrExistingUUID = errors.New("UUID already exists in datastore") ErrExistingDataName = errors.New("data name already exists") ErrInvalidDataName = errors.New("invalid data instance name") ErrInvalidDataInstance = errors.New("invalid data instance id") ErrInvalidDataUUID = errors.New("invalid data instance UUID") ErrInvalidStore = errors.New("invalid data store") ErrModifyLockedNode = errors.New("can't modify locked node") ErrBranchUnlockedNode = errors.New("can't branch an unlocked node") ErrBranchUnique = errors.New("branch already exists with given name") )
var ( // Compiled is the set of registered datatypes compiled into DVID and // held as a global variable initialized at runtime. Compiled map[dvid.URLString]TypeService )
Functions ¶
func BlockOnUpdating ¶
func BlockOnUpdating(uuid dvid.UUID, name dvid.InstanceName) error
BlockOnUpdating blocks until the given data is not updating from syncs or has events waiting in sync channels. Primarily used during testing.
func CloseReopenTest ¶
func CloseReopenTest(datamap ...DataStorageMap)
CloseReopenTest forces close and then reopening of the datastore, useful for testing persistence. We only allow close/reopen when all tests not avaiting close/reopen are finished.
func CompiledChart ¶
func CompiledChart() string
CompiledChart returns a chart (names/urls) of datatypes compiled into this DVID.
func CompiledTypes ¶
func CompiledTypes() map[dvid.TypeString]TypeService
CompiledTypes returns a map of datatypes compiled into this DVID.
func CompiledURLs ¶
func CompiledURLs() string
CompiledURLs returns a list of datatype urls supported by this DVID.
func CopyInstance ¶
CopyInstance copies a data instance locally, perhaps to a different storage engine if the new instance uses a different backend per a data instance-specific configuration. (See sample config.example.toml file in root dvid source directory.)
func DeleteConflicts ¶
DeleteConflicts removes all conflicted kv pairs for the given data instance using the priority established by parents. As a side effect, newParents are modified by new children of parents.
func DeleteDataByName ¶
DeleteDataByName returns a data service given an instance name and UUID.
func DeleteDataByVersion ¶
DeleteDataByVersion returns a data service given an instance name and UUID.
func DeleteRepo ¶
DeleteRepo deletes a Repo holding a node with UUID.
func FlattenMetadata ¶
FlattenMetadata stores the metadata of a reduced set of nodes into the destination store.
func GetAncestry ¶
GetAncestry returns a list of ancestor versions from the given version to the root.
func GetBlobStore ¶
GetBlobStore returns a blob store or nil if not available. TODO -- Add configurable option to use a file system.
func GetBranchVersions ¶
GetBranchVersions returns a slice of UUIDs for the given branch from the HEAD (leaf) to the root.
func GetBranchVersionsJSON ¶
func GetChildrenByVersion ¶
GetChildren returns the child nodes of the given version id.
func GetGraphDB ¶
GetGraphDB returns a graph store assigned to this data instance. If the store is nil or not available, an error is returned.
func GetKeyValueBatcher ¶
func GetKeyValueBatcher(d dvid.Data) (db storage.KeyValueBatcher, err error)
GetKeyValueBatcher returns a batch-capable kv data store assigned to this data instance. If the store is nil or not available, an error is returned.
func GetKeyValueDB ¶
func GetKeyValueDB(d dvid.Data) (db storage.KeyValueDB, err error)
GetKeyValueDB returns a kv data store assigned to this data instance. If the store is nil or not available, an error is returned.
func GetOrderedKeyValueDB ¶
func GetOrderedKeyValueDB(d dvid.Data) (db storage.OrderedKeyValueDB, err error)
GetOrderedKeyValueDB returns the ordered kv data store assigned to this data instance. If the store is nil or not available, an error is returned.
func GetParentsByVersion ¶
GetParents returns the parent nodes of the given version id.
func GetStorageDetails ¶
func GetStorageDetails() (map[string]StorageStats, error)
GetStorageDetails scans all key-value stores and returns detailed stats per instances.
func GetStorageSummary ¶
GetStorageSummary returns JSON for all the data instances in the stores.
func HideBranch ¶ added in v0.9.13
HideBranch makes the branch at given UUID (that node and all its children) the new master branch and renames the old master branch to the given branch name. NOTE: This command will fail if the given UUID is not a node that is directly branched off master.
func Initialize ¶
Initialize creates a repositories manager that is handled through package functions.
func LimitVersions ¶
LimitVersions removes versions from the metadata that are not present in a configuration file.
func LockedUUID ¶
LockedUUID returns true if a given UUID is locked.
func LockedVersion ¶
LockedVersion returns true if a given version is locked.
func LogRepoOpToKafka ¶
LogRepoOpToKafka logs a repo operation to kafka
func MakeMaster ¶ added in v0.9.13
MakeMaster makes the branch at given UUID (that node and all its children) the new master branch and renames the old master branch to the given branch name. NOTE: This command will fail if the given UUID is not a node that is directly branched off master.
func MarshalJSON ¶
MarshalJSON returns JSON of object where each repo is a property with root UUID name and value corresponding to repo info.
func MatchingUUID ¶
MatchingUUID returns a local version ID and the full UUID from a potentially shortened UUID string. Partial matches are accepted as long as they are unique for a datastore. So if a datastore has nodes with UUID strings 3FA22..., 7CD11..., and 836EE..., we can still find a match even if given the minimum 3 letters. (We don't allow UUID strings of less than 3 letters just to prevent mistakes.) If the passed string has a colon, the string after the colon is parsed as a case-sensitive branch name of the repo with the given UUID, and the UUID returned will be the HEAD or uncommitted leaf of that branch. Example "3FA22:master" returns the leaf UUID of branch "master" for the repo containing
the 3FA22 UUID.
func MigrateBatch ¶
MigrateBatch migrates instances specified in the config file from a source to a destination store, similar to the above "migrate" command but in a batch. Before running this command, you must modify the config TOML file so the destination store is available.
The migrate config file contains JSON with the following format:
{ "Versions": ["2881e9","52a13","57e8d"], "Migrations": [ { "Name": "instance-name", "SrcStore": "source store", "DstStore": { "Path": "/path/to/store", "Engine": "basholeveldb" } }, { "Name": "#datatype", "SrcStore": "source store", "DstStore": { "Path": "/another/store", "Engine": "badger" } }, ], "Exclusions": ["name1", "name2"] }
func MigrateInstance ¶
func MigrateInstance(uuid dvid.UUID, source dvid.InstanceName, srcStore, dstStore dvid.Store, c dvid.Config, done chan bool) error
MigrateInstance migrates a data instance locally from an old storage engine to the current configured storage.
func ModifyDataConfigByName ¶
func NewRepo ¶
NewRepo creates a new Repo and returns its UUID, either an assigned UUID if provided or creating a new UUID.
func NewTestRepo ¶
NewTestRepo returns a new datastore.Repo suitable for testing.
func NewVersion ¶
func NewVersion(parent dvid.UUID, note string, branchname string, assign *dvid.UUID) (dvid.UUID, error)
NewVersion creates a new version as a child of the given parent. If the assign parameter is not nil, the new node is given the UUID.
func NotifySubscribers ¶
func NotifySubscribers(e SyncEvent, m SyncMessage) error
NotifySubscribers sends a message to any data instances subscribed to the event.
func OpenTest ¶
func OpenTest(datamap ...DataStorageMap)
func PushData ¶
func PushData(d dvid.Data, p *PushSession) error
PushData transfers all key-value pairs pertinent to the given data instance. Each datatype can implement filters that can restrict the transmitted key-value pairs based on the given FilterSpec. Note that because of the generality of this function, a particular datatype implementation could be much more efficient when implementing filtering. For example, the imageblk datatype could scan its key-values using the ROI to generate keys (since imageblk keys will likely be a vast superset of ROI spans), while this generic routine will scan every key-value pair for a data instance and query the ROI to see if this key is ok to send.
func ReloadMetadata ¶
func ReloadMetadata() error
ReloadMetadata reloads the repositories manager from an existing metadata store. This shuts off all other dvid requests.
func RenameData ¶
RenameData renames a data service given an old instance name and UUID.
func SaveDataByUUID ¶
func SaveDataByUUID(uuid dvid.UUID, data DataService) error
SaveDataByUUID persists metadata for a data instance with given uuid. TODO -- Make this more efficient by storing data metadata separately from repo.
Currently we save entire repo.
func SaveDataByVersion ¶
func SaveDataByVersion(v dvid.VersionID, data DataService) error
SaveDataByVersion persists metadata for a data instance with given version. TODO -- Make this more efficient by storing data metadata separately from repo.
Currently we save entire repo.
func SetSyncByJSON ¶
SetSyncByJSON takes a JSON object of sync names and UUID, and creates the sync graph and sets the data instance's sync. If replace is false (default), the new sync is appended to the current syncs.
func SetSyncData ¶
SetSyncData modfies the manager sync graphs and data instance's sync list. If replace is false (default), the new sync is appended to the current syncs.
func SetTagsByJSON ¶
SetTagsByJSON takes a JSON object of tags and either appends or replaces the current data's tags depending on the replace parameter.
func Shutdown ¶
func Shutdown()
Shutdown sends signal for all goroutines for data processing to be terminated.
func TransferData ¶
TransferData copies key-value pairs from one repo to store and apply filtering as specified by the JSON configuration in the file specified by configFName. An example of the transfer JSON configuration file format:
{ "Versions": [ "8a90ec0d257c415cae29f8c46603bcae", "a5682904bb824c06aba470c0a0cbffab", ... }, "Metadata": true, }
All ancestors of desired leaf nodes should be specified because key-value pair transfer only occurs if the version in which it was saved is specified on the list. This is useful for editing a preexisting store with new versions.
If Metadata property is true, then if metadata exists in the old store, it is transferred to the new store with only the versions specified appearing in the DAG.
Types ¶
type BlobService ¶
type BlobService interface { GetBlob(ref string) (data []byte, err error) PutBlob(data []byte) (ref string, err error) }
BlobService is an interface for storing and retrieving data based on its content.
type CommitSyncer ¶
type CommitSyncer interface { // SyncOnCommit is an asynchronous function that should be called when a node is committed. SyncOnCommit(dvid.UUID, dvid.VersionID) }
CommitSyncer want to be notified when a node is committed.
type Config ¶
type Config struct { InstanceGen string InstanceStart dvid.InstanceID MutationStart uint64 ReadOnly bool }
Config specifies new instance and mutation ID generation
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
Data is the base struct of repo-specific data instances. It should be embedded in a datatype's DataService implementation and handle datastore-wide key partitioning.
func NewDataService ¶
func NewDataService(t TypeService, rootUUID dvid.UUID, id dvid.InstanceID, name dvid.InstanceName, c dvid.Config) (*Data, error)
NewDataService returns a new Data instance that fulfills the DataService interface. The UUID passed in corresponds to the root UUID of the DAG subgraph that should hold the data. This returned Data struct is usually embedded by datatype-specific data instances. By default, LZ4 and the default checksum is used.
func (*Data) Compression ¶
func (d *Data) Compression() dvid.Compression
func (*Data) DataName ¶
func (d *Data) DataName() dvid.InstanceName
func (*Data) DescribeTKeyClass ¶
DescribeTKeyClass returns a string explanation of what a particular TKeyClass is used for. This will be overriden in data types, but if not, this provides a fallback for all data types.
func (*Data) Equals ¶
Equals returns true if the two data instances are identical, not just referring to the same data instance (e.g., different names but same data UUID, etc).
func (*Data) GetReadLog ¶
func (*Data) GetType ¶
func (d *Data) GetType() TypeService
func (*Data) GetWriteLog ¶
func (*Data) InstanceID ¶
func (d *Data) InstanceID() dvid.InstanceID
func (*Data) IsMutationRequest ¶
IsMutationRequest is the default definition of mutation requests. All POST, PUT, and DELETE actions return true, while others return false.
func (*Data) MarshalJSON ¶
func (*Data) MarshalJSONTags ¶
func (*Data) MutAdd ¶
MutAdd adds a wait to this operation. Returns true if this is a new operation for this Data
func (*Data) MutDelete ¶
MutDelete removes a wait for this operation. Should only be done after all MutWait() have completed.
func (*Data) NewMutationID ¶
func (*Data) PersistMetadata ¶
func (*Data) ProduceKafkaMsg ¶
func (*Data) PushData ¶
func (d *Data) PushData(p *PushSession) error
PushData is the base implementation of pushing data instance key-value pairs to a remote DVID without any datatype-specific filtering of data.
func (*Data) SetDataUUID ¶
func (*Data) SetDeleted ¶
SetDeleted is used to indicate whether data has been deleted or is deleting.
func (*Data) SetInstanceID ¶
func (d *Data) SetInstanceID(id dvid.InstanceID)
func (*Data) SetKVStore ¶
func (*Data) SetLogStore ¶
func (*Data) SetName ¶
func (d *Data) SetName(name dvid.InstanceName)
func (*Data) SetRootUUID ¶
func (*Data) SetSync ¶
SetSync sets the list of synced UUIDs for this data instance. It does not modify the sync graph.
func (*Data) SyncPending ¶
SyncPending returns true if there are outstanding sync events in this instance's subscription.
func (*Data) SyncedData ¶
SyncedData returns a set of data UUIDs to which it is synced.
func (*Data) SyncedNames ¶
func (d *Data) SyncedNames() []dvid.InstanceName
SyncedNames returns a set of data instance names to which it is synced. Legacy and will be removed after metadata refactor.
func (*Data) TypeName ¶
func (d *Data) TypeName() dvid.TypeString
func (*Data) TypeVersion ¶
type DataAvail ¶
type DataAvail uint8
DataAvail gives the availability of data within a node or whether parent nodes must be traversed to check for key-value pairs.
const ( // DataDelta = For any query, we must also traverse this node's ancestors in the DAG // up to any DataComplete ancestor. Used if a node is marked as archived. DataDelta DataAvail = iota // DataComplete = All key-value pairs are available within this node. DataComplete // DataRoot = Queries are redirected to Root since this is unversioned. DataRoot // DataDeleted = key-value pairs have been explicitly deleted at this node and is no longer available. DataDeleted )
type DataInitializer ¶
type DataInitializer interface {
InitDataHandlers() error
}
DataInitializer is a data instance that needs to be initialized, e.g., start long-lived goroutines that handle data syncs, etc. Initialization should only constitute supporting data and goroutines and not change the data itself like InstanceMutator, so no saveNeeded flag needs to be returned.
type DataService ¶
type DataService interface { dvid.Data json.Marshaler BlobService Help() string GetType() TypeService // ModifyConfig modifies a configuration in a type-specific way. ModifyConfig(dvid.Config) error // IsMutationRequest returns true if the given HTTP method on the endpoint results in mutations. // This allows datatypes to define actions on an endpoint as immutable even if they use POST. // The endpoint is the keyword immediately following a data instance name in the URL: // /api/node/483f/grayscale/raw/xy/... // In the above URL, "raw" is the endpoint. IsMutationRequest(action, endpoint string) bool // DoRPC handles command line and RPC commands specific to a data type DoRPC(Request, *Response) error // ServeHTTP handles HTTP requests in the context of a particular version and // returns activity information that can be logged for monitoring. ServeHTTP(dvid.UUID, *VersionedCtx, http.ResponseWriter, *http.Request) (activity map[string]interface{}) // DescribeTKeyClass explains in a string what a particular TKeyClass // is used for. For example, one class of TKey for the label data types is the block-indexed // voxel values. DescribeTKeyClass(storage.TKeyClass) string // PushData handles DVID-to-DVID transmission of key-value pairs, optionally // delimited by type-specific filter specifications (e.g., "roi:roiname,uuid") // and a set of versions. DataService implementations can automatically embed // this via datastore.Data or can add filters by providing their own PushData(), // Filterer, and Filter implementations. (datatype/imageblk/distributed.go) PushData(*PushSession) error }
DataService is an interface for operations on an instance of a supported datatype.
func GetDataByDataUUID ¶
func GetDataByDataUUID(dataUUID dvid.UUID) (DataService, error)
GetDataByDataUUID returns a data service given a data UUID.
func GetDataByUUIDName ¶
func GetDataByUUIDName(uuid dvid.UUID, name dvid.InstanceName) (DataService, error)
GetDataByUUIDName returns a data service given an instance name and UUID.
func GetDataByVersionName ¶
func GetDataByVersionName(v dvid.VersionID, name dvid.InstanceName) (DataService, error)
GetDataByVersionName returns a data service given an instance name and version.
func NewData ¶
func NewData(uuid dvid.UUID, t TypeService, name dvid.InstanceName, c dvid.Config) (DataService, error)
NewData adds a new, named instance of a datatype to repo. Settings can be passed via the 'config' argument. For example, config["versioned"] with a bool value will specify whether the data is versioned.
type DataStorageMap ¶
DataStorageMap describes mappings from various instance and data type specifications to KV and Log stores.
type DataTxInit ¶
type DataTxInit struct { Session rpc.SessionID DataName dvid.InstanceName TypeName dvid.TypeString InstanceID dvid.InstanceID Tags map[string]string }
type Initializer ¶
type Initializer interface {
Initialize()
}
Initializer is a data instance that can be initialized. Typically this sets up any goroutines necessary after server configuration, etc.
type InstanceMutator ¶
type InstanceMutator interface { // Loads all mutable properties and applies any necessary migration to // transform the internal data from the stored to expected version. LoadMutable(root dvid.VersionID, storedVersion, expectedVersion uint64) (saveNeeded bool, err error) }
InstanceMutator provides a hook for data instances to load mutable data on startup. It is assumed that the data instances store data whenever its data mutates, e.g., extents for labelblk or max label for labelvol.
type InstanceStats ¶
type KVMessage ¶
type KVMessage struct { Session rpc.SessionID KV storage.KeyValue Terminate bool // true if this message is the last txn for this data instance and KV is invalid. }
KVMessage packages a key-value pair for transmission to a remote DVID as well as control of the receiving FSM.
type MergeType ¶
type MergeType uint8
MergeType describes the expectation of processing for the merge, e.g., is it expected to be free of conflicts at the key-value level, require automated type-specific key-value merging, or require external guidance.
const ( // MergeConflictFree assumes that changes in nodes-to-be-merged are disjoint // at the key-value level. MergeConflictFree MergeType = iota // MergeTypeSpecificAuto requires datatype-specific code for merging at each // key-value pair. MergeTypeSpecificAuto // MergeExternalData requires external data to reconcile merging of nodes. MergeExternalData )
type MutationDumper ¶
type MutationDumper interface {
DumpMutations(startUUID, endUUID dvid.UUID, filename string) (comment string, err error)
}
MutationDumper is a dataservice that suppports the flatten-mutations command via a DumpMutations() function.
type MutationMutexer ¶
type MutationMutexer interface { MutAdd(mutID uint64) (newOp bool) MutDone(mutID uint64) MutWait(mutID uint64) MutDelete(mutID uint64) }
MutationMutexer is an interface for mutexes on particular mutation IDs.
type PropertyCopier ¶
type PropertyCopier interface {
CopyPropertiesFrom(DataService, storage.FilterSpec) error
}
PropertyCopier are types that can copy data instance properties from another (typically identically typed) data instance with an optional filter. This is used to create copies of data instances locally or when pushing to a remote DVID.
type PushSession ¶
type PushSession struct { Filter storage.FilterSpec Versions map[dvid.VersionID]struct{} // contains filtered or unexported fields }
PushSession encapsulates parameters necessary for DVID-to-DVID push/pull processing.
func (*PushSession) EndInstancePush ¶
func (p *PushSession) EndInstancePush() error
EndInstancePush terminates a data instance push.
func (*PushSession) SendKV ¶
func (p *PushSession) SendKV(kv *storage.KeyValue) error
SendKV sends a key-value pair. The key-values may be buffered before sending for efficiency of transmission.
func (*PushSession) StartInstancePush ¶
func (p *PushSession) StartInstancePush(d dvid.Data) error
StartInstancePush initiates a data instance push. After some number of Send calls, the EndInstancePush must be called.
type Shutdowner ¶
type Shutdowner interface {
Shutdown(wg *sync.WaitGroup) // Expects wg.Done() to be called in Shutdown function.
}
Shutdowner is a data instance that has a function to call during shutdown. Typically, this exits goroutines used for background data processing.
type StorageStats ¶
type StorageStats map[string]InstanceStats
func (StorageStats) String ¶
func (stats StorageStats) String() string
type SyncMessage ¶
SyncMessage describes changes to a data instance for a given version.
type SyncSub ¶
type SyncSub struct { Event SyncEvent Notify dvid.UUID // the data UUID of data instance to notify Ch chan SyncMessage }
SyncSub is a subscription request from an instance to be notified via a channel when a given data instance has a given event.
type Syncer ¶
type Syncer interface { // GetSyncSubs returns the subscriptions that need to be created to keep this data // synced and may launch goroutines that will consume inbound channels of changes // from associated data. GetSyncSubs(dvid.Data) (SyncSubs, error) // SyncedNames returns the set of data instance UUIDs to which the data is synced. SyncedNames() []dvid.InstanceName // SyncedNames returns the set of data instance UUIDs to which the data is synced. SyncedData() dvid.UUIDSet // SyncPending returns true if there are outstanding sync events in this instance's subscription. SyncPending() bool }
Syncer types are typically DataService that know how to sync with other data.
type Type ¶
type Type struct { // Data type name and may not be unique. Name dvid.TypeString // The unique package name that fulfills the DVID Data interface URL dvid.URLString // The version identifier of this datatype code Version string // A list of interface requirements for the backend datastore Requirements *storage.Requirements }
Type identifies the datatype underlying a DataService.
func (*Type) GetStorageRequirements ¶
func (t *Type) GetStorageRequirements() *storage.Requirements
func (*Type) GetTypeName ¶
func (t *Type) GetTypeName() dvid.TypeString
func (*Type) GetTypeURL ¶
func (*Type) GetTypeVersion ¶
type TypeMigrator ¶
type TypeMigrator interface {
MigrateData([]dvid.VersionID) (DataService, error)
}
TypeMigrator is an interface for a DataService that can migrate itself to another DataService. A deprecated DataService implementation can implement this interface to auto-convert on metadata load.
type TypeService ¶
type TypeService interface { GetTypeName() dvid.TypeString GetTypeURL() dvid.URLString GetTypeVersion() string GetStorageRequirements() *storage.Requirements // Create an instance of this datatype in the given repo (identified by its root UUID) // with local instance ID and name, passing configuration parameters via dvid.Config. NewDataService(dvid.UUID, dvid.InstanceID, dvid.InstanceName, dvid.Config) (DataService, error) // Help returns a string explaining how to use a datatype's service Help() string // Do executes type-specific commands from command line. Do(Request, *Response) error }
TypeService is an interface all datatype implementations must fulfill. New types can be made by embedding Type and will automatically fulfill the Get* functions.
func TypeServiceByName ¶
func TypeServiceByName(name dvid.TypeString) (TypeService, error)
TypeServiceByName returns a TypeService given a type name. Note that the type name is possibly ambiguous, particularly if using type names across different DVID servers.
func TypeServiceByURL ¶
func TypeServiceByURL(url dvid.URLString) (TypeService, error)
TypeServiceByURL returns a TypeService given its URL. This is the preferred method for accessing datatype implementations since they should work across different DVID servers.
type TypeUpgrader ¶
type TypeUpgrader interface { DataService UpgradeData() (upgraded bool, err error) }
TypeUpgrader is an interface for a DataService that can upgrade itself to another version of data storage. A deprecated DataService implementation can implement this interface to auto-convert on metadata load.
type Updater ¶
func (*Updater) StartUpdate ¶
func (u *Updater) StartUpdate()
func (*Updater) StopUpdate ¶
func (u *Updater) StopUpdate()
type VersionInitializer ¶
VersionInitializer provides a hook for data instances to receive branch (new version) events and modify their properties as needed.
type VersionRemapper ¶
type VersionRemapper interface {
RemapVersions(dvid.VersionMap) error
}
VersionRemapper provides a hook for data instances to remap properties that depend on server-specific version ids. During DVID-to-DVID transfer of data, these version ids need to be remapped as part of the push/pull.
type VersionedCtx ¶
type VersionedCtx struct { *storage.DataContext User string }
VersionedCtx implements storage.VersionedCtx for data instances that have a version DAG.
func NewVersionedCtx ¶
func NewVersionedCtx(data dvid.Data, versionID dvid.VersionID) *VersionedCtx
NewVersionedCtx creates a new versioned context that also has ability to hold a user string.
func NewVersionedCtxMasterLeaf ¶
func NewVersionedCtxMasterLeaf(data dvid.Data) (*VersionedCtx, error)
NewVersionedCtxMasterLeaf creates a new versioned context for the master branch leaf.
func (*VersionedCtx) GetBestKeyVersion ¶
GetBestKeyVersion returns the key that most closely matches this context's version. If no suitable key or a tombstone is encountered closed to the version, nil is returned.
func (*VersionedCtx) GetGraphDB ¶
func (vctx *VersionedCtx) GetGraphDB() (storage.GraphDB, error)
GetGraphDB returns a graph store associated with this context or an error if one is not available.
func (*VersionedCtx) GetKeyValueDB ¶
func (vctx *VersionedCtx) GetKeyValueDB() (storage.KeyValueDB, error)
GetKeyValueDB returns a key-value store associated with this context on an error if one is unavailable.
func (*VersionedCtx) GetOrderedKeyValueDB ¶
func (vctx *VersionedCtx) GetOrderedKeyValueDB() (storage.OrderedKeyValueDB, error)
GetOrderedKeyValueDB returns an ordered key-value store associated with this context or an error if one is unavailable.
func (*VersionedCtx) Head ¶
func (vctx *VersionedCtx) Head() bool
Head checks whether this the open head of the master branch
func (*VersionedCtx) MasterVersion ¶
func (vctx *VersionedCtx) MasterVersion(version dvid.VersionID) bool
Head checks whether specified version is on the master branch
func (*VersionedCtx) NumVersions ¶
func (vctx *VersionedCtx) NumVersions() int32
NumVersions returns the number of versions for a given
func (*VersionedCtx) RepoRoot ¶
func (vctx *VersionedCtx) RepoRoot() (dvid.UUID, error)
RepoRoot returns the root uuid.
func (*VersionedCtx) String ¶
func (vctx *VersionedCtx) String() string
func (*VersionedCtx) VersionUUID ¶
func (vctx *VersionedCtx) VersionUUID() dvid.UUID
VersionUUID returns the UUID associated with this versioned context.
func (*VersionedCtx) Versioned ¶
func (vctx *VersionedCtx) Versioned() bool
func (*VersionedCtx) VersionedKeyValue ¶
VersionedKeyValue returns the key-value pair corresponding to this key's version given a list of key-value pairs across many versions. If no suitable key-value pair is found or a tombstone is encounterd closest to version, nil is returned.