You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.1 KiB
Go
73 lines
2.1 KiB
Go
2 years ago
|
package database
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"git.phc.dm.unipi.it/phc/cluster-dashboard/backend/executor"
|
||
|
"git.phc.dm.unipi.it/phc/cluster-dashboard/backend/model"
|
||
|
)
|
||
|
|
||
|
// simpleDB è una implementazione di [database.Database] che tiene giusto una cache in memoria e
|
||
|
// quando il server viene riavviato perde tutte le statistiche che ha accumulato. Più avanti si
|
||
|
// potrebbe pensare di scrivere queste informazioni in un file o usare un vero database.
|
||
|
type simpleDB struct {
|
||
|
Executor executor.Service
|
||
|
|
||
|
// lastUpdate tiene traccia di quando abbiamo aggiornato l'ultima volta tutti i dati
|
||
|
lastUpdate *time.Time
|
||
|
|
||
|
// Nodes is a map from hostname to node info
|
||
|
nodes map[string]model.Node
|
||
|
|
||
|
// Jobs is a map from job id to job info
|
||
|
jobs map[int]model.Job
|
||
|
|
||
|
// The following are maps from hostname to a list of sampled temperatures, used memory, used storage space and network upload and download rate.
|
||
|
|
||
|
temperatureSamples map[string][]model.Sample[float64]
|
||
|
memorySamples map[string][]model.Sample[int64]
|
||
|
storageSamples map[string][]model.Sample[int64]
|
||
|
networkUploadSamples map[string][]model.Sample[int64]
|
||
|
networkDownloadSamples map[string][]model.Sample[int64]
|
||
|
}
|
||
|
|
||
|
func NewSimpleDatabase(ex executor.Service) Database {
|
||
|
return &simpleDB{Executor: ex}
|
||
|
}
|
||
|
|
||
|
func (s *simpleDB) GetNodeStatus(hostname string) (*model.Node, error) {
|
||
|
panic("todo")
|
||
|
}
|
||
|
|
||
|
func (s *simpleDB) GetJobStatus(id int) (*model.Job, error) {
|
||
|
panic("todo")
|
||
|
}
|
||
|
|
||
|
func (s *simpleDB) AllNodes() ([]*model.Node, error) {
|
||
|
panic("todo")
|
||
|
}
|
||
|
|
||
|
func (s *simpleDB) AllJobs() ([]*model.Job, error) {
|
||
|
panic("todo")
|
||
|
}
|
||
|
|
||
|
func (s *simpleDB) QueryTemperatureSamples(from, to time.Time) ([]model.Sample[float64], error) {
|
||
|
panic("todo")
|
||
|
}
|
||
|
|
||
|
func (s *simpleDB) QueryMemorySamples(from, to time.Time) ([]model.Sample[int64], error) {
|
||
|
panic("todo")
|
||
|
}
|
||
|
|
||
|
func (s *simpleDB) QueryStorageSamples(from, to time.Time) ([]model.Sample[int64], error) {
|
||
|
panic("todo")
|
||
|
}
|
||
|
|
||
|
func (s *simpleDB) QueryNetworkUploadSamples(from, to time.Time) ([]model.Sample[int64], error) {
|
||
|
panic("todo")
|
||
|
}
|
||
|
|
||
|
func (s *simpleDB) QueryNetworkDownloadSamples(from, to time.Time) ([]model.Sample[int64], error) {
|
||
|
panic("todo")
|
||
|
}
|