Skip to content

Commit 9015006

Browse files
committed
[core] Make GetTaskClass public + smoother parent role support
1 parent 3963521 commit 9015006

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

core/task/task.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,18 @@ type Task struct {
6868

6969
bindPorts map[string]uint64
7070

71-
getTaskClass func() *TaskClass
71+
GetTaskClass func() *TaskClass
7272
// ↑ to be filled in by NewTaskForMesosOffer in Manager
7373
}
7474

75+
func (t *Task) GetParentRole() interface{} {
76+
return t.parent
77+
}
78+
79+
func (t *Task) GetParentRolePath() string {
80+
return t.parent.GetPath()
81+
}
82+
7583
func (t Task) IsLocked() bool {
7684
return len(t.hostname) > 0 &&
7785
len(t.agentId) > 0 &&
@@ -98,7 +106,7 @@ func (t *Task) GetClassName() string {
98106
// Returns a consolidated CommandInfo for this Task, based on Roles tree and
99107
// TaskClass.
100108
func (t Task) BuildTaskCommand() (cmd *common.TaskCommandInfo) {
101-
if class := t.getTaskClass(); class != nil {
109+
if class := t.GetTaskClass(); class != nil {
102110
cmd = &common.TaskCommandInfo{}
103111
cmd.CommandInfo = *class.Command.Copy()
104112
if class.Control.Mode == controlmode.FAIRMQ {
@@ -129,7 +137,7 @@ func (t Task) BuildTaskCommand() (cmd *common.TaskCommandInfo) {
129137

130138
func (t *Task) GetWantsCPU() float64 {
131139
if t != nil {
132-
if tt := t.getTaskClass(); tt != nil {
140+
if tt := t.GetTaskClass(); tt != nil {
133141
return *tt.Wants.Cpu
134142
}
135143
}
@@ -138,7 +146,7 @@ func (t *Task) GetWantsCPU() float64 {
138146

139147
func (t *Task) GetWantsMemory() float64 {
140148
if t != nil {
141-
if tt := t.getTaskClass(); tt != nil {
149+
if tt := t.GetTaskClass(); tt != nil {
142150
return *tt.Wants.Memory
143151
}
144152
}
@@ -147,7 +155,7 @@ func (t *Task) GetWantsMemory() float64 {
147155

148156
func (t *Task) GetWantsPorts() Ranges {
149157
if t != nil {
150-
if tt := t.getTaskClass(); tt != nil {
158+
if tt := t.GetTaskClass(); tt != nil {
151159
wantsPorts := make(Ranges, len(tt.Wants.Ports))
152160
copy(wantsPorts, tt.Wants.Ports)
153161
return wantsPorts
@@ -192,7 +200,7 @@ func (t Task) BuildPropertyMap(bindMap channel.BindMap) controlcommands.Property
192200
//FIXME support parent properties
193201

194202
propMap := make(controlcommands.PropertyMap)
195-
if class := t.getTaskClass(); class != nil {
203+
if class := t.GetTaskClass(); class != nil {
196204
if class.Control.Mode == controlmode.FAIRMQ {
197205
for _, inbCh := range class.Bind {
198206
port, ok := t.bindPorts[inbCh.Name]

0 commit comments

Comments
 (0)