Documentation
¶
Index ¶
- Constants
- Variables
- func AdjustTimestampsForHystersisAndMinimumWindow(startTime time.Time, endTime time.Time, rightNow time.Time, ...) (actualStartTime time.Time, actualEndTime time.Time, err error)
- func ConfigureDataImplementation(conType ConnectionType) (err error)
- func IsDBErrorPg(err error) bool
- func NewPostgresDatabase(database *DatabaseInfo) (err error)
- func ValidateTimeBoundNodeRequest(tbnr TimeBoundNodeRequest) (valid bool, err error)
- type CabinetPower
- type ConnectionType
- type DatabaseInfo
- type DummyDB
- func (d DummyDB) GetNodeEnergy(req TimeBoundNodeRequest) (nodeEnergy *NodeEnergy, err error)
- func (d DummyDB) GetNodeEnergyCounter(req TimeBoundNodeRequest) (counter *NodeEnergyCounters, err error)
- func (d DummyDB) GetNodeEnergyStats(req TimeBoundNodeRequest) (stat *NodeEnergyStats, err error)
- func (d DummyDB) GetSystemPower(tbr TimeBoundRequest) (sysPow *SystemPower, err error)
- func (d DummyDB) GetSystemPowerDetails(tbr TimeBoundRequest) (cabPower *SystemPowerByCabinet, err error)
- func (d DummyDB) ImplementationName() string
- type NodeEnergy
- type NodeEnergyCounter
- type NodeEnergyCounters
- type NodeEnergyLevel
- type NodeEnergyStats
- type NodeLookup
- type PostgresqlDB
- func (d PostgresqlDB) GetNodeEnergy(req TimeBoundNodeRequest) (nodeEnergy *NodeEnergy, err error)
- func (d PostgresqlDB) GetNodeEnergyCounter(req TimeBoundNodeRequest) (counter *NodeEnergyCounters, err error)
- func (d PostgresqlDB) GetNodeEnergyStats(req TimeBoundNodeRequest) (stat *NodeEnergyStats, err error)
- func (d PostgresqlDB) GetSystemPower(tbr TimeBoundRequest) (sysPow *SystemPower, err error)
- func (d PostgresqlDB) GetSystemPowerDetails(tbr TimeBoundRequest) (cabPower *SystemPowerByCabinet, err error)
- func (d PostgresqlDB) ImplementationName() string
- type SystemPower
- type SystemPowerByCabinet
- type TSDB
- type TimeBoundNodeRequest
- type TimeBoundRequest
- type TimeBoundRequestError
Constants ¶
const ( BadEndTime = "BAD_END_TIME" BadOptions = "BAD_OPTIONS" BadStartTime = "BAD_START_TIME" BadWindowLen = "BAD_WINDOW_LEN" InvalidArguments = "INVALID_ARGUMENTS" NoData = "NO_DATA" NoResults = "NO_RESULTS" PSQLFailure = "PSQL_FAILURE" WindowLenOutOfRange = "WINDOW_LEN_OUT_OF_RANGE" )
const ( // GetSystemPowerDetailsSQL - returns system power by mountain cabinet // NOTE: The mountain and river telemetry is very different from each // other. The mountain is collected per cabinet so is just averaged // over a time bucket, then summed up. The river has multiple // controllers per cabinet. The below query renames the location to // the cabinet name when averaging the power per window, so they all // get summed together during the 'group by' operation. GetSystemPowerDetailsSQL = `` /* 1444-byte string literal not displayed */ )
const ( //GetSystemPowerSQL - sql query to GetSystemPower from Mountain data GetSystemPowerSQL = `` /* 1103-byte string literal not displayed */ )
Variables ¶
var DB *sql.DB
DB - the Database connection
Functions ¶
func AdjustTimestampsForHystersisAndMinimumWindow ¶
func AdjustTimestampsForHystersisAndMinimumWindow(startTime time.Time, endTime time.Time, rightNow time.Time, hysteresis time.Duration, window time.Duration) (actualStartTime time.Time, actualEndTime time.Time, err error)
AdjustTimestampsForHystersisAndMinimumWindow - will adjust the start time and end time to account for the hysteresis and the window If both times are before NOW - Hystersis; then do nothing, assuming minimum period is met If Both times are GREATER than NOW - Hystersis; then slide back in time so that both values are less than Now-Hyst; keep the duration equal, assuming the window is big enough If a time falls in between Hyst and Now; then slide the whole time window back in time, so that the End is < Now-Hyst; keeping the duration equal, assuming the window is big enough.
func ConfigureDataImplementation ¶
func ConfigureDataImplementation(conType ConnectionType) (err error)
ConfigureDataImplementation - The default will be the DUMMY; but the Dockerfile sets the appropriate defaults so that Postrgres is used.
func NewPostgresDatabase ¶
func NewPostgresDatabase(database *DatabaseInfo) (err error)
NewPostgresDatabase - this is a singleton that will create a connection to the database
func ValidateTimeBoundNodeRequest ¶
func ValidateTimeBoundNodeRequest(tbnr TimeBoundNodeRequest) (valid bool, err error)
ValidateTimeBoundNodeRequest - validates that a TimeBoundNodeRequest follows the rules Immediate rules: Both startTime/endTime MUST be set && nodes list is NOT empty LONGTERM rules: Rules - Temporal : either jobID is set or BOTH startTime and endTime are set (and not 0 case) Rules - Geographical : either jobID is set or the Nodes list is not empty ONE RULE from EACH must be true!
Types ¶
type ConnectionType ¶
type ConnectionType int
ConnectionType is used to setup the type of connection
const ( //UNKNOWN - unknown -> used to tell the system need to pick between one of the following UNKNOWN ConnectionType = -1 //DUMMY - dummy implementation DUMMY ConnectionType = 0 //POSTGRES - the default connection POSTGRES ConnectionType = 1 )
var ImplementedConnection ConnectionType
ImplementedConnection is the Type of ConnectionType implemented
type DatabaseInfo ¶
type DatabaseInfo struct { Hostname string Port int Username string Password string Database string }
DatabaseInfo - the struct used to configure the DB connection
type DummyDB ¶
type DummyDB struct{}
DummyDB - the in memory version of the fox data interface
func (DummyDB) GetNodeEnergy ¶
func (d DummyDB) GetNodeEnergy(req TimeBoundNodeRequest) (nodeEnergy *NodeEnergy, err error)
GetNodeEnergy - returns dummy values
func (DummyDB) GetNodeEnergyCounter ¶
func (d DummyDB) GetNodeEnergyCounter(req TimeBoundNodeRequest) (counter *NodeEnergyCounters, err error)
GetNodeEnergyCounter - returns dummy values
func (DummyDB) GetNodeEnergyStats ¶
func (d DummyDB) GetNodeEnergyStats(req TimeBoundNodeRequest) (stat *NodeEnergyStats, err error)
GetNodeEnergyStats - returns dummy values
func (DummyDB) GetSystemPower ¶
func (d DummyDB) GetSystemPower(tbr TimeBoundRequest) (sysPow *SystemPower, err error)
GetSystemPower - returns default dummy values
func (DummyDB) GetSystemPowerDetails ¶
func (d DummyDB) GetSystemPowerDetails(tbr TimeBoundRequest) (cabPower *SystemPowerByCabinet, err error)
GetSystemPowerDetails - returns default dummy values
func (DummyDB) ImplementationName ¶
ImplementationName - returns "DUMMY"
type NodeEnergy ¶
type NodeEnergy struct { NodeCount *int TimeDuration time.Duration NodeLevels []NodeEnergyLevel }
NodeEnergy - TSDB return struct for node energy
type NodeEnergyCounter ¶
type NodeEnergyCounter struct { Node NodeLookup EnergyCtr *int SampleTime time.Time }
NodeEnergyCounter - Used by TSDB to create NodeEnergyCounters return struct
type NodeEnergyCounters ¶
type NodeEnergyCounters struct { NodeCount *int Nodes []NodeEnergyCounter }
NodeEnergyCounters - TSDB return struct for node energy counters
type NodeEnergyLevel ¶
type NodeEnergyLevel struct { Node NodeLookup Energy int }
NodeEnergyLevel - Pair of Node and Energy
type NodeEnergyStats ¶
type NodeEnergyStats struct { EnergyTotal *int EnergyAvg *float64 EnergyStd *float64 EnergyMax *NodeEnergyLevel EnergyMin *NodeEnergyLevel TimeDuration time.Duration NodeCount *int }
NodeEnergyStats - TSDB return struct for node energy stats
type NodeLookup ¶
NodeLookup - pair of Xname and Nid
type PostgresqlDB ¶
type PostgresqlDB struct{}
PostgresqlDB - Production Database interface for SQL version
func (PostgresqlDB) GetNodeEnergy ¶
func (d PostgresqlDB) GetNodeEnergy(req TimeBoundNodeRequest) (nodeEnergy *NodeEnergy, err error)
GetNodeEnergy - returns based on times and location TODO when jobID and apid are added this will need to be changed to have a dynamic selection created when we do finally have those values I recommend always querying based on time and location; and use jobid/apid to generate that range
func (PostgresqlDB) GetNodeEnergyCounter ¶
func (d PostgresqlDB) GetNodeEnergyCounter(req TimeBoundNodeRequest) (counter *NodeEnergyCounters, err error)
GetNodeEnergyCounter - returns node engery counters for input request
func (PostgresqlDB) GetNodeEnergyStats ¶
func (d PostgresqlDB) GetNodeEnergyStats(req TimeBoundNodeRequest) (stat *NodeEnergyStats, err error)
GetNodeEnergyStats - returns node energy stats for the input time period
func (PostgresqlDB) GetSystemPower ¶
func (d PostgresqlDB) GetSystemPower(tbr TimeBoundRequest) (sysPow *SystemPower, err error)
GetSystemPower gets the system power from telemetry database
func (PostgresqlDB) GetSystemPowerDetails ¶
func (d PostgresqlDB) GetSystemPowerDetails(tbr TimeBoundRequest) (cabPower *SystemPowerByCabinet, err error)
GetSystemPowerDetails - return system power data per cabinet
func (PostgresqlDB) ImplementationName ¶
func (d PostgresqlDB) ImplementationName() string
ImplementationName - Returns the database type
type SystemPower ¶
SystemPower - TSDB return struct for GetSystemPower
type SystemPowerByCabinet ¶
type SystemPowerByCabinet struct {
Cabinets []*CabinetPower
}
type TSDB ¶
type TSDB interface { // GetSystemPower retrieves the system power min, max, and average // between the specified start and end time. GetSystemPower(tbr TimeBoundRequest) (sysPow *SystemPower, err error) //TODO convert this return to be something from TSDB // GetSystemPowerDetails retrieves the by cabinet min, max, and // average (system) power between the specified start and end time. GetSystemPowerDetails(tbr TimeBoundRequest) (cabPower *SystemPowerByCabinet, err error) // GetNodeEnergy retrieves node energy usage by time, jobID and node, all logically ANDed together GetNodeEnergy(req TimeBoundNodeRequest) (nodeEnergy *NodeEnergy, err error) // GetNodeEnergyStats retrieves node energy stats by time, jobID and node, all logically ANDed together GetNodeEnergyStats(req TimeBoundNodeRequest) (stat *NodeEnergyStats, err error) // GetNodeEnergyCounter retrieves node energy counter at sample time (can be for jobID) jobID and node GetNodeEnergyCounter(req TimeBoundNodeRequest) (counter *NodeEnergyCounters, err error) // ImplementationName // Returns the database type ImplementationName() string }
TSDB - This is the interface for the database; this defines all supported methods
var TSDBContext TSDB
TSDBContext - the TSDB interface global; used for setting context
type TimeBoundNodeRequest ¶
type TimeBoundNodeRequest struct { StartTime time.Time EndTime time.Time Nodes []NodeLookup JobId string Apid string }
TimeBoundNodeRequest - the general time based/job query params for TSDB for v1.1 Apid and JobId will always be empty; Once SMA starts putting these fields in PMDB, then we can use them
type TimeBoundRequest ¶
TimeBoundRequest - the general time based/job query params for TSDB
type TimeBoundRequestError ¶
type TimeBoundRequestError struct { TimeBoundRequest ErrMsg string }
TimeBoundRequestError - Error response for no data from time bound query
func NewTimeBoundRequestError ¶
func NewTimeBoundRequestError(st, et time.Time, eMsg string) *TimeBoundRequestError
NewTimeBoundRequestError - make a new object
func (*TimeBoundRequestError) Error ¶
func (e *TimeBoundRequestError) Error() string
Implement the Error interface