Merged in resourceUsageTracking (pull request #2)

ResourceUsageTracking

Approved-by: Akash Kothawale <akothaw1@binghamton.edu>
Approved-by: Pradyumna Kaushik <pkaushi1@binghamton.edu>
This commit is contained in:
Pradyumna Kaushik 2018-02-09 22:32:44 +00:00
parent ec18b617da
commit 6c77aa777e
3 changed files with 6 additions and 5 deletions

4
.gitignore vendored
View file

@ -1,4 +0,0 @@
# Created by .ignore support plugin (hsz.mobi)
.idea/
# name of executable when built using command 'go build'
elektron

View file

@ -3,7 +3,7 @@ package def
import (
"errors"
"fmt"
"github.com/mdesenfants/gokmeans"
"github.com/mash/gokmeans"
"log"
"sort"
)

View file

@ -3,6 +3,7 @@ package schedulers
import (
"bitbucket.org/sunybingcloud/elektron/def"
elecLogDef "bitbucket.org/sunybingcloud/elektron/logging/def"
"bitbucket.org/sunybingcloud/elektron/utilities"
"bitbucket.org/sunybingcloud/elektron/utilities/schedUtils"
"bytes"
"fmt"
@ -187,6 +188,7 @@ func (s *BaseScheduler) Disconnected(sched.SchedulerDriver) {
}
func (s *BaseScheduler) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos.Offer) {
utilities.RecordTotalResourceAvailability(offers)
for _, offer := range offers {
if _, ok := s.HostNameToSlaveID[offer.GetHostname()]; !ok {
s.HostNameToSlaveID[offer.GetHostname()] = offer.GetSlaveId().GoString()
@ -212,6 +214,9 @@ func (s *BaseScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos
if *status.State == mesos.TaskState_TASK_RUNNING {
s.tasksRunning++
} else if IsTerminal(status.State) {
// Update resource availability.
utilities.ResourceAvailabilityUpdate("ON_TASK_TERMINAL_STATE",
*status.TaskId, *status.SlaveId)
s.TasksRunningMutex.Lock()
delete(s.Running[status.GetSlaveId().GoString()], *status.TaskId.Value)
s.TasksRunningMutex.Unlock()