Skip to content

Commit

Permalink
*: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed Feb 3, 2016
1 parent d2c3575 commit ecad021
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions ddl/bg_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/pingcap/tidb/terror"
)

// handleBgJobQueue handles background job queue.
// handleBgJobQueue handles the background job queue.
func (d *ddl) handleBgJobQueue() error {
if d.isClosed() {
return nil
Expand Down Expand Up @@ -73,7 +73,7 @@ func (d *ddl) handleBgJobQueue() error {
return nil
}

// runBgJob runs background job.
// runBgJob runs a background job.
func (d *ddl) runBgJob(t *meta.Meta, job *model.Job) {
job.State = model.JobRunning

Expand All @@ -99,7 +99,7 @@ func (d *ddl) runBgJob(t *meta.Meta, job *model.Job) {
}
}

// prepareBgJob prepares background job.
// prepareBgJob prepares a background job.
func (d *ddl) prepareBgJob(ddlJob *model.Job) error {
job := &model.Job{
ID: ddlJob.ID,
Expand All @@ -119,7 +119,7 @@ func (d *ddl) prepareBgJob(ddlJob *model.Job) error {
return errors.Trace(err)
}

// startBgJob starts background job.
// startBgJob starts a background job.
func (d *ddl) startBgJob(tp model.ActionType) {
switch tp {
case model.ActionDropSchema, model.ActionDropTable:
Expand All @@ -133,13 +133,13 @@ func (d *ddl) getFirstBgJob(t *meta.Meta) (*model.Job, error) {
return job, errors.Trace(err)
}

// updateBgJob updates background job.
// updateBgJob updates a background job.
func (d *ddl) updateBgJob(t *meta.Meta, job *model.Job) error {
err := t.UpdateBgJob(0, job)
return errors.Trace(err)
}

// finishBgJob finishs background job.
// finishBgJob finishs a background job.
func (d *ddl) finishBgJob(t *meta.Meta, job *model.Job) error {
log.Warnf("[ddl] finish background job %v", job)
if _, err := t.DeQueueBgJob(); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions ddl/bg_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ func (s *testDDLSuite) TestDropSchemaError(c *C) {
d.startBgJob(job.Type)

time.Sleep(lease)
testCheckBgJobState(c, d, job, model.JobDone)
verifyBgJobState(c, d, job, model.JobDone)
}

func testCheckBgJobState(c *C, d *ddl, job *model.Job, state model.JobState) {
func verifyBgJobState(c *C, d *ddl, job *model.Job, state model.JobState) {
kv.RunInNewTxn(d.store, false, func(txn kv.Transaction) error {
t := meta.NewMeta(txn)
historyBgJob, err := t.GetHistoryBgJob(job.ID)
Expand Down Expand Up @@ -81,7 +81,7 @@ func (s *testDDLSuite) TestDropTableError(c *C) {
d.startBgJob(job.Type)

time.Sleep(lease)
testCheckBgJobState(c, d, job, model.JobDone)
verifyBgJobState(c, d, job, model.JobDone)
}

func (s *testDDLSuite) TestInvalidBgJobType(c *C) {
Expand All @@ -101,5 +101,5 @@ func (s *testDDLSuite) TestInvalidBgJobType(c *C) {
d.startBgJob(model.ActionDropTable)

time.Sleep(lease)
testCheckBgJobState(c, d, job, model.JobCancelled)
verifyBgJobState(c, d, job, model.JobCancelled)
}
8 changes: 4 additions & 4 deletions meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ func (m *Meta) UpdateDDLJob(index int64, job *model.Job) error {
return m.updateDDLJob(index, job, mDDLJobListKey)
}

// DDLJobLength returns the DDL job length.
func (m *Meta) DDLJobLength() (int64, error) {
// DDLJobQueueLen returns the DDL job queue length.
func (m *Meta) DDLJobQueueLen() (int64, error) {
return m.txn.LLen(mDDLJobListKey)
}

Expand Down Expand Up @@ -619,8 +619,8 @@ func (m *Meta) EnQueueBgJob(job *model.Job) error {
return m.enQueueDDLJob(mBgJobListKey, job)
}

// BgJobLength returns the background job length.
func (m *Meta) BgJobLength() (int64, error) {
// BgJobQueueLen returns the background job queue length.
func (m *Meta) BgJobQueueLen() (int64, error) {
return m.txn.LLen(mBgJobListKey)
}

Expand Down
4 changes: 2 additions & 2 deletions meta/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (s *testSuite) TestDDL(c *C) {
job := &model.Job{ID: 1}
err = t.EnQueueDDLJob(job)
c.Assert(err, IsNil)
n, err := t.DDLJobLength()
n, err := t.DDLJobQueueLen()
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(1))

Expand Down Expand Up @@ -228,7 +228,7 @@ func (s *testSuite) TestDDL(c *C) {
bgJob := &model.Job{ID: 1}
err = t.EnQueueBgJob(bgJob)
c.Assert(err, IsNil)
n, err = t.BgJobLength()
n, err = t.BgJobQueueLen()
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(1))

Expand Down

0 comments on commit ecad021

Please sign in to comment.