storagenode

package
v0.0.0-...-49e5460 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSchema

func GetSchema() string

func TestMetaStore_Database

func TestMetaStore_Database(t *testing.T)

func TestMetaStore_ShardInstance

func TestMetaStore_ShardInstance(t *testing.T)

Types

type Config

type Config struct {
	HTTP HTTPApiConfig `yaml:"http_api"`

	Datasources map[string]*DatasourceInstanceConfig `yaml:"datasource_instances"`
}

Common configuration for all storage nodes

func ConfigFromFile

func ConfigFromFile(filepath string) (*Config, error)

ConfigFromFile returns a *Config after parsing a file path

type DatasourceInstance

type DatasourceInstance struct {
	Config           *DatasourceInstanceConfig
	MetaStore        StorageMetadataStore
	MutableMetaStore MutableStorageMetadataStore

	StoreSchema datasource.SchemaInterface
	Store       datasource.DataInterface
	// contains filtered or unexported fields
}

func NewDatasourceInstance

func NewDatasourceInstance(config *DatasourceInstanceConfig, metaStore StorageMetadataStore) (*DatasourceInstance, error)

func NewDatasourceInstanceDefault

func NewDatasourceInstanceDefault(config *DatasourceInstanceConfig) (*DatasourceInstance, error)

Create a DatasourceInstance with a default MetadataStore (based on the same config as the storagenode)

func NewLocalDatasourceInstance

func NewLocalDatasourceInstance(config *DatasourceInstanceConfig, meta *metadata.Meta) (*DatasourceInstance, error)

TODO: remove-- and just have as config options

func (*DatasourceInstance) EnsureDoesntExistCollection

func (s *DatasourceInstance) EnsureDoesntExistCollection(ctx context.Context, dbname, shardinstance, collectionname string) error

func (*DatasourceInstance) EnsureDoesntExistCollectionField

func (s *DatasourceInstance) EnsureDoesntExistCollectionField(ctx context.Context, dbname, shardinstance, collectionname, fieldname string) error

func (*DatasourceInstance) EnsureDoesntExistCollectionIndex

func (s *DatasourceInstance) EnsureDoesntExistCollectionIndex(ctx context.Context, dbname, shardinstance, collectionname, indexname string) error

func (*DatasourceInstance) EnsureDoesntExistDatabase

func (s *DatasourceInstance) EnsureDoesntExistDatabase(ctx context.Context, dbname string) error

func (*DatasourceInstance) EnsureDoesntExistShardInstance

func (s *DatasourceInstance) EnsureDoesntExistShardInstance(ctx context.Context, dbname string, shardinstance string) error

func (*DatasourceInstance) EnsureExistsCollection

func (s *DatasourceInstance) EnsureExistsCollection(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance, collection *metadata.Collection) error

func (*DatasourceInstance) EnsureExistsCollectionField

func (s *DatasourceInstance) EnsureExistsCollectionField(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance, collection *metadata.Collection, field *metadata.CollectionField) error

func (*DatasourceInstance) EnsureExistsCollectionIndex

func (s *DatasourceInstance) EnsureExistsCollectionIndex(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance, collection *metadata.Collection, index *metadata.CollectionIndex) error

func (*DatasourceInstance) EnsureExistsDatabase

func (s *DatasourceInstance) EnsureExistsDatabase(ctx context.Context, db *metadata.Database) error

func (*DatasourceInstance) EnsureExistsShardInstance

func (s *DatasourceInstance) EnsureExistsShardInstance(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance) error

func (*DatasourceInstance) GetActiveMeta

func (s *DatasourceInstance) GetActiveMeta() *metadata.Meta

func (*DatasourceInstance) GetMeta

func (s *DatasourceInstance) GetMeta() *metadata.Meta

func (*DatasourceInstance) HandleQuery

func (s *DatasourceInstance) HandleQuery(ctx context.Context, q *query.Query) *query.Result

func (*DatasourceInstance) HandleStreamQuery

func (s *DatasourceInstance) HandleStreamQuery(ctx context.Context, q *query.Query) *query.ResultStream

TODO: push sort down to the datasource instance (needed to get the stream corect) Handle all stream queries

func (*DatasourceInstance) RefreshMeta

func (s *DatasourceInstance) RefreshMeta() error

func (*DatasourceInstance) Sync

func (s *DatasourceInstance) Sync() error

TODO: remove? since we need to do this while holding the lock it seems useless

type DatasourceInstanceConfig

type DatasourceInstanceConfig struct {
	// TODO: Rename to driver? Need a consistent name for this
	StorageNodeType datasource.StorageType `yaml:"storage_type"`
	StorageConfig   map[string]interface{} `yaml:"storage_config"`

	SkipProvisionTrim bool `yaml:"skip_provision_trim"`

	Registry metrics.Registry
}

func DatasourceInstanceConfigFromFile

func DatasourceInstanceConfigFromFile(filepath string) (*DatasourceInstanceConfig, error)

func (*DatasourceInstanceConfig) GetStore

type DatasourceInstanceMetrics

type DatasourceInstanceMetrics struct {
	MetaLastSync     *metrics.ObserveArray
	MetaLastDuration *metrics.ObserveArray

	QueryTime *metrics.ObserveArray
}

func NewDatasourceInstanceMetrics

func NewDatasourceInstanceMetrics(r metrics.Registry) DatasourceInstanceMetrics

type DatasourceInstanceTransport

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

func NewDatasourceInstanceTransport

func NewDatasourceInstanceTransport(dsi *DatasourceInstance) *DatasourceInstanceTransport

func NewStaticDatasourceInstanceTransport

