/
models.go
107 lines (90 loc) · 2.7 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package runners
import (
"errors"
"fmt"
"time"
"github.com/hyperpilotio/go-utils/log"
"github.com/hyperpilotio/workload-profiler/clients"
"github.com/hyperpilotio/workload-profiler/db"
"github.com/hyperpilotio/workload-profiler/jobs"
"github.com/hyperpilotio/workload-profiler/models"
)
type ProfileRun struct {
Id string
DeployerClient *clients.DeployerClient
BenchmarkControllerClient *clients.BenchmarkControllerClient
SlowCookerClient *clients.SlowCookerClient
DeploymentId string
MetricsDB *db.MetricsDB
ApplicationConfig *models.ApplicationConfig
ProfileLog *log.FileLog
State string
Created time.Time
SkipUnreserveOnFailure bool
DirectJob bool
}
func (run *ProfileRun) IsDirectJob() bool {
return run.DirectJob
}
func (run *ProfileRun) GetId() string {
return run.Id
}
func (run *ProfileRun) GetApplicationConfig() *models.ApplicationConfig {
return run.ApplicationConfig
}
func (run *ProfileRun) GetLog() *log.FileLog {
return run.ProfileLog
}
func (run *ProfileRun) GetState() string {
return run.State
}
func (run *ProfileRun) SetState(state string) {
run.State = state
}
func (run *ProfileRun) GetSummary() jobs.JobSummary {
return jobs.JobSummary{
DeploymentId: run.DeploymentId,
RunId: run.Id,
Status: run.State,
Create: run.Created,
}
}
func (run *ProfileRun) GetJobDeploymentConfig() jobs.JobDeploymentConfig {
return jobs.JobDeploymentConfig{}
}
func (run *ProfileRun) IsSkipUnreserveOnFailure() bool {
return run.SkipUnreserveOnFailure
}
func (run *ProfileRun) GetColocatedAgentUrls(agent string, service string, placementHost string) ([]string, error) {
var colocatedService string
switch placementHost {
case "loadtester":
colocatedService = run.ApplicationConfig.LoadTester.Name
case "service":
colocatedService = service
default:
return nil, errors.New("Unknown placement host for benchmark agent: " + placementHost)
}
run.ProfileLog.Logger.Info("Getting %s url for colocated service %s from deployer client %+v",
agent, colocatedService, *run.DeployerClient)
agentUrls, err := run.DeployerClient.GetColocatedServiceUrls(run.DeploymentId, colocatedService, agent, run.ProfileLog.Logger)
if err != nil {
message := fmt.Sprintf(
"Unable to get service %s url located next to %s: %s",
agent,
colocatedService,
err.Error())
run.ProfileLog.Logger.Warningf(message)
return nil, errors.New(message)
}
return agentUrls, nil
}
type ProfileResults struct {
Id string
StageResults []StageResult
}
type StageResult struct {
Id string
StartTime string
EndTime string
}