From b64c7a635dd0898777f27e0b4aac9495bb9c28f0 Mon Sep 17 00:00:00 2001 From: gongweibao Date: Tue, 11 Jul 2017 02:41:34 +0000 Subject: [PATCH] fix by helin's comments --- go/master/client.go | 2 +- go/master/client_internal_test.go | 6 ++++++ go/master/service.go | 6 ++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/go/master/client.go b/go/master/client.go index 6f06fd04218..59bac6874c9 100644 --- a/go/master/client.go +++ b/go/master/client.go @@ -114,7 +114,7 @@ func (c *Client) taskFinished(taskID int) error { // TaskFailed tell the master server as task is failed. func (c *Client) taskFailed(meta TaskMeta) error { - return c.conn.Call("Service.TaskFinished", meta, nil) + return c.conn.Call("Service.TaskFailed", meta, nil) } // NextRecord returns next record in the dataset. diff --git a/go/master/client_internal_test.go b/go/master/client_internal_test.go index dc4d9eab14e..49263474c8f 100644 --- a/go/master/client_internal_test.go +++ b/go/master/client_internal_test.go @@ -99,6 +99,12 @@ func TestGetFinishTask(t *testing.T) { if err != nil { t.Fatalf("Error: %v, pass: %d\n", err, i) } + + err = c.taskFailed(tasks[0].Meta) + if err != nil { + t.Fatalf("Error: %v, pass: %d\n", err, i) + } + tasks = tasks[1:] task, err := c.getTask() if err != nil { diff --git a/go/master/service.go b/go/master/service.go index 1291ac48f12..a6050ab9943 100644 --- a/go/master/service.go +++ b/go/master/service.go @@ -359,7 +359,7 @@ func (s *Service) GetTask(dummy int, task *Task) error { } *task = t.Task - log.WithFields(s.logFields()).Infof("Task #%v dispatched.", t.Meta) + log.WithFields(s.logFields()).Infof("Task #%v dispatched.", t.Task.Meta) time.AfterFunc(s.timeoutDur, s.checkTimeoutFunc(t.Task.Meta.ID, t.Task.Meta.Epoch)) return nil @@ -376,7 +376,6 @@ func (s *Service) TaskFinished(taskID int, dummy *int) error { t, ok := s.taskQueues.Pending[taskID] if !ok { - err := errors.New("pending task not found") log.WithFields(s.logFields()).Warningln("Pending task #%d not found.", taskID) return nil } @@ -412,8 +411,7 @@ func (s *Service) TaskFailed(meta TaskMeta, dummy *int) error { t, ok := s.taskQueues.Pending[meta.ID] if !ok { - err := errors.New("pending task not found") - log.WithFields(s.logFields()).Warningln("TaskFailed:Pending task #%v not found.", t.Meta) + log.WithFields(s.logFields()).Warningln("TaskFailed:Pending task #%v not found.", t.Task.Meta) return nil } -- GitLab