func NewStaticDatasourceInstanceTransport(config *DatasourceInstanceConfig, meta *metadata.Meta) (*DatasourceInstanceTransport, error)

func (*DatasourceInstanceTransport) DoQuery

func (*DatasourceInstanceTransport) DoStreamQuery

type DefaultMetadataStore

type DefaultMetadataStore struct {
	Store datasource.DataInterface
}

func NewMetadataStore

func NewMetadataStore(config *DatasourceInstanceConfig) (*DefaultMetadataStore, error)

func (*DefaultMetadataStore) EnsureDoesntExistCollection

func (m *DefaultMetadataStore) EnsureDoesntExistCollection(ctx context.Context, dbname, shardinstance, collectionname string) error

func (*DefaultMetadataStore) EnsureDoesntExistCollectionField

func (m *DefaultMetadataStore) EnsureDoesntExistCollectionField(ctx context.Context, dbname, shardinstance, collectionname, fieldname string) error

func (*DefaultMetadataStore) EnsureDoesntExistCollectionIndex

func (m *DefaultMetadataStore) EnsureDoesntExistCollectionIndex(ctx context.Context, dbname, shardinstance, collectionname, indexname string) error

func (*DefaultMetadataStore) EnsureDoesntExistDatabase

func (m *DefaultMetadataStore) EnsureDoesntExistDatabase(ctx context.Context, dbname string) error

TODO:

func (*DefaultMetadataStore) EnsureDoesntExistShardInstance

func (m *DefaultMetadataStore) EnsureDoesntExistShardInstance(ctx context.Context, dbname, shardname string) error

func (*DefaultMetadataStore) EnsureExistsCollection

func (m *DefaultMetadataStore) EnsureExistsCollection(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance, collection *metadata.Collection) error

Collection Changes

func (*DefaultMetadataStore) EnsureExistsCollectionField

func (m *DefaultMetadataStore) EnsureExistsCollectionField(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance, collection *metadata.Collection, field, parentField *metadata.CollectionField) error

func (*DefaultMetadataStore) EnsureExistsCollectionIndex

func (m *DefaultMetadataStore) EnsureExistsCollectionIndex(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance, collection *metadata.Collection, index *metadata.CollectionIndex) error

Index changes

func (*DefaultMetadataStore) EnsureExistsDatabase

func (m *DefaultMetadataStore) EnsureExistsDatabase(ctx context.Context, db *metadata.Database) error

func (*DefaultMetadataStore) EnsureExistsShardInstance

func (m *DefaultMetadataStore) EnsureExistsShardInstance(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance) error

func (*DefaultMetadataStore) GetMeta

func (m *DefaultMetadataStore) GetMeta(ctx context.Context) (*metadata.Meta, error)

TODO: split into get/list for each item? TODO: have error?

type HTTPApi

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

func NewHTTPApi

func NewHTTPApi(storageNode *StorageNode) *HTTPApi

func (*HTTPApi) Start

func (h *HTTPApi) Start(router *httprouter.Router)

REST API methods:

	 GET - READ/list
	 PUT - UPDATE
  POST - CREATE
  DELETE - DELETE

Register any endpoints to the router

type HTTPApiConfig

type HTTPApiConfig struct {
	Addr string `yaml:"addr"`
}

HTTP API configuration

type MutableStorageMetadataStore

type MutableStorageMetadataStore interface {
	// This is an extension of the base interface, so we need to include it
	StorageMetadataStore

	EnsureExistsDatabase(ctx context.Context, db *metadata.Database) error
	EnsureDoesntExistDatabase(ctx context.Context, dbname string) error
	EnsureExistsShardInstance(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance) error
	EnsureDoesntExistShardInstance(ctx context.Context, dbname, shardname string) error
	EnsureExistsCollection(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance, collection *metadata.Collection) error
	EnsureDoesntExistCollection(ctx context.Context, dbname, shardinstance, collectionname string) error
	EnsureExistsCollectionIndex(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance, collection *metadata.Collection, index *metadata.CollectionIndex) error
	EnsureDoesntExistCollectionIndex(ctx context.Context, dbname, shardinstance, collectionname, indexname string) error
	EnsureExistsCollectionField(ctx context.Context, db *metadata.Database, shardInstance *metadata.ShardInstance, collection *metadata.Collection, field, parentField *metadata.CollectionField) error
	EnsureDoesntExistCollectionField(ctx context.Context, dbname, shardinstance, collectionname, fieldname string) error
}

type StaticMetadataStore

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

func NewStaticMetadataStore

func NewStaticMetadataStore(meta *metadata.Meta) *StaticMetadataStore

func (*StaticMetadataStore) GetMeta

func (s *StaticMetadataStore) GetMeta(ctx context.Context) (*metadata.Meta, error)

func (*StaticMetadataStore) SetMeta

func (s *StaticMetadataStore) SetMeta(m *metadata.Meta)

Our methods

type StorageMetadataStore

type StorageMetadataStore interface {
	GetMeta(context.Context) (*metadata.Meta, error)
}

type StorageNode

type StorageNode struct {
	Config *Config

	Datasources map[string]*DatasourceInstance
	// contains filtered or unexported fields
}

This node is responsible for handling all of the queries for a specific storage node This is also responsible for maintaining schema, indexes, etc. from the metadata store and applying them to the actual storage subsystem

func NewStorageNode

func NewStorageNode(config *Config) (*StorageNode, error)

func (*StorageNode) Start

func (s *StorageNode) Start() error

TODO: have a stop?

type StorageNodeMetrics

type StorageNodeMetrics struct {
}

func NewStorageNodeMetrics

func NewStorageNodeMetrics(r metrics.Registry) StorageNodeMetrics

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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