database

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxMongoDBVersion = semver.Version{
	Major: 3,
	Minor: 7,
	Patch: 0,
}

MaxMongoDBVersion is the upper, exclusive bound on the versions of MongoDB compatible with RITA

View Source
var MinMongoDBVersion = semver.Version{
	Major: 3,
	Minor: 2,
	Patch: 0,
}

MinMongoDBVersion is the lower, inclusive bound on the versions of MongoDB compatible with RITA

Functions

This section is empty.

Types

type DB

type DB struct {
	Session *mgo.Session
	// contains filtered or unexported fields
}

DB is the workhorse container for messing with the database

func NewDB

func NewDB(conf *config.Config, log *log.Logger) (*DB, error)

NewDB constructs a new DB struct

func (*DB) AggregateCollection added in v1.0.0

func (d *DB) AggregateCollection(sourceCollection string,
	session *mgo.Session, pipeline []bson.D) *mgo.Iter

AggregateCollection builds a collection via a MongoDB pipeline

func (*DB) CollectionExists added in v1.0.0

func (d *DB) CollectionExists(table string) bool

CollectionExists returns true if collection exists in the currently selected database

func (*DB) CreateCollection added in v1.0.0

func (d *DB) CreateCollection(name string, indexes []mgo.Index) error

CreateCollection creates a new collection in the currently selected database with the required indexes

func (*DB) GetSelectedDB added in v1.0.0

func (d *DB) GetSelectedDB() string

GetSelectedDB retrieves the currently selected database for analysis

func (*DB) SelectDB added in v1.0.0

func (d *DB) SelectDB(db string)

SelectDB selects a database for analysis

type DBMetaInfo

type DBMetaInfo struct {
	ID             bson.ObjectId `bson:"_id,omitempty"`   // Ident
	Name           string        `bson:"name"`            // Top level name of the database
	Analyzed       bool          `bson:"analyzed"`        // Has this database been analyzed
	AnalyzeVersion string        `bson:"analyze_version"` // Rita version at analyze
	Rolling        bool          `bson:"rolling"`
	TotalChunks    int           `bson:"total_chunks"`
	CurrentChunk   int           `bson:"current_chunk"`
	TsRange        Range         `bson:"ts_range"`
}

DBMetaInfo defines some information about the database

type LogInfo added in v1.1.1

type LogInfo struct {
	ID      bson.ObjectId `bson:"_id,omitempty"`   // Ident
	Time    time.Time     `bson:"LastUpdateCheck"` // Top level name of the database
	Message string        `bson:"Message"`         // Top level name of the database
	Version string        `bson:"NewestVersion"`   // Top level name of the database
}

LogInfo defines information about the UpdateChecker log

type MetaDB added in v1.0.2

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

MetaDB exports control for the meta database

func NewMetaDB added in v1.0.2

func NewMetaDB(config *config.Config, dbHandle *mgo.Session,
	log *log.Logger) *MetaDB

NewMetaDB instantiates a new handle for the RITA MetaDatabase

func (*MetaDB) AddNewDB added in v1.0.2

func (m *MetaDB) AddNewDB(name string, currentChunk, totalChunks int) error

AddNewDB adds a new database to the DBMetaInfo table. All new databases are ready to be rolling databases.

func (*MetaDB) AddParsedFiles added in v1.0.2

func (m *MetaDB) AddParsedFiles(files []*fpt.IndexedFile) error

AddParsedFiles adds indexed files to the files the metaDB using the bulk API

func (*MetaDB) AddTSRange

func (m *MetaDB) AddTSRange(name string, min int64, max int64) error

AddTSRange adds the min and max timestamps found in current dataset

func (*MetaDB) CheckCompatibleAnalyze added in v1.0.2

func (m *MetaDB) CheckCompatibleAnalyze(targetDatabase string) (bool, error)

CheckCompatibleAnalyze checks if a database was analyzed with a version of RITA which is compatible with the running version

func (*MetaDB) DBExists

func (m *MetaDB) DBExists(name string) (bool, error)

DBExists returns whether or not a metadatabase record has been created for a database

func (*MetaDB) DeleteDB added in v1.0.2

func (m *MetaDB) DeleteDB(name string) error

DeleteDB removes a database managed by RITA

func (*MetaDB) GetAnalyzedDatabases added in v1.0.2

func (m *MetaDB) GetAnalyzedDatabases() []string

GetAnalyzedDatabases builds a list of database names which have been analyzed

func (*MetaDB) GetDBMetaInfo added in v1.0.2

func (m *MetaDB) GetDBMetaInfo(name string) (DBMetaInfo, error)

GetDBMetaInfo returns a meta db entry. This is the only function which returns DBMetaInfo to code outside of meta.go.

func (*MetaDB) GetDatabases added in v1.0.2

func (m *MetaDB) GetDatabases() []string

GetDatabases returns a list of databases being tracked in metadb or an empty array on failure

func (*MetaDB) GetFiles added in v1.0.2

func (m *MetaDB) GetFiles(database string) ([]fpt.IndexedFile, error)

GetFiles gets a list of all IndexedFile objects associated with the given database. If successful return a list of files from the database. On failure return an empty list of files and generate a log message.

func (*MetaDB) GetRollingSettings

func (m *MetaDB) GetRollingSettings(db string) (exists bool, isRolling bool, currChunk int, totalChunks int, err error)

GetRollingSettings gets the current rolling settings

func (*MetaDB) GetTSRange

func (m *MetaDB) GetTSRange(name string) (int64, int64, error)

GetTSRange adds the min and max timestamps for current dataset

func (*MetaDB) GetUnAnalyzedDatabases added in v1.0.2

func (m *MetaDB) GetUnAnalyzedDatabases() []string

GetUnAnalyzedDatabases builds a list of database names which have yet to be analyzed

func (*MetaDB) IsChunkSet

func (m *MetaDB) IsChunkSet(cid int, db string) (bool, error)

IsChunkSet ....

func (*MetaDB) LastCheck added in v1.1.1

func (m *MetaDB) LastCheck() (time.Time, semver.Version)

LastCheck returns most recent version check

func (*MetaDB) MarkDBAnalyzed added in v1.0.2

func (m *MetaDB) MarkDBAnalyzed(name string, complete bool) error

MarkDBAnalyzed marks a database as having been analyzed

func (*MetaDB) RemoveFilesByChunk

func (m *MetaDB) RemoveFilesByChunk(database string, cid int) error

RemoveFilesByChunk removes FilesTable entries for a given database chunk. This helps provide the ability to re-import a given chunk.

func (*MetaDB) SetChunk

func (m *MetaDB) SetChunk(cid int, db string, analyzed bool) error

SetChunk ....

func (*MetaDB) SetRollingSettings

func (m *MetaDB) SetRollingSettings(db string, chunk int, numchunks int) error

SetRollingSettings ensures that a given db is marked as rolling, ensures that total_chunks matches numchunks, and sets the current_chunk to chunk.

type Range

type Range struct {
	Min int64 `bson:"min"`
	Max int64 `bson:"max"`
}

Range defines a min and max value

Jump to

Keyboard shortcuts

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