Changed signature of Allocation Stats Reporter

This commit is contained in:
Diptanu Choudhury
2016-05-25 12:49:38 -07:00
parent 3a2cce2419
commit 31af4e0ac4
3 changed files with 7 additions and 3 deletions

View File

@@ -31,7 +31,6 @@ type AllocStateUpdater func(alloc *structs.Allocation)
// AllocStatsReporter exposes stats related APIs of an allocation runner
type AllocStatsReporter interface {
AllocStats() map[string]TaskStatsReporter
TaskStats(task string) (TaskStatsReporter, error)
}
// AllocRunner is used to wrap an allocation and provide the execution context.

View File

@@ -37,7 +37,12 @@ const (
// TaskStatsReporter exposes APIs to query resource usage of a Task
type TaskStatsReporter interface {
// ResourceUsage returns the latest resource usage data point collected for
// the task
ResourceUsage() *cstructs.TaskResourceUsage
// ResourceUsageTS returns all the resource usage data points since a given
// time
ResourceUsageTS(since time.Time) []*cstructs.TaskResourceUsage
}

View File

@@ -76,8 +76,8 @@ func (s *HTTPServer) ClientAllocRequest(resp http.ResponseWriter, req *http.Requ
}
if task := req.URL.Query().Get("task"); task != "" {
taskStats, err := allocStats.TaskStats(task)
if err != nil {
taskStats, ok := allocStats.AllocStats()[task]
if !ok {
return nil, CodedError(404, "task not present in allocation")
}
return taskStats.ResourceUsage(), nil